The @Service annotation is used on a component implementation class to specify the SCA services offered by the implementation. An implementation class need not be declared as implementing all of the interfaces implied by the services declared in its @Service annotation, but all methods of all the declared service interfaces MUST be present. [JCA90042] A class used as the implementation of a service is not required to have a @Service annotation. If a class has no @Service annotation, then the rules determining which services are offered and what interfaces those services have are determined by the specific implementation type.
The @Service annotation has the following attributes:
value (1..1) – An array of interface or class objects that are exposed as services by this implementation. The array of interfaces or classes specified by the value attribute of the @Service annotation MUST contain at least one element. [JCA90059]
names (0..1) - An array of Strings which are used as the service names for each of the interfaces declared in the value array. The number of Strings in the names attribute array of the @Service annotation MUST match the number of elements in the value attribute array. [JCA90050] The value of each element in the @Service names array MUST be unique amongst all the other element values in the array. [JCA90060]
The service name of an exposed service defaults to the name of its interface or class, without the package name. If the names attribute is specified, the service name for each interface or class in the value attribute array is the String declared in the corresponding position in the names attribute array.
A component implementation MUST NOT have two services with the same Java simple name. [JCA90045] If a Java implementation needs to realize two services with the same Java simple name then this can be achieved through subclassing of the interface.
The following snippet shows an implementation of the HelloService marked with the @Service annotation.
This specification applies the WSDL to Java and Java to WSDL mapping rules as defined by the JAX-WS specification [JAX-WS] for generating remotable Java interfaces from WSDL portTypes and vice versa.
For the purposes of the Java-to-WSDL mapping algorithm, the SCA runtime MUST treat a Java interface as if it had a @WebService annotation on the class, even if it doesn't. [JCA100001] The SCA runtime MUST treat an @org.oasisopen.sca.annotation.OneWay annotation as a synonym for the @javax.jws.OneWay annotation. [JCA100002] For the WSDL-to-Java mapping, the SCA runtime MUST take the generated @WebService annotation to imply that the Java interface is @Remotable. [JCA100003]
For the mapping from Java types to XML schema types, SCA permits both the JAXB 2.1 [JAX-B] mapping and the SDO 2.1 [SDO] mapping. SCA runtimes MUST support the JAXB 2.1 mapping from Java types to XML schema types. [JCA100004] SCA runtimes MAY support the SDO 2.1 mapping from Java types to XML schema types. [JCA100005] Having a choice of binding technologies is allowed, as noted in the first paragraph of section 5 of the JSR 181 (version 2) specification, which is referenced by the JAX-WS specification.