I have fixed this under revision #561972, we now utilize the contribution file name or it's location (in case of a folder) to construct the contribution URI.
On 7/30/07, Luciano Resende <[EMAIL PROTECTED]> wrote: > Looks like DefaultSCADomain is always setting contributionURI to > empty string. With the current behavior, can we have side effects by > using the contributionURI as the scope for HelperContext ? > > Here is a output I get after setting a System.out inside > DefaultSCADomain(line 113) and ImportSDOPostProcessor (line 117), and > then executing the helloworld-ws-sdo sample. > > contributionURI => > HelperContext ID: > contributionURI => > HelperContext ID: > addServletMapping port: 8085 path: /HelloWorldService > Injected helloWorldService > Called getGreetings > > Thoughts ? > > ---------- Forwarded message ---------- > From: [EMAIL PROTECTED] <[EMAIL PROTECTED]> > Date: Jul 30, 2007 1:48 PM > Subject: svn commit: r561111 - > /incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java > To: [EMAIL PROTECTED] > > > Author: rfeng > Date: Mon Jul 30 13:48:15 2007 > New Revision: 561111 > > URL: http://svn.apache.org/viewvc?view=rev&rev=561111 > Log: > Use the contribution URI as the scope for HelperContext > > Modified: > > incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java > > Modified: > incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java > URL: > http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java?view=diff&rev=561111&r1=561110&r2=561111 > ============================================================================== > --- > incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java > (original) > +++ > incubator/tuscany/java/sca/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOPostProcessor.java > Mon Jul 30 13:48:15 2007 > @@ -32,16 +32,17 @@ > import commonj.sdo.impl.HelperProvider; > > /** > - * PostProcessor resposible for identifying SDO Factories and > register them with SDO Helper Context > + * PostProcessor resposible for identifying SDO Factories and > register them with > + * SDO Helper Context > * > * @version $Rev$ $Date$ > */ > public class ImportSDOPostProcessor implements ContributionPostProcessor { > private static final String URI_SEPARATOR = "/"; > private static final String JAVA_SEPARATOR = "."; > - > + > private HelperContextRegistry helperContextRegistry; > - > + > public ImportSDOPostProcessor(HelperContextRegistry > helperContextRegistry) { > super(); > this.helperContextRegistry = helperContextRegistry; > @@ -58,10 +59,10 @@ > if (clazz.getClass() != null) { > try { > //check if it's a SDO factory by > introspecting INSTANCE field > - if(isSDOFactory(clazz.getJavaClass())) { > - register(clazz.getJavaClass(), > this.getHelperContext()); > + if (isSDOFactory(clazz.getJavaClass())) { > + register(clazz.getJavaClass(), > this.getHelperContext(contribution)); > } > - > + > } catch (Exception e) { > e.printStackTrace(); > } > @@ -71,7 +72,9 @@ > } > > /** > - * Transform class artifact URI into a java class name for proper > loading by the class loader > + * Transform class artifact URI into a java class name for proper > loading by > + * the class loader > + * > * @param factoryURI > * @return > */ > @@ -80,39 +83,37 @@ > int pos = factoryURI.lastIndexOf(JAVA_SEPARATOR); > return factoryURI.substring(0, pos); > } > - > + > /** > * Check if a specific class is a SDO Factory by checking INSTANCE field > + * > * @param factoryClass > * @return > */ > private boolean isSDOFactory(Class factoryClass) { > - Field field = null; > try { > - field = factoryClass.getField("INSTANCE"); > - } catch (Exception e) { > - // ignore any exception > - } > - > - if (field != null) { > + // The factory interface has a constant "INSTANCE" field > + Field field = factoryClass.getField("INSTANCE"); > + // A public method: register(HelperContext scope) > + Method method = factoryClass.getMethod("register", > HelperContext.class); > return true; > - } else { > + } catch (NoSuchMethodException e) { > + return false; > + } catch (NoSuchFieldException e) { > return false; > } > - > } > - > + > /** > * Get a SDO HelperContext reference > + * > * @return > */ > - private HelperContext getHelperContext() { > + private HelperContext getHelperContext(Contribution contribution) { > HelperContext helperContext = null; > > - // FIXME: [rfeng] How to get the enclosing composite? > - int id = System.identityHashCode(getClass()); > - // FIXME: [rfeng] How to associate the TypeHelper with deployment > - // context? > + // FIXME: [rfeng] Should we scope the HelperContext by > contribution URI? > + String id = contribution.getURI(); > synchronized (helperContextRegistry) { > helperContext = helperContextRegistry.getHelperContext(id); > if (helperContext == null) { > @@ -120,12 +121,13 @@ > helperContextRegistry.register(id, helperContext); > } > } > - > + > return helperContext; > } > - > + > /** > * Register an SDO Factory with the helper context > + * > * @param factoryClass > * @param helperContext > * @throws Exception > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > Luciano Resende > Apache Tuscany Committer > http://people.apache.org/~lresende > http://lresende.blogspot.com/ > -- Luciano Resende Apache Tuscany Committer http://people.apache.org/~lresende http://lresende.blogspot.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
