10.6@ComponentName
The following Java code defines the @ComponentName annotation:
package org.oasisopen.sca.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface ComponentName {
}
The @ComponentName annotation is used to denote a Java class field or setter method that is used to inject the component name.
The following snippet shows a component name field definition sample.
@ComponentName
private String componentName;
The following snippet shows a component name setter method sample.
@ComponentName
public void setComponentName(String name) {
//…
}
10.7@Confidentiality
The following Java code defines the @Confidentiality annotation:
package org.oasisopen.sca.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.oasisopen.sca.Constants.SCA_PREFIX;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Inherited
@Target({TYPE, FIELD, METHOD, PARAMETER})
@Retention(RUNTIME)
@Intent(Confidentiality.CONFIDENTIALITY)
public @interface Confidentiality {
String CONFIDENTIALITY = SCA_PREFIX + "confidentiality";
String CONFIDENTIALITY_MESSAGE = CONFIDENTIALITY + ".message";
String CONFIDENTIALITY_TRANSPORT = CONFIDENTIALITY + ".transport";
/**
* List of confidentiality qualifiers such as "message" or
* "transport".
*
* @return confidentiality qualifiers
*/
@Qualifier
String[] value() default "";
}
The @Confidentiality annotation is used to indicate the need for confidentiality. See the SCA Policy Framework Specification [POLICY] for details on the meaning of the intent. See the section on Application of Intent Annotations for samples of how intent annotations are used in Java.
10.8@Constructor
The following Java code defines the @Constructor annotation:
package org.oasisopen.sca.annotation;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target(CONSTRUCTOR)
@Retention(RUNTIME)
public @interface Constructor { }
The @Constructor annotation is used to mark a particular constructor to use when instantiating a Java component implementation. If a constructor of an implementation class is annotated with @Constructor and the constructor has parameters, each of these parameters MUST have either a @Property annotation or a @Reference annotation. [JCA90003]
The following snippet shows a sample for the @Constructor annotation.
public class HelloServiceImpl implements HelloService {
public HelloServiceImpl(){
...
}
@Constructor
public HelloServiceImpl(@Property(name="someProperty")
String someProperty ){
...
}
public String hello(String message) {
...
}
}
10.9@Context
The following Java code defines the @Context annotation:
package org.oasisopen.sca.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Context {
}
The @Context annotation is used to denote a Java class field or a setter method that is used to inject a composite context for the component. The type of context to be injected is defined by the type of the Java class field or type of the setter method input argument; the type is either ComponentContext or RequestContext.
The @Context annotation has no attributes.
The following snippet shows a ComponentContext field definition sample.
@Context
protected ComponentContext context;
The following snippet shows a RequestContext field definition sample.
@Context
protected RequestContext context;
Share with your friends: |