Java interface implementation service in SCA

Source: Internet
Author: User

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>

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.