[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [JAVA-1] Updated code proposal
Hi, I have updated the code for JAVA-1 based on our recent
discussions to include the following requested changes from the previous
version.
·
Project java-1-samplevendor-systemproperties Sample
vendor implementation that uses System Properties ·
Project
java-1-samplevendor-METAINFservices Sample
vendor implementation that uses META-INF/services file ·
Project
java-1-samplevendor-injection Sample
vendor implementation that uses direct injection into
SCAClientFactory Code Overview
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.newInstance();
final HelloService
helloService = scaClient.getService(HelloService.class, serviceURI, domainURI);
final String reply =
helloService.sayHello("Mark"); The client first calls SCAClientFactory.newInstance() that
returns an instance of SCAClient. This SCAClient instance can then be used to look
up the HelloService SCAClient Interface The 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 abstract
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 newInstance() method. The SCAClientFactory class
provides this indirection to the vendor’s implementation by:
The code for the SCAClientFactory is now quite short and consists of
(I’ve trimmed the JavaDoc to make it easer to read in this email) public abstract class SCAClientFactory { private static
SCAClientFactory defaultFactory; public static SCAClient
newInstance() { return newInstance(null, null); } public static SCAClient
newInstance(Properties properties) { return newInstance(properties,
null); } public static SCAClient
newInstance(ClassLoader classLoader) { return newInstance(null, classLoader); } public static SCAClient
newInstance(Properties properties, ClassLoader classLoader) { final SCAClientFactory factory; if(defaultFactory == null) {
factory = SCAClientFactoryFinder.find(properties,
classLoader); } else {
factory = defaultFactory; } return factory.createSCAClient(); } protected abstract SCAClient
createSCAClient(); } SCAClientFactoryFinder class SCA will provide a reference
implementation of the SCAClientFactory class. It
will discover the Vendors SCAClientFactory
implementation by referring to the following information:
Since this is a reference
implementation Vendors are free to replace the SCAClientFactoryFinder class with
an alternative implementation that meets the lookup mechanisms require for
their SCA Runtime. What does the
Vendor need to do?
Implement their SCAClientFactory and SCAClient implementation
classes Vendors need to provide an implementation of SCAClient that is
capable of looking up Services in their SCA Runtime. Vendors need to subclass SCAClientFactory
and implement the createSCAClient() method so
that it creates an instance of their SCAClient
implementation. Configure the Vendor Implementation classes
so they are used Vendors have several options: Option 1: Set System Property to point to the Vendor’s
implementation Vendors set the org.oasisopen.sca.client.SCAClientFactory System
Property to point to their implementation class and use the reference
implementation of SCAClientFactoryFinder Option 2: Provide a META-INF/services file Vendors provide a META-INF/services/org.oasisopen.sca.client.SCAClientFactory file that
points to their implementation class and use the reference implementation of SCAClientFactoryFinder Option 3: Inject a vendor implementation instance into SCAClientFactory Vendors inject an instance into the defaultFactory field of SCAClientFactory. The SCAClientFactoryFinder is not used
in this scenario. Option 4: Provide a Vendor specific implementation of SCAClientFactoryFinder Vendors write a new implementation of SCAClientFactoryFinder and replace
the reference implementation that
is provided by SCA. Source Code
I have attached a ZIP file that contains the source code,
unit tests and an Eclipse project files for JAVA-1. The projects are: JAVA-1-Code-Proposal Code
proposal for JAVA-1 JAVA-1-SampleVendor-Injection Sample
Vendor implementation that injects directly into SCAClientFactory JAVA-1-SampleVendor-METAINFservices Sample
Vendor implementation that uses a META-INF/services file JAVA-1-SampleVendor-SystemProperties Sample
Vendor implementation that uses System Properties. JAVA-1-SampleCommonCode Sample
Service that is used as part of the demonstration of the vendor code When loading the Eclipse project files, 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 updated
proposal. Thanks, Mark Mark Combellack| Software Developer| Avaya | |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]