diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-26 08:43:01 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-26 08:43:01 +0000 |
commit | 758114996eea515967ae25389b8349c7cf573c19 (patch) | |
tree | c87f3e22d73f6947b1193090fd8b5135765c5917 /sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting | |
parent | 6865c59e74f19ed6057d03583944b47abd6e036e (diff) |
Remove the folder
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027404 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting')
8 files changed, 0 insertions, 1003 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/README b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/README deleted file mode 100644 index b33446cde8..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/README +++ /dev/null @@ -1,6 +0,0 @@ -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/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/pom.xml b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/pom.xml deleted file mode 100644 index f02dd38b24..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-samples</artifactId>
- <version>2.0-Beta1-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-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-feature-core</artifactId>
- <type>pom</type>
- <version>2.0-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-feature-webservice</artifactId>
- <type>pom</type>
- <version>2.0-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-feature-ejava</artifactId>
- <type>pom</type>
- <version>2.0-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-script-runtime</artifactId>
- <version>2.0-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
- <version>2.0-Beta1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-databinding-json</artifactId>
- <version>2.0-Beta1-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/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/calculator/CalculatorService.java deleted file mode 100644 index 12d80ffd1c..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/calculator/CalculatorService.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncheCalculator.java b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncheCalculator.java deleted file mode 100644 index 25729ea1ea..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncheCalculator.java +++ /dev/null @@ -1,333 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package reporting;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-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 JSELauncheCalculator {
-
- private static NodeFactory nodeFactory;
- private static Node node1;
- private static Node node2;
- private static CalculatorService calculator;
-
-
- public static void main(String[] args) throws Exception {
- JSELauncheCalculator launcher = new JSELauncheCalculator();
- launcher.setUp();
-
- launcher.callCalulator();
- launcher.listExtensions();
- launcher.listNodes();
- launcher.listNodeConfigurations();
- launcher.listContributions();
- launcher.listDomainComposite();
- 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 node2New = nodeFactoryNew.createNode();
- node2New.installContribution("../domain/distributed-calculator/contribution-calculator/target/classes");
-
- calculator = node2New.getService(CalculatorService.class, "CalculatorServiceComponent");
-*/
-
-/* old */
- // TUSCANY-3675 - push hazelcast config into factory as adding it to URI doesn't work
- Properties properties = new Properties();
- properties.setProperty("bind", "192.168.0.2");
- nodeFactory = NodeFactory.newInstance(properties);
-
- // TUSCANY-3675 - push hazelcast config into factory as adding it to URI doesn't work
- //node2 = nodeFactory.createNode(new Contribution("c1", "../domain/distributed-calculator/contribution-calculator/target/classes"));
- //node2 = nodeFactory.createNode(URI.create("tuscany:default?listen=127.0.0.1:14820"), "../domain/distributed-calculator/contribution-calculator/target/classes");
- //node2 = nodeFactory.createNode(URI.create("tuscany:default"), "../domain/distributed-calculator/contribution-calculator/target/classes");
- node2 = nodeFactory.createNode(new File("./target/classes/node-calculator.xml").toURL());
-
- node2.start();
-
- calculator = node2.getService(CalculatorService.class, "CalculatorServiceComponent");
-
- } catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- node2.stop();
- }
-
- @Test
- public void callCalulator(){
- printTestName("callCalulator");
- double result = calculator.add(3, 2);
- System.out.println("3 + 2 = " + result);
- }
-
- @Test
- public void listExtensions(){
- printTestName("listExtensions");
- // TODO
- }
-
- @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();
- }
- }
-
-}
diff --git a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncherAdd.java b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncherAdd.java deleted file mode 100644 index 5351ed263b..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/java/reporting/JSELauncherAdd.java +++ /dev/null @@ -1,144 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package reporting;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.StringWriter;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-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.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-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.apache.tuscany.sca.runtime.RuntimeProperties;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-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 JSELauncherAdd {
-
- private static NodeFactory nodeFactory;
- private static Node node1;
- private static Node node2;
- private static CalculatorService calculator;
-
-
- public static void main(String[] args) throws Exception {
- JSELauncherAdd launcher = new JSELauncherAdd ();
- launcher.setUp();
-
- launcher.waitForInput();
-
- 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");
-
-*/
-
-/* old */
- // TUSCANY-3675 - push hazelcast config into factory as adding it to URI doesn't work
- Properties properties = new Properties();
- properties.setProperty("bind", "192.168.0.2");
- nodeFactory = NodeFactory.newInstance(properties);
-
- // TUSCANY-3675 - push hazelcast config into factory as adding it to URI doesn't work
- //node1 = nodeFactory.createNode(new Contribution("c1", "../domain/distributed-calculator/contribution-add/target/classes"));
- //node1 = nodeFactory.createNode(URI.create("tuscany:default?listen=127.0.0.1:14820"), "../domain/distributed-calculator/contribution-add/target/classes");
- //node1 = nodeFactory.createNode(URI.create("tuscany:default"), "../domain/distributed-calculator/contribution-add/target/classes");
- node1 = nodeFactory.createNode(new File("./target/classes/node-add.xml").toURL());
-
- node1.start();
-
- } catch (Exception ex){
- ex.printStackTrace();
- }
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- node1.stop();
- }
-
- @Test
- @Ignore
- public void waitForInput(){
- System.out.println("Press key to end");
- try {
- System.in.read();
- } catch(Exception ex){
- // do nothing
- }
- }
-
-}
diff --git a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-add.xml b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-add.xml deleted file mode 100644 index 7a4a6d5695..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-add.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- uri="node-add"
- domain="default"
- domainRegistry="tuscany:default">
-
- <!-- Configure the base URIs for a given binding -->
- <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca"/>
- <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws"/>
-
- <!-- Configure a list of contributions -->
- <contribution uri="contribution-add" location="../../../domain/distributed-calculator/contribution-add/target/classes"/>
-
-</node>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-calculator.xml b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-calculator.xml deleted file mode 100644 index 31098b129d..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/main/resources/node-calculator.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- uri="node-calculator"
- domain="default"
- domainRegistry="tuscany:default">
-
- <!-- Configure the base URIs for a given binding -->
- <binding name="sca:binding.sca" baseURIs="http://localhost:8083/sca"/>
- <binding name="sca:binding.ws" baseURIs="http://localhost:8084/ws"/>
-
- <!-- Configure a list of contributions -->
- <contribution uri="contribution-calculator" location="../../../domain/distributed-calculator/contribution-calculator/target/classes"/>
-
-</node>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java b/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java deleted file mode 100644 index b4cc8fa3ee..0000000000 --- a/sca-java-2.x/branches/2.0-Beta1/unreleased/samples/reporting/src/test/java/reporting/JSELauncherReportingTestCase.java +++ /dev/null @@ -1,320 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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();
- }
- }
-
-}
|