org.jboss.seam.annotations
Annotation Type Factory


@Target(value=METHOD)
@Retention(value=RUNTIME)
@Documented
public @interface Factory

Marks a method as a factory method for a context variable. A factory method is called whenever no value is bound to the named context variable, and is expected to initialize the value of the context variable. There are two kinds of factory methods. Factory methods with void return type are responsible for outjecting a value to the context variable. Factory methods which return a value do not need to explicitly ouject the value, since Seam will bind the returned value to the specified scope. This annotation supports use of the Seam "factory component" pattern.

Author:
Gavin King

Optional Element Summary
 boolean autoCreate
          Specifies that this factory method should be automatically called whenever the variable is asked for, even if @In does not specify create=true.
 ScopeType scope
          The scope() element is meaningful only for factory methods that return the value to be outjected.
 String value
           
 

value

public abstract String value
Returns:
the name of the context variable
Default:
""

scope

public abstract ScopeType scope
The scope() element is meaningful only for factory methods that return the value to be outjected. Factory methods that return void are expected to take responsibility for outjecting the value, and then scope() is ignored. If the factory method returns a value, but no scope is explicitly specified, the scope of the component with the @Factory attribute is used. But if the component scope is STATELESS, the EVENT scope is used.

Returns:
the scope to outject any returned value
Default:
org.jboss.seam.ScopeType.UNSPECIFIED

autoCreate

public abstract boolean autoCreate
Specifies that this factory method should be automatically called whenever the variable is asked for, even if @In does not specify create=true.

Default:
false