summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java8
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java272
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java7
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java6
-rw-r--r--branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java23
-rw-r--r--branches/sca-equinox/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java19
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java8
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java8
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java43
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java2
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java39
-rw-r--r--branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java98
-rw-r--r--branches/sca-equinox/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java18
-rw-r--r--branches/sca-equinox/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java2
-rw-r--r--branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java7
-rw-r--r--branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java2
-rw-r--r--branches/sca-equinox/modules/host-jetty/pom.xml3
-rw-r--r--branches/sca-equinox/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java2
-rw-r--r--branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java10
-rw-r--r--branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java3
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java12
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java4
-rw-r--r--branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java28
-rw-r--r--branches/sca-equinox/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java2
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/README (renamed from branches/sca-equinox/samples/calculator-osgi/README)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/calculator.png (renamed from branches/sca-equinox/samples/calculator-osgi/calculator.png)bin20552 -> 20552 bytes
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/calculator.svg (renamed from branches/sca-equinox/samples/calculator-osgi/calculator.svg)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/pom.xml (renamed from branches/sca-equinox/samples/calculator-osgi/pom.xml)22
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddService.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideService.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractService.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/main/resources/Calculator.composite (renamed from branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite)0
-rw-r--r--branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java (renamed from branches/sca-equinox/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java)0
-rw-r--r--branches/sca-equinox/samples/calculator-osgi/build.xml72
-rw-r--r--branches/sca-equinox/samples/calculator-rcp/pom.xml78
-rw-r--r--branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java13
57 files changed, 284 insertions, 553 deletions
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java
index b69c58a0ff..bf8d75dba9 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultModelFactoryExtensionPoint.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.contribution;
import java.lang.reflect.Constructor;
import java.util.HashMap;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
@@ -91,8 +92,9 @@ public class DefaultModelFactoryExtensionPoint implements ModelFactoryExtensionP
// Dynamically load a factory class declared under META-INF/services
try {
- Class<?> factoryClass = ServiceDiscovery.getInstance().loadFirstServiceClass(factoryInterface);
- if (factoryClass != null) {
+ ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName());
+ if (factoryDeclaration != null) {
+ Class<?> factoryClass = factoryDeclaration.loadClass();
try {
// Default empty constructor
@@ -115,7 +117,7 @@ public class DefaultModelFactoryExtensionPoint implements ModelFactoryExtensionP
// Call the newInstance static method on the factory abstract class
try {
- factory = ServiceDiscovery.getInstance().newFactoryClassInstance(factoryInterface);
+ factory = ServiceDiscovery.getInstance().newFactoryClassInstance(factoryInterface.getName());
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java
index 426d7beb29..589bcc9d92 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java
@@ -67,7 +67,7 @@ public class DefaultPackageProcessorExtensionPoint implements PackageProcessorEx
// Get the processor service declarations
Set<ServiceDeclaration> processorDeclarations;
try {
- processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(PackageProcessor.class);
+ processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(PackageProcessor.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
index f23ebc2c36..46ac9897a1 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
@@ -161,7 +161,7 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends
// Get the processor service declarations
Set<ServiceDeclaration> processorDeclarations;
try {
- processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXArtifactProcessor.class);
+ processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXArtifactProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
error("IllegalStateException", extensibleStAXProcessor, ie);
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
index d81e236b40..aa8875c08f 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
@@ -155,7 +155,7 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends
// Get the processor service declarations
Set<ServiceDeclaration> processorDeclarations;
try {
- processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXAttributeProcessor.class);
+ processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(StAXAttributeProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
error("IllegalStateException", extensibleStAXAttributeProcessor, ie);
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
index 045c201638..4d7374d803 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
@@ -127,7 +127,7 @@ public class DefaultURLArtifactProcessorExtensionPoint
// Get the processor service declarations
Set<ServiceDeclaration> processorDeclarations;
try {
- processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(URLArtifactProcessor.class);
+ processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(URLArtifactProcessor.class.getName());
} catch (IOException e) {
IllegalStateException ie = new IllegalStateException(e);
error("IllegalStateException", staxProcessor, ie);
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java
deleted file mode 100644
index d52a110c05..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package org.apache.tuscany.sca.contribution.processor;
-
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
-
-public class DefaultUnknownElementProcessor{
-
- private Monitor monitor;
- private static final Logger logger = Logger.getLogger(DefaultUnknownElementProcessor.class.getName());
-
- public DefaultUnknownElementProcessor(Monitor monitor){
- this.monitor = monitor;
- }
- private DocumentBuilderFactory documentBuilderFactory;
- private Document document;
-
- /**
- * Reads the contetns of the unknown elements and generates the DOM
- * @param reader
- * @param name
- * @return
- * @throws XMLStreamException
- */
- public Object read(XMLStreamReader reader, QName name) throws XMLStreamException{
-
- int event = reader.getEventType();
- int level = 0;
- ArrayList<String> elementList = new ArrayList<String>();
- document = createDocument();
- while(reader.hasNext()){
- switch(event){
- case START_ELEMENT:
- elementList.add(reader.getName().getLocalPart());
- if(level == 0){
- generateDOM(reader,null);
- level++;
- }
- else{
- generateDOM(reader,elementList.get(elementList.size()-2).toString());
- }
-
- break;
- case END_ELEMENT:
- elementList.remove(reader.getName().getLocalPart());
- }
- if(reader.hasNext()){
- event = reader.next();
- }
-
- if(event == START_ELEMENT || event == END_ELEMENT){
- if(reader.getName().equals(name)){
- break;
- }
- }
- }
- return document;
- }
-
- /**
- * Writes unknown portions back to the writer
- * @param model
- * @param writer
- */
- public void write(Object model, XMLStreamWriter writer) {
-
- if( ! (model instanceof Document)) {
- return;
- }
-
- Document doc = (Document)model;
- try{
- DocumentTraversal traversal = (DocumentTraversal)doc;
- TreeWalker walker = traversal.createTreeWalker(doc.getDocumentElement(),NodeFilter.SHOW_ALL, null, true);
- writeDOM(walker,writer);
- }
- catch(Exception e){
- if (logger.isLoggable(Level.SEVERE)) {
- logger.log(Level.SEVERE, "Document not created ");
- }
- error("Document not created",document,e);
- }
- }
-
- /**
- * Method to generate the DOM
- * @param reader
- * @param parent
- * @throws Exception
- */
- //private void generateDOM(String elementText, String parent) {
- private void generateDOM(XMLStreamReader reader, String parent) {
- try{
- String elePrefix = reader.getPrefix();
- String eleQName = reader.getLocalName();
- if (elePrefix != null && elePrefix.length() != 0) {
- eleQName = elePrefix + ":" + eleQName;
- }
-
- Element element = document.createElementNS(reader.getNamespaceURI(), eleQName);
-
- int attributeCount = reader.getAttributeCount();
- for(int i = 0;i < attributeCount;i++){
- String ns = reader.getAttributeNamespace(i);
- String prefix = reader.getAttributePrefix(i);
- String qname = reader.getAttributeLocalName(i);
- String value = reader.getAttributeValue(i);
- if (prefix != null && prefix.length() != 0) {
- qname = prefix + ":" + qname;
- }
- element.setAttributeNS(ns,qname,value);
- }
- if(parent == null){
- if(document != null){
- document.appendChild(element);
- }
- else{
- if (logger.isLoggable(Level.SEVERE)) {
- logger.log(Level.SEVERE, "Document not created ");
- }
- error("Document not created",document,element);
- }
- }
- else{
- Node parentNode = getParentNode(document,parent);
- if(parentNode != null){
- parentNode.appendChild(element);
- }
- else{
- if (logger.isLoggable(Level.SEVERE)) {
- logger.log(Level.SEVERE, "Parent node not found");
- }
- error("Parent node not found",document,parentNode.getNodeName());
- }
- }
- }
- catch(Exception e){
- e.printStackTrace();
- if (logger.isLoggable(Level.SEVERE)) {
- logger.log(Level.SEVERE, "Document not created ");
- }
- error("Document not created",document,e);
- }
- }
-
- /**
- * Method to create an empty document
- * @return
- */
- private Document createDocument() {
- try {
- if (documentBuilderFactory == null) {
- documentBuilderFactory = DocumentBuilderFactory.newInstance();
- }
- document = documentBuilderFactory.newDocumentBuilder().newDocument();
- return document;
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Method to traverse the DOM structure and write the elements
- * @param walker
- * @param writer
- * @throws XMLStreamException
- */
- private void writeDOM(TreeWalker walker,XMLStreamWriter writer) throws XMLStreamException {
-
- Node parent = walker.getCurrentNode();
-
- writer.writeStartElement(parent.getPrefix(), parent.getLocalName(), parent.getNamespaceURI());
-
- NamedNodeMap attributes = parent.getAttributes();
-
- for(int i = 0;i<attributes.getLength();i++){
- writer.writeAttribute(attributes.item(i).getPrefix(), attributes.item(i).getNamespaceURI(), attributes.item(i).getLocalName(), attributes.item(i).getNodeValue());
- }
-
- for (Node n = walker.firstChild();n != null;n = walker.nextSibling()) {
- writeDOM(walker,writer);
- }
- writer.writeEndElement();
-
- walker.setCurrentNode(parent);
- }
-
- /**
- * Method to get the Parent node out of the DOM structure
- * @param doc
- * @param parent
- * @return
- */
- private Node getParentNode(Node doc,String parent) {
- Node parentNode = null;
- try{
- DocumentTraversal traversal = (DocumentTraversal)doc;
-
- CharSequence prefixChar = ":";
- NodeIterator iterator = traversal.createNodeIterator(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
- for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
- String nodeName = n.getNodeName();
- String[] str = null;
- if(n.getNodeName().contains(prefixChar)){
- str = nodeName.split(":");
- nodeName = str[str.length-1];
- }
- if(parent.equalsIgnoreCase(nodeName)){
- parentNode = n;
- }
- }
- return parentNode;
- }
- catch(Exception e){
- e.printStackTrace();
- }
- return parentNode;
- }
-
- /**
- * Marshals exceptions into the monitor
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex);
- monitor.problem(problem);
- }
- }
-
- /**
- * Report a error.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
index ca5c36fe98..ce706fa69c 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
@@ -39,7 +39,6 @@ import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.contribution.service.UnrecognizedElementException;
-import org.apache.tuscany.sca.contribution.processor.DefaultUnknownElementProcessor;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
@@ -134,14 +133,12 @@ public class ExtensibleStAXArtifactProcessor
QName name = source.getName();
StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(name);
if (processor == null) {
- DefaultUnknownElementProcessor unknownElementProcessor = new DefaultUnknownElementProcessor(monitor);
Location location = source.getLocation();
if (logger.isLoggable(Level.WARNING)) {
logger.warning("Element " + name + " cannot be processed. (" + location + ")");
}
warning("ElementCannotBeProcessed", processors, name, location);
- //return null;
- return unknownElementProcessor.read(source,name);
+ return null;
}
return processor.read(source);
}
@@ -155,8 +152,6 @@ public class ExtensibleStAXArtifactProcessor
if (processor != null) {
processor.write(model, outputSource);
} else {
- DefaultUnknownElementProcessor unknownElementProcessor = new DefaultUnknownElementProcessor(monitor);
- unknownElementProcessor.write(model,outputSource);
if (logger.isLoggable(Level.WARNING)) {
logger.warning("No StAX processor is configured to handle " + model.getClass());
}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
index 77570aa13d..878a2efdab 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
@@ -97,7 +97,7 @@ public class DefaultModelResolverExtensionPoint implements ModelResolverExtensio
// Get the model resolver service declarations
Set<ServiceDeclaration> modelResolverDeclarations;
try {
- modelResolverDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModelResolver.class);
+ modelResolverDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModelResolver.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
index 24aae45b59..7610cb5aba 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
@@ -64,7 +64,7 @@ public class DefaultContributionScannerExtensionPoint implements ContributionSca
// Get the scanner service declarations
Set<ServiceDeclaration> scannerDeclarations;
try {
- scannerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionScanner.class);
+ scannerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionScanner.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
index 1ab80e344b..f36595d64f 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
@@ -82,7 +82,7 @@ public class DefaultContributionListenerExtensionPoint implements ContributionLi
// Get the listener service declarations
Set<ServiceDeclaration> listenerDeclarations;
try {
- listenerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionListener.class);
+ listenerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionListener.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
index 5a0aefe55d..7a35036f03 100644
--- a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
+++ b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Constructor;
import java.util.HashMap;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
@@ -93,8 +94,9 @@ public class DefaultContextFactoryExtensionPoint implements ContextFactoryExtens
// Dynamically load a factory class declared under META-INF/services
try {
- Class<?> factoryClass = ServiceDiscovery.getInstance().loadFirstServiceClass(factoryInterface);
- if (factoryClass != null) {
+ ServiceDeclaration factoryDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(factoryInterface.getName());
+ if (factoryDeclaration != null) {
+ Class<?> factoryClass = factoryDeclaration.loadClass();
// Default empty constructor
Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class);
diff --git a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
index 2849c27c1a..81f619cef3 100644
--- a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
+++ b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
@@ -100,7 +100,7 @@ public class DefaultEndpointResolverFactoryExtensionPoint implements EndpointRes
Set<ServiceDeclaration> factoryDeclarations;
ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
try {
- factoryDeclarations = serviceDiscovery.getServiceDeclarations(EndpointResolverFactory.class);
+ factoryDeclarations = serviceDiscovery.getServiceDeclarations(EndpointResolverFactory.class.getName());
} catch (Exception e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
index dfc3ddb468..0b7b779b46 100644
--- a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
+++ b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -129,7 +129,7 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte
Set<ServiceDeclaration> factoryDeclarations;
ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
try {
- factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass);
+ factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass.getName());
} catch (Exception e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java
index 068d0d12d7..3e1f1a10c5 100644
--- a/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java
+++ b/branches/sca-equinox/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java
@@ -68,7 +68,7 @@ public class DefaultSCADefinitionsProviderExtensionPoint implements
try {
defnProviderDecls =
- ServiceDiscovery.getInstance().getServiceDeclarations(SCADefinitionsProvider.class);
+ ServiceDiscovery.getInstance().getServiceDeclarations(SCADefinitionsProvider.class.getName());
for (ServiceDeclaration aDefnProviderDecl : defnProviderDecls) {
providerClass = aDefnProviderDecl.loadClass();
diff --git a/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java b/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
index b2da024a72..51cbba02d2 100644
--- a/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
+++ b/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
@@ -111,7 +111,7 @@ public class DefaultDataBindingExtensionPoint implements DataBindingExtensionPoi
// Get the databinding service declarations
Set<ServiceDeclaration> dataBindingDeclarations;
try {
- dataBindingDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(DataBinding.class);
+ dataBindingDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(DataBinding.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java b/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
index 7aa55d2cff..3bd729b472 100644
--- a/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
+++ b/branches/sca-equinox/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
@@ -115,7 +115,7 @@ public class DefaultTransformerExtensionPoint implements TransformerExtensionPoi
Set<ServiceDeclaration> transformerDeclarations;
try {
- transformerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(transformerClass);
+ transformerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(transformerClass.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
diff --git a/branches/sca-equinox/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
index 5ab5a66077..c918ad735d 100644
--- a/branches/sca-equinox/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
+++ b/branches/sca-equinox/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
@@ -23,6 +23,8 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -181,8 +183,17 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer {
}
return attributes;
}
+
+ public ServiceDeclaration getFirstServiceDeclaration(String name) throws IOException {
+ Set<ServiceDeclaration> declarations = getServiceDeclarations(name);
+ if (declarations.isEmpty()) {
+ return null;
+ } else {
+ return declarations.iterator().next();
+ }
+ }
- public Set<ServiceDeclaration> discover(String serviceName, boolean firstOnly) {
+ public Set<ServiceDeclaration> getServiceDeclarations(String serviceName) throws IOException {
boolean debug = logger.isLoggable(Level.FINE);
Set<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
@@ -256,9 +267,6 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer {
ServiceDeclarationImpl descriptor =
new ServiceDeclarationImpl(bundle, url, className, attributes);
descriptors.add(descriptor);
- if (firstOnly) {
- return descriptors;
- }
}
}
} finally {
@@ -278,4 +286,11 @@ public class EquinoxServiceDiscoverer implements ServiceDiscoverer {
return descriptors;
}
+ public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException {
+ Class<?> factoryClass = Class.forName(name, false, getClass().getClassLoader());
+ Method newInstanceMethod = factoryClass.getMethod("newInstance");
+ Object factory = newInstanceMethod.invoke(null);
+ return factory;
+ }
+
}
diff --git a/branches/sca-equinox/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java b/branches/sca-equinox/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java
index 3126365748..c21e4984f5 100644
--- a/branches/sca-equinox/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java
+++ b/branches/sca-equinox/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.extensibility.equinox;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -131,21 +132,19 @@ public class EquinoxServiceDiscovererTestCase {
}
@Test
- public void testDiscovery() {
- Set<ServiceDeclaration> descriptors =
- discoverer.discover("test.TestService", false);
+ public void testDiscovery() throws IOException {
+ Set<ServiceDeclaration> descriptors = discoverer.getServiceDeclarations("test.TestService");
Assert.assertEquals(1, descriptors.size());
- descriptors = discoverer.discover("notthere", false);
+ descriptors = discoverer.getServiceDeclarations("notthere");
Assert.assertEquals(0, descriptors.size());
}
@Test
- public void testDiscoveryFirst() {
- Set<ServiceDeclaration> descriptors =
- discoverer.discover("test.TestService", true);
- Assert.assertEquals(1, descriptors.size());
- descriptors = discoverer.discover("notthere", true);
- Assert.assertEquals(0, descriptors.size());
+ public void testDiscoveryFirst() throws IOException {
+ ServiceDeclaration descriptor = discoverer.getFirstServiceDeclaration("test.TestService");
+ Assert.assertNotNull(descriptor);
+ descriptor = discoverer.getFirstServiceDeclaration("notthere");
+ Assert.assertNull(descriptor);
}
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
index 48f240559c..12979723b1 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
@@ -103,9 +104,10 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
// Dynamically load an extension point class declared under META-INF/services
try {
- Class<?> extensionPointClass =
- ServiceDiscovery.getInstance().loadFirstServiceClass(extensionPointType);
- if (extensionPointClass != null) {
+ ServiceDeclaration extensionPointDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(extensionPointType.getName());
+ if (extensionPointDeclaration != null) {
+ Class<?> extensionPointClass = extensionPointDeclaration.loadClass();
+
// Construct the extension point
Constructor<?>[] constructors = extensionPointClass.getConstructors();
Constructor<?> constructor = getConstructor(constructors, new Class<?>[] {ExtensionPointRegistry.class});
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
index 8ca030c0dd..d84f28f11e 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
@@ -65,7 +65,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
// Get the activator service declarations
Set<ServiceDeclaration> activatorDeclarations;
try {
- activatorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class);
+ activatorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
index 6f7c83c8d9..9906bef909 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
@@ -103,9 +104,10 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
// Dynamically load a utility class declared under META-INF/utilities
try {
- Class<?> utilityClass =
- ServiceDiscovery.getInstance().loadFirstServiceClass(utilityType);
- if (utilityClass != null) {
+ ServiceDeclaration utilityDeclaration =ServiceDiscovery.getInstance().getFirstServiceDeclaration(utilityType.getName());
+ if (utilityDeclaration != null) {
+ Class<?> utilityClass = utilityDeclaration.loadClass();
+
// Construct the utility
Constructor<?>[] constructors = utilityClass.getConstructors();
Constructor<?> constructor = getConstructor(constructors, new Class<?>[] {ExtensionPointRegistry.class});
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
index 2e11234095..0f408600aa 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
@@ -24,13 +24,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -85,7 +86,7 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
}
public Class<?> loadClass(String className) throws ClassNotFoundException {
- return classLoaderReference.get().loadClass(className);
+ return Class.forName(className, false, classLoaderReference.get());
}
public String toString() {
@@ -112,21 +113,12 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
this.classLoaderReference = new WeakReference<ClassLoader>(classLoader);
}
- private List<URL> getResources(final String name, final boolean firstOnly) throws IOException {
+ private List<URL> getResources(final String name) throws IOException {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<List<URL>>() {
public List<URL> run() throws IOException {
- if (firstOnly) {
- URL url = classLoaderReference.get().getResource(name);
- if (url != null) {
- return Arrays.asList(url);
- } else {
- return Collections.emptyList();
- }
- } else {
- List<URL> urls = Collections.list(classLoaderReference.get().getResources(name));
- return urls;
- }
+ List<URL> urls = Collections.list(classLoaderReference.get().getResources(name));
+ return urls;
}
});
} catch (PrivilegedActionException e) {
@@ -169,13 +161,22 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
return attributes;
}
- public Set<ServiceDeclaration> discover(String serviceName, boolean firstOnly) {
+ public ServiceDeclaration getFirstServiceDeclaration(String name) throws IOException {
+ Set<ServiceDeclaration> declarations = getServiceDeclarations(name);
+ if (declarations.isEmpty()) {
+ return null;
+ } else {
+ return declarations.iterator().next();
+ }
+ }
+
+ public Set<ServiceDeclaration> getServiceDeclarations(String serviceName) {
Set<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
String name = "META-INF/services/" + serviceName;
boolean debug = logger.isLoggable(Level.FINE);
try {
- for (final URL url : getResources(name, firstOnly)) {
+ for (final URL url : getResources(name)) {
if (debug) {
logger.fine("Reading service provider file: " + url.toExternalForm());
}
@@ -223,9 +224,6 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
}
ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(url, className, attributes);
descriptors.add(descriptor);
- if (firstOnly) {
- return descriptors;
- }
}
}
} finally {
@@ -245,4 +243,11 @@ public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
}
+ public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException {
+ Class<?> factoryClass = Class.forName(name, false, classLoaderReference.get());
+ Method newInstanceMethod = factoryClass.getMethod("newInstance");
+ Object factory = newInstanceMethod.invoke(null);
+ return factory;
+ }
+
}
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java
index 403b6aa7a7..d7ac8b449f 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java
@@ -37,11 +37,13 @@ public interface ServiceDeclaration {
* @throws ClassNotFoundException
*/
Class<?> loadClass(String className) throws ClassNotFoundException;
+
/**
* Get the java class for the service impl
* @return The java class
*/
Class<?> loadClass() throws ClassNotFoundException;
+
/**
* Get all attributes (name=value pairs) defined for the given entry
* @return All attributes keyed by name
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java
index 1722cd5f49..679e3d1f57 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java
@@ -19,19 +19,44 @@
package org.apache.tuscany.sca.extensibility;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.util.Set;
/**
* A SPI that allows different implementations of discovering service declarations
*/
public interface ServiceDiscoverer {
+
/**
- * Discover the service descriptors by name
- * @param serviceName The name of the service
- * @param firstOnly A flag to indicate if only the first instance is to be discovered
- *
- * @return A set of service descriptors
+ * Get all service declarations for this interface
+ *
+ * @param name
+ * @return set of service declarations
+ * @throws IOException
*/
- Set<ServiceDeclaration> discover(String serviceName, boolean firstOnly);
-
+ public Set<ServiceDeclaration> getServiceDeclarations(String name) throws IOException;
+
+ /**
+ * Get first service declaration class for the given interface
+ *
+ * @param name
+ * @return service implementation class
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public ServiceDeclaration getFirstServiceDeclaration(String name) throws IOException;
+
+ /**
+ * Create a new instance of a factory service class.
+ *
+ * @param name
+ * @return service implementation class
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ */
+ public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException;
+
}
diff --git a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
index ce41a44068..552691ab6b 100644
--- a/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
+++ b/branches/sca-equinox/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
@@ -21,12 +21,9 @@ package org.apache.tuscany.sca.extensibility;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.HashSet;
import java.util.Set;
-import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -37,13 +34,12 @@ import java.util.logging.Logger;
*
* @version $Rev$ $Date$
*/
-public class ServiceDiscovery {
+public class ServiceDiscovery implements ServiceDiscoverer {
private static final Logger logger = Logger.getLogger(ServiceDiscovery.class.getName());
private final static ServiceDiscovery INSTANCE = new ServiceDiscovery();
private ServiceDiscoverer discoverer;
- private Set<ClassLoader> registeredClassLoaders = new HashSet<ClassLoader>();
/**
* Get an instance of Service discovery, one instance is created per
@@ -69,101 +65,27 @@ public class ServiceDiscovery {
discoverer = sd;
}
- /**
- * @deprecated
- * Register a ClassLoader with this discovery mechanism. Tuscany extension
- * ClassLoaders are registered here.
- *
- * @param classLoader
- */
- @Deprecated
- public synchronized void registerClassLoader(ClassLoader classLoader) {
- registeredClassLoaders.add(classLoader);
- }
-
- /**
- * @deprecated
- * Unregister a ClassLoader with this discovery mechanism.
- *
- * @param classLoader
- */
- @Deprecated
- public synchronized void unregisterClassLoader(ClassLoader classLoader) {
- registeredClassLoaders.remove(classLoader);
- }
-
- /**
- * Get all service declarations for this name
- *
- * @param name
- * @return set of service declarations
- * @throws IOException
- */
public Set<ServiceDeclaration> getServiceDeclarations(String name) throws IOException {
- Set<ServiceDeclaration> services = getServiceDiscoverer().discover(name, false);
+ Set<ServiceDeclaration> services = getServiceDiscoverer().getServiceDeclarations(name);
return services;
}
- /**
- * Get all service declarations for this interface
- *
- * @param serviceInterface
- * @return set of service declarations
- * @throws IOException
- */
- public Set<ServiceDeclaration> getServiceDeclarations(Class<?> serviceInterface) throws IOException {
-
- return getServiceDeclarations(serviceInterface.getName());
- }
-
- /**
- * Load one service implementation class for this interface
- *
- * @param serviceInterface
- * @return service implementation class
- * @throws IOException
- * @throws ClassNotFoundException
- */
- public Class<?> loadFirstServiceClass(final Class<?> serviceInterface) throws IOException, ClassNotFoundException {
+ public ServiceDeclaration getFirstServiceDeclaration(final String name) throws IOException {
// Try System property first
String className = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty(serviceInterface.getName());
+ return System.getProperty(name);
}
});
- if (className != null) {
- try {
- // Try the classloader for the service interface first
- return Class.forName(className, false, serviceInterface.getClassLoader());
- } catch (ClassNotFoundException e) {
- try {
- // Try the thread context classloader
- return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
- } catch (ClassNotFoundException ex) {
- logger.log(Level.WARNING, ex.getMessage(), ex);
- }
- }
- }
- Set<ServiceDeclaration> services = getServiceDiscoverer().discover(serviceInterface.getName(), true);
- if (services.isEmpty()) {
- return null;
+ if (className == null) {
+ className = name;
}
- return services.iterator().next().loadClass();
+ ServiceDeclaration service = getServiceDiscoverer().getFirstServiceDeclaration(className);
+ return service;
}
- /**
- * Create a new instance of a factory service class.
- *
- * @param serviceInterface
- * @return service implementation class
- * @throws SecurityException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalAccessException
- */
- public Object newFactoryClassInstance(final Class<?> serviceInterface) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- Method newInstanceMethod = serviceInterface.getMethod("newInstance");
- Object factory = newInstanceMethod.invoke(null);
+ public Object newFactoryClassInstance(String name) throws SecurityException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException {
+ Object factory = getServiceDiscoverer().newFactoryClassInstance(name);
return factory;
}
diff --git a/branches/sca-equinox/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java b/branches/sca-equinox/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
index fd508402fc..4c965420ca 100644
--- a/branches/sca-equinox/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
+++ b/branches/sca-equinox/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.extensibility;
+import java.io.IOException;
import java.util.Set;
import junit.framework.Assert;
@@ -44,21 +45,20 @@ public class ContextClassLoaderServiceDiscovererTestCase {
@Test
public void testDiscovery() {
Set<ServiceDeclaration> discriptors =
- discover.discover("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint", false);
+ discover.getServiceDeclarations("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
Assert.assertEquals(1, discriptors.size());
discriptors =
- discover.discover("notthere", false);
+ discover.getServiceDeclarations("notthere");
Assert.assertEquals(0, discriptors.size());
}
@Test
- public void testDiscoveryFirst() {
- Set<ServiceDeclaration> discriptors =
- discover.discover("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint", true);
- Assert.assertEquals(1, discriptors.size());
- discriptors =
- discover.discover("notthere", true);
- Assert.assertEquals(0, discriptors.size());
+ public void testDiscoveryFirst() throws IOException {
+ ServiceDeclaration descriptor =
+ discover.getFirstServiceDeclaration("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
+ Assert.assertNotNull(descriptor);
+ descriptor = discover.getFirstServiceDeclaration("notthere");
+ Assert.assertNull(descriptor);
}
diff --git a/branches/sca-equinox/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java b/branches/sca-equinox/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
index 720d409a44..5a7ac48e62 100644
--- a/branches/sca-equinox/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
+++ b/branches/sca-equinox/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
@@ -43,7 +43,7 @@ public class DiscoveryUtils {
List<T> activators;
try {
Set<ServiceDeclaration> activatorClasses =
- ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass);
+ ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass.getName());
activators = new ArrayList<T>();
for (ServiceDeclaration declaration : activatorClasses) {
try {
diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
index a7f148cdda..aaa4c6ee95 100644
--- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
+++ b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.host.embedded;
import java.lang.reflect.Constructor;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain;
import org.apache.tuscany.sca.host.embedded.management.ComponentManager;
@@ -174,9 +175,9 @@ public abstract class SCADomain {
final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader();
final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
- Class<?> implClass = ServiceDiscovery.getInstance().loadFirstServiceClass(SCADomain.class);
+ ServiceDeclaration implDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(SCADomain.class.getName());
- if (implClass == null) {
+ if (implDeclaration == null) {
// Create a default SCA domain implementation
domain =
@@ -187,6 +188,7 @@ public abstract class SCADomain {
// Create an instance of the discovered SCA domain implementation
Constructor<?> constructor = null;
try {
+ Class<?> implClass = implDeclaration.loadClass();
constructor =
implClass.getConstructor(ClassLoader.class,
ClassLoader.class,
@@ -204,6 +206,7 @@ public abstract class SCADomain {
composites);
} else {
+ Class<?> implClass = implDeclaration.loadClass();
constructor = implClass.getConstructor(ClassLoader.class, String.class);
domain = (SCADomain)constructor.newInstance(runtimeClassLoader, domainURI);
}
diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
index 55b6afb6f2..be700cb2d0 100644
--- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
+++ b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
@@ -305,7 +305,7 @@ public class ReallySmallRuntime {
modules = new ArrayList<ModuleActivator>();
try {
Set<ServiceDeclaration> moduleActivators =
- ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class);
+ ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName());
Set<String> moduleClasses = new HashSet<String>();
for (ServiceDeclaration moduleDeclarator : moduleActivators) {
if (moduleClasses.contains(moduleDeclarator.getClassName())) {
diff --git a/branches/sca-equinox/modules/host-jetty/pom.xml b/branches/sca-equinox/modules/host-jetty/pom.xml
index 9d4570b9ec..736a6f8dde 100644
--- a/branches/sca-equinox/modules/host-jetty/pom.xml
+++ b/branches/sca-equinox/modules/host-jetty/pom.xml
@@ -75,7 +75,8 @@
org.mortbay.jetty.servlet;version="6.1.7",
org.mortbay.log;version="6.1.7",
org.mortbay.resource;version="6.1.7",
- org.mortbay.thread;version="6.1.7"
+ org.mortbay.thread;version="6.1.7",
+ *
</Import-Package>
</instructions>
</configuration>
diff --git a/branches/sca-equinox/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java b/branches/sca-equinox/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
index 7853b597d3..2a0fc8099a 100644
--- a/branches/sca-equinox/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
+++ b/branches/sca-equinox/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
@@ -70,7 +70,7 @@ public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implem
// Get the databinding service declarations
Set<ServiceDeclaration> visitorDeclarations;
try {
- visitorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavaInterfaceVisitor.class);
+ visitorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavaInterfaceVisitor.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java
index e41afd29c4..2c91032653 100644
--- a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java
+++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java
@@ -123,13 +123,11 @@ public abstract class SCANodeFactory {
// final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// Use reflection APIs to call ServiceDiscovery to avoid hard dependency to tuscany-extensibility
try {
- Class<?> discoveryClass =
- Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery");
+ Class<?> discoveryClass = Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery");
Object instance = discoveryClass.getMethod("getInstance").invoke(null);
- Class<?> factoryImplClass =
- (Class<?>)discoveryClass.getMethod("loadFirstServiceClass", Class.class)
- .invoke(instance, SCANodeFactory.class);
- if (factoryImplClass != null) {
+ Object factoryDeclaration = discoveryClass.getMethod("getFirstServiceDeclaration", String.class).invoke(instance, SCANodeFactory.class.getName());
+ if (factoryDeclaration != null) {
+ Class<?> factoryImplClass = (Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
scaNodeFactory = (SCANodeFactory)factoryImplClass.newInstance();
return scaNodeFactory;
}
diff --git a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
index 5b0e31fd03..15a348afd8 100644
--- a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
+++ b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java
@@ -299,6 +299,7 @@ public class RuntimeBootStrapper {
//now that all system sca definitions have been read, lets resolve them right away
definitionsProcessor.resolve(systemSCADefinitions, policyDefinitionsResolver);
+
} catch (Exception e) {
throw new ActivationException(e);
}
@@ -310,7 +311,7 @@ public class RuntimeBootStrapper {
modules = new ArrayList<ModuleActivator>();
try {
Set<ServiceDeclaration> moduleActivators =
- ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class);
+ ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName());
Set<String> moduleClasses = new HashSet<String>();
for (ServiceDeclaration moduleDeclarator : moduleActivators) {
if (moduleClasses.contains(moduleDeclarator.getClassName())) {
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index 6efdcb0da5..aabfd4bcfe 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.node.equinox.launcher;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.bundleLocation;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.installBundle;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string;
import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME;
@@ -153,7 +154,7 @@ public class EquinoxHost {
// Install the launcher bundle
String bundleLocation = bundleLocation();
logger.info("Installing launcher bundle: " + bundleLocation);
- launcherBundle = bundleContext.installBundle(bundleLocation);
+ launcherBundle = installBundle(bundleContext, bundleLocation);
logger.info("Starting bundle: " + string(launcherBundle, false));
launcherBundle.start();
@@ -229,6 +230,15 @@ public class EquinoxHost {
if (mf.isFile()) {
Manifest manifest = new Manifest(new FileInputStream(mf));
bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ } else {
+ if (file.getPath().endsWith("target/classes")) {
+ // Development mode, MANIFEST.MF is outside the bundle location
+ mf = new File(file.getParentFile().getParentFile(), "META-INF/MANIFEST.MF");
+ if (mf.isFile()) {
+ Manifest manifest = new Manifest(new FileInputStream(mf));
+ bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ }
+ }
}
} else {
JarFile jar = new JarFile(file, false);
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
index 3f88bd89e9..b2c80f6fd7 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java
@@ -3,6 +3,7 @@ package org.apache.tuscany.sca.node.equinox.launcher;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.getProperty;
import static java.lang.System.setProperty;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.installBundle;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.libraryBundle;
import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string;
@@ -77,9 +78,10 @@ public class EquinoxLauncherBundleHelper implements BundleListener {
continue;
}
long installStart = currentTimeMillis();
- Bundle bundle = bundleContext.installBundle(bundleFile);
+ Bundle bundle = installBundle(bundleContext, bundleFile);
logger.info("Bundle installed in " + (currentTimeMillis() - installStart) + " ms: " + string(bundle, false));
installedBundles.add(bundle);
+ alreadyInstalledBundleNames.add(bundleName);
}
}
diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
index bf65c3f323..0bbf09d101 100644
--- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
+++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -31,8 +31,10 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.net.URISyntaxException;
@@ -50,6 +52,7 @@ import java.util.zip.ZipInputStream;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
/**
* Common functions and constants used by the admin components.
@@ -344,6 +347,31 @@ final class NodeLauncherUtil {
return path;
}
}
+
+ static Bundle installBundle(BundleContext bundleContext, String location) throws BundleException, IOException {
+ // Development mode, copy the MANIFEST.MF file to the bundle location
+ if (location.endsWith("/target/classes/")) {
+ File target = file(new URL(location));
+ File targetManifest = new File(target, "META-INF/MANIFEST.MF");
+ File sourceManifest = new File(target.getParentFile().getParentFile(), "META-INF/MANIFEST.MF");
+ targetManifest.getParentFile().mkdirs();
+ OutputStream os = new FileOutputStream(targetManifest);
+ InputStream is = new FileInputStream(sourceManifest);
+ byte[] buf = new byte[2048];
+ for (;;) {
+ int l = is.read(buf);
+ if (l == -1) {
+ break;
+ }
+ os.write(buf, 0, l);
+ }
+ is.close();
+ os.close();
+ }
+
+ Bundle bundle = bundleContext.installBundle(location);
+ return bundle;
+ }
static String string(Bundle b, boolean verbose) {
StringBuffer sb = new StringBuffer();
diff --git a/branches/sca-equinox/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java b/branches/sca-equinox/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
index 3a37ed3c41..e9af4912a3 100644
--- a/branches/sca-equinox/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
+++ b/branches/sca-equinox/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
@@ -42,7 +42,7 @@ public class PolicyHandlerDefinitionsLoader {
// Get the processor service declarations
Set<ServiceDeclaration> sds;
try {
- sds = ServiceDiscovery.getInstance().getServiceDeclarations(PolicyHandler.class);
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(PolicyHandler.class.getName());
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/branches/sca-equinox/samples/calculator-osgi/README b/branches/sca-equinox/samples/calculator-equinox/README
index cde5fe981f..cde5fe981f 100644
--- a/branches/sca-equinox/samples/calculator-osgi/README
+++ b/branches/sca-equinox/samples/calculator-equinox/README
diff --git a/branches/sca-equinox/samples/calculator-osgi/calculator.png b/branches/sca-equinox/samples/calculator-equinox/calculator.png
index 995a57b1fd..995a57b1fd 100644
--- a/branches/sca-equinox/samples/calculator-osgi/calculator.png
+++ b/branches/sca-equinox/samples/calculator-equinox/calculator.png
Binary files differ
diff --git a/branches/sca-equinox/samples/calculator-osgi/calculator.svg b/branches/sca-equinox/samples/calculator-equinox/calculator.svg
index af34f07e04..af34f07e04 100644
--- a/branches/sca-equinox/samples/calculator-osgi/calculator.svg
+++ b/branches/sca-equinox/samples/calculator-equinox/calculator.svg
diff --git a/branches/sca-equinox/samples/calculator-osgi/pom.xml b/branches/sca-equinox/samples/calculator-equinox/pom.xml
index a1d371df73..394fc331ab 100644
--- a/branches/sca-equinox/samples/calculator-osgi/pom.xml
+++ b/branches/sca-equinox/samples/calculator-equinox/pom.xml
@@ -25,7 +25,7 @@
<version>1.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <artifactId>sample-calculator-osgi</artifactId>
+ <artifactId>sample-calculator-equinox</artifactId>
<name>Apache Tuscany SCA Calculator OSGi Sample</name>
<repositories>
@@ -44,6 +44,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
@@ -71,20 +77,6 @@
</dependency>
<dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-node-launcher-equinox</artifactId>
- <version>1.4-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version> <!-- To be compatible with Jetty 6 -->
- <scope>provided</scope>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddService.java
index 188451ebac..188451ebac 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddService.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddService.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java
index 7ca8fb04b5..7ca8fb04b5 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java
index c193b2ce66..c193b2ce66 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java
index 031fa8b912..031fa8b912 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java
index 3d861f2018..3d861f2018 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideService.java
index 30d248208b..30d248208b 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideService.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideService.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java
index 1323edf55a..1323edf55a 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java
index 5290605938..5290605938 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java
index 91b803bc9e..91b803bc9e 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractService.java
index bf0d1882b6..bf0d1882b6 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractService.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractService.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java
index 58cc4a3547..58cc4a3547 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite b/branches/sca-equinox/samples/calculator-equinox/src/main/resources/Calculator.composite
index 913081b9be..913081b9be 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/main/resources/Calculator.composite
+++ b/branches/sca-equinox/samples/calculator-equinox/src/main/resources/Calculator.composite
diff --git a/branches/sca-equinox/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java
index dc0da7d20d..dc0da7d20d 100644
--- a/branches/sca-equinox/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java
+++ b/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java
diff --git a/branches/sca-equinox/samples/calculator-osgi/build.xml b/branches/sca-equinox/samples/calculator-osgi/build.xml
deleted file mode 100644
index c4b755ef94..0000000000
--- a/branches/sca-equinox/samples/calculator-osgi/build.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project name="calculator" default="compile">
- <property name="test.class" value="calculator.CalculatorClient" />
- <property name="test.jar" value="sample-calculator.jar" />
-
- <target name="init">
- <mkdir dir="target/classes"/>
- </target>
-
- <target name="compile" depends="init">
- <javac srcdir="src/main/java"
- destdir="target/classes"
- debug="on"
- source="1.5"
- target="1.5">
- <classpath>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
- </classpath>
- </javac>
- <copy todir="target/classes">
- <fileset dir="src/main/resources"/>
- </copy>
- <jar destfile="target/${test.jar}" basedir="target/classes">
- <manifest>
- <attribute name="Main-Class" value="${test.class}" />
- </manifest>
- </jar>
- </target>
-
- <target name="run-classes">
- <java classname="${test.class}"
- fork="true">
- <classpath>
- <pathelement path="target/classes"/>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
- </classpath>
- </java>
- </target>
-
- <target name="run">
- <java classname="${test.class}"
- fork="true">
- <classpath>
- <pathelement path="target/${test.jar}"/>
- <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
- </classpath>
- </java>
- </target>
-
- <target name="clean">
- <delete quiet="true" includeemptydirs="true">
- <fileset dir="target"/>
- </delete>
- </target>
-</project>
diff --git a/branches/sca-equinox/samples/calculator-rcp/pom.xml b/branches/sca-equinox/samples/calculator-rcp/pom.xml
index a487076de6..c50048c028 100644
--- a/branches/sca-equinox/samples/calculator-rcp/pom.xml
+++ b/branches/sca-equinox/samples/calculator-rcp/pom.xml
@@ -25,7 +25,7 @@
<version>1.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <artifactId>sample.calculator.rcp</artifactId>
+ <artifactId>sample-calculator-rcp</artifactId>
<name>Apache Tuscany SCA Calculator RCP Sample</name>
<repositories>
<repository>
@@ -34,6 +34,7 @@
</url>
</repository>
</repositories>
+
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
@@ -70,13 +71,79 @@
<version>1.4-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
- <!--
+
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>ui</artifactId>
<version>3.3.0-I20070614-0800</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>swt</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>help</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>swt</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>jface</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>expressions</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jface</groupId>
+ <artifactId>databinding</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
- -->
+
+ <dependency>
+ <groupId>org.eclipse.swt.win32.win32</groupId>
+ <artifactId>x86</artifactId>
+ <version>3.3.0-v3346</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>jface</artifactId>
+ <version>3.3.0-I20070606-0010</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>swt</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>commands</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>common</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>commands</artifactId>
+ <version>3.3.0-I20070605-0010</version>
+ </dependency>
+
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@@ -90,6 +157,7 @@
<scope>test</scope>
</dependency>
</dependencies>
+
<build>
<finalName>${artifactId}</finalName>
<plugins>
@@ -108,8 +176,6 @@
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
</classpathContainer>
- <classpathContainer>org.eclipse.pde.core.requiredPlugins
- </classpathContainer>
</classpathContainers>
</configuration>
</plugin>
@@ -123,4 +189,4 @@
</plugin>
</plugins>
</build>
-</project> \ No newline at end of file
+</project>
diff --git a/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java b/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java
index 50f68dcb01..2b1bae34de 100644
--- a/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java
+++ b/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java
@@ -21,9 +21,9 @@ package calculator.rcp;
import java.io.File;
import org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoverer;
-import org.apache.tuscany.sca.node.SCAContribution;
import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -39,6 +39,7 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ private NodeLauncher launcher;
private SCANode node;
/**
@@ -54,9 +55,8 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- Class<?> cls = EquinoxServiceDiscoverer.class;
- SCANodeFactory factory = SCANodeFactory.newInstance();
- node = factory.createSCANode("Calculator.composite", new SCAContribution("c1", new File("target/classes").toURI().toString()));
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNode("Calculator.composite", new Contribution("c1", new File("target/classes").toURI().toString()));
node.start();
}
@@ -70,6 +70,9 @@ public class Activator extends AbstractUIPlugin {
if (node != null) {
node.stop();
}
+ if (launcher != null) {
+ launcher.destroy();
+ }
}
/**