Author: rfeng
Date: Mon Mar  9 21:39:29 2009
New Revision: 751855

URL: http://svn.apache.org/viewvc?rev=751855&view=rev
Log:
Work in progress for implementation.osgi

Added:
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/test/resources/bundle.componentType
Modified:
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
    
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
    
tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgiproptest.composite

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
 Mon Mar  9 21:39:29 2009
@@ -37,8 +37,9 @@
     String getBundleVersion();
 
     void setBundleVersion(String version);
-    
+
     Bundle getBundle();
+
     void setBundle(Bundle bundle);
 
 }

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
 Mon Mar  9 21:39:29 2009
@@ -23,7 +23,7 @@
 import org.osgi.framework.BundleContext;
 
 public class OSGiImplementationActivator implements BundleActivator {
-    static BundleContext bundleContext;
+    private static BundleContext bundleContext;
 
     public void start(BundleContext context) throws Exception {
         bundleContext = context;

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
 Mon Mar  9 21:39:29 2009
@@ -44,11 +44,9 @@
 import org.apache.tuscany.sca.assembly.Multiplicity;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.factory.InstanceWrapper;
 import org.apache.tuscany.sca.core.factory.ObjectCreationException;
 import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.core.invocation.impl.JDKProxyFactory;
 import org.apache.tuscany.sca.core.scope.Scope;
 import org.apache.tuscany.sca.core.scope.ScopeContainer;
@@ -111,7 +109,7 @@
     private Hashtable<String, Object> componentProperties = new 
Hashtable<String, Object>();
     private RuntimeComponent runtimeComponent;
 
-    private Bundle osgiBundle;
+    Bundle osgiBundle;
     private ArrayList<Bundle> dependentBundles = new ArrayList<Bundle>();
     private OSGiServiceListener osgiServiceListener;
     private PackageAdmin packageAdmin;
@@ -127,41 +125,23 @@
     public OSGiImplementationProvider(RuntimeComponent definition,
                                       OSGiImplementation impl,
                                       DataBindingExtensionPoint 
dataBindingRegistry,
-                                      JavaPropertyValueObjectFactory 
propertyValueFactory,
-                                      ProxyFactory proxyFactory,
                                       ScopeRegistry scopeRegistry,
-                                      RequestContextFactory 
requestContextFactory,
                                       MessageFactory messageFactory,
                                       InterfaceContractMapper mapper) throws 
BundleException {
 
         this.implementation = (OSGiImplementationImpl)impl;
         this.runtimeComponent = definition;
         this.dataBindingRegistry = dataBindingRegistry;
-        this.propertyValueFactory = propertyValueFactory;
         this.scopeRegistry = scopeRegistry;
         this.messageFactory = messageFactory;
         this.mapper = mapper;
 
-        BundleContext bundleContext = 
OSGiImplementationActivator.bundleContext;
-        osgiBundle = (Bundle)implementation.getOSGiBundle();
+        BundleContext bundleContext = 
OSGiImplementationActivator.getBundleContext();
+        osgiBundle = (Bundle)implementation.getBundle();
         bundleContext.addBundleListener(this);
         osgiServiceListener = new OSGiServiceListener(osgiBundle);
         bundleContext.addServiceListener(osgiServiceListener);
 
-        // Install and start all dependent  bundles
-        String[] imports = implementation.getImports();
-        for (int i = 0; i < imports.length; i++) {
-            String location = imports[i].trim();
-            if (location.length() > 0) {
-                Bundle bundle = bundleContext.installBundle(location);
-                dependentBundles.add(bundle);
-            }
-        }
-
-        this.osgiAnnotations =
-            new OSGiAnnotations(implementation.getModelFactories(), 
implementation.getClassList(), runtimeComponent,
-                                propertyValueFactory, proxyFactory, 
requestContextFactory, osgiBundle, dependentBundles);
-
         // PackageAdmin is used to resolve bundles 
         org.osgi.framework.ServiceReference packageAdminReference =
             
bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java
 Mon Mar  9 21:39:29 2009
@@ -85,9 +85,8 @@
 
         try {
 
-            return new OSGiImplementationProvider(component, implementation, 
dataBindings, propertyFactory,
-                                                  proxyFactory, scopeRegistry, 
requestContextFactory, messageFactory,
-                                                  mapper);
+            return new OSGiImplementationProvider(component, implementation, 
dataBindings, scopeRegistry,
+                                                  requestContextFactory, 
messageFactory, mapper);
 
         } catch (BundleException e) {
             throw new RuntimeException(e);

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java?rev=751855&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
 Mon Mar  9 21:39:29 2009
@@ -0,0 +1,40 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.implementation.osgi.runtime;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * A ServiceTracker
+ */
+public class OSGiServiceTracker implements ServiceTrackerCustomizer {
+
+    public Object addingService(ServiceReference serviceReference) {
+        return null;
+    }
+
+    public void modifiedService(ServiceReference serviceReference, Object 
service) {
+    }
+
+    public void removedService(ServiceReference serviceReference, Object 
service) {
+    }
+
+}

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiServiceTracker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java
 Mon Mar  9 21:39:29 2009
@@ -23,16 +23,11 @@
 import java.lang.reflect.Method;
 
 import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.interfacedef.ConversationSequence;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.EndpointReference;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 
 /**
@@ -55,11 +50,6 @@
     private final OSGiImplementationProvider provider;
     private final RuntimeComponentService service;
 
-    // Scope container is reset by the OSGi implementation provider if @Scope
-    // annotation is used to modify the scope (default is composite)
-    // Hence this field is initialized on the first invoke.
-    private ScopeContainer scopeContainer;
-
     public OSGiTargetInvoker(Operation operation, OSGiImplementationProvider 
provider, RuntimeComponentService service) {
 
         this.operation = operation;
@@ -68,82 +58,22 @@
 
     }
 
-    /**
-     * Resolves the target service instance or returns a cached one
-     */
-    @SuppressWarnings("unchecked")
-    protected InstanceWrapper getInstance(Object contextId) throws 
TargetResolutionException {
-
-        if (scopeContainer == null)
-            scopeContainer = provider.getScopeContainer();
-
-        return scopeContainer.getWrapper(contextId);
-
-    }
-
-    @SuppressWarnings("unchecked")
     private Object invokeTarget(Message msg) throws InvocationTargetException {
 
-        if (scopeContainer == null)
-            scopeContainer = provider.getScopeContainer();
-
         Operation op = msg.getOperation();
         if (op == null) {
             op = this.operation;
         }
-        ConversationSequence sequence = op.getConversationSequence();
-
-        Object contextId = null;
-
-        EndpointReference from = msg.getFrom();
-        ReferenceParameters parameters = null;
-
-        if (from != null) {
-            parameters = from.getReferenceParameters();
-        }
-        // check what sort of context is required
-        if (scopeContainer != null) {
-            Scope scope = scopeContainer.getScope();
-            if (scope == Scope.REQUEST) {
-                contextId = Thread.currentThread();
-            } else if (scope == Scope.CONVERSATION && parameters != null) {
-                contextId = parameters.getConversationID();
-            }
-        }
 
         try {
-
-            OSGiInstanceWrapper wrapper = 
(OSGiInstanceWrapper)getInstance(contextId);
-            Object instance;
-
-            // detects whether the scope container has created a conversation 
Id. This will
-            // happen in the case that the component has conversational scope 
but only the
-            // callback interface is conversational. Or in the callback case 
if the service interface
-            // is conversational and the callback interface isn't. If we are 
in this situation we need
-            // to get the contextId of this component and remove it after we 
have invoked the method on 
-            // it. It is possible that the component instance will not go away 
when it is removed below 
-            // because a callback conversation will still be holding a 
reference to it
-            boolean removeTemporaryConversationalComponentAfterCall = false;
-            if (parameters != null && (contextId == null) && 
(parameters.getConversationID() != null)) {
-                contextId = parameters.getConversationID();
-                removeTemporaryConversationalComponentAfterCall = true;
-            }
-
-            instance = wrapper.getInstance(service);
+            JavaInterface javaInterface = (JavaInterface)op.getInterface();
+            // FIXME: What is the filter?
+            Object instance = 
provider.osgiBundle.getBundleContext().getServiceReference(javaInterface.getName());
 
             Method m = JavaInterfaceUtil.findMethod(instance.getClass(), 
operation);
 
             Object ret = invokeMethod(instance, m, msg);
 
-            scopeContainer.returnWrapper(wrapper, contextId);
-
-            if ((sequence == ConversationSequence.CONVERSATION_END) || 
(removeTemporaryConversationalComponentAfterCall)) {
-                // if end conversation, or we have the special case where a 
conversational
-                // object was created to service the stateless half of a 
stateful component
-                scopeContainer.remove(contextId);
-                parameters.setConversationID(null);
-            }
-
             return ret;
         } catch (InvocationTargetException e) {
             throw e;
@@ -173,11 +103,6 @@
 
     public Message invoke(Message msg) {
         try {
-            //            Object messageId = msg.getMessageID();
-            //            Message workContext = 
ThreadMessageContext.getMessageContext();
-            //            if (messageId != null) {
-            //                workContext.setCorrelationID(messageId);
-            //            }
             Object resp = invokeTarget(msg);
             msg.setBody(resp);
         } catch (InvocationTargetException e) {

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
 Mon Mar  9 21:39:29 2009
@@ -323,48 +323,6 @@
         return ref.getJavaClass();
     }
 
-    private Service createService(Service serv, Class<?> interfaze, Class<?> 
callbackInterfaze)
-        throws InvalidInterfaceException {
-        Service service = assemblyFactory.createService();
-        JavaInterfaceContract interfaceContract = 
javaInterfaceFactory.createJavaInterfaceContract();
-        service.setInterfaceContract(interfaceContract);
-
-        // create a relative URI
-        service.setName(serv.getName());
-
-        JavaInterface callInterface = 
javaInterfaceFactory.createJavaInterface(interfaze);
-        service.getInterfaceContract().setInterface(callInterface);
-
-        if (callbackInterfaze != null) {
-            JavaInterface callbackInterface = 
javaInterfaceFactory.createJavaInterface(callbackInterfaze);
-            
service.getInterfaceContract().setCallbackInterface(callbackInterface);
-        } else if (callInterface.getCallbackClass() != null) {
-            JavaInterface callbackInterface =
-                
javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
-            
service.getInterfaceContract().setCallbackInterface(callbackInterface);
-        }
-        return service;
-    }
-
-    private Reference createReference(Reference ref, Class<?> clazz) throws 
InvalidInterfaceException {
-        org.apache.tuscany.sca.assembly.Reference reference = 
assemblyFactory.createReference();
-        JavaInterfaceContract interfaceContract = 
javaInterfaceFactory.createJavaInterfaceContract();
-        reference.setInterfaceContract(interfaceContract);
-
-        reference.setName(ref.getName());
-        reference.setMultiplicity(ref.getMultiplicity());
-
-        JavaInterface callInterface = 
javaInterfaceFactory.createJavaInterface(clazz);
-        reference.getInterfaceContract().setInterface(callInterface);
-        if (callInterface.getCallbackClass() != null) {
-            JavaInterface callbackInterface =
-                
javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
-            
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
-        }
-
-        return reference;
-    }
-
     public void write(OSGiImplementation model, XMLStreamWriter outputSource) 
throws ContributionWriteException,
         XMLStreamException {
 
@@ -386,162 +344,4 @@
         }
     }
 
-    private void declareNamespace(Element element, String prefix, String ns) {
-        String qname = null;
-        if ("".equals(prefix)) {
-            qname = "xmlns";
-        } else {
-            qname = "xmlns:" + prefix;
-        }
-        Node node = element;
-        boolean declared = false;
-        while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
-            NamedNodeMap attrs = node.getAttributes();
-            if (attrs == null) {
-                break;
-            }
-            Node attr = attrs.getNamedItem(qname);
-            if (attr != null) {
-                declared = ns.equals(attr.getNodeValue());
-                break;
-            }
-            node = node.getParentNode();
-        }
-        if (!declared) {
-            org.w3c.dom.Attr attr = 
element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
-            attr.setValue(ns);
-            element.setAttributeNodeNS(attr);
-        }
-    }
-
-    private Element createElement(Document document, QName name) {
-        String prefix = name.getPrefix();
-        String qname =
-            (prefix != null && prefix.length() > 0) ? prefix + ":" + 
name.getLocalPart() : name.getLocalPart();
-        return document.createElementNS(name.getNamespaceURI(), qname);
-    }
-
-    private void loadElement(XMLStreamReader reader, Element root) throws 
XMLStreamException {
-        Document document = root.getOwnerDocument();
-        Node current = root;
-        while (true) {
-            switch (reader.next()) {
-                case XMLStreamConstants.START_ELEMENT:
-                    QName name = reader.getName();
-                    Element child = createElement(document, name);
-
-                    // push the new element and make it the current one
-                    current.appendChild(child);
-                    current = child;
-
-                    declareNamespace(child, name.getPrefix(), 
name.getNamespaceURI());
-
-                    int count = reader.getNamespaceCount();
-                    for (int i = 0; i < count; i++) {
-                        String prefix = reader.getNamespacePrefix(i);
-                        String ns = reader.getNamespaceURI(i);
-                        declareNamespace(child, prefix, ns);
-                    }
-
-                    // add the attributes for this element
-                    count = reader.getAttributeCount();
-                    for (int i = 0; i < count; i++) {
-                        String ns = reader.getAttributeNamespace(i);
-                        String prefix = reader.getAttributePrefix(i);
-                        String localPart = reader.getAttributeLocalName(i);
-                        String value = reader.getAttributeValue(i);
-                        child.setAttributeNS(ns, localPart, value);
-                        declareNamespace(child, prefix, ns);
-                    }
-
-                    break;
-                case XMLStreamConstants.CDATA:
-                    
current.appendChild(document.createCDATASection(reader.getText()));
-                    break;
-                case XMLStreamConstants.CHARACTERS:
-                    
current.appendChild(document.createTextNode(reader.getText()));
-                    break;
-                case XMLStreamConstants.END_ELEMENT:
-                    // if we are back at the root then we are done
-                    if (current == root) {
-                        return;
-                    }
-
-                    // pop the element off the stack
-                    current = current.getParentNode();
-            }
-        }
-    }
-
-    private Document readPropertyValue(XMLStreamReader reader, QName type) 
throws XMLStreamException,
-        ParserConfigurationException {
-
-        Document doc = domFactory.newDocumentBuilder().newDocument();
-
-        // root element has no namespace and local name "value"
-        Element root = doc.createElementNS(null, "value");
-        if (type != null) {
-            org.w3c.dom.Attr xsi = 
doc.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
-            xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
-            root.setAttributeNodeNS(xsi);
-
-            String prefix = type.getPrefix();
-            if (prefix == null || prefix.length() == 0) {
-                prefix = "ns";
-            }
-
-            declareNamespace(root, prefix, type.getNamespaceURI());
-
-            org.w3c.dom.Attr xsiType = 
doc.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
-            xsiType.setValue(prefix + ":" + type.getLocalPart());
-            root.setAttributeNodeNS(xsiType);
-        }
-        doc.appendChild(root);
-
-        loadElement(reader, root);
-        return doc;
-    }
-
-    private void readProperty(ComponentProperty prop, XMLStreamReader reader) 
throws XMLStreamException,
-        ContributionReadException {
-
-        prop.setName(reader.getAttributeValue(null, "name"));
-        String xsdType = reader.getAttributeValue(null, "type");
-        if (xsdType != null)
-            prop.setXSDType(getQNameValue(reader, xsdType));
-        else
-            prop.setXSDType(SimpleTypeMapperImpl.XSD_STRING);
-
-        try {
-            Document value = readPropertyValue(reader, prop.getXSDType());
-            prop.setValue(value);
-        } catch (ParserConfigurationException e) {
-            ContributionReadException ce = new ContributionReadException(e);
-            error("ContributionReadException", reader, ce);
-            throw ce;
-        }
-    }
-
-    private List<ComponentProperty> readProperties(XMLStreamReader reader) 
throws XMLStreamException,
-        ContributionReadException {
-
-        List<ComponentProperty> properties = new 
ArrayList<ComponentProperty>();
-
-        while (reader.hasNext()) {
-
-            int next = reader.next();
-            if (next == END_ELEMENT && 
PROPERTIES_QNAME.equals(reader.getName())) {
-                break;
-            } else if (next == START_ELEMENT && 
PROPERTY_QNAME.equals(reader.getName())) {
-
-                ComponentProperty componentProperty = 
assemblyFactory.createComponentProperty();
-                readProperty(componentProperty, reader);
-                properties.add(componentProperty);
-            }
-        }
-
-        return properties;
-
-    }
-
 }

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java?rev=751855&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
 Mon Mar  9 21:39:29 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.    
+ */
+
+package org.apache.tuscany.sca.implementation.osgi.xml;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The OSGi RFC 119 description of a remote OSGi service
+ */
+public class ServiceDescription {
+    public final static String REMOTE_SERVICE_FOLDER = 
"OSGI-INF/remote-service";
+    public final static String SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0";;
+    public final static QName SERVICE_DESCRIPTIONS_QNAME = new QName(SD_NS, 
"service-descriptions");
+    public final static QName SERVICE_DESCRIPTION_QNAME = new QName(SD_NS, 
"service-description");
+    public final static String REMOTE_SERVICE_HEADER = "Remote-Service";
+    public final static String PROP_SERVICE_INTENTS = "service.intents";
+    public final static String PROP_REQUIRES_INTENTS = 
"osgi.remote.requires.intents";
+    public final static String PROP_CONFIGURATION_TYPE = 
"osgi.remote.configuration.type";
+    public final static String CONFIGURATION_TYPE_SCA = "sca";
+    public final static String PROP_CONFIGURATION_SCA_BINDINGS = 
"osgi.remote.configuration.sca.bindings";
+
+    private List<String> interfaces = new ArrayList<String>();
+    private Map<String, Object> properties = new HashMap<String, Object>();
+
+    public List<String> getInterfaces() {
+        return interfaces;
+    }
+
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    public String toString() {
+        return "service-description: interfaces=" + interfaces + "properties=" 
+ properties;
+    }
+}
\ No newline at end of file

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescription.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
 Mon Mar  9 21:39:29 2009
@@ -20,9 +20,7 @@
 package org.apache.tuscany.sca.implementation.osgi.xml;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
@@ -51,30 +49,6 @@
 </service-descriptions>
 */
 public class ServiceDescriptionsProcessor {
-    public final static String REMOTE_SERVICE_FOLDER = 
"OSGI-INF/remote-service";
-    public final static String SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0";;
-    public final static QName SERVICE_DESCRIPTIONS_QNAME = new QName(SD_NS, 
"service-descriptions");
-    public final static QName SERVICE_DESCRIPTION_QNAME = new QName(SD_NS, 
"service-description");
-    public final static String REMOTE_SERVICE_HEADER = "Remote-Service";
-    public final static String PROP_SERVICE_INTENTS = "service.intents";
-    public final static String PROP_CONFIGURATION_TYPE = 
"osgi.remote.configuration.type";
-
-    public static class ServiceDescription {
-        private List<String> interfaces = new ArrayList<String>();
-        private Map<String, Object> properties = new HashMap<String, Object>();
-
-        public List<String> getInterfaces() {
-            return interfaces;
-        }
-
-        public Map<String, Object> getProperties() {
-            return properties;
-        }
-
-        public String toString() {
-            return "service-description: interfaces=" + interfaces + 
"properties=" + properties;
-        }
-    }
 
     public List<ServiceDescription> read(XMLStreamReader reader) throws 
XMLStreamException {
         int event = reader.getEventType();
@@ -84,13 +58,13 @@
             switch (event) {
                 case XMLStreamConstants.START_ELEMENT:
                     QName name = reader.getName();
-                    if (SERVICE_DESCRIPTION_QNAME.equals(name)) {
+                    if 
(ServiceDescription.SERVICE_DESCRIPTION_QNAME.equals(name)) {
                         sd = new ServiceDescription();
                         sds.add(sd);
                     } else if ("provide".equals(name.getLocalPart())) {
                         String interfaceName = reader.getAttributeValue(null, 
"interface");
                         if (interfaceName != null) {
-                            sd.interfaces.add(interfaceName);
+                            sd.getInterfaces().add(interfaceName);
                         }
                     } else if ("property".equals(name.getLocalPart())) {
                         String propName = reader.getAttributeValue(null, 
"name");
@@ -123,16 +97,16 @@
                         } else if ("Boolean".equals(propType)) {
                             prop = Boolean.valueOf(propValue);
                         }
-                        sd.properties.put(propName, prop);
+                        sd.getProperties().put(propName, prop);
                     }
                     break;
                 case XMLStreamConstants.END_ELEMENT:
                     name = reader.getName();
-                    if (SERVICE_DESCRIPTION_QNAME.equals(name)) {
+                    if 
(ServiceDescription.SERVICE_DESCRIPTION_QNAME.equals(name)) {
                         // Reset the sd
                         sd = null;
                     }
-                    if (SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+                    if 
(ServiceDescription.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
                         return sds;
                     }
                     break;

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml?rev=751855&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
 Mon Mar  9 21:39:29 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"; 
+    targetNamespace="http://www.osgi.org/xmlns/sca/intents/v1.0.0";>
+                 
+    <intent name="passByReference" constrains="sca:implementation" 
+        intentType="implementation">
+        <description>
+            An OSGi intent to pass data by reference
+        </description>
+    </intent>
+    
+    <intent name="passByValue" constrains="sca:implementation" 
+        intentType="implementation">
+        <description>
+            An OSGi intent to pass data by value
+        </description>
+    </intent>
+    
+</sca:definitions>
\ No newline at end of file

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
 Mon Mar  9 21:39:29 2009
@@ -25,7 +25,6 @@
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 
-import 
org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsProcessor.ServiceDescription;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;

Added: 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/bundle.componentType
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/resources/bundle.componentType?rev=751855&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/bundle.componentType
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/bundle.componentType
 Mon Mar  9 21:39:29 2009
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"; 
+               xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+               xmlns:t = "http://tuscany.apache.org/xmlns/sca/1.1";
+               >
+    <!-- The service elment defines an SCA view of the OSGi service -->
+    <service name="Calculator">
+        <!-- The interface will be mapped into the OSGi service class -->
+        <interface.java interface="calculator.CalculatorService"/>
+        <!-- The list of OSGi properties -->
+        <t:osgi.property name="prop1">1</t:osgi.property>
+        <t:osgi.property name="prop2">ABC</t:osgi.property>
+    </service>
+    
+    <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+    <reference name="addService">
+        <interface.java interface="calculator.AddService"/>
+        <t:osgi.property name="prop1">1</t:osgi.property>
+        <t:osgi.property name="prop2">ABC</t:osgi.property>
+    </reference>
+    <reference name="subtractService">
+        <interface.java interface="calculator.SubtractService"/>
+        <t:osgi.property name="prop1">1</t:osgi.property>
+        <t:osgi.property name="prop2">ABC</t:osgi.property>
+    </reference>
+    <reference name="multiplyService">
+        <interface.java interface="calculator.MultiplyService"/>
+        <t:osgi.property name="prop1">1</t:osgi.property>
+        <t:osgi.property name="prop2">ABC</t:osgi.property>
+    </reference>
+    <reference name="divideService">
+        <interface.java interface="calculator.DivideService"/>
+        <t:osgi.property name="prop1">1</t:osgi.property>
+        <t:osgi.property name="prop2">ABC</t:osgi.property>
+    </reference>
+    
+</componentType>

Modified: 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgiproptest.composite
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgiproptest.composite?rev=751855&r1=751854&r2=751855&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgiproptest.composite
 (original)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/test/resources/osgiproptest.composite
 Mon Mar  9 21:39:29 2009
@@ -1,14 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
-    <!--
-        * 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.
-    -->
+<!--
+    * 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.    
+-->
 <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"; 
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="OSGiTestComposite">
 


Reply via email to