Java interface Implementation Service__java in SCA

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.