1, Java-based service interfaces and Java classes to implement components
Interface package Services.hello;
Public interface HelloService {
string Hello (String message);
}
Realize package Services.hello;
Import Org.osoa.sca.annotations. * ;
@Service (HelloService. Class)
public class Helloserviceimpl implements HelloService {
public string, hello (String message) {
...
}
}
The 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, its definition of service interface and implementation of the 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 rules for @service annotations: If a service has only one interface, implementing the interface is to implement the service.
So the above implementation can also be rewritten as follows: Package Services.hello;
public class Helloserviceimpl implements Anotherinterface {
public string, hello (String message) {
...
}
...
}
The 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, a Java implementation class implements two service 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) {
...
}
..
}
The 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 through the interface subclass relationship to achieve two service
Service 1 package Services.hello;
Public interface HelloService {
string Hello (String message);
}
Service 2 package Services.hello;
Public interface HelloService2 extends HelloService {
}
Realize package Services.hello;
Import Org.osoa.sca.annotations. * ;
@Service (interfaces = {HelloService. class, HelloService2. Class})
public class Helloserviceimpl implements HelloService {
public string, hello (String message) {
...
}
}
Corresponds to 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