sca-j message
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]
Subject: RE: [sca-j] [JAVA-1] Updated code proposal
- From: David Booz <booz@us.ibm.com>
- To: sca-j@lists.oasis-open.org
- Date: Mon, 16 Mar 2009 08:02:08 -0400
Raymond's comment also reminds me to think about the Java2 security implications in the FactoryFinder implementation...are there any? This is an area that's always been unclear to me. The factory finder is accessing a file through the class loader, does that need to be done in a doPriveleged?
Dave Booz
STSM, BPM and SCA Architecture
Co-Chair OASIS SCA-Policy TC and SCA-J TC
"Distributed objects first, then world hunger"
Poughkeepsie, NY (845)-435-6093 or 8-295-6093
e-mail:booz@us.ibm.com
Raymond Feng---03/15/2009 01:33:48 AM---Hi, Can we make the defaultFactory field protected instead of private? There
From: |
Raymond Feng/Burlingame/IBM@IBMUS |
To: |
sca-j@lists.oasis-open.org |
Date: |
03/15/2009 01:33 AM |
Subject: |
RE: [sca-j] [JAVA-1] Updated code proposal |
Hi,
Can we make the defaultFactory field protected instead of private? There are two reasons:
1) In SCA Java, we only honor protected and public fields or setters for injection.
2) If the defaultFactory is protected static, a subclass of SCAClientFactory can access the defaultFactory without the reflection backdoor which requires a security permission.
Thanks,
Raymond
public abstract class SCAClientFactory {
/**
* The default implementation of the SCAClientFactory. A Vendor may use reflection to inject
* a default SCAClientFactory instance that will be used in the newInstance() methods rather
* than using the SCAClientFactoryFinder.
*/
protected static SCAClientFactory defaultFactory;
...
}
Raymond Feng
Senior Software Engineer, Apache Tuscany PMC Member & Committer
IBM Bay Area Lab, 1001 E Hillsdale Blvd, Suite 400, Foster City, CA 94404, USA
E-mail: rfeng@us.ibm.com, Notes: Raymond Feng/Burlingame/IBM, Tel: 650-645-8117, T/L: 367-8117
Apache Tuscany: http://tuscany.apache.org
From: | "Mark Combellack" <mcombellack@avaya.com> |
To: | <sca-j@lists.oasis-open.org> |
Date: | 03/13/2009 05:12 AM |
Subject: | RE: [sca-j] [JAVA-1] Updated code proposal |
***********************
Warning: Your file, java-1.zip, contains more than 32 files after decompression and cannot be scanned.
*********************** |
Hi,
I have updated the code for this proposal to include the correct OASIS copyright header on the source files in the proposal. I have not made any other changes.
Thanks,
Mark
Mark Combellack| Software Developer| Avaya | Eastern Business Park | St. Mellons | Cardiff | CF3 5EA | Voice: +44 (0) 29 2081 7624 | mcombellack@avaya.com
From: Mark Combellack [mailto:mcombellack@avaya.com]
Sent: 12 March 2009 13:08
To: sca-j@lists.oasis-open.org
Subject: [sca-j] [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.
- Moved the SCAClient and SCAClientFactory client code into org.oasisopen.sca.client package
- Renamed the package containing the SCAClientFactoryFinder from org.oasisopen.sca.impl to org.oasisopen.sca.client.spi
- Split the test cases into separate Eclipse projects to show the different ways that a Vendor can integrate their implementation:
· 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:
- if a defaultFactory has been injected then use it.
- If no defaultFactory has been injected then delegate to the SCAClientFactoryFinder
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:
- The org.oasisopen.sca.client.SCAClientFactory property from the Properties specified on the newInstance() method call if specified
- The org.oasisopen.sca.client.SCAClientFactory property from the System Properties
- The META-INF/services/org.oasisopen.sca.client.SCAClientFactory file
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:
- Select the Properties menu item on the Project menu.
- Select the Java Build Path in the list on the left hand side
- Select the JRE System Library on the right hand side
- Press the Edit button
- Make sure the workspace default JRE is selected and press Finish
- Press OK
I would appreciate your thoughts/comments on this updated proposal.
Thanks,
Mark
Mark Combellack| Software Developer| Avaya | Eastern Business Park | St. Mellons | Cardiff | CF3 5EA | Voice: +44 (0) 29 2081 7624 | mcombellack@avaya.com
[attachment "java-1.zip" deleted by Raymond Feng/Burlingame/IBM] ---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that
generates this mail. Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]