diff options
Diffstat (limited to 'sandbox/slaws/jms-osgi/jms-osgi')
11 files changed, 214 insertions, 67 deletions
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/META-INF/MANIFEST.MF b/sandbox/slaws/jms-osgi/jms-osgi/META-INF/MANIFEST.MF index 616766a3a7..e035a688b2 100644 --- a/sandbox/slaws/jms-osgi/jms-osgi/META-INF/MANIFEST.MF +++ b/sandbox/slaws/jms-osgi/jms-osgi/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0
-Bundle-Version: 2.0.0
+Bundle-Version: 1.0.0
Bundle-Name: JMS OSGi
-Bundle-Activator: calculator.CalculatorActivator
+Bundle-Activator: sample.HelloworldActivator
Bundle-ManifestVersion: 2
Import-Package: org.oasisopen.sca.annotation;version="2.0.0",
org.oasisopen.sca;version="2.0.0",
@@ -10,7 +10,9 @@ Import-Package: org.oasisopen.sca.annotation;version="2.0.0", org.osgi.framework,
org.osgi.service.component;resolution:=optional,
org.osgi.service.packageadmin,
- org.osgi.util.tracker
+ org.osgi.util.tracker,
+ javax.naming,
+ javax.jms
Bundle-SymbolicName: jms.osgi
Bundle-Vendor: The Apache Software Foundation
Eclipse-LazyStart: true
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.componentType b/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.componentType new file mode 100644 index 0000000000..fd8c5ed793 --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.componentType @@ -0,0 +1,28 @@ +<?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/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- The service element defines an SCA view of the OSGi service -->
+ <service name="HelloworldService">
+ <interface.java interface="sample.Helloworld"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.composite b/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.composite new file mode 100644 index 0000000000..4f40da9868 --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/OSGI-INF/sca/bundle.composite @@ -0,0 +1,34 @@ +<?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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://sample" + xmlns:sample="http://sample" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + name="Helloworld"> + + + <component name="HelloworldComponent"> + <tuscany:implementation.osgi bundleSymbolicName="jms.osgi" bundleVersion="1.0.0"/> + <service name="HelloworldService"> + <binding.jms/> + </service> + </component> + +</composite> diff --git a/sandbox/slaws/jms-osgi/jms-osgi/pom.xml b/sandbox/slaws/jms-osgi/jms-osgi/pom.xml index fbd6be20c5..e81705f9bc 100644 --- a/sandbox/slaws/jms-osgi/jms-osgi/pom.xml +++ b/sandbox/slaws/jms-osgi/jms-osgi/pom.xml @@ -31,7 +31,7 @@ <artifactId>sample-jms-osgi</artifactId>
<version>2.0-SNAPSHOT</version>
- <name>Apache Tuscany SCA Sample Calculator OSGi</name>
+ <name>Apache Tuscany SCA Sample JMS OSGi</name>
<properties>
<tuscany.version>${project.version}</tuscany.version>
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/calculator/CalculatorActivator.java b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/calculator/CalculatorActivator.java index 5e65623761..1c7a9bec51 100644 --- a/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/calculator/CalculatorActivator.java +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/calculator/CalculatorActivator.java @@ -35,8 +35,8 @@ public class CalculatorActivator implements BundleActivator { public void start(BundleContext context) throws Exception {
logger.info("Starting " + context.getBundle());
- Node node = TuscanyRuntime.runComposite("Calculator.composite", context.getBundle().getLocation());
- node.stop();
+ //Node node = TuscanyRuntime.runComposite("Calculator.composite", context.getBundle().getLocation());
+ //node.stop();
}
public void stop(BundleContext context) throws Exception {
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/Helloworld.java b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..f4e8c50448 --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/Helloworld.java @@ -0,0 +1,28 @@ +/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldActivator.java b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldActivator.java new file mode 100644 index 0000000000..46f74c0f68 --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldActivator.java @@ -0,0 +1,50 @@ +/*
+ * 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 sample;
+
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class HelloworldActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(HelloworldActivator.class.getName());
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+
+ logger.info("Registering " + Helloworld.class.getName());
+ props.put("sca.service", "HelloworldComponent#service-name(HelloworldService)");
+ context.registerService(Helloworld.class.getName(), new HelloworldImpl(), props);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+}
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldImpl.java b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..01b2b1197d --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,29 @@ +/*
+ * 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 sample;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ String returnString = "Hello " + name;
+ System.out.println(returnString);
+ return returnString;
+ }
+
+}
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/main/resources/Calculator.composite b/sandbox/slaws/jms-osgi/jms-osgi/src/main/resources/Calculator.composite deleted file mode 100644 index 36ef198015..0000000000 --- a/sandbox/slaws/jms-osgi/jms-osgi/src/main/resources/Calculator.composite +++ /dev/null @@ -1,59 +0,0 @@ -<?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. ---> -<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" - targetNamespace="http://sample" - xmlns:sample="http://sample" - name="Calculator"> - - - <component name="CalculatorServiceComponent"> - <implementation.java class="calculator.CalculatorServiceImpl"/> - <reference name="addService" target="AddServiceComponent"/> - <reference name="subtractService" target="SubtractServiceComponent" /> - <reference name="multiplyService" target="MultiplyServiceComponent" /> - <reference name="divideService" target="DivideServiceComponent" /> - </component> - - <component name="AddServiceComponent"> - <implementation.java class="calculator.AddServiceImpl"/> - <service name="AddService"> - <binding.jms/> - </service> - </component> - - <component name="SubtractServiceComponent"> - <implementation.java class="calculator.SubtractServiceImpl"/> - </component> - - <component name="MultiplyServiceComponent"> - <implementation.java class="calculator.MultiplyServiceImpl"/> - </component> - - <component name="DivideServiceComponent"> - <implementation.java class="calculator.DivideServiceImpl"/> - </component> - - - <component name="CalculatorClient"> - <implementation.java class="calculator.CalculatorClient"/> - <reference name="calculatorService" target="CalculatorServiceComponent" /> - </component> - -</composite> diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/calculator/CalculatorTestCase.java b/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/calculator/CalculatorTestCase.java index a81b58bced..eb9fa883fe 100644 --- a/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/calculator/CalculatorTestCase.java +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/calculator/CalculatorTestCase.java @@ -34,9 +34,9 @@ public class CalculatorTestCase { @Test
public void testCalculate() throws NoSuchServiceException {
-
+/*
// Run the SCA composite in a Tuscany runtime
- Node node = TuscanyRuntime.runComposite("Calculator.composite", "target/classes");
+ Node node = TuscanyRuntime.runComposite("OSGI-INF/sca/bundle.composite", "target/classes");
try {
@@ -45,5 +45,6 @@ public class CalculatorTestCase { // Stop the Tuscany runtime Node
node.stop();
}
+*/
}
}
diff --git a/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/sample/HelloworldTestCase.java b/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..2ca6bde1c6 --- /dev/null +++ b/sandbox/slaws/jms-osgi/jms-osgi/src/test/java/sample/HelloworldTestCase.java @@ -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 sample;
+
+import org.junit.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testCalculate() throws NoSuchServiceException {
+ // TODO
+ }
+}
|