diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-09 09:17:30 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-09 09:17:30 +0000 |
commit | dc15447dfebac2b0218cb1ce6903923c574c84df (patch) | |
tree | 5cf9aba844a018bccab0743005af5d3701e98cce /java/sca/samples | |
parent | 7ea46da4356a04cd45cfa1cadcad9f7fdb28aa7f (diff) |
Fixes to get the Equinox integration working. Use the parent classloader instead of the Thread context classloader as parent of the contribution classloader. Use the ServiceDiscovery to get instances of DocumentBuilderFactory and TransformerFactory. Pass these factories around instead of creating new instances in different places. Clarified the few prints in the calculator-osgi sample showing which classloader is used.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@693411 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/samples')
5 files changed, 27 insertions, 8 deletions
diff --git a/java/sca/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/java/sca/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java index 4e28301c25..a7dcba8f5e 100644 --- a/java/sca/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java +++ b/java/sca/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java @@ -42,8 +42,7 @@ public class CalculatorClient { public void calculate() { // Calculate - System.out.println(getClass().getClassLoader()); - System.out.println(Reference.class.getClassLoader()); + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); System.out.println("3 + 2=" + calculatorService.add(3, 2)); System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); diff --git a/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java index 0561370d3a..dc0da7d20d 100644 --- a/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java +++ b/java/sca/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java @@ -39,7 +39,7 @@ public class CalculatorTestCase extends TestCase { protected void setUp() throws Exception { launcher = NodeLauncher.newInstance(); node = launcher.createNodeFromClassLoader("Calculator.composite", getClass().getClassLoader()); - System.out.println(node.getClass().getClassLoader()); + System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader()); node.start(); } diff --git a/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java b/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java index 380d501ab5..28eede693d 100644 --- a/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java +++ b/java/sca/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java @@ -40,6 +40,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; @@ -100,6 +101,8 @@ public class DistributeAndRunComponents { private static WorkspaceFactory workspaceFactory; private static AssemblyFactory assemblyFactory; private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; private static StAXArtifactProcessor<Object> xmlProcessor; private static ContributionDependencyBuilder contributionDependencyBuilder; private static CompositeBuilder domainCompositeBuilder; @@ -127,6 +130,8 @@ public class DistributeAndRunComponents { modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); // Get contribution workspace and assembly model factories workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); @@ -152,10 +157,12 @@ public class DistributeAndRunComponents { SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); - domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); // Create a node composite builder - nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, contractMapper, null, monitor); + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor); } diff --git a/java/sca/samples/domain-management/src/main/java/manager/DistributeComponents.java b/java/sca/samples/domain-management/src/main/java/manager/DistributeComponents.java index 4af2547a81..def0a1894f 100644 --- a/java/sca/samples/domain-management/src/main/java/manager/DistributeComponents.java +++ b/java/sca/samples/domain-management/src/main/java/manager/DistributeComponents.java @@ -37,6 +37,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; @@ -113,6 +114,8 @@ public class DistributeComponents { private static WorkspaceFactory workspaceFactory; private static AssemblyFactory assemblyFactory; private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; private static StAXArtifactProcessor<Object> xmlProcessor; private static ContributionDependencyBuilder contributionDependencyBuilder; private static CompositeBuilder domainCompositeBuilder; @@ -140,6 +143,8 @@ public class DistributeComponents { modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); // Get contribution workspace and assembly model factories workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); @@ -165,10 +170,12 @@ public class DistributeComponents { SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); - domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); // Create a node composite builder - nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, contractMapper, null, monitor); + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor); } diff --git a/java/sca/samples/domain-management/src/main/java/manager/WireComponents.java b/java/sca/samples/domain-management/src/main/java/manager/WireComponents.java index 899a6fd412..d24d5c67c9 100644 --- a/java/sca/samples/domain-management/src/main/java/manager/WireComponents.java +++ b/java/sca/samples/domain-management/src/main/java/manager/WireComponents.java @@ -34,6 +34,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; @@ -92,6 +93,8 @@ public class WireComponents { private static WorkspaceFactory workspaceFactory; private static AssemblyFactory assemblyFactory; private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; private static StAXArtifactProcessor<Object> xmlProcessor; private static ContributionDependencyBuilder contributionDependencyBuilder; private static CompositeBuilder domainCompositeBuilder; @@ -116,6 +119,8 @@ public class WireComponents { modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); // Get contribution workspace and assembly model factories workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); @@ -139,7 +144,8 @@ public class WireComponents { SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); - domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, contractMapper, monitor); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); } |