diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-07 23:52:54 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-07 23:52:54 +0000 |
commit | d123827b572d59f86e23d4e7fac42864d646ee60 (patch) | |
tree | e85a7e9a64391cf9b11830b5b6654dd51185be0d /sandbox/sebastien/java/shell/contrib/samples | |
parent | ba5e7230636b321793db90d642b066b423d59c34 (diff) |
Sandbox to experiment with deployment and management commands.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@993560 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/sebastien/java/shell/contrib/samples')
72 files changed, 3463 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml new file mode 100644 index 0000000000..cdf1c59f2b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml @@ -0,0 +1,76 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>embedded-jse-async-sample-launcher</artifactId> + <name>Embedded JSE Launcher for async samples</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-feature-api</artifactId> + <type>pom</type> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-feature-core</artifactId> + <type>pom</type> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-feature-webservice</artifactId> + <type>pom</type> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-feature-ejava</artifactId> + <type>pom</type> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + + <plugins> + + </plugins> + </build> +</project> diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..9937323993 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java @@ -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 calculator; +import org.oasisopen.sca.annotation.Remotable; + + +/** + * The Calculator service interface. + */ + +@Remotable +public interface CalculatorService { + String calculate(Integer n1); +}
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java new file mode 100644 index 0000000000..aa36b6009b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java @@ -0,0 +1,43 @@ +/* + * 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 launcher; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + + +/** + * Base JSE launcher function + */ +public class RuntimeIntegration { + + + public Node startNode(Contribution... contributions){ + Node node = NodeFactory.newInstance().createNode(contributions); + node.start(); + return node; + } + + public void stopNode(Node node){ + node.stop(); + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java new file mode 100644 index 0000000000..a5e6d75d24 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java @@ -0,0 +1,45 @@ +/* + * 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 launcher; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; + +import calculator.CalculatorService; + + +/** + * This client program shows how to create an embedded SCA runtime, load a contribution, + * start it and, in some cases, locate and invoke an SCA component + */ +public class SampleJSELauncher extends RuntimeIntegration { + + protected boolean waitBeforeStopping = false; + + public static void main(String[] args) throws Exception { + SampleJSELauncher launcher = new SampleJSELauncher(); + launcher.launchImplementationJavaCalculatorAsync(); + } + + public void launchImplementationJavaCalculatorAsync(){ + Node node = startNode(new Contribution("c1", "../sample-contribution-implementation-java-calculator-async/target/sample-contribution-implementation-java-calculator-async.jar")); + stopNode(node); + } +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java new file mode 100644 index 0000000000..1eacb94b19 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java @@ -0,0 +1,42 @@ +/* + * 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 launcher; + +/** + * This exception signals problems in the management of SCA component execution. + */ +public class SampleLauncherException extends RuntimeException { + /** + * Constructs a SampleLauncherException with no detail message. + */ + public SampleLauncherException() { + super(); + } + + /** + * Constructs a SampleLauncherException with the specified detail + * message. + * + * @param message the detail message + */ + public SampleLauncherException(String message) { + super(message); + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java new file mode 100644 index 0000000000..538b693e3c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java @@ -0,0 +1,33 @@ +/* + * 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 launcher; + +import org.junit.Test; + +/** + * Test sample contributions. + */ +public class LauncherTestCase { + + @Test + public void testContributionImplementationJavaCalculatorAsync() throws Exception { + SampleJSELauncher.main(null); + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/async/pom.xml new file mode 100644 index 0000000000..f44ae33067 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/pom.xml @@ -0,0 +1,44 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../../../pom.xml</relativePath> + </parent> + <artifactId>tuscany-sample-async</artifactId> + <packaging>pom</packaging> + <name>MYYYYYYYYYYYYYYYYYYY Apache Tuscany SCA Samples for Synchronous/Asynchronous invocation</name> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <modules> + <module>sample-contribution-implementation-java-calculator-async</module> + <module>embedded-jse-async-sample-launcher</module> + </modules> + </profile> + </profiles> +</project> diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml new file mode 100644 index 0000000000..a0f60bcf6b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml @@ -0,0 +1,58 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>sample-contribution-implementation-java-calculator-async</artifactId> + <name>Apache Tuscany SCA Sample Contribution Implementation Java Calculator for Async Sample</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-feature-api</artifactId> + <type>pom</type> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>2.0-SNAPSHOT</version> + </plugin> + </plugins> + </build> + +</project> diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java new file mode 100644 index 0000000000..6ae8fd13f6 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java @@ -0,0 +1,48 @@ +/* + * 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 calculator; + +import java.util.concurrent.Future; + +import javax.xml.ws.AsyncHandler; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Async client version of the CalculatorService interface + * + */ + +@Remotable +public interface CalculateViaAsyncRef { + + //public Response<String> calculate( Integer i1); + + // Sync + public String calculate(Integer i1); + + // Aysnc Poll + public Future<String> calculateAsync(Integer i1); + + // Async Callback + public Future<String> calculateAsync(Integer i1, AsyncHandler<String> handler); + +} + diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java new file mode 100644 index 0000000000..abaeef8062 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java @@ -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 calculator;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * Handles callbacks to the async client
+ */
+
+public class CalculatorAsyncHandler implements AsyncHandler<String> {
+ public void handleResponse(Response<String> res) {
+ try {
+ System.out.println("Async client callback patern: result in handler = " + res.get());
+ } catch(Exception ex){
+ System.out.println("Async client callback patern: exception in handler = " + ex.getMessage());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..cc1d1d8d46 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,48 @@ +/* + * 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 calculator; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + System.out.println("calculation=" + calculatorService.calculate(20)); + } + + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..45bdd265d4 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,30 @@ +/* + * 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 calculator; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The sync Calculator service interface. + */ + +@Remotable +public interface CalculatorService { + String calculate(Integer n1); +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java new file mode 100644 index 0000000000..3979529595 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java @@ -0,0 +1,33 @@ +/*
+ * 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 calculator;
+
+import org.oasisopen.sca.ResponseDispatch;
+import org.oasisopen.sca.annotation.AsyncInvocation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The async Calculator service interface.
+ */
+
+@Remotable
+@AsyncInvocation
+public interface CalculatorServiceAsync {
+ void calculateAsync(Integer n1, ResponseDispatch<String> response);
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java new file mode 100644 index 0000000000..1906f46f5b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.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 calculator; + +import org.oasisopen.sca.ResponseDispatch; + +public class CalculatorServiceAsyncImpl implements CalculatorServiceAsync { + + @Override + public void calculateAsync(Integer n1, ResponseDispatch<String> response) { + int result = n1 + n1; + String retval = "async service invoked: " + n1 + " + " + n1 + " = " + result; + + response.sendResponse(retval); + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java new file mode 100644 index 0000000000..69c96fe892 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java @@ -0,0 +1,89 @@ +/* + * 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 calculator; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import org.oasisopen.sca.annotation.Reference; + +/** + * An implementation of the Calculator service which just proxies + * to sync and asyn versions of the calculator service. This proxy + * exercises the various async interface alternatives + */ +public class CalculatorServiceProxyImpl implements CalculatorService { + + @Reference + protected CalculateViaAsyncRef calculatorServiceRefSync; + + @Reference + protected CalculateViaAsyncRef calculatorServiceRefAsync; + + @Override + public String calculate(Integer n1) { + String result = null; + + // calculate using a sync service + System.out.println("Calling sync service"); + result = calculate(calculatorServiceRefSync, n1); + + // calculate using an aycn service + System.out.println("Calling async service"); + result += calculate(calculatorServiceRefAsync, n1); + + return result; + } + + // exercise sync and async versions of a service interface method + private String calculate(CalculateViaAsyncRef calculatorRef, Integer n1) { + + // sync + String result = calculatorRef.calculate(1); + System.out.println("Sync client patern: result = " + result); + + // async poll + Future<String> future = calculatorRef.calculateAsync(20); + + while (!future.isDone()){ + System.out.println("Waiting for poll"); + } + + try { + result = future.get(); + System.out.println("Async client poll patern: result = " + result); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // async callback + CalculatorAsyncHandler handler = new CalculatorAsyncHandler(); + future = calculatorRef.calculateAsync(3, handler); + + while (!future.isDone()){ + System.out.println("Waiting for callback"); + } + + return result; + } +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java new file mode 100644 index 0000000000..615a4f4f11 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java @@ -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 calculator; + +public class CalculatorServiceSyncImpl implements CalculatorService { + + @Override + public String calculate(Integer n1) { + int result = n1 + n1; + String retval = "sync service invoked: " + n1 + " + " + n1 + " = " + result; + return retval; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..6117d436db --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite @@ -0,0 +1,43 @@ +<?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:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceProxyImpl"/>
+ <reference name="calculatorServiceRefSync" target="CalculatorSync"/>
+ <reference name="calculatorServiceRefAsync" target="CalculatorAsync"/>
+ </component>
+
+ <component name="CalculatorSync">
+ <implementation.java class="calculator.CalculatorServiceSyncImpl"/>
+ </component>
+
+ <component name="CalculatorAsync">
+ <implementation.java class="calculator.CalculatorServiceAsyncImpl"/>
+ <service name="CalculatorServiceAsync">
+ <binding.ws uri="http://localhost:8085/CalculatorAsync"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite new file mode 100644 index 0000000000..374ef27e2b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite @@ -0,0 +1,30 @@ +<?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="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3e64787ce4 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?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. +--> +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sample="http://sample"> + <deployable composite="sample:Calculator"/> + <deployable composite="sample:CalculatorClient"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/deploy.sh b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/deploy.sh new file mode 100755 index 0000000000..eb53bd5c76 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/deploy.sh @@ -0,0 +1,20 @@ +# 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 + +#!/bin/bash + +mvn clean install +appcfg.sh update target/comet-webapp
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/pom.xml new file mode 100644 index 0000000000..7ac99df289 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/pom.xml @@ -0,0 +1,77 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>sample-comet-webapp</artifactId> + <packaging>war</packaging> + <version>1.0</version> + <name>comet-webapp</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca.shades</groupId> + <artifactId>tuscany-base-nodep</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.atmosphere</groupId> + <artifactId>atmosphere-commons</artifactId> + <version>0.6.1</version> + </dependency> + <dependency> + <groupId>org.atmosphere</groupId> + <artifactId>atmosphere-runtime</artifactId> + <version>0.6.1</version> + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-comet</artifactId> + <version>2.0-SNAPSHOT</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-comet-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + </dependencies> + + <build> + <finalName>comet-webapp</finalName> + </build> +</project> + diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/Helper.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/Helper.java new file mode 100644 index 0000000000..eecc6044ea --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/Helper.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 org.apache.tuscany.sca.sample.comet; + +import java.util.Date; +import java.util.Random; + +public final class Helper { + + public static int randomInt(final int max) { + return (new Random(new Date().getTime()).nextInt(100)); + } + + private Helper() { + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/HumidityService.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/HumidityService.java new file mode 100644 index 0000000000..00cbe73e82 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/HumidityService.java @@ -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.sample.comet; + +import org.apache.tuscany.sca.sample.comet.model.Location; +import org.apache.tuscany.sca.sample.comet.model.Response; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HumidityService { + + Response getHumidity(Location location); + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationService.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationService.java new file mode 100644 index 0000000000..afbdcbc8d7 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationService.java @@ -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.sample.comet; + +import org.apache.tuscany.sca.sample.comet.model.Location; +import org.apache.tuscany.sca.sample.comet.model.Response; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface PrecipitationService { + + Response getPrecipitation(Location location); + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationServiceImpl.java new file mode 100644 index 0000000000..4278ef975b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/PrecipitationServiceImpl.java @@ -0,0 +1,39 @@ +/* + * 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.sample.comet; + +import java.util.Date; + +import org.apache.tuscany.sca.sample.comet.model.Location; +import org.apache.tuscany.sca.sample.comet.model.Response; +import org.oasisopen.sca.annotation.Service; + +@Service(PrecipitationService.class) +public class PrecipitationServiceImpl implements PrecipitationService { + + @Override + public Response getPrecipitation(final Location location) { + final Response response = new Response(); + response.setDate(new Date()); + response.setData(Helper.randomInt(100) + "%"); + return response; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureHumidityServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureHumidityServiceImpl.java new file mode 100644 index 0000000000..55f935fa9f --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureHumidityServiceImpl.java @@ -0,0 +1,48 @@ +/* + * 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.sample.comet; + +import java.util.Date; + +import org.apache.tuscany.sca.sample.comet.model.Location; +import org.apache.tuscany.sca.sample.comet.model.Response; +import org.oasisopen.sca.annotation.Service; + +@Service({TemperatureService.class, HumidityService.class}) +public class TemperatureHumidityServiceImpl implements TemperatureService, HumidityService { + + @Override + public Response getHumidity(final Location location) { + final Response response = new Response(); + response.setDate(new Date()); + response.setData(Helper.randomInt(90) + "%"); + return response; + } + + @Override + public Response getTemperature(final Location location, final int scale) { + final Response response = new Response(); + response.setDate(new Date()); + final String data = "" + Helper.randomInt(scale == TemperatureService.CELSIUS ? 40 : 150); + response.setData(data); + return response; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureService.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureService.java new file mode 100644 index 0000000000..092988213b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/TemperatureService.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 org.apache.tuscany.sca.sample.comet; + +import org.apache.tuscany.sca.sample.comet.model.Location; +import org.apache.tuscany.sca.sample.comet.model.Response; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface TemperatureService { + + public static final int CELSIUS = 1; + public static final int FAHRENHEIT = 2; + + Response getTemperature(Location location, int scale); + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Location.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Location.java new file mode 100644 index 0000000000..ff2da3a360 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Location.java @@ -0,0 +1,43 @@ +/* + * 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.sample.comet.model; + +public class Location { + + private String city; + private String country; + + public String getCity() { + return this.city; + } + + public void setCity(final String city) { + this.city = city; + } + + public String getCountry() { + return this.country; + } + + public void setCountry(final String country) { + this.country = country; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Response.java b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Response.java new file mode 100644 index 0000000000..aaa23f0b8a --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/model/Response.java @@ -0,0 +1,45 @@ +/* + * 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.sample.comet.model; + +import java.util.Date; + +public class Response { + + private Date date; + private String data; + + public Date getDate() { + return this.date; + } + + public void setDate(final Date date) { + this.date = date; + } + + public String getData() { + return this.data; + } + + public void setData(final String data) { + this.data = data; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0
+
diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/appengine-web.xml b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 0000000000..e3979a7001 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> + <application>tuscany-comet</application> + <version>1</version> + <sessions-enabled>true</sessions-enabled> +</appengine-web-app>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..05b2ddd0d7 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,45 @@ +<?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" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://samples" + name="Stock"> + + <component name="c1"> + <implementation.java class="org.apache.tuscany.sca.sample.comet.TemperatureHumidityServiceImpl"/> + <service name="TemperatureService"> + <interface.java interface="org.apache.tuscany.sca.sample.comet.TemperatureService"/> + <tuscany:binding.comet/> + </service> + <service name="HumidityService"> + <interface.java interface="org.apache.tuscany.sca.sample.comet.HumidityService"/> + <tuscany:binding.comet/> + </service> + </component> + + <component name="c2"> + <implementation.java class="org.apache.tuscany.sca.sample.comet.PrecipitationServiceImpl"/> + <service name="PrecipitationService"> + <interface.java interface="org.apache.tuscany.sca.sample.comet.PrecipitationService"/> + <tuscany:binding.comet/> + </service> + </component> + +</composite>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..25b06c457a --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/WEB-INF/web.xml @@ -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. +--> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:j2ee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3.0.xsd" version="3.0"> + <display-name>Apache Tuscany Stock Comet Sample</display-name> + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + <async-supported>true</async-supported> + </filter> + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> +</web-app>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/index.html b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/index.html new file mode 100644 index 0000000000..0387e67adb --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/comet-webapp/src/main/webapp/index.html @@ -0,0 +1,157 @@ +<!-- + * 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. +--> +<html> + <head> + <title>Apache Tuscany Comet Sample</title> + <!-- Tuscany Comet Javascript Toolkit is dependent on jQuery --> + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> + <script type="text/javascript" src="org.apache.tuscany.sca.cometComponentContext.js"></script> + <script type="text/javascript"> + $(document).ready(function() + { + // Initialization + var location = new Object(); + location.city = null; + location.country = null; + + document.getElementById('locationButton').disabled = true; + document.getElementById('tempCButton').disabled = true; + document.getElementById('tempFButton').disabled = true; + document.getElementById('humButton').disabled = true; + document.getElementById('precipButton').disabled = true; + + document.getElementById('locationButton').onclick = function(event) { + location.city = document.getElementById('city').value; + location.country = document.getElementById('country').value; + document.getElementById('locationButton').value = 'Switch location'; + document.getElementById('tempCButton').disabled = false; + document.getElementById('tempFButton').disabled = false; + document.getElementById('humButton').disabled = false; + document.getElementById('precipButton').disabled = false; + document.getElementById('tempCText').textContent = 'N/A'; + document.getElementById('tempCDate').textContent = ''; + document.getElementById('tempFText').textContent = 'N/A'; + document.getElementById('tempFDate').textContent = ''; + document.getElementById('humText').textContent = 'N/A'; + document.getElementById('humDate').textContent = ''; + document.getElementById('precipText').textContent = 'N/A'; + document.getElementById('precipDate').textContent = ''; + } + + // Tuscany Comet specific API + + document.getElementById('connect').onclick = function(event) { + /* transport can be : long-polling or streaming */ + SCA.TuscanyComet.connect(document.getElementById('transport').value); + document.getElementById('connect').disabled = true; + document.getElementById('transport').disabled = true; + document.getElementById('locationButton').disabled = false; + } + + + document.getElementById('tempCButton').onclick = function(event) { + SCA.CometComponentContext.TemperatureService.getTemperature(location, 1, updateTempC); + } + + document.getElementById('tempFButton').onclick = function(event) { + SCA.CometComponentContext.TemperatureService.getTemperature(location, 2, updateTempF); + } + + document.getElementById('humButton').onclick = function(event) { + SCA.CometComponentContext.HumidityService.getHumidity(location, updateHum); + } + + document.getElementById('precipButton').onclick = function(event) { + SCA.CometComponentContext.PrecipitationService.getPrecipitation(location, updatePrecip); + } + }); + + function updateTempC(response) { + document.getElementById('tempCText').textContent = response.data; + document.getElementById('tempCDate').textContent = response.date; + } + + function updateTempF(response) { + document.getElementById('tempFText').textContent = response.data; + document.getElementById('tempFDate').textContent = response.date; + } + + function updateHum(response) { + document.getElementById('humText').textContent = response.data; + document.getElementById('humDate').textContent = response.date; + } + + function updatePrecip(response) { + document.getElementById('precipText').textContent = response.data; + document.getElementById('precipDate').textContent = response.date; + } + </script> + </head> + <body> + <div id='sidebar'> + <h2>Apache Tuscany Comet Sample</h2> + <label>Select transport</label> + <select id="transport"> + <option id="streaming" value="streaming">http streaming</option> + <option id="long-polling" value="long-polling">long-polling</option> + </select> + <input id='connect' type='submit' value='Connect'/> + <h3>Weather Monitor</h3> + <p/> + <table> + <tr> + <td>City</td> + <td><input type="text" id='city' value='Brasov'/></td> + </tr> + <tr> + <td>Country</td> + <td><input type="text" id ='country' value='Romania'/></td> + </tr> + </table> + <input type="button" id='locationButton' value='Set location'/> + <p/> + <table> + <tr> + <th align="left">Temperature (Celsius):</th> + <td><span id='tempCText'>N/A</span></td> + <td><input type='button' id='tempCButton' value="Update"/></td> + <td><span id='tempCDate'></span> + </tr> + <tr> + <th align="left">Temperature (Fahrenheit):</th> + <td><span id='tempFText'>N/A</span></td> + <td><input type='button' id='tempFButton' value="Update"/></td> + <td><span id='tempFDate'></span> + </tr> + <tr> + <th align="left">Humidity:</th> + <td><span id='humText'>N/A</span></td> + <td><input type='button' id='humButton' value="Update"/></td> + <td><span id='humDate'></span> + </tr> + <tr> + <th align="left">Precipitation probability:</th> + <td><span id='precipText'>N/A</span></td> + <td><input type='button' id='precipButton' value="Update"/></td> + <td><span id='precipDate'></span> + </tr> + </table> + </div> + </body> +</html> diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/pom.xml new file mode 100644 index 0000000000..c25184e295 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/pom.xml @@ -0,0 +1,74 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sample-domain-distributed-calculator</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-domain-distributed-calculator-contribution-add</artifactId>
+ <name>Apache Tuscany SCA Sample Domain Distributed Calculator Contribution Add</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c7e6383559 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddService.java @@ -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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,30 @@ +/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/Add.composite b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/Add.composite new file mode 100644 index 0000000000..a452c24141 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/Add.composite @@ -0,0 +1,30 @@ +<?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"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Add">
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..37e304ac4d --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ +<?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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Add"/>
+</contribution>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/test/java/calculator/AddTestCase.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/test/java/calculator/AddTestCase.java new file mode 100644 index 0000000000..b7baf9b64b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-add/src/test/java/calculator/AddTestCase.java @@ -0,0 +1,56 @@ +/*
+ * 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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import java.rmi.Naming;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class AddTestCase {
+
+ private static Node node;
+ private static AddService addService;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ addService = new AddServiceImpl();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(addService.add(3, 2), 5.0, 0.0);
+ }
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/pom.xml new file mode 100644 index 0000000000..63c2220108 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/pom.xml @@ -0,0 +1,74 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sample-domain-distributed-calculator</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-domain-distributed-calculator-contribution-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Domain Distributed Calculator Contribution Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c7e6383559 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/AddService.java @@ -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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..0bac3da45c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,39 @@ +/*
+ * 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 calculator;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService extends Remote {
+
+ double add(double n1, double n2) throws RemoteException;
+
+ double subtract(double n1, double n2) throws RemoteException;
+
+ double multiply(double n1, double n2) throws RemoteException;
+
+ double divide(double n1, double n2) throws RemoteException;
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..389ecb5f82 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,68 @@ +/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ // @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ // @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ // @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The interface for the divide service
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the subtract service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..32b748d5ab --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,31 @@ +<?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"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent/AddService"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/AddServiceImpl.java @@ -0,0 +1,30 @@ +/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..6cccf83fbb --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,59 @@ +/*
+ * 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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestCase {
+
+ private static Node node;
+ private static CalculatorService calculatorService;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ calculatorService = new CalculatorServiceImpl();
+ ((CalculatorServiceImpl)calculatorService).setAddService(new AddServiceImpl());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0, 0.0);
+ }
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/pom.xml new file mode 100644 index 0000000000..3cb2db8c64 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/distributed-calculator/pom.xml @@ -0,0 +1,44 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sample-domain</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-domain-distributed-calculator</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample Domain Distributed Calculator</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ <module>contribution-add</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/domain/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/domain/pom.xml new file mode 100644 index 0000000000..1e50881ff2 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/domain/pom.xml @@ -0,0 +1,42 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>tuscany-sample-domain</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample Domain</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>distributed-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/pom.xml new file mode 100644 index 0000000000..8254ce61a5 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/pom.xml @@ -0,0 +1,53 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>sample-jsonp-webapp</artifactId> + <packaging>war</packaging> + <version>1.0</version> + <name>jsonp-webapp</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca.shades</groupId> + <artifactId>tuscany-base-nodep</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonp-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <type>jar</type> + </dependency> + </dependencies> + + <build> + <finalName>jsonp-webapp</finalName> + </build> +</project> + diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/Location.java b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/Location.java new file mode 100644 index 0000000000..1a47edf73c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/Location.java @@ -0,0 +1,33 @@ +package sample; + +public class Location { + + private String city; + private String country; + private int altitude; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public int getAltitude() { + return altitude; + } + + public void setAltitude(int altitude) { + this.altitude = altitude; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareService.java b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareService.java new file mode 100644 index 0000000000..3c79c6c2e9 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareService.java @@ -0,0 +1,14 @@ +package sample; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface ShareService { + + String shareName(String firstName, String lastName); + + int shareAge(int age); + + Location shareLocation(Location location); + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareServiceImpl.java b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareServiceImpl.java new file mode 100644 index 0000000000..13bae36eb9 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/java/sample/ShareServiceImpl.java @@ -0,0 +1,23 @@ +package sample; + +import org.oasisopen.sca.annotation.Service; + +@Service(ShareService.class) +public class ShareServiceImpl implements ShareService { + + @Override + public String shareName(String firstName, String lastName) { + return firstName + " " + lastName; + } + + @Override + public int shareAge(int age) { + return age; + } + + @Override + public Location shareLocation(Location location) { + return location; + } + +} diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0
+
diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..515c2dba09 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,33 @@ +<?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" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://samples" + name="Stock"> + + <component name="c"> + <implementation.java class="sample.ShareServiceImpl"/> + <service name="ShareService"> + <interface.java interface="sample.ShareService"/> + <tuscany:binding.jsonp/> + </service> + </component> + +</composite>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..0deec29fcc --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/WEB-INF/web.xml @@ -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. +--> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:j2ee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3.0.xsd" version="3.0"> + <display-name>Apache Tuscany JSONP Sample</display-name> + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + <async-supported>true</async-supported> + </filter> + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> +</web-app>
\ No newline at end of file diff --git a/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/index.html b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/index.html new file mode 100644 index 0000000000..2a754e494e --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/jsonp-webapp/src/main/webapp/index.html @@ -0,0 +1,104 @@ +<!-- + * 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. +--> +<html> + <head> + <title>Apache Tuscany Comet Sample</title> + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> + <script type="text/javascript" src="http://jquery-json.googlecode.com/svn/trunk/jquery.json.min.js"></script> + <script type="text/javascript"> + $(document).ready(function() { + document.getElementById("shareLocationButton").onclick = function(event) { + var location = { + city: document.getElementById("city").value, + country: document.getElementById("country").value, + altitude: document.getElementById("altitude").value + }; + $.getJSON("c/ShareService/shareLocation", "location=" + $.toJSON(location), shareLocationCallback); + } + }); + + function shareNameCallback(response) { + alert("Your name, " + response + ", has been shared."); + } + + function shareAge() { + document.getElementById("shareAgeForm").submit(); + } + + function shareAgeCallback(response) { + alert("Your age, " + response + ", has been shared."); + } + + function shareLocationCallback(response) { + alert("Your location, " + response.city + " - " + response.country + " - " + response.altitude + ", has been shared."); + } + </script> + </head> + <body> + <h2>Apache Tuscany JSONP Sample</h2> + <h3>Share Personal Information Webapp</h3> + + <form method="GET" action="c/ShareService/shareName"> + <b><label>Share Full Name</label></b> + <table> + <tr> + <td>First Name</td> + <td><input type="text" name="firstName" value="John"/> + </tr> + <tr> + <td>Last Name</td> + <td><input type="text" name="lastName" value="Locke"/> + </tr> + </table> + <input type="hidden" name="callback" value="shareNameCallback"/> + <input type="submit" value="Share"/> + </form> + + <form method="GET" id="shareAgeForm" action="c/ShareService/shareAge"> + <b><label>Share Age</label></b> + <table> + <tr> + <td>Age</td> + <td><input type="text" name="age" value="54"/> + </tr> + </table> + <input type="hidden" name="callback" value="shareAgeCallback"/> + <input type="submit" value="Share" onclick="shareAge()"/> + </form> + + <form method="GET" > + <b><label>Share Location</label></b> + <table> + <tr> + <td>City</td> + <td><input type="text" name="city" id="city" value="Los Angeles" /> + </tr> + <tr> + <td>Country</td> + <td><input type="text" name="country" id="country" value="USA" /> + </tr> + <tr> + <td>Altitude</td> + <td><input type="text" name="altitude" id="altitude" value="560" /> + </tr> + </table> + <input type="button" id="shareLocationButton" value="Share"/> + </form> + </body> +</html> diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/README b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/README new file mode 100644 index 0000000000..7108333efa --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/README @@ -0,0 +1,20 @@ +JSE Sample Launcher
+===================
+
+This directory contains a sample java launcher for the
+tuscany sample contributions.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers ( where distribution-unpack-dir is the directory in which you
+unpacked the tuscany binary distribution archive)
+
+To use this sample JSE launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
+
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/build.xml b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/build.xml new file mode 100644 index 0000000000..64bad00b76 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/build.xml @@ -0,0 +1,118 @@ +<!--
+ * 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="launcher-embedded-jse" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-jse.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+ <property name="wait.before.stopping" value="dontWaitBeforeStopping" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <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"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ <echo> 'ant run-contribution-binding-ws-calculator' </echo>
+ <echo> 'ant run-contribution-binding-rmi-calculator' </echo>
+ <echo> 'ant run-contribution-implementation-java-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ <arg value="${wait.before.stopping}"/>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingWSCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-rmi-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-rmi-calculator"/>
+ </java>
+ </target>
+
+ <target name="run-contribution-implementation-java-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-implementaton-java-calculator"/>
+ </java>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/pom.xml new file mode 100644 index 0000000000..b1f8e5c15c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/pom.xml @@ -0,0 +1,83 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-jse-spec</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded JSE Spec</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..12d80ffd1c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,38 @@ +/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java new file mode 100644 index 0000000000..2f48e273bd --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java @@ -0,0 +1,75 @@ +/*
+ * 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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingWSCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingWSCalculator launcher = new JSELauncherBindingWSCalculator();
+ launcher.launchBindingWSCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingWSCalculator(){
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ Node node = nodeFactory.createNode("MyDomain");
+
+ try {
+ node.installContribution("../../../samples/contribution-binding-ws-calculator/target/sample-contribution-binding-ws-calculator.jar");
+ } catch(Exception ex){
+ System.out.println("Exception on installContribution");
+ ex.printStackTrace();
+ }
+
+ //node.start();
+
+ CalculatorService calculator = null;
+
+ try {
+ calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ } catch(Exception ex){
+ System.out.println("Exception on getService");
+ ex.printStackTrace();
+ }
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java new file mode 100644 index 0000000000..f2ed3d421d --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java @@ -0,0 +1,42 @@ +/*
+ * 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java new file mode 100644 index 0000000000..04521d326b --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java @@ -0,0 +1,33 @@ +/*
+ * 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 launcher;
+
+import org.junit.Test;
+
+/**
+ * Test sample contributions.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ JSELauncherBindingWSCalculator.main(null);
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/pom.xml new file mode 100644 index 0000000000..1459d66152 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/pom.xml @@ -0,0 +1,90 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>tuscany-contrib-samples</artifactId> + <packaging>pom</packaging> + <name>Apache Tuscany SCA Contributed Samples</name> + + <modules> + <module>comet-webapp</module> + </modules> + + <profiles> + <profile> + <id>eclipse</id> + <build> + <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal> + <!-- + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>1.0.6</version> + <extensions>true</extensions> + <executions> + <execution> + <id>generate-pde</id> + <phase>generate-resources</phase> + <goals> + <goal>eclipse</goal> + </goals> + <configuration> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + --> + </build> + </profile> + </profiles> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + +</project> diff --git a/sandbox/sebastien/java/shell/contrib/samples/reporting/README b/sandbox/sebastien/java/shell/contrib/samples/reporting/README new file mode 100644 index 0000000000..b33446cde8 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/reporting/README @@ -0,0 +1,6 @@ +Reporting Sample
+================
+
+A simple sample to motivate the implementation of some mechanisms for
+retiriving information about an active domain and it's nodes.
+
diff --git a/sandbox/sebastien/java/shell/contrib/samples/reporting/pom.xml b/sandbox/sebastien/java/shell/contrib/samples/reporting/pom.xml new file mode 100644 index 0000000000..103734b9f7 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/reporting/pom.xml @@ -0,0 +1,94 @@ +<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-reporting</artifactId>
+ <name>Apache Tuscany SCA Sample Reporting</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/shell/contrib/samples/reporting/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/shell/contrib/samples/reporting/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..12d80ffd1c --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/reporting/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,38 @@ +/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/shell/contrib/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java b/sandbox/sebastien/java/shell/contrib/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java new file mode 100644 index 0000000000..51221ee7b5 --- /dev/null +++ b/sandbox/sebastien/java/shell/contrib/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java @@ -0,0 +1,320 @@ +/*
+ * 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 reporting;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.sun.jmx.remote.util.Service;
+import com.sun.xml.internal.txw2.output.IndentingXMLStreamWriter;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to extract useful(?) information from the Tuscany SCA runtime
+ */
+public class JSELauncherReportingTestCase {
+
+ private static NodeFactory nodeFactory;
+ private static Node node1;
+ private static Node node2;
+ private static CalculatorService calculator;
+
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherReportingTestCase launcher = new JSELauncherReportingTestCase ();
+ launcher.setUp();
+
+ launcher.callCalulator();
+/*
+ launcher.listNodes();
+ launcher.listNodeConfigurations();
+ launcher.listContributions();
+ launcher.listDomainDefinitions();
+ launcher.listEndpoints();
+*/
+ launcher.listWires();
+ launcher.tearDown();
+ }
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+/* new
+ org.apache.tuscany.sca.node2.NodeFactory nodeFactoryNew = org.apache.tuscany.sca.node2.NodeFactory.newInstance();
+ org.apache.tuscany.sca.node2.Node node1New = nodeFactoryNew.createNode();
+ node1New.installContribution("../domain/distributed-calculator/contribution-add/target/classes");
+
+ org.apache.tuscany.sca.node2.Node node2New = nodeFactoryNew.createNode();
+ node2New.installContribution("../domain/distributed-calculator/contribution-calculator/target/classes");
+
+ calculator = node2New.getService(CalculatorService.class, "CalculatorServiceComponent");
+*/
+
+/* old */
+ nodeFactory = NodeFactory.newInstance();
+ node1 = nodeFactory.createNode(new Contribution("c1", "../domain/distributed-calculator/contribution-add/target/classes"));
+ node1.start();
+
+ node2 = nodeFactory.createNode(new Contribution("c1", "../domain/distributed-calculator/contribution-calculator/target/classes"));
+ node2.start();
+
+ calculator = node2.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node1.stop();
+ node2.stop();
+ }
+
+ @Test
+ public void callCalulator(){
+ printTestName("callCalulator");
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ }
+
+ @Test
+ public void listNodes(){
+ printTestName("listNodes");
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ for (Object nodeKey : nodes.keySet()){
+ System.out.println(nodeKey);
+ }
+ }
+
+ @Test
+ public void listNodeConfigurations(){
+ printTestName("listNodeConfigurations");
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ for (Node node : nodes.values()){
+ System.out.println("Node: " + ((NodeImpl)node).getURI());
+ printXML(((NodeImpl)node).getConfiguration());
+ }
+ }
+
+ @Test
+ public void listContributions(){
+ printTestName("listContributions");
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ for (Node node : nodes.values()){
+ System.out.println("Node: " + ((NodeImpl)node).getURI());
+ NodeConfiguration nodeConfiguration = ((NodeImpl)node).getConfiguration();
+ for (org.apache.tuscany.sca.contribution.Contribution contribution : ((NodeImpl)node).getContributions()){
+ System.out.println("Contribution: " + contribution.getURI() + " location " + contribution.getLocation());
+ for (Artifact artifact : contribution.getArtifacts()){
+ System.out.println(" Artifact: " + artifact.getURI() + " location " + artifact.getLocation());
+ }
+ }
+ }
+ }
+
+ @Test
+ public void listDomainComposite(){
+ printTestName("listDomainComposite");
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ for (Node node : nodes.values()){
+ System.out.println("Node: " + ((NodeImpl)node).getURI());
+ printXML(((NodeImpl)node).getDomainComposite());
+ }
+ }
+
+ @Test
+ public void listDomainDefinitions(){
+ printTestName("listDomainDefinitions");
+ Deployer deployer = ((NodeFactoryImpl)nodeFactory).getDeployer();
+ Definitions systemDefinitions = deployer.getSystemDefinitions();
+ printXML(systemDefinitions);
+ }
+
+ @Test
+ public void listEndpoints(){
+ printTestName("listEndpoints");
+ ExtensionPointRegistry registry = ((NodeFactoryImpl)nodeFactory).getExtensionPointRegistry();
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ Node firstNode = nodes.values().iterator().next();
+ NodeConfiguration firstNodeConfig = ((NodeImpl)firstNode).getConfiguration();
+
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+ // TODO - I don't understand where the scheme gets set/used
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("vm:" + firstNodeConfig.getDomainRegistryURI(), firstNodeConfig.getDomainURI());
+
+ for (Endpoint endpoint : endpointRegistry.getEndpoints()){
+ System.out.println(endpoint);
+ printEndpointXML(endpoint);
+ }
+ }
+
+ @Test
+ public void listWires(){
+ printTestName("listWires");
+ Map<Object, Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodes();
+ for (Node node : nodes.values()){
+ System.out.println("Node: " + ((NodeImpl)node).getURI());
+ listComponentWires(((NodeImpl)node).getDomainComposite());
+ }
+ }
+
+ // utils
+
+ private void listComponentWires(Composite composite){
+ for(Component component : composite.getComponents()){
+ if (component.getImplementation() instanceof Composite){
+ listComponentWires((Composite)component.getImplementation());
+ }
+ System.out.println(" Component: " + component.getName());
+
+ for(ComponentService service : component.getServices()){
+ System.out.println(" Service: " + service.getName());
+ for(Endpoint endpoint : service.getEndpoints()){
+ System.out.println(" Endpoint: " + endpoint);
+ System.out.println(" Binding: " + endpoint.getBinding().getType());
+ printInvocationChains(((RuntimeEndpointImpl)endpoint).getInvocationChains());
+ }
+ }
+ for(ComponentReference reference : component.getReferences()){
+ System.out.println(" Reference: " + reference.getName());
+ for(EndpointReference endpointReference : reference.getEndpointReferences()){
+ System.out.println(" EndpointReference: " + endpointReference);
+ Binding binding = endpointReference.getBinding();
+ if (binding != null){
+ System.out.println(" Binding: " + binding.getType());
+ printInvocationChains(((RuntimeEndpointReferenceImpl)endpointReference).getInvocationChains());
+ }
+ }
+ }
+ }
+ }
+
+ private void printInvocationChains(List<InvocationChain> chains){
+ for(InvocationChain chain : chains){
+ System.out.println(" Operation: " + chain.getTargetOperation().getName());
+ Invoker invoker = chain.getHeadInvoker();
+ while(invoker != null){
+ System.out.println(" Invoker: " + invoker.getClass().getName());
+ if (invoker instanceof Interceptor){
+ invoker = ((Interceptor)invoker).getNext();
+ } else {
+ invoker = null;
+ }
+ }
+ }
+ }
+
+ private void printTestName(String name){
+ System.out.println("=====================================================================");
+ System.out.println(name);
+ System.out.println("=====================================================================");
+ }
+
+ private void printXML(Object model){
+ try {
+ ExtensionPointRegistry registry = ((NodeFactoryImpl)nodeFactory).getExtensionPointRegistry();
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint xmlProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Object> xmlProcessor = new ExtensibleStAXArtifactProcessor(xmlProcessors, inputFactory, null);
+
+ ProcessorContext context = new ProcessorContext(registry);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLOutputFactory outputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLOutputFactory.class);
+ XMLStreamWriter writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(bos));
+
+ xmlProcessor.write(model, writer, context);
+ writer.flush();
+
+ System.out.println(bos.toString());
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ // TODO - we don't have a processor registered for RuntimeEndpointImpl?
+ private void printEndpointXML(Endpoint model){
+ try {
+ ExtensionPointRegistry registry = ((NodeFactoryImpl)nodeFactory).getExtensionPointRegistry();
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint xmlProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Endpoint> xmlProcessor = xmlProcessors.getProcessor(Endpoint.class);
+
+ ProcessorContext context = new ProcessorContext(registry);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLOutputFactory outputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLOutputFactory.class);
+ XMLStreamWriter writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(bos));
+
+ xmlProcessor.write(model, writer, context);
+ writer.flush();
+
+ System.out.println(bos.toString());
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
|