Author: rfeng
Date: Wed Mar  4 22:04:05 2009
New Revision: 750185

URL: http://svn.apache.org/viewvc?rev=750185&view=rev
Log:
Add missing files

Added:
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
   (with props)
    
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
   (with props)

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java?rev=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import 
org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactoryImpl;
+
+/**
+ * 
+ */
+public class DefaultOSGiImplementationFactory extends 
OSGiImplementationFactoryImpl {
+
+    public DefaultOSGiImplementationFactory(FactoryExtensionPoint 
factoryExtensionPoint) {
+        super(factoryExtensionPoint);
+    }
+
+}

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

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

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java?rev=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * The factory interface to create OSGiImplementation instances
+ */
+public interface OSGiImplementationFactory {
+    /**
+     * Create a new instance of OSGiImplementation
+     * @return
+     */
+    OSGiImplementation createOSGiImplementation();
+}

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

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

Added: 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java?rev=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,41 @@
+/*
+ * 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.impl;
+
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+
+/**
+ * 
+ */
+public class OSGiImplementationFactoryImpl implements 
OSGiImplementationFactory {
+    private final FactoryExtensionPoint factoryExtensionPoint;
+
+    public OSGiImplementationFactoryImpl(FactoryExtensionPoint 
factoryExtensionPoint) {
+        super();
+        this.factoryExtensionPoint = factoryExtensionPoint;
+    }
+
+    public OSGiImplementation createOSGiImplementation() {
+        return new OSGiImplementationImpl(factoryExtensionPoint);
+    }
+
+}

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

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

Added: 
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=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationActivator.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class OSGiImplementationActivator implements BundleActivator {
+    static BundleContext bundleContext;
+
+    public void start(BundleContext context) throws Exception {
+        bundleContext = context;
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        bundleContext = context;
+    }
+
+}

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

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

Added: 
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=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,147 @@
+/*
+ * 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;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0";>
+    <service-description>
+        <provide interface="com.iona.soa.pojo.hello.HelloService"/>
+        <property name="service.intents">SOAP HTTP</property>
+        <property name="osgi.remote.configuration.type">pojo</property>
+        <property name="osgi.remote.configuration.pojo.address">
+            http://localhost:9000/hello
+        </property>
+    </service-description>
+    <service-description>
+        <provide interface="com.iona.soa.pojo.hello.GreeterService"/>
+        <property name="service.intents">SOAP HTTP</property>
+        <property name="osgi.remote.configuration.type">pojo</property>
+        <property name="osgi.remote.configuration.pojo.address">
+            http://localhost:9005/greeter
+        </property>
+    </service-description>
+</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();
+        List<ServiceDescription> sds = new ArrayList<ServiceDescription>();
+        ServiceDescription sd = null;
+        while (true) {
+            switch (event) {
+                case XMLStreamConstants.START_ELEMENT:
+                    QName name = reader.getName();
+                    if (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);
+                        }
+                    } else if ("property".equals(name.getLocalPart())) {
+                        String propName = reader.getAttributeValue(null, 
"name");
+                        String propValue = reader.getAttributeValue(null, 
"value");
+                        String propType = reader.getAttributeValue(null, 
"type");
+                        if (propType == null) {
+                            propType = "String";
+                        }
+                        if (propValue == null) {
+                            propValue = reader.getElementText();
+                        }
+                        if (propValue != null) {
+                            propValue = propValue.trim();
+                        }
+                        Object prop = propValue;
+                        if ("Integer".equals(propType)) {
+                            prop = Integer.valueOf(propValue);
+                        } else if ("Long".equals(propType)) {
+                            prop = Long.valueOf(propValue);
+                        } else if ("Float".equals(propType)) {
+                            prop = Float.valueOf(propValue);
+                        } else if ("Double".equals(propType)) {
+                            prop = Double.valueOf(propValue);
+                        } else if ("Short".equals(propType)) {
+                            prop = Short.valueOf(propValue);
+                        } else if ("Character".equals(propType)) {
+                            prop = propValue.charAt(0);
+                        } else if ("Byte".equals(propType)) {
+                            prop = Byte.valueOf(propValue);
+                        } else if ("Boolean".equals(propType)) {
+                            prop = Boolean.valueOf(propValue);
+                        }
+                        sd.properties.put(propName, prop);
+                    }
+                    break;
+                case XMLStreamConstants.END_ELEMENT:
+                    name = reader.getName();
+                    if (SERVICE_DESCRIPTION_QNAME.equals(name)) {
+                        // Reset the sd
+                        sd = null;
+                    }
+                    if (SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+                        return sds;
+                    }
+                    break;
+            }
+            if (reader.hasNext()) {
+                event = reader.next();
+            } else {
+                return sds;
+            }
+        }
+    }
+}

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

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

Added: 
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=750185&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
 (added)
+++ 
tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
 Wed Mar  4 22:04:05 2009
@@ -0,0 +1,87 @@
+/*
+ * 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.io.StringReader;
+import java.util.List;
+
+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;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class ServiceDescriptionsTestCase {
+    private static final String xml =
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<service-descriptions 
xmlns=\"http://www.osgi.org/xmlns/sd/v1.0.0\";>"
+            + "<service-description>"
+            + "<provide interface=\"com.iona.soa.pojo.hello.HelloService\"/>"
+            + "<property name=\"service.intents\">SOAP HTTP</property>"
+            + "<property 
name=\"osgi.remote.configuration.type\">pojo</property>"
+            + "<property name=\"osgi.remote.configuration.pojo.address\">"
+            + "http://localhost:9000/hello";
+            + "</property>"
+            + "</service-description>"
+            + "<service-description>"
+            + "<provide interface=\"com.iona.soa.pojo.hello.GreeterService\"/>"
+            + "<property name=\"service.intents\">SOAP HTTP</property>"
+            + "<property 
name=\"osgi.remote.configuration.type\">pojo</property>"
+            + "<property name=\"osgi.remote.configuration.pojo.address\">"
+            + "http://localhost:9005/greeter";
+            + "</property>"
+            + "</service-description>"
+            + "</service-descriptions>";
+
+    private static XMLStreamReader reader;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        XMLInputFactory factory = XMLInputFactory.newInstance();
+        reader = factory.createXMLStreamReader(new StringReader(xml));
+    }
+
+    @Test
+    public void testLoad() throws Exception {
+        ServiceDescriptionsProcessor processor = new 
ServiceDescriptionsProcessor();
+        List<ServiceDescription> descriptions = processor.read(reader);
+        Assert.assertEquals(2, descriptions.size());
+        System.out.println(descriptions);
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        if (reader != null) {
+            reader.close();
+        }
+    }
+
+}

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

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


Reply via email to