@Retention(value=RUNTIME) @Target(value={METHOD,TYPE}) @GenerateServiceFromMethod(implementation="org.glassfish.config.support.GenericCreateCommand", advertisedContracts="org.glassfish.api.admin.AdminCommand") public @interface Create
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();
or
void 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 with Param
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 the Param
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.
The CreationDecorator
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. The I18n
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
public interface ParentContainer {
@Element("*)
List>ParentConfigType< children();
}
@Create(....)
@Decorate(parentType=ParentContainer.class, methodName="children",
with={Create.class})
public interface SomeChild extends ParentConfigType {
...
}
Modifier and Type | Required Element and 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.
|
Modifier and Type | Optional Element and 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.
|
@GeneratedServiceName public abstract String value
public abstract I18n i18n
public abstract Class<? extends CrudResolver> resolver
public abstract Class<? extends CreationDecorator> decorator
Copyright © 2019. All rights reserved.