Annotation Type Create
-
@Retention(RUNTIME) @Target({METHOD,TYPE}) @GenerateServiceFromMethod(implementation="org.glassfish.config.support.GenericCreateCommand", advertisedContracts="org.glassfish.api.admin.AdminCommand") public @interface Create
Create command annotation.Methods annotated with this annotation delegates to the framework to provide a generic administrative command that create configured instances. A Create annotation is used on a method of a configured interface. The method identifies the setter of a type that can be added to the configured interface. The annotated method must follow one of the two pattern :
List<X> getXs();
orvoid setX(X x);
The name of the method is immaterial, only the generic type of the returned List or the single parameter of the setter method are used to determine the type of configured instance the command will create. The resolver is used to find which instance of the parent type should be used to add the newly created child. The resolver can also be annotated withParam
to get parameters passed to the command invocation (like a name or a target parameter). The generic command implementation will use the parameters passed to the command invocation with theParam
annotations on the child type to match command parameters to configuration attributes. Sometimes, the creation of a new configuration will require more work or more attributes/elements creation than what can be provided or specified during the command invocation. In such a case, the Create annotation can specify a decorator that will be called during the generic command execution, with the newly created instance. TheCreationDecorator
will be looked up by its type and normal injection or parameter injection can happen.Internationalization of generic commands follow the same rule as described in the
AdminCommand
javadocs. TheI18n
annotation referenced from this annotation will be used as the top level command annotation, which should provide the command description and expected result. Parameters can be annotated with @I18n as well to override the default mapping and all resources must be located in the target type module local strings properties file. Sometimes, the @Create annotation cannot be used in the parent configuration object because the parent cannot have a direct reference its children types.For instance, if you have a declaration like
you cannot use the @Create annotation in such declaration because you do not know which subtypes of ParentConfigType will exist. In such cases, you should place the @Create on the child type and use the @Decorate annotation alongside to specify the parent's method used to add the element to the parent.public interface ParentContainer { @Element("*) List>ParentConfigType< children(); }
@Create(....) @Decorate(parentType=ParentContainer.class, methodName="children", with={Create.class}) public interface SomeChild extends ParentConfigType { ... }
- Author:
- Jerome Dochez
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description I18n
i18n
Returns the i18n key that will be used to look up a localized string in the annotated type module.String
value
Name of the command that will be used to register this generic command implementation under.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description ExecuteOn
cluster
Returns the desired behaviors in a clustered environment.Class<? extends CreationDecorator>
decorator
Returns a decorator type that should be looked up and called when a new configuration element of the annotated type is created.Class<? extends CrudResolver>
resolver
Returns the instance of the parent that should be used to add the newly created instance under.
-
-
-
Element Detail
-
value
@GeneratedServiceName String value
Name of the command that will be used to register this generic command implementation under.- Returns:
- the command name as the user types it.
-
-
-
i18n
I18n i18n
Returns the i18n key that will be used to look up a localized string in the annotated type module.- Returns:
- the key to look up localized description for the command.
-
-
-
resolver
Class<? extends CrudResolver> resolver
Returns the instance of the parent that should be used to add the newly created instance under. The implementation of that interface can use the command parameters to make a determination about which instance should be used.- Returns:
- the parent instance.
- Default:
- org.glassfish.config.support.CrudResolver.DefaultResolver.class
-
-
-
decorator
Class<? extends CreationDecorator> decorator
Returns a decorator type that should be looked up and called when a new configuration element of the annotated type is created.- Returns:
- a decorator for the annotated type
- Default:
- org.glassfish.config.support.CreationDecorator.NoDecoration.class
-
-