[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: JAVA-1: Source code for SCAClientFactory proposal
Hi, I have an action item to write some code to show SCAClient as an interface and SCAClientFactory as a concrete
class and still allow vendors to plug in implementations that provide the
vendor specific functionality. The main reasons for doing this include:
What I will do is run you through the main points of the
code and how it works. The code could do with more polish before it is
considered complete. SCA Client Perspective The scenario is fairly simple – some code that is
running outside of the SCA Domain wants to lookup and use a Service that is
inside the domain. The following code shows how the HelloService could be looked up and invoked from
unmanaged SCA Code. final String serviceURI = "SomeHelloServiceURI"; final URI domainURI = new URI("SomeDomainURI"); final SCAClient scaClient = SCAClientFactory.createSCAClient(); final HelloService helloService =
scaClient.getService(HelloService.class, serviceURI, domainURI); final String reply = helloService.sayHello("Mark"); The client first calls SCAClientFactory.createSCAClient() that returns
an instance of SCAClient. This SCAClient instance can then be used to look
up the HelloService SCAClient Interface The main change from Mike’s original proposal is to make
SCAClient an
interface rather than a class. The main reason for this is that it allows
mocking of the SCAClient so that it
can be unit tested. The new definition of SCAClient interface would be: public interface SCAClient { <T> T getService(Class<T> interfaze,
String serviceURI, URI domainURI) throws NoSuchServiceException, NoSuchDomainException;
} SCAClientFactory class The SCAClientFactory class is responsible
for providing the indirection from the user’s generic SCA code and the
vendor’s implementation of the SCA Runtime. The user’s code will
ask it for a SCAClient via the createSCAClient() method. The SCAClientFactory class
provides this indirection to the vendor’s implementation by attempting to
discover the class name of the vendor’s implementation using:
It is important to note that this class does not need to be
updated by the Vendor to include their implementation. All the Vendor needs to
do is set the System Property or provide the correct services file What does the Vendor need to do? The Vendor will need to provide a class that will be able to
look up a Service in their SCA Runtime. To do this, they need to:
The SCAClientFactorySPI interface
has a single method that the vendors need to implement: public interface SCAClientFactorySPI { SCAClient createSCAClient(); } Source Code I have attached a ZIP file that contains the source code for
the above. The ZIP file contains: Implementation of SCAClient and SCAClientFactory in the org.oasisopen.sca package Implementation of SCAClientFactorySPI in the org.oasisopen.sca.spi package
When loading the Eclipse project file, you may need to set
the target JDK to match the JDK you have installed. To do this simply:
I would appreciate your thoughts/comments on this proposal. Thanks, Mark Mark Combellack| Software Developer| Avaya | |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]