1. Java-based service interfaces and Java classes for implementing components
Interface
Package Services. Hello;
Public interface helloservice {
String Hello (string message );
}
Implementation
Package Services. Hello;
Import org. osoa. SCA. Annotations .*;
@ Service (helloservice. Class)
Public class helloserviceimpl implements helloservice {
Public String Hello (string message ){
...
}
}
Corresponding componet type
<? XML version = "1.0" encoding = "ASCII"?>
<Componenttype xmlns = http://www.osoa.org/xmlns/sca/1.0>
<Service name = "helloservice">
<Interface. Java interface = "services. Hello. helloservice"/>
</Service>
</Componenttype>
2. self-defined service interface and implemented JAVA Implementation class
Package Services. Hello;
Import org. osoa. SCA. Annotations .*;
@ Service (helloserviceimpl. Class)
Public class helloserviceimpl implements anotherinterface {
Public String Hello (string message ){
...
}
...
}
According to the default rule of @ service annotation: If a service has only one interface, an interface is implemented as a service.
Therefore, the above implementation can be rewritten as follows:
Package Services. Hello;
Public class helloserviceimpl implements anotherinterface {
Public String Hello (string message ){
...
}
...
}
Corresponding component type
<? XML version = "1.0" encoding = "ASCII"?>
<Componenttype xmlns = http://www.osoa.org/xmlns/sca/1.0>
<Service name = "helloservice">
<Interface. Java interface = "services. Hello. helloserviceimpl"/>
</Service>
</Componenttype>
3. One Java implementation class implements two services
Package Services. Hello;
Import org. osoa. SCA. Annotations .*;
@ Service (interfaces = {helloservice. Class, anotherinterface. Class })
Public class helloserviceimpl implements helloservice, anotherinterface {
Public String Hello (string message ){
...
}
...
}
Corresponding component type
<? XML version = "1.0" encoding = "ASCII"?>
<Componenttype xmlns = http://www.osoa.org/xmlns/sca/1.0>
<Service name = "helloservice">
<Interface. Java interface = "services. Hello. helloservice"/>
</Service>
<Service name = "anotherservice">
<Interface. Java interface = "services. Hello. anotherservice"/>
</Service>
</Componenttype>
4. Java implementation class implements two services through the interface subclass relationship
Service 1
Package Services. Hello;
Public interface helloservice {
String Hello (string message );
}
Service 2
Package Services. Hello;
Public interface helloservice2 extends helloservice {
}
Implementation
Package Services. Hello;
Import org. osoa. SCA. Annotations .*;
@ Service (interfaces = {helloservice. Class, helloservice2.class })
Public class helloserviceimpl implements helloservice {
Public String Hello (string message ){
...
}
}
Corresponding component type
<? XML version = "1.0" encoding = "ASCII"?>
<Componenttype xmlns = "http://www.osoa.org/xmlns/sca/1.0">
<Service name = "helloservice">
<Interface. Java interface = "services. Hello. helloservice"/>
</Service>
<Service name = "helloservice2">
<Interface. Java interface = "services. Hello. helloservice2"/>
</Service>
</Componenttype>