summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-06-05 05:17:47 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-06-05 05:17:47 +0000
commitf052ca9d9dc273dc0f625c9a6ec6eb38d6bc0f3a (patch)
treec316c1a4a098d965f91aef6422aebb862a88a0f7 /sca-java-2.x/trunk
parent8fde4cc2b0f89400b21744d67d91db49f1df8318 (diff)
Setting svn:eol-style for java and xml files
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@951651 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java124
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java66
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java190
-rw-r--r--sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java516
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/pom.xml116
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java108
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java66
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java132
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java116
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java104
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java254
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java196
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java58
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java66
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java228
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java60
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java90
-rw-r--r--sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java86
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java80
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java468
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java110
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java212
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java54
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java58
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java74
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java54
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java60
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java2
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java190
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java56
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java458
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java144
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java1546
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java322
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java106
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java74
-rw-r--r--sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java156
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml82
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java52
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java336
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java62
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java94
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java214
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java72
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java202
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java136
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java76
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java214
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java468
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java218
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/pom.xml122
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java358
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java134
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/itest/nodes/Helloworld.java58
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java168
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java174
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java210
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java164
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java470
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java194
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java276
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java120
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java556
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java150
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java228
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/test/java/sample/Helloworld.java48
-rw-r--r--sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml46
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast-client/pom.xml90
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java240
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast/pom.xml126
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java740
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java358
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java284
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java82
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java338
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java158
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java72
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml378
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script/pom.xml96
-rw-r--r--sca-java-2.x/trunk/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-client/pom.xml136
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java518
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java140
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java60
-rw-r--r--sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java170
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java2
-rw-r--r--sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java80
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java92
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java54
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java58
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java70
-rw-r--r--sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java578
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java98
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java154
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java420
-rw-r--r--sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java152
-rw-r--r--sca-java-2.x/trunk/modules/wink/pom.xml138
-rw-r--r--sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java132
-rw-r--r--sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java132
-rw-r--r--sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java76
-rw-r--r--sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java104
103 files changed, 9417 insertions, 9417 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
index fcfa689a7d..25ae82aa8f 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
@@ -1,62 +1,62 @@
-/*
- * 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.assembly;
-
-import org.apache.tuscany.sca.policy.PolicySubject;
-
-/**
- * Represents an Operation. Typically Operation elements are used when there is a
- * need to apply certain facets such as intents and policysets only to a specific
- * operation provided by a service or reference.
- *
- * @tuscany.spi.extension.asclient
- * @version $Rev$ $Date$
- */
-public interface ConfiguredOperation extends Base, PolicySubject {
- /**
- * Returns the name of the operation.
- *
- * @return the name of the operation
- */
- String getName();
-
- /**
- * Sets the name of the operation.
- *
- * @param name the name of the operation
- */
- void setName(String name);
-
- /**
- * Returns the name of the service or reference to which this operation belongs.
- * This method is particularly useful when operation elements are specified under implementation
- * elements and it is necessary to identify which of the various services provided by the
- * implementation is referred to by the operation element in question
- *
- * @return the name of the contract to which this operation belongs
- */
- String getContractName();
-
- /**
- * Sets the name of the service or reference to which this operation belongs.
- *
- * @param contractName the name of the contract to which this operation belongs
- */
- void setContractName(String contractName);
-}
+/*
+ * 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.assembly;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an Operation. Typically Operation elements are used when there is a
+ * need to apply certain facets such as intents and policysets only to a specific
+ * operation provided by a service or reference.
+ *
+ * @tuscany.spi.extension.asclient
+ * @version $Rev$ $Date$
+ */
+public interface ConfiguredOperation extends Base, PolicySubject {
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ String getName();
+
+ /**
+ * Sets the name of the operation.
+ *
+ * @param name the name of the operation
+ */
+ void setName(String name);
+
+ /**
+ * Returns the name of the service or reference to which this operation belongs.
+ * This method is particularly useful when operation elements are specified under implementation
+ * elements and it is necessary to identify which of the various services provided by the
+ * implementation is referred to by the operation element in question
+ *
+ * @return the name of the contract to which this operation belongs
+ */
+ String getContractName();
+
+ /**
+ * Sets the name of the service or reference to which this operation belongs.
+ *
+ * @param contractName the name of the contract to which this operation belongs
+ */
+ void setContractName(String contractName);
+}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
index d82d923605..9563d2e1cb 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
@@ -1,33 +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 org.apache.tuscany.sca.assembly;
-
-import java.util.List;
-
-/**
- * Interface to be implemented by SCA artifacts that support configuration of 'operation' child
- * elements for policies etc.
- * @tuscany.spi.extension.inheritfrom
- * @version $Rev$ $Date$
- */
-
-public interface OperationsConfigurator {
- List<ConfiguredOperation> getConfiguredOperations();
-}
+/*
+ * 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.assembly;
+
+import java.util.List;
+
+/**
+ * Interface to be implemented by SCA artifacts that support configuration of 'operation' child
+ * elements for policies etc.
+ * @tuscany.spi.extension.inheritfrom
+ * @version $Rev$ $Date$
+ */
+
+public interface OperationsConfigurator {
+ List<ConfiguredOperation> getConfiguredOperations();
+}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
index 32377faf54..80c1c7cd21 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
@@ -1,95 +1,95 @@
-/*
- * 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.assembly.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.policy.ExtensionType;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * Represents an Operation.
- *
- * @version $Rev$ $Date$
- */
-public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOperation {
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private List<Intent> requiredIntents = new ArrayList<Intent>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
-
- private String name;
- private String contractName;
- private ExtensionType type;
-
- /**
- * Constructs a new Operation.
- */
- protected ConfiguredOperationImpl() {
- }
-
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
-
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public String getContractName() {
- return contractName;
- }
-
- public void setContractName(String contractName) {
- this.contractName = contractName;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
- public ExtensionType getExtensionType() {
- return type;
- }
-
- public void setExtensionType(ExtensionType type) {
- this.type = type;
- }
-
-
-}
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an Operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOperation {
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ private String name;
+ private String contractName;
+ private ExtensionType type;
+
+ /**
+ * Constructs a new Operation.
+ */
+ protected ConfiguredOperationImpl() {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public String getContractName() {
+ return contractName;
+ }
+
+ public void setContractName(String contractName) {
+ this.contractName = contractName;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
index 32b2a286b8..0b999ae1c9 100644
--- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
+++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
@@ -1,258 +1,258 @@
-/*
- * 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.binding.atom;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Date;
-
-import junit.framework.Assert;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.i18n.iri.IRI;
-import org.apache.abdera.model.Content;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.Parser;
-import org.apache.abdera.protocol.Response.ResponseType;
-import org.apache.abdera.protocol.client.AbderaClient;
-import org.apache.abdera.protocol.client.ClientResponse;
-import org.apache.abdera.protocol.client.RequestOptions;
-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;
-
-
-/**
- * Tests use of content negotiation for Atom binding in Tuscany.
- * Uses the SCA provided Provider composite to act as a server.
- * Uses the Abdera provided Client to act as a client.
- *
- * @version $Rev$ $Date$
- */
-public class ContentNegotiationTest {
- public final static String providerURI = "http://localhost:8084/customer";
-
- protected static Node scaProviderNode;
-
- protected static CustomerClient testService;
- protected static Abdera abdera;
- protected static AbderaClient client;
- protected static Parser abderaParser;
- protected static String lastId;
-
- @BeforeClass
- public static void init() throws Exception {
- try {
- //System.out.println(">>>ContentNegotiationTest.init");
- String contribution = ContributionLocationHelper.getContributionLocation(ContentNegotiationTest.class);
-
- scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
- scaProviderNode.start();
-
- abdera = new Abdera();
- client = new AbderaClient(abdera);
- abderaParser = Abdera.getNewParser();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @AfterClass
- public static void destroy() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.destroy");
- if (scaProviderNode != null) {
- scaProviderNode.stop();
- }
- }
-
- @Test
- public void testPrelim() throws Exception {
- Assert.assertNotNull(scaProviderNode);
- Assert.assertNotNull( client );
- }
-
- @Test
- public void testPost() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.testPost");
- // Testing of entry creation
- Factory factory = abdera.getFactory();
- String customerName = "Fred Farkle";
- Entry entry = factory.newEntry();
- entry.setTitle("customer " + customerName);
- entry.setUpdated(new Date());
- entry.addAuthor("Apache Tuscany");
- // ID created by collection.
- Content content = abdera.getFactory().newContent();
- content.setContentType(Content.Type.TEXT);
- content.setValue(customerName);
- entry.setContentElement(content);
-
- RequestOptions opts = new RequestOptions();
- final String contentType = "application/atom+xml; type=entry";
- opts.setContentType(contentType);
- // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts );
- IRI colUri = new IRI(providerURI).resolve("customer");
- // res = client.post(colUri.toString() + "?test=foo", entry, opts);
- ClientResponse res = client.post(colUri.toString(), entry, opts);
-
- // Assert response status code is 201-OK.
- // Assert response header Content-Type: application/atom+xml; charset=UTF-8
- Assert.assertEquals(201, res.getStatus());
- String returnedContentType = res.getContentType().toString().trim();
- Assert.assertEquals(contentType, returnedContentType );
-
- String eTag = res.getHeader( "ETag" );
- if ( eTag != null)
- lastId = eTag.substring( 1, eTag.length()-1);
-
- // AtomTestCaseUtils.printResponseHeaders( "Entry post response headers:", " ", res );
- // System.out.println("Entry post response content:");
- // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
- }
-
- @Test
- public void testXMLEntryGet() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/atom+xml" );
-
- IRI colUri = new IRI(providerURI).resolve("customer");
- ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
- Assert.assertEquals(200, res.getStatus());
- String returnedContentType = res.getContentType().toString().trim();
- // Assert.assertEquals(contentType, returnedContentType );
- res.release();
- }
-
- @Test
- public void testJSONEntryGet() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/json" );
-
- IRI colUri = new IRI(providerURI).resolve("customer");
- ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
- try {
- Assert.assertEquals(200, res.getStatus());
- // Abdera 0.4 throws exception on getContentType with application/json.
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
- String contentType = res.getHeader( "Content-Type");
- Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
- // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
- // JSONObject jsonResp = new JSONObject(res.);
- // Assert.assertEquals(12345, jsonResp.getInt("result"));
- String responseBody = readResponse( res.getReader() );
- Assert.assertTrue( responseBody.startsWith( "{") );
- Assert.assertTrue( responseBody.endsWith( "}") );
- Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
- // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
- } finally {
- res.release();
- }
- }
-
- @Test
- public void testXMLFeedGet() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/atom+xml" );
-
- // Atom feed request
- ClientResponse res = client.get(providerURI, opts);
- Assert.assertNotNull(res);
- try {
- // Asser feed provided since no predicates
- Assert.assertEquals(200, res.getStatus());
- Assert.assertEquals(ResponseType.SUCCESS, res.getType());
- // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
- // System.out.println("Feed response content:");
- // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-
- // Perform other tests on feed.
- Document<Feed> doc = res.getDocument();
- Assert.assertNotNull( doc );
- Feed feed = doc.getRoot();
- Assert.assertNotNull( feed );
- // RFC 4287 requires non-null id, title, updated elements
- Assert.assertNotNull( feed.getId() );
- Assert.assertNotNull( feed.getTitle() );
- Assert.assertNotNull( feed.getUpdated() );
- // AtomTestCaseUtils.printFeed( "Feed values", " ", feed );
- } finally {
- res.release();
- }
- }
-
- @Test
- public void testJSONFeedGet() throws Exception {
- //System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/json" );
-
- // JSON feed request
- ClientResponse res = client.get(providerURI, opts);
- Assert.assertNotNull(res);
- try {
- // Assert feed provided since no predicates
- Assert.assertEquals(200, res.getStatus());
- // Abdera 0.4 throws exception on getContentType with application/json.
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
- String contentType = res.getHeader( "Content-Type");
- Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
- // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
- // JSONObject jsonResp = new JSONObject(res.);
- // Assert.assertEquals(12345, jsonResp.getInt("result"));
- String responseBody = readResponse( res.getReader() );
- Assert.assertTrue( responseBody.startsWith( "{") );
- Assert.assertTrue( responseBody.endsWith( "}") );
- Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"entries\"" ));
- // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
- } finally {
- res.release();
- }
- }
-
- protected String readResponse( Reader responseReader ) {
- if ( responseReader == null ) return "";
- StringBuffer sb = new StringBuffer(1024);
- try {
- int charValue = 0;
- while ((charValue = responseReader.read()) != -1) {
- //result = result + (char) charValue;
- sb.append((char)charValue);
- }
- } catch ( IOException e ) {
- }
- return sb.toString();
- }
-}
+/*
+ * 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.binding.atom;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+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;
+
+
+/**
+ * Tests use of content negotiation for Atom binding in Tuscany.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContentNegotiationTest {
+ public final static String providerURI = "http://localhost:8084/customer";
+
+ protected static Node scaProviderNode;
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+ protected static String lastId;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>ContentNegotiationTest.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(ContentNegotiationTest.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.destroy");
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testPost() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testPost");
+ // Testing of entry creation
+ Factory factory = abdera.getFactory();
+ String customerName = "Fred Farkle";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated(new Date());
+ entry.addAuthor("Apache Tuscany");
+ // ID created by collection.
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts );
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+ // Assert response status code is 201-OK.
+ // Assert response header Content-Type: application/atom+xml; charset=UTF-8
+ Assert.assertEquals(201, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ Assert.assertEquals(contentType, returnedContentType );
+
+ String eTag = res.getHeader( "ETag" );
+ if ( eTag != null)
+ lastId = eTag.substring( 1, eTag.length()-1);
+
+ // AtomTestCaseUtils.printResponseHeaders( "Entry post response headers:", " ", res );
+ // System.out.println("Entry post response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ }
+
+ @Test
+ public void testXMLEntryGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/atom+xml" );
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ Assert.assertEquals(200, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ // Assert.assertEquals(contentType, returnedContentType );
+ res.release();
+ }
+
+ @Test
+ public void testJSONEntryGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/json" );
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ try {
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with application/json.
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
+ String contentType = res.getHeader( "Content-Type");
+ Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
+ // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse( res.getReader() );
+ Assert.assertTrue( responseBody.startsWith( "{") );
+ Assert.assertTrue( responseBody.endsWith( "}") );
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
+ // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testXMLFeedGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/atom+xml" );
+
+ // Atom feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Asser feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+ // Perform other tests on feed.
+ Document<Feed> doc = res.getDocument();
+ Assert.assertNotNull( doc );
+ Feed feed = doc.getRoot();
+ Assert.assertNotNull( feed );
+ // RFC 4287 requires non-null id, title, updated elements
+ Assert.assertNotNull( feed.getId() );
+ Assert.assertNotNull( feed.getTitle() );
+ Assert.assertNotNull( feed.getUpdated() );
+ // AtomTestCaseUtils.printFeed( "Feed values", " ", feed );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testJSONFeedGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/json" );
+
+ // JSON feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Assert feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with application/json.
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
+ String contentType = res.getHeader( "Content-Type");
+ Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
+ // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse( res.getReader() );
+ Assert.assertTrue( responseBody.startsWith( "{") );
+ Assert.assertTrue( responseBody.endsWith( "}") );
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"entries\"" ));
+ // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ protected String readResponse( Reader responseReader ) {
+ if ( responseReader == null ) return "";
+ StringBuffer sb = new StringBuffer(1024);
+ try {
+ int charValue = 0;
+ while ((charValue = responseReader.read()) != -1) {
+ //result = result + (char) charValue;
+ sb.append((char)charValue);
+ }
+ } catch ( IOException e ) {
+ }
+ return sb.toString();
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/pom.xml
index 3f366edb9b..189ab5d9e5 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/pom.xml
@@ -1,58 +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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
- <name>Apache Tuscany SCA Binding Hazelcast Runtime</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-endpoint-hazelcast</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-ws-wsdlgen</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>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <name>Apache Tuscany SCA Binding Hazelcast Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</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>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java
index 36d4e74813..42f6193940 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java
@@ -1,54 +1,54 @@
-/*
- * 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.binding.hazelcast;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-
-public class EndpointStash {
-
- // TODO a better way of sharing these endpoints than a static
- // the issue is that the ServiceInvoker needs to get hold of the Endpoint
- // for a URI. The ServiceInvoker runs in the context of a Hazelcast spawned
- // thread so can only get to Tuscany via a static. The Hazelcast endpoint
- // registry does actually have these endpoints so perhaps an alternative could be
- // to use NodeFactory.getNodeFactories to get at the Hazelcast endpoint registry.
- private static Map<String, RuntimeEndpoint> endpoints = new ConcurrentHashMap<String, RuntimeEndpoint>();
-
- public static void addEndpoint(RuntimeEndpoint endpoint) {
- endpoints.put(endpoint.getURI(), endpoint);
- }
-
- public static RuntimeEndpoint getEndpoint(String uri) {
- for (RuntimeEndpoint ep : endpoints.values()) {
- if (ep.matches(uri)) {
- return ep;
- }
- }
- return null;
- }
-
- public static void removeEndpoint(String uri) {
- endpoints.remove(uri);
- }
-}
+/*
+ * 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.binding.hazelcast;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+
+public class EndpointStash {
+
+ // TODO a better way of sharing these endpoints than a static
+ // the issue is that the ServiceInvoker needs to get hold of the Endpoint
+ // for a URI. The ServiceInvoker runs in the context of a Hazelcast spawned
+ // thread so can only get to Tuscany via a static. The Hazelcast endpoint
+ // registry does actually have these endpoints so perhaps an alternative could be
+ // to use NodeFactory.getNodeFactories to get at the Hazelcast endpoint registry.
+ private static Map<String, RuntimeEndpoint> endpoints = new ConcurrentHashMap<String, RuntimeEndpoint>();
+
+ public static void addEndpoint(RuntimeEndpoint endpoint) {
+ endpoints.put(endpoint.getURI(), endpoint);
+ }
+
+ public static RuntimeEndpoint getEndpoint(String uri) {
+ for (RuntimeEndpoint ep : endpoints.values()) {
+ if (ep.matches(uri)) {
+ return ep;
+ }
+ }
+ return null;
+ }
+
+ public static void removeEndpoint(String uri) {
+ endpoints.remove(uri);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java
index 63b18ce8a2..1636ed16ca 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java
@@ -1,33 +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 org.apache.tuscany.sca.binding.hazelcast;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.impl.BindingImpl;
-
-public class HazelcastBinding extends BindingImpl {
-
- public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.hazelcast");
-
- public HazelcastBinding() {
- super(TYPE);
- }
-}
+/*
+ * 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.binding.hazelcast;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
+public class HazelcastBinding extends BindingImpl {
+
+ public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.hazelcast");
+
+ public HazelcastBinding() {
+ super(TYPE);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java
index b56d8a1e50..f202e16a69 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java
@@ -1,66 +1,66 @@
-/*
- * 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.binding.hazelcast;
-
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
-import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
-import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.provider.BindingProviderFactory;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-
-public class HazelcastBindingProviderFactory implements BindingProviderFactory<HazelcastBinding> {
-
- private ExtensionPointRegistry extensionsRegistry;
-
- public HazelcastBindingProviderFactory(ExtensionPointRegistry extensionsRegistry) {
- this.extensionsRegistry = extensionsRegistry;
- }
-
- public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
- InterfaceContract interfaceContract = createDOMInterfaceContract(endpointReference.getComponent(), endpointReference.getReference());
- return new HazelcastReferenceBindingProvider(extensionsRegistry, endpointReference.getBinding().getURI(), interfaceContract);
- }
-
- public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
- InterfaceContract interfaceContract = createDOMInterfaceContract(endpoint.getComponent(), endpoint.getService());
- return new HazelcastServiceBindingProvider(endpoint, interfaceContract);
- }
-
- private InterfaceContract createDOMInterfaceContract(Component component, Contract contract) {
- WebServiceBindingFactory wsFactory = extensionsRegistry.getExtensionPoint(WebServiceBindingFactory.class);
- WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
- BindingWSDLGenerator.generateWSDL(component, contract, wsBinding, extensionsRegistry, null);
- InterfaceContract interfaceContract = wsBinding.getBindingInterfaceContract();
- interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
- return interfaceContract;
- }
-
- public Class<HazelcastBinding> getModelType() {
- return HazelcastBinding.class;
- }
-}
+/*
+ * 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.binding.hazelcast;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class HazelcastBindingProviderFactory implements BindingProviderFactory<HazelcastBinding> {
+
+ private ExtensionPointRegistry extensionsRegistry;
+
+ public HazelcastBindingProviderFactory(ExtensionPointRegistry extensionsRegistry) {
+ this.extensionsRegistry = extensionsRegistry;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ InterfaceContract interfaceContract = createDOMInterfaceContract(endpointReference.getComponent(), endpointReference.getReference());
+ return new HazelcastReferenceBindingProvider(extensionsRegistry, endpointReference.getBinding().getURI(), interfaceContract);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ InterfaceContract interfaceContract = createDOMInterfaceContract(endpoint.getComponent(), endpoint.getService());
+ return new HazelcastServiceBindingProvider(endpoint, interfaceContract);
+ }
+
+ private InterfaceContract createDOMInterfaceContract(Component component, Contract contract) {
+ WebServiceBindingFactory wsFactory = extensionsRegistry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(component, contract, wsBinding, extensionsRegistry, null);
+ InterfaceContract interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ return interfaceContract;
+ }
+
+ public Class<HazelcastBinding> getModelType() {
+ return HazelcastBinding.class;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java
index f7cb0ffeee..29546f405e 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java
@@ -1,58 +1,58 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.binding.hazelcast;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-
-public class HazelcastReferenceBindingProvider implements ReferenceBindingProvider {
-
- private ExtensionPointRegistry extensionsRegistry;
- private String serviceURI;
- private InterfaceContract interfaceContract;
-
- public HazelcastReferenceBindingProvider(ExtensionPointRegistry extensionsRegistry, String serviceURI, InterfaceContract interfaceContract) {
- this.extensionsRegistry = extensionsRegistry;
- this.serviceURI = serviceURI;
- this.interfaceContract = interfaceContract;
- }
-
- public Invoker createInvoker(Operation operation) {
- return new ReferenceInvoker(extensionsRegistry, serviceURI, operation);
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return interfaceContract;
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+public class HazelcastReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private ExtensionPointRegistry extensionsRegistry;
+ private String serviceURI;
+ private InterfaceContract interfaceContract;
+
+ public HazelcastReferenceBindingProvider(ExtensionPointRegistry extensionsRegistry, String serviceURI, InterfaceContract interfaceContract) {
+ this.extensionsRegistry = extensionsRegistry;
+ this.serviceURI = serviceURI;
+ this.interfaceContract = interfaceContract;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new ReferenceInvoker(extensionsRegistry, serviceURI, operation);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java
index d911e5b245..6ac3542a8e 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java
@@ -1,52 +1,52 @@
-/*
- * 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.binding.hazelcast;
-
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-public class HazelcastServiceBindingProvider implements ServiceBindingProvider {
-
- private RuntimeEndpoint endpoint;
- private InterfaceContract interfaceContract;
-
-
- public HazelcastServiceBindingProvider(RuntimeEndpoint endpoint, InterfaceContract interfaceContract) {
- this.endpoint = endpoint;
- this.interfaceContract = interfaceContract;
- }
-
- public void start() {
- EndpointStash.addEndpoint(endpoint);
- }
-
- public void stop() {
- EndpointStash.removeEndpoint(endpoint.getURI());
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return interfaceContract;
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-}
+/*
+ * 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.binding.hazelcast;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class HazelcastServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private InterfaceContract interfaceContract;
+
+
+ public HazelcastServiceBindingProvider(RuntimeEndpoint endpoint, InterfaceContract interfaceContract) {
+ this.endpoint = endpoint;
+ this.interfaceContract = interfaceContract;
+ }
+
+ public void start() {
+ EndpointStash.addEndpoint(endpoint);
+ }
+
+ public void stop() {
+ EndpointStash.removeEndpoint(endpoint.getURI());
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java
index f588f87bdd..7caf3e4841 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java
@@ -1,127 +1,127 @@
-/*
- * 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.binding.hazelcast;
-
-import java.io.IOException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.FutureTask;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.util.FaultException;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import com.hazelcast.core.DistributedTask;
-import com.hazelcast.core.Member;
-
-public class ReferenceInvoker implements Invoker {
-
- HazelcastEndpointRegistry hzRegistry;
- DOMHelper domHelper;
- String serviceURI;
- private Operation operation;
- MessageFactory messageFactory;
-
- public ReferenceInvoker(ExtensionPointRegistry extensionsRegistry, String serviceURI, Operation operation) {
- this.serviceURI = serviceURI;
- this.operation = operation;
- DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
- for (EndpointRegistry r : domainRegistryFactory.getEndpointRegistries()) {
- if (r instanceof HazelcastEndpointRegistry) {
- hzRegistry = (HazelcastEndpointRegistry)r;
- break;
- }
- }
- this.domHelper = DOMHelper.getInstance(extensionsRegistry);
- FactoryExtensionPoint modelFactories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- this.messageFactory = modelFactories.getFactory(MessageFactory.class);
- }
-
- public Message invoke(Message msg) {
- Member owningMember = hzRegistry.getOwningMember(serviceURI);
- if (owningMember == null) {
- throw new ServiceRuntimeException("service not found: " + serviceURI);
- }
- String requestXML = getRequestXML(msg);
- Callable<String> callable = new ServiceInvoker(serviceURI, operation.getName(), requestXML);
- FutureTask<String> task = new DistributedTask<String>(callable, owningMember);
- ExecutorService executorService = getExecutorService();
- executorService.execute(task);
- try {
- return getResponseNode(task.get());
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- /**
- * Hazelcast ExecutorService can't nest invocations so use a separate ExecutorService
- * for nested calls. See http://groups.google.com/group/hazelcast/browse_thread/thread/1cc0b943716476e9
- */
- private ExecutorService getExecutorService() {
- String threadName = Thread.currentThread().getName();
- if (!threadName.startsWith("hz.executor.") || threadName.indexOf("binding.sca.") == -1) {
- return hzRegistry.getHazelcastInstance().getExecutorService("binding.sca.1");
- } else {
- String oldName = threadName.substring(threadName.lastIndexOf("binding.sca."), threadName.lastIndexOf(".thread-"));
- int x = Integer.parseInt(oldName.substring(oldName.lastIndexOf('.') + 1));
- return hzRegistry.getHazelcastInstance().getExecutorService(oldName.substring(0, 12) + (x + 1));
- }
- }
-
- private String getRequestXML(Message msg) {
- Object[] args = msg.getBody();
- String msgXML = domHelper.saveAsString((Node)args[0]);
- return msgXML;
- }
-
- private Message getResponseNode(String responseXML) throws IOException, SAXException {
- Message msg = messageFactory.createMessage();
- if (responseXML.startsWith("DECLAREDEXCEPTION:")) {
- Document responseDOM = domHelper.load(responseXML.substring(18));
- FaultException e = new FaultException("remote exception", responseDOM);
- Node node = ((Node)responseDOM).getFirstChild();
- e.setFaultName(new QName(node.getNamespaceURI(), node.getLocalName()));
- msg.setFaultBody(e);
- } else if (responseXML.startsWith("EXCEPTION:")) {
- throw new ServiceRuntimeException("Remote exception:" + responseXML.substring(10));
- } else {
- Document responseDOM = domHelper.load(responseXML);
- msg.setBody(responseDOM);
- }
- return msg;
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.FutureTask;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import com.hazelcast.core.DistributedTask;
+import com.hazelcast.core.Member;
+
+public class ReferenceInvoker implements Invoker {
+
+ HazelcastEndpointRegistry hzRegistry;
+ DOMHelper domHelper;
+ String serviceURI;
+ private Operation operation;
+ MessageFactory messageFactory;
+
+ public ReferenceInvoker(ExtensionPointRegistry extensionsRegistry, String serviceURI, Operation operation) {
+ this.serviceURI = serviceURI;
+ this.operation = operation;
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+ for (EndpointRegistry r : domainRegistryFactory.getEndpointRegistries()) {
+ if (r instanceof HazelcastEndpointRegistry) {
+ hzRegistry = (HazelcastEndpointRegistry)r;
+ break;
+ }
+ }
+ this.domHelper = DOMHelper.getInstance(extensionsRegistry);
+ FactoryExtensionPoint modelFactories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public Message invoke(Message msg) {
+ Member owningMember = hzRegistry.getOwningMember(serviceURI);
+ if (owningMember == null) {
+ throw new ServiceRuntimeException("service not found: " + serviceURI);
+ }
+ String requestXML = getRequestXML(msg);
+ Callable<String> callable = new ServiceInvoker(serviceURI, operation.getName(), requestXML);
+ FutureTask<String> task = new DistributedTask<String>(callable, owningMember);
+ ExecutorService executorService = getExecutorService();
+ executorService.execute(task);
+ try {
+ return getResponseNode(task.get());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Hazelcast ExecutorService can't nest invocations so use a separate ExecutorService
+ * for nested calls. See http://groups.google.com/group/hazelcast/browse_thread/thread/1cc0b943716476e9
+ */
+ private ExecutorService getExecutorService() {
+ String threadName = Thread.currentThread().getName();
+ if (!threadName.startsWith("hz.executor.") || threadName.indexOf("binding.sca.") == -1) {
+ return hzRegistry.getHazelcastInstance().getExecutorService("binding.sca.1");
+ } else {
+ String oldName = threadName.substring(threadName.lastIndexOf("binding.sca."), threadName.lastIndexOf(".thread-"));
+ int x = Integer.parseInt(oldName.substring(oldName.lastIndexOf('.') + 1));
+ return hzRegistry.getHazelcastInstance().getExecutorService(oldName.substring(0, 12) + (x + 1));
+ }
+ }
+
+ private String getRequestXML(Message msg) {
+ Object[] args = msg.getBody();
+ String msgXML = domHelper.saveAsString((Node)args[0]);
+ return msgXML;
+ }
+
+ private Message getResponseNode(String responseXML) throws IOException, SAXException {
+ Message msg = messageFactory.createMessage();
+ if (responseXML.startsWith("DECLAREDEXCEPTION:")) {
+ Document responseDOM = domHelper.load(responseXML.substring(18));
+ FaultException e = new FaultException("remote exception", responseDOM);
+ Node node = ((Node)responseDOM).getFirstChild();
+ e.setFaultName(new QName(node.getNamespaceURI(), node.getLocalName()));
+ msg.setFaultBody(e);
+ } else if (responseXML.startsWith("EXCEPTION:")) {
+ throw new ServiceRuntimeException("Remote exception:" + responseXML.substring(10));
+ } else {
+ Document responseDOM = domHelper.load(responseXML);
+ msg.setBody(responseDOM);
+ }
+ return msg;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java
index d25c32a68c..42cac191aa 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java
@@ -1,98 +1,98 @@
-/*
- * 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.binding.hazelcast;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.Callable;
-
-import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.util.FaultException;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-public class ServiceInvoker implements Callable<String>, Serializable {
- private static final long serialVersionUID = 1L;
-
- // all fields MUST be Serializable
- private String serviceURI;
- private String operationName;
- private String requestXML;
-
- public ServiceInvoker(String serviceURI, String operationName, String msgXML) {
- this.serviceURI = serviceURI;
- this.operationName = operationName;
- this.requestXML = msgXML;
- }
-
- public String call() throws Exception {
- RuntimeEndpoint endpoint = EndpointStash.getEndpoint(serviceURI);
- if (endpoint == null) {
- throw new NoSuchServiceException(serviceURI);
- }
- Operation operation = getRequestOperation(endpoint);
- DOMHelper domHelper = DOMHelper.getInstance(endpoint.getCompositeContext().getExtensionPointRegistry());
- Object[] args = getRequestArgs(domHelper);
- String responseXML;
- try {
- Object response = endpoint.invoke(operation, args);
- responseXML = getResponseXML(domHelper, response);
- } catch (Exception e) {
- if (e instanceof InvocationTargetException && ((InvocationTargetException)e).getTargetException() instanceof FaultException) {
- responseXML = "DECLAREDEXCEPTION:" + getResponseXML(domHelper, ((FaultException)((InvocationTargetException)e).getTargetException()).getFaultInfo());
- } else {
- responseXML = "EXCEPTION: " + e.getClass() + ":" + e.getMessage();
- }
- }
- return responseXML;
- }
-
- private Operation getRequestOperation(RuntimeEndpoint endpoint) {
- InterfaceContract ic = endpoint.getBindingInterfaceContract();
- Interface iface = ic.getInterface();
- for (Operation op : iface.getOperations()) {
- if (op.getName().equals(operationName)) {
- return op;
- }
-
- }
- // TODO: return err msg
- throw new ServiceRuntimeException("operation not found " + operationName);
- }
-
- private Object[] getRequestArgs(DOMHelper domHelper) throws IOException, SAXException {
- Document requestDOM = domHelper.load(requestXML);
- return new Object[] {requestDOM};
- }
-
- private String getResponseXML(DOMHelper domHelper, Object response) {
- String responseXML = domHelper.saveAsString((Node)response);
- return responseXML;
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class ServiceInvoker implements Callable<String>, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // all fields MUST be Serializable
+ private String serviceURI;
+ private String operationName;
+ private String requestXML;
+
+ public ServiceInvoker(String serviceURI, String operationName, String msgXML) {
+ this.serviceURI = serviceURI;
+ this.operationName = operationName;
+ this.requestXML = msgXML;
+ }
+
+ public String call() throws Exception {
+ RuntimeEndpoint endpoint = EndpointStash.getEndpoint(serviceURI);
+ if (endpoint == null) {
+ throw new NoSuchServiceException(serviceURI);
+ }
+ Operation operation = getRequestOperation(endpoint);
+ DOMHelper domHelper = DOMHelper.getInstance(endpoint.getCompositeContext().getExtensionPointRegistry());
+ Object[] args = getRequestArgs(domHelper);
+ String responseXML;
+ try {
+ Object response = endpoint.invoke(operation, args);
+ responseXML = getResponseXML(domHelper, response);
+ } catch (Exception e) {
+ if (e instanceof InvocationTargetException && ((InvocationTargetException)e).getTargetException() instanceof FaultException) {
+ responseXML = "DECLAREDEXCEPTION:" + getResponseXML(domHelper, ((FaultException)((InvocationTargetException)e).getTargetException()).getFaultInfo());
+ } else {
+ responseXML = "EXCEPTION: " + e.getClass() + ":" + e.getMessage();
+ }
+ }
+ return responseXML;
+ }
+
+ private Operation getRequestOperation(RuntimeEndpoint endpoint) {
+ InterfaceContract ic = endpoint.getBindingInterfaceContract();
+ Interface iface = ic.getInterface();
+ for (Operation op : iface.getOperations()) {
+ if (op.getName().equals(operationName)) {
+ return op;
+ }
+
+ }
+ // TODO: return err msg
+ throw new ServiceRuntimeException("operation not found " + operationName);
+ }
+
+ private Object[] getRequestArgs(DOMHelper domHelper) throws IOException, SAXException {
+ Document requestDOM = domHelper.load(requestXML);
+ return new Object[] {requestDOM};
+ }
+
+ private String getResponseXML(DOMHelper domHelper, Object response) {
+ String responseXML = domHelper.saveAsString((Node)response);
+ return responseXML;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java
index f7ca89e7bb..937046f0b1 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java
@@ -1,29 +1,29 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.binding.hazelcast;
-
-public class BadStringException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public BadStringException(String msg) {
- super(msg);
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+public class BadStringException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public BadStringException(String msg) {
+ super(msg);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java
index 79e695d38a..68353c89cf 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java
@@ -1,33 +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 org.apache.tuscany.sca.binding.hazelcast;
-
-public class ComplexType {
-
- private String s;
-
- public void setString(String s) {
- this.s = s;
- }
-
- public String getString() {
- return s;
- }
-}
+/*
+ * 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.binding.hazelcast;
+
+public class ComplexType {
+
+ private String s;
+
+ public void setString(String s) {
+ this.s = s;
+ }
+
+ public String getString() {
+ return s;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java
index 1183ae9732..18831eafac 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java
@@ -1,114 +1,114 @@
-/*
- * 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.binding.hazelcast;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-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;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-public class HazelcastBindingTestCase {
-
- private static Node serviceNode;
- private static Node clientNode;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- // Note use of NodeFactory.newInstance() so as to start separate runtimes
- serviceNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("service.composite", new String[]{"target/test-classes"});
- serviceNode.start();
- clientNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client.composite", new String[]{"target/test-classes"});
- clientNode.start();
- }
-
- @Test
- public void testNestedClient() throws Exception {
- Node client2Node = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client2.composite", new String[]{"target/test-classes"});
- client2Node.start();
- TestService service = client2Node.getService(TestService.class, "TestServiceClient2");
- assertNotNull(service);
- assertEquals("Petra", service.echoString("Petra"));
- client2Node.stop();
- }
-
- @Test
- public void testEchoString() throws Exception {
- TestService service = clientNode.getService(TestService.class, "TestServiceClient");
- assertNotNull(service);
- assertEquals("Petra", service.echoString("Petra"));
- }
-
- @Test
- public void testOnewayString() throws Exception {
- TestService service = clientNode.getService(TestService.class, "TestServiceClient");
- assertNotNull(service);
- service.onewayString("Petra");
- }
-
- @Test
- public void testEchoComplexType() throws Exception {
- TestService service = clientNode.getService(TestService.class, "TestServiceClient");
- assertNotNull(service);
- ComplexType ct = new ComplexType();
- ct.setString("beate");
- assertEquals("beate", service.echoComplexType(ct).getString());
- }
-
- @Test
- public void testDeclaredException() throws Exception {
- TestService service = clientNode.getService(TestService.class, "TestServiceClient");
- assertNotNull(service);
- try {
- service.testExceptions("Sue");
- fail();
- } catch (BadStringException e) {
- assertEquals("Sue", e.getMessage());
- }
- }
-
- @Test
- public void testRuntimeException() throws Exception {
- TestService service = clientNode.getService(TestService.class, "TestServiceClient");
- assertNotNull(service);
- try {
- service.testExceptions("runtime");
- fail();
- } catch (ServiceRuntimeException e) {
- assertEquals("org.oasisopen.sca.ServiceRuntimeException: Remote exception: class java.lang.RuntimeException:runtime", e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- if (clientNode != null) {
- clientNode.stop();
- }
- if (serviceNode != null) {
- serviceNode.stop();
- }
- }
-}
-
+/*
+ * 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.binding.hazelcast;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+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;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class HazelcastBindingTestCase {
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // Note use of NodeFactory.newInstance() so as to start separate runtimes
+ serviceNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("service.composite", new String[]{"target/test-classes"});
+ serviceNode.start();
+ clientNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client.composite", new String[]{"target/test-classes"});
+ clientNode.start();
+ }
+
+ @Test
+ public void testNestedClient() throws Exception {
+ Node client2Node = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client2.composite", new String[]{"target/test-classes"});
+ client2Node.start();
+ TestService service = client2Node.getService(TestService.class, "TestServiceClient2");
+ assertNotNull(service);
+ assertEquals("Petra", service.echoString("Petra"));
+ client2Node.stop();
+ }
+
+ @Test
+ public void testEchoString() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ assertEquals("Petra", service.echoString("Petra"));
+ }
+
+ @Test
+ public void testOnewayString() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ service.onewayString("Petra");
+ }
+
+ @Test
+ public void testEchoComplexType() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ ComplexType ct = new ComplexType();
+ ct.setString("beate");
+ assertEquals("beate", service.echoComplexType(ct).getString());
+ }
+
+ @Test
+ public void testDeclaredException() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ try {
+ service.testExceptions("Sue");
+ fail();
+ } catch (BadStringException e) {
+ assertEquals("Sue", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testRuntimeException() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ try {
+ service.testExceptions("runtime");
+ fail();
+ } catch (ServiceRuntimeException e) {
+ assertEquals("org.oasisopen.sca.ServiceRuntimeException: Remote exception: class java.lang.RuntimeException:runtime", e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
+
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java
index e2462daa76..3ffcb0d384 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java
@@ -1,30 +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 org.apache.tuscany.sca.binding.hazelcast;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface TestService {
- String echoString(String s);
- void onewayString(String s);
- ComplexType echoComplexType(ComplexType ct);
- String testExceptions(String s) throws BadStringException;
-}
+/*
+ * 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.binding.hazelcast;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface TestService {
+ String echoString(String s);
+ void onewayString(String s);
+ ComplexType echoComplexType(ComplexType ct);
+ String testExceptions(String s) throws BadStringException;
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java
index 18cd2555b3..4b462068f0 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java
@@ -1,45 +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.binding.hazelcast;
-
-import org.oasisopen.sca.annotation.Reference;
-
-public class TestServiceClient implements TestService {
-
- @Reference
- public TestService service;
-
- public String echoString(String s) {
- return service.echoString(s);
- }
-
- public void onewayString(String s) {
- service.onewayString(s);
- }
-
- public ComplexType echoComplexType(ComplexType ct) {
- return service.echoComplexType(ct);
- }
-
- public String testExceptions(String s) throws BadStringException {
- return service.testExceptions(s);
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class TestServiceClient implements TestService {
+
+ @Reference
+ public TestService service;
+
+ public String echoString(String s) {
+ return service.echoString(s);
+ }
+
+ public void onewayString(String s) {
+ service.onewayString(s);
+ }
+
+ public ComplexType echoComplexType(ComplexType ct) {
+ return service.echoComplexType(ct);
+ }
+
+ public String testExceptions(String s) throws BadStringException {
+ return service.testExceptions(s);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java
index 6c9a5d71bf..1f5a3872c6 100644
--- a/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java
+++ b/sca-java-2.x/trunk/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java
@@ -1,43 +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.binding.hazelcast;
-
-public class TestServiceImpl implements TestService {
-
- public String echoString(String s) {
- return s;
- }
-
- public void onewayString(String s) {
- System.out.println("onewayString " + s);
- }
-
- public ComplexType echoComplexType(ComplexType ct) {
- return ct;
- }
-
- public String testExceptions(String s) throws BadStringException {
- if (s.equals("runtime")) {
- throw new RuntimeException("runtime");
- }
- throw new BadStringException(s);
- }
-
-}
+/*
+ * 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.binding.hazelcast;
+
+public class TestServiceImpl implements TestService {
+
+ public String echoString(String s) {
+ return s;
+ }
+
+ public void onewayString(String s) {
+ System.out.println("onewayString " + s);
+ }
+
+ public ComplexType echoComplexType(ComplexType ct) {
+ return ct;
+ }
+
+ public String testExceptions(String s) throws BadStringException {
+ if (s.equals("runtime")) {
+ throw new RuntimeException("runtime");
+ }
+ throw new BadStringException(s);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
index 7de30c265a..cac346adf4 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
@@ -1,40 +1,40 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.binding.jms.host;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.work.WorkScheduler;
-
-public class DefaultJMSHostExtensionPoint implements JMSHostExtensionPoint {
-
- private JMSServiceListenerFactory jmsServiceListenerFactory;
-
- public DefaultJMSHostExtensionPoint(ExtensionPointRegistry extensionPoints) {
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- WorkScheduler workScheduler = utilities.getUtility(WorkScheduler.class);
- this.jmsServiceListenerFactory = new DefaultJMSServiceListenerFactory(workScheduler);
- }
-
- public JMSServiceListenerFactory getJMSServiceListenerFactory() {
- return jmsServiceListenerFactory;
- }
-
-}
+/*
+ * 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.binding.jms.host;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class DefaultJMSHostExtensionPoint implements JMSHostExtensionPoint {
+
+ private JMSServiceListenerFactory jmsServiceListenerFactory;
+
+ public DefaultJMSHostExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ WorkScheduler workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.jmsServiceListenerFactory = new DefaultJMSServiceListenerFactory(workScheduler);
+ }
+
+ public JMSServiceListenerFactory getJMSServiceListenerFactory() {
+ return jmsServiceListenerFactory;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
index 9dc41eb3bc..3bd7b8c345 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
@@ -1,234 +1,234 @@
-/*
- * 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.binding.jms.host;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.NamingException;
-
-import org.apache.tuscany.sca.binding.jms.JMSBinding;
-import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
-import org.apache.tuscany.sca.binding.jms.JMSBindingException;
-import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
-import org.apache.tuscany.sca.work.WorkScheduler;
-
-/**
- * Implementation of the JMS service binding provider.
- *
- * @version $Rev: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $
- */
-public class DefaultJMSServiceListener implements JMSServiceListener {
- private static final Logger logger = Logger.getLogger(DefaultJMSServiceListener.class.getName());
-
- private MessageListener listener;
- private String serviceName;
- private boolean isCallbackService;
- private JMSBinding jmsBinding;
- private WorkScheduler workScheduler;
-
- private JMSResourceFactory jmsResourceFactory;
- private MessageConsumer consumer;
- private boolean running;
-
- private Destination destination;
-
- public DefaultJMSServiceListener(MessageListener listener, String serviceName, boolean isCallbackService, JMSBinding jmsBinding, WorkScheduler workScheduler, JMSResourceFactory rf) {
- this.listener = listener;
- this.serviceName = serviceName;
- this.isCallbackService = isCallbackService;
- this.jmsBinding = jmsBinding;
- this.workScheduler = workScheduler;
- this.jmsResourceFactory = rf;
- }
-
- public void start() {
- this.running = true;
-
- try {
- registerListerner();
- } catch (Exception e) {
- throw new JMSBindingException("Error starting JMSServiceBinding", e);
- }
- }
-
- public void stop() {
- this.running = false;
- try {
- consumer.close();
- jmsResourceFactory.closeConnection();
- jmsResourceFactory.closeResponseConnection();
- } catch (Exception e) {
- // if using an embedded broker then when shutting down Tuscany the broker may get closed
- // before this stop method is called. I can't see how to detect that so for now just
- // ignore the exception if the message is that the transport is already disposed
- if ((e.getMessage() == null) || !e.getMessage().contains("disposed")) {
- throw new JMSBindingException("Error stopping JMSServiceBinding", e);
- }
- }
- }
-
- private void registerListerner() throws NamingException, JMSException {
-
- Session session = jmsResourceFactory.createSession();
- destination = lookupDestinationQueue();
- if (destination == null) {
- destination = session.createTemporaryQueue();
- }
-
- if (jmsBinding.getJMSSelector() != null) {
- consumer = session.createConsumer(destination, jmsBinding.getJMSSelector());
- } else {
- consumer = session.createConsumer(destination);
- }
-
- try {
-
- consumer.setMessageListener(listener);
- jmsResourceFactory.startConnection();
-
- } catch (javax.jms.JMSException e) {
-
- // setMessageListener not allowed in JEE container so use Tuscany threads
-
- jmsResourceFactory.startConnection();
- workScheduler.scheduleWork(new Runnable() {
- public void run() {
- try {
- while (running) {
- final Message msg = consumer.receive();
- workScheduler.scheduleWork(new Runnable() {
- public void run() {
- try {
- listener.onMessage(msg);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- logger.log(Level.INFO, "JMS " + (isCallbackService ? "callback service" : "service")
- + " '"
- + serviceName
- + "' listening on destination "
- + ((destination instanceof Queue) ? ((Queue)destination).getQueueName() : ((Topic)destination).getTopicName()));
- }
-
- /**
- * Looks up the Destination Queue for the JMS Binding.
- * <p>
- * What happens in the look up will depend on the create mode specified for the JMS Binding:
- * <ul>
- * <li>always - the JMS queue is always created. It is an error if the queue already exists
- * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists
- * <li>never - the JMS queue is never created. It is an error if the queue does not exist
- * </ul>
- * See the SCA JMS Binding specification for more information.
- * <p>
- *
- * @return The Destination queue.
- * @throws NamingException Failed to lookup JMS queue
- * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that the JMS queue's current existence/non-existence is not
- * compatible with the create mode specified on the binding
- */
- private Destination lookupDestinationQueue() throws NamingException, JMSBindingException {
-
- if (isCallbackService && (jmsBinding.getDestinationName() == null)) {
- // if its a callback service returning null indicates to use a temporary queue
- return null;
- }
-
- Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName());
-
- String qCreateMode = jmsBinding.getDestinationCreate();
- if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
- // In this mode, the queue must not already exist as we are creating it
- if (destination != null) {
- throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
- + " already exists but has create mode of \""
- + qCreateMode
- + "\" while registering service "
- + serviceName
- + " listener");
- }
-
- // Create the queue
- destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
-
- } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
- // In this mode, the queue may nor may not exist. It will be created if it does not exist
- if (destination == null) {
- destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
- }
-
- } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
- // In this mode, the queue must have already been created.
- if (destination == null) {
- throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
- + " not found but create mode of \""
- + qCreateMode
- + "\" while registering service "
- + serviceName
- + " listener");
- }
- }
-
- // Make sure we ended up with a queue
- if (destination == null) {
- throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
- + " not found with create mode of \""
- + qCreateMode
- + "\" while registering service "
- + serviceName
- + " listener");
- }
-
- return destination;
- }
-
- public String getDestinationName() {
- try {
- if (destination instanceof Queue) {
- return ((Queue)destination).getQueueName();
- } else if (destination instanceof Topic) {
- return ((Topic)destination).getTopicName();
- } else {
- return null;
- }
- } catch (JMSException e) {
- throw new JMSBindingException(e);
- }
- }
-
-}
+/*
+ * 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.binding.jms.host;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * Implementation of the JMS service binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultJMSServiceListener implements JMSServiceListener {
+ private static final Logger logger = Logger.getLogger(DefaultJMSServiceListener.class.getName());
+
+ private MessageListener listener;
+ private String serviceName;
+ private boolean isCallbackService;
+ private JMSBinding jmsBinding;
+ private WorkScheduler workScheduler;
+
+ private JMSResourceFactory jmsResourceFactory;
+ private MessageConsumer consumer;
+ private boolean running;
+
+ private Destination destination;
+
+ public DefaultJMSServiceListener(MessageListener listener, String serviceName, boolean isCallbackService, JMSBinding jmsBinding, WorkScheduler workScheduler, JMSResourceFactory rf) {
+ this.listener = listener;
+ this.serviceName = serviceName;
+ this.isCallbackService = isCallbackService;
+ this.jmsBinding = jmsBinding;
+ this.workScheduler = workScheduler;
+ this.jmsResourceFactory = rf;
+ }
+
+ public void start() {
+ this.running = true;
+
+ try {
+ registerListerner();
+ } catch (Exception e) {
+ throw new JMSBindingException("Error starting JMSServiceBinding", e);
+ }
+ }
+
+ public void stop() {
+ this.running = false;
+ try {
+ consumer.close();
+ jmsResourceFactory.closeConnection();
+ jmsResourceFactory.closeResponseConnection();
+ } catch (Exception e) {
+ // if using an embedded broker then when shutting down Tuscany the broker may get closed
+ // before this stop method is called. I can't see how to detect that so for now just
+ // ignore the exception if the message is that the transport is already disposed
+ if ((e.getMessage() == null) || !e.getMessage().contains("disposed")) {
+ throw new JMSBindingException("Error stopping JMSServiceBinding", e);
+ }
+ }
+ }
+
+ private void registerListerner() throws NamingException, JMSException {
+
+ Session session = jmsResourceFactory.createSession();
+ destination = lookupDestinationQueue();
+ if (destination == null) {
+ destination = session.createTemporaryQueue();
+ }
+
+ if (jmsBinding.getJMSSelector() != null) {
+ consumer = session.createConsumer(destination, jmsBinding.getJMSSelector());
+ } else {
+ consumer = session.createConsumer(destination);
+ }
+
+ try {
+
+ consumer.setMessageListener(listener);
+ jmsResourceFactory.startConnection();
+
+ } catch (javax.jms.JMSException e) {
+
+ // setMessageListener not allowed in JEE container so use Tuscany threads
+
+ jmsResourceFactory.startConnection();
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ try {
+ while (running) {
+ final Message msg = consumer.receive();
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ try {
+ listener.onMessage(msg);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ logger.log(Level.INFO, "JMS " + (isCallbackService ? "callback service" : "service")
+ + " '"
+ + serviceName
+ + "' listening on destination "
+ + ((destination instanceof Queue) ? ((Queue)destination).getQueueName() : ((Topic)destination).getTopicName()));
+ }
+
+ /**
+ * Looks up the Destination Queue for the JMS Binding.
+ * <p>
+ * What happens in the look up will depend on the create mode specified for the JMS Binding:
+ * <ul>
+ * <li>always - the JMS queue is always created. It is an error if the queue already exists
+ * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists
+ * <li>never - the JMS queue is never created. It is an error if the queue does not exist
+ * </ul>
+ * See the SCA JMS Binding specification for more information.
+ * <p>
+ *
+ * @return The Destination queue.
+ * @throws NamingException Failed to lookup JMS queue
+ * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that the JMS queue's current existence/non-existence is not
+ * compatible with the create mode specified on the binding
+ */
+ private Destination lookupDestinationQueue() throws NamingException, JMSBindingException {
+
+ if (isCallbackService && (jmsBinding.getDestinationName() == null)) {
+ // if its a callback service returning null indicates to use a temporary queue
+ return null;
+ }
+
+ Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName());
+
+ String qCreateMode = jmsBinding.getDestinationCreate();
+ if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
+ // In this mode, the queue must not already exist as we are creating it
+ if (destination != null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " already exists but has create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+
+ // Create the queue
+ destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ // In this mode, the queue may nor may not exist. It will be created if it does not exist
+ if (destination == null) {
+ destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
+ }
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
+ // In this mode, the queue must have already been created.
+ if (destination == null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " not found but create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+ }
+
+ // Make sure we ended up with a queue
+ if (destination == null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " not found with create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+
+ return destination;
+ }
+
+ public String getDestinationName() {
+ try {
+ if (destination instanceof Queue) {
+ return ((Queue)destination).getQueueName();
+ } else if (destination instanceof Topic) {
+ return ((Topic)destination).getTopicName();
+ } else {
+ return null;
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
index bb4b30d190..1976d687b6 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
@@ -1,55 +1,55 @@
-/*
- * 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.binding.jms.host;
-
-import javax.jms.MessageListener;
-import javax.naming.NamingException;
-
-import org.apache.tuscany.sca.binding.jms.JMSBindingException;
-import org.apache.tuscany.sca.binding.jms.provider.JMSBindingServiceBindingProvider;
-import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.work.WorkScheduler;
-
-public class DefaultJMSServiceListenerFactory implements JMSServiceListenerFactory {
-
- private WorkScheduler workScheduler;
-
- public DefaultJMSServiceListenerFactory(WorkScheduler workScheduler) {
- this.workScheduler = workScheduler;
- }
-
- public JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsSLD) {
- try {
-
- JMSResourceFactory rf = ((JMSBindingServiceBindingProvider)jmsSLD).getResourceFactory();
-
- RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService();
- MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
-
-// return new ASFListener(listener, service.getName(), service.isCallback(), jmsSLD.getJmsBinding(), workScheduler, rf);
-// TODO: 2.x migration, service.isCallback()
- return new DefaultJMSServiceListener(listener, service.getName(), false, jmsSLD.getJmsBinding(), workScheduler, rf);
-
- } catch (NamingException e) {
- throw new JMSBindingException(e);
- }
- }
-}
+/*
+ * 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.binding.jms.host;
+
+import javax.jms.MessageListener;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.provider.JMSBindingServiceBindingProvider;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class DefaultJMSServiceListenerFactory implements JMSServiceListenerFactory {
+
+ private WorkScheduler workScheduler;
+
+ public DefaultJMSServiceListenerFactory(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ public JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsSLD) {
+ try {
+
+ JMSResourceFactory rf = ((JMSBindingServiceBindingProvider)jmsSLD).getResourceFactory();
+
+ RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService();
+ MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
+
+// return new ASFListener(listener, service.getName(), service.isCallback(), jmsSLD.getJmsBinding(), workScheduler, rf);
+// TODO: 2.x migration, service.isCallback()
+ return new DefaultJMSServiceListener(listener, service.getName(), false, jmsSLD.getJmsBinding(), workScheduler, rf);
+
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
index 0e1ee1bfd0..9f3062f065 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
@@ -1,106 +1,106 @@
-/*
- * 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.binding.jms.host;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.naming.NamingException;
-
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.binding.jms.JMSBinding;
-import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
-import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-/**
- * TODO RRB experiement
- * Listener for the JMSBinding.
- *
- * @version $Rev: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $
- */
-public class DefaultServiceInvoker implements MessageListener {
-
- private static final Logger logger = Logger.getLogger(DefaultServiceInvoker.class.getName());
-
- private RuntimeEndpoint endpoint;
- private JMSBinding jmsBinding;
- private Binding targetBinding;
- private JMSResourceFactory jmsResourceFactory;
- private RuntimeComponentService service;
- private MessageFactory messageFactory;
-
- public DefaultServiceInvoker(RuntimeEndpoint endpoint, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
- this.endpoint = endpoint;
- this.jmsBinding = (JMSBinding) endpoint.getBinding();
- this.jmsResourceFactory = rf;
- this.service = (RuntimeComponentService) endpoint.getService();
- this.targetBinding = targetBinding;
- this.messageFactory = messageFactory;
-
- }
-
- public void onMessage(Message requestJMSMsg) {
- logger.log(Level.FINE, "JMS service '" + service.getName() + "' received message " + requestJMSMsg);
- try {
- invokeService(requestJMSMsg);
- } catch (Throwable e) {
- logger.log(Level.SEVERE, "Exception send fault response '" + service.getName(), e);
- }
- }
-
- protected void invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException {
-
- // create the tuscany message
- org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
-
- // populate the message context with JMS binding information
- JMSBindingContext context = new JMSBindingContext();
- tuscanyMsg.setBindingContext(context);
-
- context.setJmsMsg(requestJMSMsg);
- context.setJmsResourceFactory(jmsResourceFactory);
- context.setReplyToDestination(requestJMSMsg.getJMSReplyTo());
-
- // set the message body
- tuscanyMsg.setBody(requestJMSMsg);
-
- // call the runtime wire - the response is handled by the
- // transport interceptor
- getEndpoint(targetBinding).invoke(tuscanyMsg);
-
- }
-
- private RuntimeEndpoint getEndpoint(Binding targetBinding) {
- for(Endpoint ep: service.getEndpoints()) {
- if(ep.getBinding() == targetBinding) {
- return (RuntimeEndpoint) ep;
- }
- }
- return endpoint;
- }
-
-}
+/*
+ * 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.binding.jms.host;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * TODO RRB experiement
+ * Listener for the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultServiceInvoker implements MessageListener {
+
+ private static final Logger logger = Logger.getLogger(DefaultServiceInvoker.class.getName());
+
+ private RuntimeEndpoint endpoint;
+ private JMSBinding jmsBinding;
+ private Binding targetBinding;
+ private JMSResourceFactory jmsResourceFactory;
+ private RuntimeComponentService service;
+ private MessageFactory messageFactory;
+
+ public DefaultServiceInvoker(RuntimeEndpoint endpoint, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
+ this.endpoint = endpoint;
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.jmsResourceFactory = rf;
+ this.service = (RuntimeComponentService) endpoint.getService();
+ this.targetBinding = targetBinding;
+ this.messageFactory = messageFactory;
+
+ }
+
+ public void onMessage(Message requestJMSMsg) {
+ logger.log(Level.FINE, "JMS service '" + service.getName() + "' received message " + requestJMSMsg);
+ try {
+ invokeService(requestJMSMsg);
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, "Exception send fault response '" + service.getName(), e);
+ }
+ }
+
+ protected void invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException {
+
+ // create the tuscany message
+ org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
+
+ // populate the message context with JMS binding information
+ JMSBindingContext context = new JMSBindingContext();
+ tuscanyMsg.setBindingContext(context);
+
+ context.setJmsMsg(requestJMSMsg);
+ context.setJmsResourceFactory(jmsResourceFactory);
+ context.setReplyToDestination(requestJMSMsg.getJMSReplyTo());
+
+ // set the message body
+ tuscanyMsg.setBody(requestJMSMsg);
+
+ // call the runtime wire - the response is handled by the
+ // transport interceptor
+ getEndpoint(targetBinding).invoke(tuscanyMsg);
+
+ }
+
+ private RuntimeEndpoint getEndpoint(Binding targetBinding) {
+ for(Endpoint ep: service.getEndpoints()) {
+ if(ep.getBinding() == targetBinding) {
+ return (RuntimeEndpoint) ep;
+ }
+ }
+ return endpoint;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
index e4bf31f7ee..a15a84b60e 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
@@ -1,27 +1,27 @@
-/*
- * 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.binding.jms.host;
-
-
-public interface JMSHostExtensionPoint {
-
- JMSServiceListenerFactory getJMSServiceListenerFactory();
-
-}
+/*
+ * 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.binding.jms.host;
+
+
+public interface JMSHostExtensionPoint {
+
+ JMSServiceListenerFactory getJMSServiceListenerFactory();
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
index b6ccb5be9b..444d796b12 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
@@ -1,29 +1,29 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.binding.jms.host;
-
-public interface JMSServiceListener {
-
- void start();
-
- void stop();
-
- String getDestinationName();
-}
+/*
+ * 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.binding.jms.host;
+
+public interface JMSServiceListener {
+
+ void start();
+
+ void stop();
+
+ String getDestinationName();
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java
index c183a720e2..451f3680d6 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java
@@ -1,37 +1,37 @@
-/*
- * 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.binding.jms.host;
-
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.binding.jms.JMSBinding;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-public interface JMSServiceListenerDetails {
-
- JMSBinding getJmsBinding();
-
- Binding getTargetBinding();
-
- RuntimeEndpoint getEndpoint();
-
- MessageFactory getMessageFactory();
-
-}
+/*
+ * 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.binding.jms.host;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public interface JMSServiceListenerDetails {
+
+ JMSBinding getJmsBinding();
+
+ Binding getTargetBinding();
+
+ RuntimeEndpoint getEndpoint();
+
+ MessageFactory getMessageFactory();
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
index 5f3f773985..9dc23f1d8d 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
@@ -1,27 +1,27 @@
-/*
- * 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.binding.jms.host;
-
-
-public interface JMSServiceListenerFactory {
-
- JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsServiceBindingProvider);
-
-}
+/*
+ * 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.binding.jms.host;
+
+
+public interface JMSServiceListenerFactory {
+
+ JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsServiceBindingProvider);
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java
index 17542ace9d..32531fa6c3 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java
@@ -1,30 +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 org.apache.tuscany.sca.binding.jms.provider;
-
-import org.apache.tuscany.sca.binding.jms.JMSBinding;
-
-public class DefaultJMSResourceFactoryExtensionPoint implements JMSResourceFactoryExtensionPoint {
-
- public JMSResourceFactory createJMSResourceFactory(JMSBinding binding) {
- return new JMSResourceFactoryImpl(binding.getConnectionFactoryName(), binding.getResponseConnectionFactoryName(), binding.getInitialContextFactoryName(), binding.getJndiURL());
- }
-
-}
+/*
+ * 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.binding.jms.provider;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+
+public class DefaultJMSResourceFactoryExtensionPoint implements JMSResourceFactoryExtensionPoint {
+
+ public JMSResourceFactory createJMSResourceFactory(JMSBinding binding) {
+ return new JMSResourceFactoryImpl(binding.getConnectionFactoryName(), binding.getResponseConnectionFactoryName(), binding.getInitialContextFactoryName(), binding.getJndiURL());
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
index 2628bf50a1..b7622c942e 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
@@ -28,7 +28,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry;
/**
* Utility methods to load JMS message processors.
*
- * @version $Rev: $ $Date: $
+ * @version $Rev$ $Date$
*/
public class JMSMessageProcessorUtil {
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
index 348764fe43..cd53857ed8 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
@@ -1,95 +1,95 @@
-/*
- * 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.binding.jms.provider;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.naming.NamingException;
-
-public interface JMSResourceFactory {
-
- /*
- * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
- * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
- * an AppServer Then we could leverage the JMS resources it provides
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
- */
- public abstract Connection getConnection() throws NamingException, JMSException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
- */
- public abstract Session createSession() throws JMSException, NamingException;
-
- public abstract void closeSession(Session session) throws JMSException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#startConnection()
- */
- public abstract void startConnection() throws JMSException, NamingException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#closeConnection()
- */
- public abstract void closeConnection() throws JMSException;
-
- public abstract Destination lookupDestination(String destName) throws NamingException;
-
- /**
- * You can create a destination in ActiveMQ (and have it appear in JNDI) by putting "dynamicQueues/" in front of the queue name being looked up
- */
- public abstract Destination createDestination(String jndiName) throws NamingException;
-
- /*
- * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
- * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
- * an AppServer Then we could leverage the JMS resources it provides
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
- */
- public abstract Connection getResponseConnection() throws NamingException, JMSException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
- */
- public abstract Session createResponseSession() throws JMSException, NamingException;
-
- public abstract void closeResponseSession(Session session) throws JMSException;
-
- public abstract void closeResponseConnection() throws JMSException;
-
- /*
- * Indicates whether connections obtained using getConnection() or getResponseConnection()
- * must be closed after each use. This is necessary in environments where connections are
- * shared with other users, or where connections cannot be held across transaction boundaries.
- */
- public abstract boolean isConnectionClosedAfterUse();
-}
+/*
+ * 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.binding.jms.provider;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+public interface JMSResourceFactory {
+
+ /*
+ * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
+ * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
+ * an AppServer Then we could leverage the JMS resources it provides
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
+ */
+ public abstract Connection getConnection() throws NamingException, JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
+ */
+ public abstract Session createSession() throws JMSException, NamingException;
+
+ public abstract void closeSession(Session session) throws JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#startConnection()
+ */
+ public abstract void startConnection() throws JMSException, NamingException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#closeConnection()
+ */
+ public abstract void closeConnection() throws JMSException;
+
+ public abstract Destination lookupDestination(String destName) throws NamingException;
+
+ /**
+ * You can create a destination in ActiveMQ (and have it appear in JNDI) by putting "dynamicQueues/" in front of the queue name being looked up
+ */
+ public abstract Destination createDestination(String jndiName) throws NamingException;
+
+ /*
+ * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
+ * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
+ * an AppServer Then we could leverage the JMS resources it provides
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
+ */
+ public abstract Connection getResponseConnection() throws NamingException, JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
+ */
+ public abstract Session createResponseSession() throws JMSException, NamingException;
+
+ public abstract void closeResponseSession(Session session) throws JMSException;
+
+ public abstract void closeResponseConnection() throws JMSException;
+
+ /*
+ * Indicates whether connections obtained using getConnection() or getResponseConnection()
+ * must be closed after each use. This is necessary in environments where connections are
+ * shared with other users, or where connections cannot be held across transaction boundaries.
+ */
+ public abstract boolean isConnectionClosedAfterUse();
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java
index 4fc20c0cb3..afd2508043 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java
@@ -1,28 +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 org.apache.tuscany.sca.binding.jms.provider;
-
-import org.apache.tuscany.sca.binding.jms.JMSBinding;
-
-public interface JMSResourceFactoryExtensionPoint {
-
- JMSResourceFactory createJMSResourceFactory(JMSBinding binding);
-
-}
+/*
+ * 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.binding.jms.provider;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+
+public interface JMSResourceFactoryExtensionPoint {
+
+ JMSResourceFactory createJMSResourceFactory(JMSBinding binding);
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
index 625d5b4817..5b59389a18 100644
--- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
+++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
@@ -1,229 +1,229 @@
-/*
- * 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.binding.jms;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
-import org.junit.Test;
-
-/**
- * This unit test is used to ensure that a JMS Message delivered to a Component will select the correct operation based
- * on the details in section 1.5 of the JMS Binding specification.
- *
- * @version $Rev$ $Date$
- */
-public class OperationSelectionTestCaseFIXME {
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName is not specified in the JMS
- * Message
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameNotSpecified() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - not specified
- final String scaOperationName = null;
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message matches the
- * method name on the Service
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameMatches() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - matches operation name
- final String scaOperationName = expectedOperation.getName();
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message is
- * different the method name on the Service
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameDifferent() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - different to operation name
- final String scaOperationName = "Does Not Match Opeation Name";
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
- * Message matches an operation name
- * <p>
- * Expected behaviour is that the named method will be invoked.
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithMultipleOperationsScaOperationNameSpecified() throws Exception {
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- for (int i = 0; i < 5; i++) {
- operations.add(newOperation("operation" + i));
- }
-
- // Now try and invoke each operation
- for (Operation expectedOperation : operations) {
- // The name of the Operation in the JMS Message
- final String scaOperationName = expectedOperation.getName();
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
- }
-
- /**
- * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
- * Message is not set so we invoke the onMessage() method
- * <p>
- * Expected behaviour is that the onMessage() method should be used instead
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithMultipleOperationsScaOperationNotSpecified() throws Exception {
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- for (int i = 0; i < 5; i++) {
- operations.add(newOperation("operation" + i));
- }
-
- // Add the onMessage operation to the Service Contract
- final Operation onMessageOperation = newOperation("onMessage");
- operations.add(onMessageOperation);
-
- // The name of the Operation in the JMS Message is not set so it will attempt
- // to invoke the onMessage() method
- final String scaOperationName = null;
-
- // Do the test
- doTestJMSBinding(onMessageOperation, operations, scaOperationName);
- }
-
- /**
- * This is the test method that will attempt to unit test invoking a Service with the specified operations using a
- * JMS Message with the specified scaOperationName to ensure that it invokes the expectedOperation
- *
- * @param expectedOperation The Operation we are expecting to be invoked over JMS
- * @param operations The list of Operations supported by the Service
- * @param scaOperationName The value to set scaOperationName in the JMS Message
- * @throws Exception Failed
- */
- private void doTestJMSBinding(Operation expectedOperation, List<Operation> operations, String scaOperationName)
- throws Exception {
- // Create the test JMS Binding
- final JMSBinding jmsBinding = new JMSBinding();
- JMSResourceFactory jmsResourceFactory = null;
-
- // Extra information for the method we are invoking
- final String operationParams = "Hello";
- final Object operationReturnValue = "Operation Success";
-
- // Mock up the Service. Basically, it is going to call:
- // List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
-// final InterfaceContract ifaceContract = EasyMock.createStrictMock(InterfaceContract.class);
-// final RuntimeComponentService service = EasyMock.createStrictMock(RuntimeComponentService.class);
-// final Interface iface = EasyMock.createStrictMock(Interface.class);
-// EasyMock.expect(iface.getOperations()).andReturn(operations);
-// EasyMock.expect(ifaceContract.getInterface()).andReturn(iface);
-// EasyMock.expect(service.getInterfaceContract()).andReturn(ifaceContract);
-//
-// // Mock up getting and invoking the RuntimeWire. It is going to call:
-// // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload);
-// final RuntimeWire runtimeWire = EasyMock.createStrictMock(RuntimeWire.class);
-// EasyMock.expect(service.getRuntimeWire(jmsBinding)).andReturn(runtimeWire);
-// EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[] {operationParams}))
-// .andReturn(operationReturnValue);
-//
-// // Create the JMS Binding Listener
-// // final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
-//
-// // Simulate a message
-// final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class);
-// EasyMock.expect(requestJMSMsg.getStringProperty("scaOperationName")).andReturn(scaOperationName);
-// EasyMock.expect(requestJMSMsg.getText()).andReturn(operationParams);
-// EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(null);
-//
-// // Lets put all the mocks into replay mode
-// // EasyMock.replay(iface);
-// EasyMock.replay(ifaceContract);
-// EasyMock.replay(service);
-// EasyMock.replay(requestJMSMsg);
-// EasyMock.replay(runtimeWire);
-
- // Do the test
- // bindingListener.onMessage(requestJMSMsg);
-
- // Verify our Mock objects
- // EasyMock.verify(iface);
- // EasyMock.verify(ifaceContract);
- // EasyMock.verify(service);
- // EasyMock.verify(requestJMSMsg);
- // EasyMock.verify(runtimeWire);
- }
-
- private static Operation newOperation(String name) {
- Operation operation = new OperationImpl();
- operation.setName(name);
- return operation;
- }
-}
+/*
+ * 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.binding.jms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.junit.Test;
+
+/**
+ * This unit test is used to ensure that a JMS Message delivered to a Component will select the correct operation based
+ * on the details in section 1.5 of the JMS Binding specification.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectionTestCaseFIXME {
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName is not specified in the JMS
+ * Message
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameNotSpecified() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - not specified
+ final String scaOperationName = null;
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message matches the
+ * method name on the Service
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameMatches() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - matches operation name
+ final String scaOperationName = expectedOperation.getName();
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message is
+ * different the method name on the Service
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameDifferent() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - different to operation name
+ final String scaOperationName = "Does Not Match Opeation Name";
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
+ * Message matches an operation name
+ * <p>
+ * Expected behaviour is that the named method will be invoked.
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithMultipleOperationsScaOperationNameSpecified() throws Exception {
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ for (int i = 0; i < 5; i++) {
+ operations.add(newOperation("operation" + i));
+ }
+
+ // Now try and invoke each operation
+ for (Operation expectedOperation : operations) {
+ // The name of the Operation in the JMS Message
+ final String scaOperationName = expectedOperation.getName();
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+ }
+
+ /**
+ * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
+ * Message is not set so we invoke the onMessage() method
+ * <p>
+ * Expected behaviour is that the onMessage() method should be used instead
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithMultipleOperationsScaOperationNotSpecified() throws Exception {
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ for (int i = 0; i < 5; i++) {
+ operations.add(newOperation("operation" + i));
+ }
+
+ // Add the onMessage operation to the Service Contract
+ final Operation onMessageOperation = newOperation("onMessage");
+ operations.add(onMessageOperation);
+
+ // The name of the Operation in the JMS Message is not set so it will attempt
+ // to invoke the onMessage() method
+ final String scaOperationName = null;
+
+ // Do the test
+ doTestJMSBinding(onMessageOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This is the test method that will attempt to unit test invoking a Service with the specified operations using a
+ * JMS Message with the specified scaOperationName to ensure that it invokes the expectedOperation
+ *
+ * @param expectedOperation The Operation we are expecting to be invoked over JMS
+ * @param operations The list of Operations supported by the Service
+ * @param scaOperationName The value to set scaOperationName in the JMS Message
+ * @throws Exception Failed
+ */
+ private void doTestJMSBinding(Operation expectedOperation, List<Operation> operations, String scaOperationName)
+ throws Exception {
+ // Create the test JMS Binding
+ final JMSBinding jmsBinding = new JMSBinding();
+ JMSResourceFactory jmsResourceFactory = null;
+
+ // Extra information for the method we are invoking
+ final String operationParams = "Hello";
+ final Object operationReturnValue = "Operation Success";
+
+ // Mock up the Service. Basically, it is going to call:
+ // List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
+// final InterfaceContract ifaceContract = EasyMock.createStrictMock(InterfaceContract.class);
+// final RuntimeComponentService service = EasyMock.createStrictMock(RuntimeComponentService.class);
+// final Interface iface = EasyMock.createStrictMock(Interface.class);
+// EasyMock.expect(iface.getOperations()).andReturn(operations);
+// EasyMock.expect(ifaceContract.getInterface()).andReturn(iface);
+// EasyMock.expect(service.getInterfaceContract()).andReturn(ifaceContract);
+//
+// // Mock up getting and invoking the RuntimeWire. It is going to call:
+// // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload);
+// final RuntimeWire runtimeWire = EasyMock.createStrictMock(RuntimeWire.class);
+// EasyMock.expect(service.getRuntimeWire(jmsBinding)).andReturn(runtimeWire);
+// EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[] {operationParams}))
+// .andReturn(operationReturnValue);
+//
+// // Create the JMS Binding Listener
+// // final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
+//
+// // Simulate a message
+// final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class);
+// EasyMock.expect(requestJMSMsg.getStringProperty("scaOperationName")).andReturn(scaOperationName);
+// EasyMock.expect(requestJMSMsg.getText()).andReturn(operationParams);
+// EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(null);
+//
+// // Lets put all the mocks into replay mode
+// // EasyMock.replay(iface);
+// EasyMock.replay(ifaceContract);
+// EasyMock.replay(service);
+// EasyMock.replay(requestJMSMsg);
+// EasyMock.replay(runtimeWire);
+
+ // Do the test
+ // bindingListener.onMessage(requestJMSMsg);
+
+ // Verify our Mock objects
+ // EasyMock.verify(iface);
+ // EasyMock.verify(ifaceContract);
+ // EasyMock.verify(service);
+ // EasyMock.verify(requestJMSMsg);
+ // EasyMock.verify(runtimeWire);
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
index d06170a70d..7aa62215ff 100644
--- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
+++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
@@ -1,72 +1,72 @@
-/*
- * 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.binding.jms;
-
-public class BindingProperty {
-
- private String name;
- private String type;
- private Object value;
-
- public BindingProperty(String name, String type, Object value) {
- this.name = name;
- this.type = type;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-
- public Object getValue() {
- return value;
- }
-
- @Override
- public boolean equals(Object object) {
- return (object instanceof BindingProperty) && equals((BindingProperty)object);
- }
-
- /**
- * Test whether this and another Binding Property are equal.
- *
- * @param property
- * @return true if all fields of property match.
- */
- public boolean equals(BindingProperty property) {
- if (name == null && property.getName() != null)
- return false;
- else if (!name.equals(property.getName()))
- return false;
- else if (type == null && property.getType() != null)
- return false;
- else if (!type.equals(property.getType()))
- return false;
- else if (value == null && property.getValue() != null)
- return false;
- else if (!value.equals(property.getValue()))
- return false;
- return true;
- }
-}
+/*
+ * 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.binding.jms;
+
+public class BindingProperty {
+
+ private String name;
+ private String type;
+ private Object value;
+
+ public BindingProperty(String name, String type, Object value) {
+ this.name = name;
+ this.type = type;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return (object instanceof BindingProperty) && equals((BindingProperty)object);
+ }
+
+ /**
+ * Test whether this and another Binding Property are equal.
+ *
+ * @param property
+ * @return true if all fields of property match.
+ */
+ public boolean equals(BindingProperty property) {
+ if (name == null && property.getName() != null)
+ return false;
+ else if (!name.equals(property.getName()))
+ return false;
+ else if (type == null && property.getType() != null)
+ return false;
+ else if (!type.equals(property.getType()))
+ return false;
+ else if (value == null && property.getValue() != null)
+ return false;
+ else if (!value.equals(property.getValue()))
+ return false;
+ return true;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java b/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
index 40e40c7326..67a14068ae 100644
--- a/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
@@ -1,773 +1,773 @@
-/*
- * 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.binding.jms;
-
-import java.io.StringReader;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
-import org.apache.tuscany.sca.assembly.WireFormat;
-import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
-import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
-import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
-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;
-
-/**
- * Tests for JMS binding xml
- */
-public class JMSBindingProcessorTestCase extends TestCase {
- // Note: If you are adding new JMS binding read test cases,
- // consider adding a similar test case to JMSBindingProcessorWriteTestCase.
- public static final String COMPOSITE =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" />"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String HEADERS1 =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"5\">"
- + " </headers>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String HEADERS_INVALID_PRIORITY =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"medium\">"
- + " </headers>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String PROPERTIES1 =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <headers>"
- + " <property name=\"p1\">bla</property>"
- + " <property name=\"intProp\" type=\"int\">42</property>"
- + " </headers>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String OP_PROPERTIES1 =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <operationProperties name=\"op1\">"
- + " <headers type=\"op1Type\" >"
- + " <property name=\"p1\">bla</property>"
- + " <property name=\"intProp\" type=\"int\">42</property>"
- + " </headers>"
- + " </operationProperties >"
- + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
- + " <headers type=\"op2Type\">"
- + " <property name=\"p2\">op2bla</property>"
- + " <property name=\"intProp\" type=\"int\">77</property>"
- + " </headers>"
- + " </operationProperties >"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String OP_NAMES_NO_PROPERTIES1 =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <operationProperties name=\"op1\">"
- + " </operationProperties >"
- + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
- + " </operationProperties >"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String SELECTOR =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <messageSelection selector=\"prop1 = 2\" />"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String COMPOSITE_INVALID_URI =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"invalidjms:testQueue\" />"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- // Invalid: contains both a response attribute and a response element.
- public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" responseConnection=\"responseConnectionAttrName\">"
- + " <response>"
- + " <destination jndiName=\"responseConnectionElementName\"/>"
- + " </response>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String DEST_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <destination jndiName=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </destination>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String CF_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <connectionFactory jndiName=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </connectionFactory>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String AS_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <activationSpec name=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </activationSpec>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String RESP_DEST_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <response>"
- + " <destination jndiName=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </destination>"
- + " </response>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String RESP_CF_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <response>"
- + " <connectionFactory jndiName=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </connectionFactory>"
- + " </response>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String RESP_AS_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <response>"
- + " <activationSpec name=\"foo\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </activationSpec>"
- + " </response>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String OP_PROPS_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <operationProperties name=\"op1\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </operationProperties >"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String RES_ADPT_PROPS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms>"
- + " <resourceAdapter name=\"r1\">"
- + " <property name=\"xxx\" type=\"yyy\">"
- + " some value text"
- + " </property>"
- + " <property name=\"two\">"
- + " bla"
- + " </property>"
- + " </resourceAdapter>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String CONFIGURED_OPERATIONS =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <operationProperties name=\"op1\">"
- + " </operationProperties >"
- + " <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String WIRE_FORMAT =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms uri=\"jms:testQueue\" >"
- + " <response>"
- + " <destination jndiName=\"responseConnectionElementName\"/>"
- + " <tuscany:wireFormat.jmsBytes/>"
- + " </response>"
- + " <tuscany:wireFormat.jmsObject/>"
- + " </binding.jms>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- public static final String OP_PROP_NAME =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <binding.jms operationProperties=\"foo\"/>"
- + " </service>"
- + " </component>"
- + "</composite>";
-
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
- private ProcessorContext context;
-
- @Override
- protected void setUp() throws Exception {
- DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
- context = new ProcessorContext(extensionPoints);
- inputFactory = XMLInputFactory.newInstance();
- StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
- staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
-
- }
-
- /**
- * Test parsing valid composite definition. Valid composite populated with correct values expected.
- * @throws Exception
- */
- public void testLoadValidComposite() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertEquals("testQueue", binding.getDestinationName());
- }
-
- public void testHeaders1() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS1));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertEquals("myType", binding.getJMSType());
- assertTrue(binding.isdeliveryModePersistent());
- assertEquals(54321, binding.getJMSTimeToLive().longValue());
- assertEquals(5, binding.getJMSPriority().intValue());
- }
-
- public void testProperties1() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(PROPERTIES1));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertEquals("bla", binding.getProperty("p1"));
- assertEquals(42, ((Integer)binding.getProperty("intProp")).intValue());
- }
-
- public void testOpProperties1() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
-
- Map<String, Object> op1Props = binding.getOperationProperties("op1");
- assertEquals("op1Type", binding.getOperationJMSType("op1"));
- assertEquals("bla", op1Props.get("p1"));
- assertEquals(42, ((Integer)op1Props.get("intProp")).intValue());
-
- assertEquals("op2Type", binding.getOperationJMSType("op2"));
- Map<String, Object> op2Props = binding.getOperationProperties("op2");
- assertEquals("op2bla", op2Props.get("p2"));
- assertEquals(77, ((Integer)op2Props.get("intProp")).intValue());
- }
-
- public void testSubscriptionHeaders () throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(SELECTOR));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
-
- assertEquals("prop1 = 2", binding.getJMSSelector());
- }
-
- /** Test various parsing validation requirements. */
- public void testParsingValidationErrors1() throws Exception {
- // Composite with malformed URI.
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_URI));
-
- try {
- Composite composite = (Composite)staxProcessor.read(reader, context);
- } catch(Exception e) {
- // JMSBindingExceptions are expected with invalid composite.
- if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
- throw e;
- // Do assertion to make sure test registers results.
- assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
- }
- }
-
- public void testParsingValidationErrors2() throws Exception {
- // Composite with invalid priority
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS_INVALID_PRIORITY));
-
- try {
- Composite composite = (Composite)staxProcessor.read(reader, context);
- } catch(Exception e) {
- // JMSBindingExceptions are expected with invalid composite.
- if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
- throw e;
- // Do assertion to make sure test registers results.
- assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
- return;
- }
- }
-
- /** Test various model validation requirements. */
- public void testValidationErrors1() throws Exception {
- // Composite with response connection attr and element.
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT));
-
- try {
- Composite composite = (Composite)staxProcessor.read(reader, context);
- } catch(Exception e) {
- // JMSBindingExceptions are expected with invalid composite.
- if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
- throw e;
- // Do assertion to make sure test registers results.
- assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
- }
- }
-
- public void testDestinationProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(DEST_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getDestinationProperties());
- assertEquals(2, binding.getDestinationProperties().size());
- BindingProperty bp = binding.getDestinationProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getDestinationProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testConnectionFactoryProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CF_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getConnectionFactoryProperties());
- assertEquals(2, binding.getConnectionFactoryProperties().size());
- BindingProperty bp = binding.getConnectionFactoryProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getConnectionFactoryProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testActivationSpecProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(AS_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getActivationSpecProperties());
- assertEquals(2, binding.getActivationSpecProperties().size());
- BindingProperty bp = binding.getActivationSpecProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getActivationSpecProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testResponseDestinationProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_DEST_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getResponseDestinationProperties());
- assertEquals(2, binding.getResponseDestinationProperties().size());
- BindingProperty bp = binding.getResponseDestinationProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getResponseDestinationProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testResponseConnectionFactoryProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_CF_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getResponseConnectionFactoryProperties());
- assertEquals(2, binding.getResponseConnectionFactoryProperties().size());
- BindingProperty bp = binding.getResponseConnectionFactoryProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getResponseConnectionFactoryProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testResponseActivationSpecProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_AS_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getResponseActivationSpecProperties());
- assertEquals(2, binding.getResponseActivationSpecProperties().size());
- BindingProperty bp = binding.getResponseActivationSpecProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getResponseActivationSpecProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testOperationPropertiesProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPS_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertNotNull(binding.getOperationPropertiesProperties("op1"));
- assertEquals(2, binding.getOperationPropertiesProperties("op1").size());
- BindingProperty bp = binding.getOperationPropertiesProperties("op1").get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getOperationPropertiesProperties("op1").get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
- public void testResouceAdapterProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RES_ADPT_PROPS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertEquals("r1", binding.getResourceAdapterName());
- assertNotNull(binding.getResourceAdapterProperties());
- assertEquals(2, binding.getResourceAdapterProperties().size());
- BindingProperty bp = binding.getResourceAdapterProperties().get("xxx");
- assertEquals("xxx", bp.getName());
- assertEquals("yyy", bp.getType());
- assertEquals("some value text", bp.getValue().toString().trim());
- BindingProperty bp2 = binding.getResourceAdapterProperties().get("two");
- assertEquals("two", bp2.getName());
- assertEquals(null, bp2.getType());
- assertEquals("bla", bp2.getValue().toString().trim());
- }
-
- /**
- * Tests the APIs:
- * public Set<String> getOperationNames();
- * public Object getOperationProperty(String opName, String propName );
- * @throws Exception
- */
- public void testOpProperties2() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
-
- Set<String> opNames = binding.getOperationNames();
- assertEquals( 2, opNames.size() );
- // Recall that order is not guaranteed iterating over a set.
- for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
- String opName = it.next();
- assertTrue( opName.equals( "op1") || opName.equals( "op2"));
- }
-
- Object value = binding.getOperationProperty( "op1", "p1" );
- assertEquals("bla", value);
- value = binding.getOperationProperty( "op1", "intProp" );
- assertEquals(42, ((Integer)value).intValue());
-
- value = binding.getOperationProperty( "op2", "p2" );
- assertEquals("op2bla", value);
- value = binding.getOperationProperty( "op2", "intProp" );
- assertEquals(77, ((Integer)value).intValue());
- }
-
- /**
- * Tests the APIs:
- * public Set<String> getOperationNames();
- * Provides no optional properties or sub elements
- * @throws Exception
- */
- public void testOpProperties3() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_NAMES_NO_PROPERTIES1));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
-
- Set<String> opNames = binding.getOperationNames();
- assertEquals( 2, opNames.size() );
- // Recall that order is not guaranteed iterating over a set.
- for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
- String opName = it.next();
- assertTrue( opName.equals( "op1") || opName.equals( "op2"));
- }
- }
-
- /**
- * Tests the APIs:
- * public Set<String> getOperationNames();
- * Provides no optional properties or sub elements
- * @throws Exception
- */
- public void testConfiguredOperations1() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CONFIGURED_OPERATIONS));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
- assertNotNull(binding);
-
- OperationsConfigurator opConfig = ((OperationsConfigurator)binding);
- assertEquals(opConfig.getConfiguredOperations().get(0).getRequiredIntents().size(), 2);
- }
-
- /**
- * Tests the APIs:
- * public WireFormat getRequstWireFormat();
- * public WireFormat getResponseWireFormat();
- *
- * @throws Exception
- */
- public void testWireFormat() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WIRE_FORMAT));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
- assertNotNull(binding);
-
- WireFormat requestWireFormat = binding.getRequestWireFormat();
- assertEquals(WireFormatJMSObject.class, requestWireFormat.getClass());
-
- WireFormat responseWireFormat = binding.getResponseWireFormat();
- assertEquals(WireFormatJMSBytes.class, responseWireFormat.getClass());
- }
-
- public void testOpPropertiesName() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROP_NAME));
-
- Composite composite = (Composite)staxProcessor.read(reader, context);
- JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
-
- assertNotNull(binding);
- assertEquals( "foo", binding.getOperationPropertiesName().getLocalPart() );
- }
-}
+/*
+ * 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.binding.jms;
+
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+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;
+
+/**
+ * Tests for JMS binding xml
+ */
+public class JMSBindingProcessorTestCase extends TestCase {
+ // Note: If you are adding new JMS binding read test cases,
+ // consider adding a similar test case to JMSBindingProcessorWriteTestCase.
+ public static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" />"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String HEADERS1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"5\">"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String HEADERS_INVALID_PRIORITY =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"medium\">"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers>"
+ + " <property name=\"p1\">bla</property>"
+ + " <property name=\"intProp\" type=\"int\">42</property>"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " <headers type=\"op1Type\" >"
+ + " <property name=\"p1\">bla</property>"
+ + " <property name=\"intProp\" type=\"int\">42</property>"
+ + " </headers>"
+ + " </operationProperties >"
+ + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
+ + " <headers type=\"op2Type\">"
+ + " <property name=\"p2\">op2bla</property>"
+ + " <property name=\"intProp\" type=\"int\">77</property>"
+ + " </headers>"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_NAMES_NO_PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " </operationProperties >"
+ + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String SELECTOR =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <messageSelection selector=\"prop1 = 2\" />"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String COMPOSITE_INVALID_URI =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"invalidjms:testQueue\" />"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ // Invalid: contains both a response attribute and a response element.
+ public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" responseConnection=\"responseConnectionAttrName\">"
+ + " <response>"
+ + " <destination jndiName=\"responseConnectionElementName\"/>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String DEST_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <destination jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </destination>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String CF_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <connectionFactory jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </connectionFactory>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String AS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <activationSpec name=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </activationSpec>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_DEST_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <destination jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </destination>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_CF_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <connectionFactory jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </connectionFactory>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_AS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <activationSpec name=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </activationSpec>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROPS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <operationProperties name=\"op1\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RES_ADPT_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <resourceAdapter name=\"r1\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </resourceAdapter>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String CONFIGURED_OPERATIONS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " </operationProperties >"
+ + " <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String WIRE_FORMAT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <response>"
+ + " <destination jndiName=\"responseConnectionElementName\"/>"
+ + " <tuscany:wireFormat.jmsBytes/>"
+ + " </response>"
+ + " <tuscany:wireFormat.jmsObject/>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROP_NAME =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms operationProperties=\"foo\"/>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("testQueue", binding.getDestinationName());
+ }
+
+ public void testHeaders1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("myType", binding.getJMSType());
+ assertTrue(binding.isdeliveryModePersistent());
+ assertEquals(54321, binding.getJMSTimeToLive().longValue());
+ assertEquals(5, binding.getJMSPriority().intValue());
+ }
+
+ public void testProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("bla", binding.getProperty("p1"));
+ assertEquals(42, ((Integer)binding.getProperty("intProp")).intValue());
+ }
+
+ public void testOpProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Map<String, Object> op1Props = binding.getOperationProperties("op1");
+ assertEquals("op1Type", binding.getOperationJMSType("op1"));
+ assertEquals("bla", op1Props.get("p1"));
+ assertEquals(42, ((Integer)op1Props.get("intProp")).intValue());
+
+ assertEquals("op2Type", binding.getOperationJMSType("op2"));
+ Map<String, Object> op2Props = binding.getOperationProperties("op2");
+ assertEquals("op2bla", op2Props.get("p2"));
+ assertEquals(77, ((Integer)op2Props.get("intProp")).intValue());
+ }
+
+ public void testSubscriptionHeaders () throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(SELECTOR));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ assertEquals("prop1 = 2", binding.getJMSSelector());
+ }
+
+ /** Test various parsing validation requirements. */
+ public void testParsingValidationErrors1() throws Exception {
+ // Composite with malformed URI.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_URI));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
+
+ public void testParsingValidationErrors2() throws Exception {
+ // Composite with invalid priority
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS_INVALID_PRIORITY));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ return;
+ }
+ }
+
+ /** Test various model validation requirements. */
+ public void testValidationErrors1() throws Exception {
+ // Composite with response connection attr and element.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
+
+ public void testDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(DEST_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getDestinationProperties());
+ assertEquals(2, binding.getDestinationProperties().size());
+ BindingProperty bp = binding.getDestinationProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getDestinationProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CF_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getConnectionFactoryProperties());
+ assertEquals(2, binding.getConnectionFactoryProperties().size());
+ BindingProperty bp = binding.getConnectionFactoryProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getConnectionFactoryProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(AS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getActivationSpecProperties());
+ assertEquals(2, binding.getActivationSpecProperties().size());
+ BindingProperty bp = binding.getActivationSpecProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getActivationSpecProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_DEST_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseDestinationProperties());
+ assertEquals(2, binding.getResponseDestinationProperties().size());
+ BindingProperty bp = binding.getResponseDestinationProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseDestinationProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_CF_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseConnectionFactoryProperties());
+ assertEquals(2, binding.getResponseConnectionFactoryProperties().size());
+ BindingProperty bp = binding.getResponseConnectionFactoryProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseConnectionFactoryProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_AS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseActivationSpecProperties());
+ assertEquals(2, binding.getResponseActivationSpecProperties().size());
+ BindingProperty bp = binding.getResponseActivationSpecProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseActivationSpecProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testOperationPropertiesProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getOperationPropertiesProperties("op1"));
+ assertEquals(2, binding.getOperationPropertiesProperties("op1").size());
+ BindingProperty bp = binding.getOperationPropertiesProperties("op1").get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getOperationPropertiesProperties("op1").get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResouceAdapterProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RES_ADPT_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("r1", binding.getResourceAdapterName());
+ assertNotNull(binding.getResourceAdapterProperties());
+ assertEquals(2, binding.getResourceAdapterProperties().size());
+ BindingProperty bp = binding.getResourceAdapterProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResourceAdapterProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * public Object getOperationProperty(String opName, String propName );
+ * @throws Exception
+ */
+ public void testOpProperties2() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Set<String> opNames = binding.getOperationNames();
+ assertEquals( 2, opNames.size() );
+ // Recall that order is not guaranteed iterating over a set.
+ for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ assertTrue( opName.equals( "op1") || opName.equals( "op2"));
+ }
+
+ Object value = binding.getOperationProperty( "op1", "p1" );
+ assertEquals("bla", value);
+ value = binding.getOperationProperty( "op1", "intProp" );
+ assertEquals(42, ((Integer)value).intValue());
+
+ value = binding.getOperationProperty( "op2", "p2" );
+ assertEquals("op2bla", value);
+ value = binding.getOperationProperty( "op2", "intProp" );
+ assertEquals(77, ((Integer)value).intValue());
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * Provides no optional properties or sub elements
+ * @throws Exception
+ */
+ public void testOpProperties3() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_NAMES_NO_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Set<String> opNames = binding.getOperationNames();
+ assertEquals( 2, opNames.size() );
+ // Recall that order is not guaranteed iterating over a set.
+ for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ assertTrue( opName.equals( "op1") || opName.equals( "op2"));
+ }
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * Provides no optional properties or sub elements
+ * @throws Exception
+ */
+ public void testConfiguredOperations1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CONFIGURED_OPERATIONS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ OperationsConfigurator opConfig = ((OperationsConfigurator)binding);
+ assertEquals(opConfig.getConfiguredOperations().get(0).getRequiredIntents().size(), 2);
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getRequstWireFormat();
+ * public WireFormat getResponseWireFormat();
+ *
+ * @throws Exception
+ */
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WIRE_FORMAT));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ WireFormat requestWireFormat = binding.getRequestWireFormat();
+ assertEquals(WireFormatJMSObject.class, requestWireFormat.getClass());
+
+ WireFormat responseWireFormat = binding.getResponseWireFormat();
+ assertEquals(WireFormatJMSBytes.class, responseWireFormat.getClass());
+ }
+
+ public void testOpPropertiesName() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROP_NAME));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals( "foo", binding.getOperationPropertiesName().getLocalPart() );
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
index a5d0c3a8da..e68d8e676b 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
@@ -1,161 +1,161 @@
-/*
- * 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.binding.jsonp.runtime;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.net.URLCodec;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-
-public class JSONPInvoker implements Invoker {
-
- protected Operation operation;
- protected EndpointReference endpoint;
-
- protected ObjectMapper mapper; // TODO: share mapper btw invoker and servlet or move to databinding
-
- public JSONPInvoker(Operation operation, EndpointReference endpoint) {
- this.operation = operation;
- this.endpoint = endpoint;
- this.mapper = new ObjectMapper();
- }
-
- public Message invoke(Message msg) {
- try {
-
- return doInvoke(msg);
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public Message doInvoke(Message msg) throws JsonGenerationException, JsonMappingException, IOException, EncoderException {
- String uri = endpoint.getBinding().getURI() + "/" + operation.getName();
- String[] jsonArgs = objectsToJSON((Object[])msg.getBody());
-
- String responseJSON = invokeHTTPRequest(uri, jsonArgs);
-
- Object response = jsonToObjects(responseJSON)[0];
- msg.setBody(response);
-
- return msg;
- }
-
- protected String invokeHTTPRequest(String url, String[] jsonArgs) throws IOException, EncoderException {
-
- HttpClient httpclient = new DefaultHttpClient();
-
-
- URLCodec uc = new URLCodec();
- for (int i=0 ; i<jsonArgs.length; i++) {
- if (i == 0) {
- url += '?';
- } else {
- url += '&';
- }
- url += "arg" + i + "=";
- url += uc.encode(jsonArgs[i]);
- }
-
- HttpGet httpget = new HttpGet(url);
-
- HttpResponse response = httpclient.execute(httpget);
-
- StringBuffer responseJSON = new StringBuffer();
-
- HttpEntity entity = response.getEntity();
-
- // If the response does not enclose an entity, there is no need
- // to worry about connection release
- if (entity != null) {
- InputStream instream = entity.getContent();
- try {
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
- String s = null;
- while ((s = reader.readLine()) != null) {
- responseJSON.append(s);
- }
-
- } catch (IOException ex) {
-
- // In case of an IOException the connection will be released
- // back to the connection manager automatically
- throw ex;
-
- } catch (RuntimeException ex) {
-
- // In case of an unexpected exception you may want to abort
- // the HTTP request in order to shut down the underlying
- // connection and release it back to the connection manager.
- httpget.abort();
- throw ex;
-
- } finally {
-
- // Closing the input stream will trigger connection release
- instream.close();
-
- }
-
- // When HttpClient instance is no longer needed,
- // shut down the connection manager to ensure
- // immediate deallocation of all system resources
- httpclient.getConnectionManager().shutdown();
- }
-
- return responseJSON.toString();
- }
-
- protected String[] objectsToJSON(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
- String[] jsonArgs = new String[msgArgs.length];
- for (int i=0; i<msgArgs.length; i++) {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- mapper.writeValue(os , msgArgs[i]);
- jsonArgs[i] = os.toString();
- }
- return jsonArgs;
- }
-
- protected Object[] jsonToObjects(String jsonRequest) throws JsonParseException, JsonMappingException, IOException {
- Class<?> c = new Object[0].getClass();
- Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
- return args;
- }
-
-}
+/*
+ * 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.binding.jsonp.runtime;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.net.URLCodec;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+
+public class JSONPInvoker implements Invoker {
+
+ protected Operation operation;
+ protected EndpointReference endpoint;
+
+ protected ObjectMapper mapper; // TODO: share mapper btw invoker and servlet or move to databinding
+
+ public JSONPInvoker(Operation operation, EndpointReference endpoint) {
+ this.operation = operation;
+ this.endpoint = endpoint;
+ this.mapper = new ObjectMapper();
+ }
+
+ public Message invoke(Message msg) {
+ try {
+
+ return doInvoke(msg);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Message doInvoke(Message msg) throws JsonGenerationException, JsonMappingException, IOException, EncoderException {
+ String uri = endpoint.getBinding().getURI() + "/" + operation.getName();
+ String[] jsonArgs = objectsToJSON((Object[])msg.getBody());
+
+ String responseJSON = invokeHTTPRequest(uri, jsonArgs);
+
+ Object response = jsonToObjects(responseJSON)[0];
+ msg.setBody(response);
+
+ return msg;
+ }
+
+ protected String invokeHTTPRequest(String url, String[] jsonArgs) throws IOException, EncoderException {
+
+ HttpClient httpclient = new DefaultHttpClient();
+
+
+ URLCodec uc = new URLCodec();
+ for (int i=0 ; i<jsonArgs.length; i++) {
+ if (i == 0) {
+ url += '?';
+ } else {
+ url += '&';
+ }
+ url += "arg" + i + "=";
+ url += uc.encode(jsonArgs[i]);
+ }
+
+ HttpGet httpget = new HttpGet(url);
+
+ HttpResponse response = httpclient.execute(httpget);
+
+ StringBuffer responseJSON = new StringBuffer();
+
+ HttpEntity entity = response.getEntity();
+
+ // If the response does not enclose an entity, there is no need
+ // to worry about connection release
+ if (entity != null) {
+ InputStream instream = entity.getContent();
+ try {
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
+ String s = null;
+ while ((s = reader.readLine()) != null) {
+ responseJSON.append(s);
+ }
+
+ } catch (IOException ex) {
+
+ // In case of an IOException the connection will be released
+ // back to the connection manager automatically
+ throw ex;
+
+ } catch (RuntimeException ex) {
+
+ // In case of an unexpected exception you may want to abort
+ // the HTTP request in order to shut down the underlying
+ // connection and release it back to the connection manager.
+ httpget.abort();
+ throw ex;
+
+ } finally {
+
+ // Closing the input stream will trigger connection release
+ instream.close();
+
+ }
+
+ // When HttpClient instance is no longer needed,
+ // shut down the connection manager to ensure
+ // immediate deallocation of all system resources
+ httpclient.getConnectionManager().shutdown();
+ }
+
+ return responseJSON.toString();
+ }
+
+ protected String[] objectsToJSON(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
+ String[] jsonArgs = new String[msgArgs.length];
+ for (int i=0; i<msgArgs.length; i++) {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ mapper.writeValue(os , msgArgs[i]);
+ jsonArgs[i] = os.toString();
+ }
+ return jsonArgs;
+ }
+
+ protected Object[] jsonToObjects(String jsonRequest) throws JsonParseException, JsonMappingException, IOException {
+ Class<?> c = new Object[0].getClass();
+ Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
+ return args;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
index 0af9582e97..9682b33f61 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
@@ -1,53 +1,53 @@
-/*
- * 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.binding.jsonp.runtime;
-
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-
-public class JSONPReferenceBindingProvider implements ReferenceBindingProvider {
-
- private EndpointReference endpoint;
-
- public JSONPReferenceBindingProvider(EndpointReference endpoint) {
- this.endpoint = endpoint;
- }
- public Invoker createInvoker(Operation operation) {
- return new JSONPInvoker(operation, endpoint);
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return null;
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-
-}
+/*
+ * 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.binding.jsonp.runtime;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+public class JSONPReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpoint;
+
+ public JSONPReferenceBindingProvider(EndpointReference endpoint) {
+ this.endpoint = endpoint;
+ }
+ public Invoker createInvoker(Operation operation) {
+ return new JSONPInvoker(operation, endpoint);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java
index 5ee1f167ea..97c5084910 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java
@@ -1,37 +1,37 @@
-/*
- * 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 helloworld;
-
-import org.oasisopen.sca.annotation.Reference;
-
-public class HelloWorldClient implements HelloWorldService {
-
- @Reference
- public HelloWorldService ref;
-
- public String sayHello(String name) {
- return ref.sayHello(name);
- }
-
- public String sayHello2(String firstName, String lastName) {
- return ref.sayHello2(firstName, lastName);
- }
-
-}
+/*
+ * 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 helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorldService {
+
+ @Reference
+ public HelloWorldService ref;
+
+ public String sayHello(String name) {
+ return ref.sayHello(name);
+ }
+
+ public String sayHello2(String firstName, String lastName) {
+ return ref.sayHello2(firstName, lastName);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
index 346bf5fcc9..5a786f3bd0 100644
--- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
@@ -1,78 +1,78 @@
-/*
- * 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.binding.rss;
-
-import junit.framework.Assert;
-
-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.Ignore;
-import org.junit.Test;
-
-/**
- * Basic test case that will get the feed entries from an RSS feed.
- */
-public class RSSGetTestCase {
- protected static Node scaConsumerNode;
- protected static Node scaProviderNode;
- protected static CustomerClient testService;
-
- @BeforeClass
- public static void init() throws Exception {
- System.out.println(">>>RSSGetTestCase.init entry");
- String contribution = ContributionLocationHelper.getContributionLocation(RSSGetTestCase.class);
-
- scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Provider.composite", new Contribution("provider", contribution));
- scaProviderNode.start();
-
- scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Consumer.composite", new Contribution("consumer", contribution));
- scaConsumerNode.start();
-
- testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
- }
-
- @AfterClass
- public static void destroy() throws Exception {
- // System.out.println(">>>RSSGetTestCase.destroy entry");
- if (scaConsumerNode != null) {
- scaConsumerNode.stop();
- }
- if (scaProviderNode != null) {
- scaProviderNode.stop();
- }
- }
-
- @Test
- public void testPrelim() throws Exception {
- Assert.assertNotNull(scaProviderNode);
- Assert.assertNotNull(scaConsumerNode);
- Assert.assertNotNull(testService);
- }
-
- @Test
- @Ignore("TUSCANY-3537")
- public void testRSSGet() throws Exception {
- testService.testCustomerCollection();
- }
-}
+/*
+ * 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.binding.rss;
+
+import junit.framework.Assert;
+
+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.Ignore;
+import org.junit.Test;
+
+/**
+ * Basic test case that will get the feed entries from an RSS feed.
+ */
+public class RSSGetTestCase {
+ protected static Node scaConsumerNode;
+ protected static Node scaProviderNode;
+ protected static CustomerClient testService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println(">>>RSSGetTestCase.init entry");
+ String contribution = ContributionLocationHelper.getContributionLocation(RSSGetTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Consumer.composite", new Contribution("consumer", contribution));
+ scaConsumerNode.start();
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>RSSGetTestCase.destroy entry");
+ if (scaConsumerNode != null) {
+ scaConsumerNode.stop();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ }
+
+ @Test
+ @Ignore("TUSCANY-3537")
+ public void testRSSGet() throws Exception {
+ testService.testCustomerCollection();
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml
index 1816348aa2..74a35634ee 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml
@@ -1,41 +1,41 @@
-<?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.
--->
-
-<!-- $Rev: 907636 $ $Date: 2010-02-09 01:39:16 +1300 (Tue, 09 Feb 2010) $ -->
-
-<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
-
- <sca:bindingType type="sca:binding.ws" mayProvide="sca:SOAP sca:SOAP.v1_1 sca:SOAP.v1_2 tuscany:MTOM" alwaysProvides=""/>
-
- <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
- <!-- assembly-xsd module for spec defined intents -->
-
- <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
-
- <sca:intent name="MTOM" constrains="sca:binding.ws">
- <sca:description>
- Communication through this binding requires MTOM support
- </sca:description>
- </sca:intent>
-
- </sca:definitions>
+<?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.
+-->
+
+<!-- $Rev: 907636 $ $Date: 2010-02-09 01:39:16 +1300 (Tue, 09 Feb 2010) $ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.ws" mayProvide="sca:SOAP sca:SOAP.v1_1 sca:SOAP.v1_2 tuscany:MTOM" alwaysProvides=""/>
+
+ <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
+ <!-- assembly-xsd module for spec defined intents -->
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
+
+ <sca:intent name="MTOM" constrains="sca:binding.ws">
+ <sca:description>
+ Communication through this binding requires MTOM support
+ </sca:description>
+ </sca:intent>
+
+ </sca:definitions>
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
index 222ba62fb6..7d20ec7fc0 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
@@ -1,26 +1,26 @@
-/*
- * 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.management;
-
-import java.util.Map;
-
-public interface ConfigAttributes {
- Map<String, String> getAttributes();
-}
+/*
+ * 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.management;
+
+import java.util.Map;
+
+public interface ConfigAttributes {
+ Map<String, String> getAttributes();
+}
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java
index e6e6d3773d..6de0878383 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java
@@ -1,168 +1,168 @@
-/*
- * 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.runtime;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * Utility to parse the config uri string.
- *
- * tuscany:[domainName]?listen=[port|ip:port]]&password=abc&multicast=[off|port|ip:port]&remotes=ip:port,ip:port,...
-
- * listen - defines the local bind address and port, it defaults to all network interfaces on port 14820 and if that port in use it will try incrementing by one till a free port is found.
- * password - is the password other nodes must use to connect to this domain. The default is 'tuscany'.
- * multicast - defines if multicast discovery is used and if so what multicast ip group and port is used.
- * The default is multicast is off if remotes= is specified (only for now due to a Hazelcast limitation that is planned to be fixed),
- * otherwise if remotes= is not specified then multicast defaults to 224.5.12.10:51482
- * remotes - a list of ipAddress:port for remote nodes
- *
- * @tuscany.spi.extension.asclient
- *
- */
-public class DomainRegistryURI {
-
- private String domainName = "default";
- private String bindAddress = null; // null means all network adapters
- private int listenPort = 14820;
- private String password = "tuscany";
- private boolean multicastDisabled = false;
- private String multicastAddress = "224.5.12.10";
- private int multicastPort = 51482;
- private List<String> remotes = new ArrayList<String>();
- private String uri;
-
- public DomainRegistryURI(String uri) {
- this.uri = uri;
- parseURI(uri);
- }
-
- private void parseURI(String uri) {
- if (uri.startsWith("tuscanyclient:")) {
- uri = uri.replace("tuscanyclient:", "tuscany:");
- }
-
- if (!uri.startsWith("tuscany:")) {
- throw new IllegalArgumentException("Config URI must start with 'tuscany:'");
- }
-
- // make it a URI so java.net.URI can be used to parse it
- int i = uri.indexOf(":");
- if (uri.charAt("tuscany:".length()) != '/') {
- uri = uri.replaceFirst(":", ":/");
- }
- if (uri.charAt("tuscany:".length()+1) != '/') {
- uri = uri.replaceFirst(":/", "://");
- }
- URI configURI = URI.create(uri);
-
- this.domainName = configURI.getHost();
-
- String query = configURI.getQuery();
- if (query != null && query.length() > 0) {
- String[] params = query.split("&");
- Map<String, String> paramMap = new HashMap<String, String>();
- for (String param : params) {
- paramMap.put(param.split("=")[0], param.split("=")[1]);
- }
- for (String name : paramMap.keySet()) {
- String value = paramMap.get(name);
- if ("listen".equals(name)) {
- if (value.indexOf(":") == -1) {
- this.listenPort = Integer.parseInt(value);
- } else {
- String[] addr = value.split(":");
- this.bindAddress = addr[0];
- this.listenPort = Integer.parseInt(addr[1]);
- }
- } else if ("multicast".equals(name)) {
- if ("off".equalsIgnoreCase(value)) {
- this.multicastDisabled = true;
- } else {
- if (value.indexOf(":") == -1) {
- this.multicastAddress = value;
- } else {
- String[] addr = value.split(":");
- this.multicastAddress = addr[0];
- this.multicastPort = Integer.parseInt(addr[1]);
- }
- }
- } else if ("password".equals(name)) {
- this.password = value;
- } else if ("remotes".equals(name)) {
- String[] ips = value.split(",");
- for (String ip : ips) {
- if (ip.indexOf(":") == -1) {
- remotes.add(ip + ":14820");
- } else {
- remotes.add(ip);
- }
- }
- if (paramMap.containsKey("multicast")) {
-// throw new IllegalArgumentException("Cannot have multicast and remotes (for now)");
- } else {
- this.multicastDisabled = true;
- }
- }
- }
- }
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public String getBindAddress() {
- return bindAddress;
- }
-
- public int getListenPort() {
- return listenPort;
- }
-
- public String getPassword() {
- return password;
- }
-
- public boolean isMulticastDisabled() {
- return multicastDisabled;
- }
-
- public String getMulticastAddress() {
- return multicastAddress;
- }
-
- public int getMulticastPort() {
- return multicastPort;
- }
-
- public List<String> getRemotes() {
- return remotes;
- }
-
- public String toString() {
- return uri;
- }
-
-}
+/*
+ * 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.runtime;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Utility to parse the config uri string.
+ *
+ * tuscany:[domainName]?listen=[port|ip:port]]&password=abc&multicast=[off|port|ip:port]&remotes=ip:port,ip:port,...
+
+ * listen - defines the local bind address and port, it defaults to all network interfaces on port 14820 and if that port in use it will try incrementing by one till a free port is found.
+ * password - is the password other nodes must use to connect to this domain. The default is 'tuscany'.
+ * multicast - defines if multicast discovery is used and if so what multicast ip group and port is used.
+ * The default is multicast is off if remotes= is specified (only for now due to a Hazelcast limitation that is planned to be fixed),
+ * otherwise if remotes= is not specified then multicast defaults to 224.5.12.10:51482
+ * remotes - a list of ipAddress:port for remote nodes
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class DomainRegistryURI {
+
+ private String domainName = "default";
+ private String bindAddress = null; // null means all network adapters
+ private int listenPort = 14820;
+ private String password = "tuscany";
+ private boolean multicastDisabled = false;
+ private String multicastAddress = "224.5.12.10";
+ private int multicastPort = 51482;
+ private List<String> remotes = new ArrayList<String>();
+ private String uri;
+
+ public DomainRegistryURI(String uri) {
+ this.uri = uri;
+ parseURI(uri);
+ }
+
+ private void parseURI(String uri) {
+ if (uri.startsWith("tuscanyclient:")) {
+ uri = uri.replace("tuscanyclient:", "tuscany:");
+ }
+
+ if (!uri.startsWith("tuscany:")) {
+ throw new IllegalArgumentException("Config URI must start with 'tuscany:'");
+ }
+
+ // make it a URI so java.net.URI can be used to parse it
+ int i = uri.indexOf(":");
+ if (uri.charAt("tuscany:".length()) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (uri.charAt("tuscany:".length()+1) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ URI configURI = URI.create(uri);
+
+ this.domainName = configURI.getHost();
+
+ String query = configURI.getQuery();
+ if (query != null && query.length() > 0) {
+ String[] params = query.split("&");
+ Map<String, String> paramMap = new HashMap<String, String>();
+ for (String param : params) {
+ paramMap.put(param.split("=")[0], param.split("=")[1]);
+ }
+ for (String name : paramMap.keySet()) {
+ String value = paramMap.get(name);
+ if ("listen".equals(name)) {
+ if (value.indexOf(":") == -1) {
+ this.listenPort = Integer.parseInt(value);
+ } else {
+ String[] addr = value.split(":");
+ this.bindAddress = addr[0];
+ this.listenPort = Integer.parseInt(addr[1]);
+ }
+ } else if ("multicast".equals(name)) {
+ if ("off".equalsIgnoreCase(value)) {
+ this.multicastDisabled = true;
+ } else {
+ if (value.indexOf(":") == -1) {
+ this.multicastAddress = value;
+ } else {
+ String[] addr = value.split(":");
+ this.multicastAddress = addr[0];
+ this.multicastPort = Integer.parseInt(addr[1]);
+ }
+ }
+ } else if ("password".equals(name)) {
+ this.password = value;
+ } else if ("remotes".equals(name)) {
+ String[] ips = value.split(",");
+ for (String ip : ips) {
+ if (ip.indexOf(":") == -1) {
+ remotes.add(ip + ":14820");
+ } else {
+ remotes.add(ip);
+ }
+ }
+ if (paramMap.containsKey("multicast")) {
+// throw new IllegalArgumentException("Cannot have multicast and remotes (for now)");
+ } else {
+ this.multicastDisabled = true;
+ }
+ }
+ }
+ }
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public int getListenPort() {
+ return listenPort;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public boolean isMulticastDisabled() {
+ return multicastDisabled;
+ }
+
+ public String getMulticastAddress() {
+ return multicastAddress;
+ }
+
+ public int getMulticastPort() {
+ return multicastPort;
+ }
+
+ public List<String> getRemotes() {
+ return remotes;
+ }
+
+ public String toString() {
+ return uri;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java
index 6b538ad172..c413276b37 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java
@@ -1,31 +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.runtime;
-
-import java.util.Properties;
-/**
- *
- * @tuscany.spi.extension.asclient
- *
- */
-public interface RuntimeProperties {
- Properties getProperties();
- void setProperties(Properties properties);
-}
+/*
+ * 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.runtime;
+
+import java.util.Properties;
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public interface RuntimeProperties {
+ Properties getProperties();
+ void setProperties(Properties properties);
+}
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java
index 6060910a17..5d3ed1ce41 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java
@@ -1,47 +1,47 @@
-/*
- * 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.runtime;
-
-import java.util.ResourceBundle;
-
-public class Version {
-
- public static final String VERSION;
- public static final String REVISION;
- public static final String BUILDTIME;
- static {
- ResourceBundle rb = ResourceBundle.getBundle("org/apache/tuscany/sca/runtime/revision");
- VERSION = rb.getString("version");
- REVISION = rb.getString("revision");
- BUILDTIME = rb.getString("buildtime");
- }
-
- public static String getVersion() {
- return VERSION;
- }
-
- public static String getRevsion() {
- return REVISION;
- }
-
- public static String getBuildTime() {
- return BUILDTIME;
- }
-}
+/*
+ * 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.runtime;
+
+import java.util.ResourceBundle;
+
+public class Version {
+
+ public static final String VERSION;
+ public static final String REVISION;
+ public static final String BUILDTIME;
+ static {
+ ResourceBundle rb = ResourceBundle.getBundle("org/apache/tuscany/sca/runtime/revision");
+ VERSION = rb.getString("version");
+ REVISION = rb.getString("revision");
+ BUILDTIME = rb.getString("buildtime");
+ }
+
+ public static String getVersion() {
+ return VERSION;
+ }
+
+ public static String getRevsion() {
+ return REVISION;
+ }
+
+ public static String getBuildTime() {
+ return BUILDTIME;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java
index 8ac2c3ceb8..b7e96a8b28 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java
@@ -1,107 +1,107 @@
-/*
- * 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.runtime;
-
-import java.net.UnknownHostException;
-
-import junit.framework.Assert;
-
-import org.apache.tuscany.sca.runtime.DomainRegistryURI;
-import org.junit.Test;
-
-public class ConfigURITestCase {
-
- @Test
- public void testInvalidPrefix() throws UnknownHostException {
- try {
- new DomainRegistryURI("foo");
- Assert.fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- @Test
- public void testDomainName() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertFalse(configURI.isMulticastDisabled());
- }
-
- @Test
- public void testListenAddr() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=4321");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertFalse(configURI.isMulticastDisabled());
- Assert.assertEquals(4321, configURI.getListenPort());
- Assert.assertNull(configURI.getBindAddress());
- }
- @Test
- public void testListenAddr2() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=1.1.1.1:4321");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertFalse(configURI.isMulticastDisabled());
- Assert.assertEquals(4321, configURI.getListenPort());
- Assert.assertEquals("1.1.1.1", configURI.getBindAddress());
- }
-
- @Test
- public void testMulticase1() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=off");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertTrue(configURI.isMulticastDisabled());
- }
-
- @Test
- public void testMulticase2() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4:67");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertFalse(configURI.isMulticastDisabled());
- Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
- Assert.assertEquals(67, configURI.getMulticastPort());
- }
-
- @Test
- public void testMulticase3() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertFalse(configURI.isMulticastDisabled());
- Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
- Assert.assertEquals(51482, configURI.getMulticastPort());
- }
-
- @Test
- public void testPassword() {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?password=bla");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertEquals("bla", configURI.getPassword());
- }
-
- @Test
- public void testRemotes() throws UnknownHostException {
- DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?remotes=1.1.1.1:23,2.2.2.2");
- Assert.assertEquals("myDomain", configURI.getDomainName());
- Assert.assertTrue(configURI.isMulticastDisabled());
- Assert.assertEquals(2, configURI.getRemotes().size());
- Assert.assertEquals("1.1.1.1:23", configURI.getRemotes().get(0));
- Assert.assertEquals("2.2.2.2:14820", configURI.getRemotes().get(1));
- }
-
-}
+/*
+ * 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.runtime;
+
+import java.net.UnknownHostException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.runtime.DomainRegistryURI;
+import org.junit.Test;
+
+public class ConfigURITestCase {
+
+ @Test
+ public void testInvalidPrefix() throws UnknownHostException {
+ try {
+ new DomainRegistryURI("foo");
+ Assert.fail();
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDomainName() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ }
+
+ @Test
+ public void testListenAddr() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=4321");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals(4321, configURI.getListenPort());
+ Assert.assertNull(configURI.getBindAddress());
+ }
+ @Test
+ public void testListenAddr2() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=1.1.1.1:4321");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals(4321, configURI.getListenPort());
+ Assert.assertEquals("1.1.1.1", configURI.getBindAddress());
+ }
+
+ @Test
+ public void testMulticase1() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=off");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertTrue(configURI.isMulticastDisabled());
+ }
+
+ @Test
+ public void testMulticase2() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4:67");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
+ Assert.assertEquals(67, configURI.getMulticastPort());
+ }
+
+ @Test
+ public void testMulticase3() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
+ Assert.assertEquals(51482, configURI.getMulticastPort());
+ }
+
+ @Test
+ public void testPassword() {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?password=bla");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertEquals("bla", configURI.getPassword());
+ }
+
+ @Test
+ public void testRemotes() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?remotes=1.1.1.1:23,2.2.2.2");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertTrue(configURI.isMulticastDisabled());
+ Assert.assertEquals(2, configURI.getRemotes().size());
+ Assert.assertEquals("1.1.1.1:23", configURI.getRemotes().get(0));
+ Assert.assertEquals("2.2.2.2:14820", configURI.getRemotes().get(1));
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java
index 8a534299ca..89ca99484c 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java
@@ -1,36 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.runtime;
-
-import org.junit.Test;
-import org.junit.Ignore;
-
-/**
- */
-@Ignore
-public class VersionTestCase {
-
- @Test
- public void testRevision() {
- // Doesn't test much, just that it has been initilized to a number
- System.out.println(Version.getVersion() + " " + Version.getRevsion() + " " + Version.getBuildTime());
- Integer.parseInt(Version.getRevsion());
- }
-
-}
+/*
+ * 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.runtime;
+
+import org.junit.Test;
+import org.junit.Ignore;
+
+/**
+ */
+@Ignore
+public class VersionTestCase {
+
+ @Test
+ public void testRevision() {
+ // Doesn't test much, just that it has been initilized to a number
+ System.out.println(Version.getVersion() + " " + Version.getRevsion() + " " + Version.getBuildTime());
+ Integer.parseInt(Version.getRevsion());
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
index 67b1b923eb..bb2e34b311 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
@@ -1,101 +1,101 @@
-/*
- * 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.core.invocation.impl;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.concurrent.Future;
-
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.oasisopen.sca.ServiceReference;
-
-public class AsyncJDKInvocationHandler extends JDKInvocationHandler {
-
- private static final long serialVersionUID = 1L;
-
- public AsyncJDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
- super(messageFactory, callableReference);
- }
-
- public AsyncJDKInvocationHandler(MessageFactory messageFactory,
- Class<?> businessInterface,
- Invocable source) {
- super(messageFactory, businessInterface, source);
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (isAsyncCallback(method)) {
- return doInvokeAsyncCallback(proxy, method, args);
- } else if (isAsyncPoll(method)) {
- return doInvokeAsyncPoll(proxy, method, args);
- } else {
- return super.invoke(proxy, method, args);
- }
- }
-
- protected boolean isAsyncCallback(Method method) {
- if (method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Future.class))) {
- if (method.getParameterTypes().length > 0) {
- return method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class);
- }
- }
- return false;
- }
-
- protected boolean isAsyncPoll(Method method) {
- return method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Response.class));
- }
-
- protected AsyncResponse doInvokeAsyncPoll(Object proxy, Method asyncMethod, Object[] args) {
- Object response;
- boolean isException;
- try {
- response = super.invoke(proxy, getNonAsyncMethod(asyncMethod), args);
- isException = false;
- } catch (Throwable e) {
- response = e;
- isException = true;
- }
- return new AsyncResponse(response, isException);
- }
-
- private Object doInvokeAsyncCallback(Object proxy, Method asyncMethod, Object[] args) {
- AsyncHandler handler = (AsyncHandler)args[args.length-1];
- Response response = doInvokeAsyncPoll(proxy,asyncMethod,Arrays.copyOf(args, args.length-1));
- handler.handleResponse(response);
-
- return null;
- }
-
- protected Method getNonAsyncMethod(Method asyncMethod) {
- String methodName = asyncMethod.getName().substring(0, asyncMethod.getName().length()-5);
- for (Method m : businessInterface.getMethods()) {
- if (methodName.equals(m.getName())) {
- return m;
- }
- }
- throw new IllegalStateException("No non-async method matching async method " + asyncMethod.getName());
- }
-}
+/*
+ * 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.core.invocation.impl;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.oasisopen.sca.ServiceReference;
+
+public class AsyncJDKInvocationHandler extends JDKInvocationHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ public AsyncJDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
+ super(messageFactory, callableReference);
+ }
+
+ public AsyncJDKInvocationHandler(MessageFactory messageFactory,
+ Class<?> businessInterface,
+ Invocable source) {
+ super(messageFactory, businessInterface, source);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (isAsyncCallback(method)) {
+ return doInvokeAsyncCallback(proxy, method, args);
+ } else if (isAsyncPoll(method)) {
+ return doInvokeAsyncPoll(proxy, method, args);
+ } else {
+ return super.invoke(proxy, method, args);
+ }
+ }
+
+ protected boolean isAsyncCallback(Method method) {
+ if (method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Future.class))) {
+ if (method.getParameterTypes().length > 0) {
+ return method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class);
+ }
+ }
+ return false;
+ }
+
+ protected boolean isAsyncPoll(Method method) {
+ return method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Response.class));
+ }
+
+ protected AsyncResponse doInvokeAsyncPoll(Object proxy, Method asyncMethod, Object[] args) {
+ Object response;
+ boolean isException;
+ try {
+ response = super.invoke(proxy, getNonAsyncMethod(asyncMethod), args);
+ isException = false;
+ } catch (Throwable e) {
+ response = e;
+ isException = true;
+ }
+ return new AsyncResponse(response, isException);
+ }
+
+ private Object doInvokeAsyncCallback(Object proxy, Method asyncMethod, Object[] args) {
+ AsyncHandler handler = (AsyncHandler)args[args.length-1];
+ Response response = doInvokeAsyncPoll(proxy,asyncMethod,Arrays.copyOf(args, args.length-1));
+ handler.handleResponse(response);
+
+ return null;
+ }
+
+ protected Method getNonAsyncMethod(Method asyncMethod) {
+ String methodName = asyncMethod.getName().substring(0, asyncMethod.getName().length()-5);
+ for (Method m : businessInterface.getMethods()) {
+ if (methodName.equals(m.getName())) {
+ return m;
+ }
+ }
+ throw new IllegalStateException("No non-async method matching async method " + asyncMethod.getName());
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
index 07086dfae3..7b459f3e7d 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
@@ -1,68 +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 org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.xml.ws.Response;
-
-public class AsyncResponse implements Response {
-
- private Object response;
- private boolean isException;
-
- public AsyncResponse(Object response, boolean isException) {
- this.response = response;
- this.isException = isException;
- }
-
- public Map getContext() {
- return new HashMap();
- }
-
- public boolean cancel(boolean mayInterruptIfRunning) {
- return false;
- }
-
- public Object get() throws InterruptedException, ExecutionException {
- if (isException) {
- throw new ExecutionException((Throwable)response);
- } else {
- return response;
- }
- }
-
- public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- return get();
- }
-
- public boolean isCancelled() {
- return false;
- }
-
- public boolean isDone() {
- return true;
- }
-
-}
+/*
+ * 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.core.invocation.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.ws.Response;
+
+public class AsyncResponse implements Response {
+
+ private Object response;
+ private boolean isException;
+
+ public AsyncResponse(Object response, boolean isException) {
+ this.response = response;
+ this.isException = isException;
+ }
+
+ public Map getContext() {
+ return new HashMap();
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false;
+ }
+
+ public Object get() throws InterruptedException, ExecutionException {
+ if (isException) {
+ throw new ExecutionException((Throwable)response);
+ } else {
+ return response;
+ }
+ }
+
+ public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ return get();
+ }
+
+ public boolean isCancelled() {
+ return false;
+ }
+
+ public boolean isDone() {
+ return true;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java
index 1bbb97d975..cd8bc936af 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java
@@ -1,38 +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 org.apache.tuscany.sca.core.runtime.impl;
-
-import java.util.Properties;
-
-import org.apache.tuscany.sca.runtime.RuntimeProperties;
-
-public class RuntimePropertiesImpl implements RuntimeProperties {
-
- private Properties properties = new Properties();
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
-}
+/*
+ * 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.core.runtime.impl;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+public class RuntimePropertiesImpl implements RuntimeProperties {
+
+ private Properties properties = new Properties();
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java
index 7e432dd2c2..1ef689185a 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java
@@ -1,107 +1,107 @@
-/*
- * 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.databinding.sdo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.Base;
-
-import commonj.sdo.Type;
-
-/**
- * The model object for sdo.types
- *
- * @version $Rev: 537464 $ $Date: 2007-05-12 08:37:14 -0700 (Sat, 12 May 2007) $
- *
- * This extends the META-INF/sca-contribution.xml to register SDO types from static factory classes or WSDL/XSD files
- *
- * &lt;contribution xmlns=&quot;http://tuscany.apache.org/xmlns/sca/1.1&quot;<br>
- * &nbsp;&nbsp;&nbsp;&nbsp;xmlns:tuscany=&quot;http://tuscany.apache.org/xmlns/sca/1.0&quot;&gt;<br>
- * &nbsp;&nbsp;&nbsp;&nbsp;&lt;tuscany:sdo.types namespace=&quot;http://helloworld&quot; location=&quot;wsdl/helloworld.wsdl&quot;/&gt;<br>
- * &lt;/contribution&gt;
- *
- */
-public class SDOTypes {
- public static final QName SDO_TYPES = new QName(Base.SCA11_TUSCANY_NS, "sdo.types");
-
- private String factory;
- private String schemaLocation;
- private String namespace;
-
- private List<Type> types = new ArrayList<Type>();
-
- private boolean unresolved;
-
- public SDOTypes() {
- super();
- setUnresolved(true);
- }
-
- public boolean isUnresolved() {
- return unresolved;
- }
-
- public void setUnresolved(boolean undefined) {
- this.unresolved = undefined;
- }
-
- /**
- * @return the factoryClassName
- */
- public String getFactory() {
- return factory;
- }
-
- /**
- * @param factoryClassName the factoryClassName to set
- */
- public void setFactory(String factoryClassName) {
- this.factory = factoryClassName;
- }
-
- /**
- * @return the schemaLocation
- */
- public String getSchemaLocation() {
- return schemaLocation;
- }
-
- /**
- * @param schemaLocation the schemaLocation to set
- */
- public void setSchemaLocation(String schemaLocation) {
- this.schemaLocation = schemaLocation;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
- public List<Type> getTypes() {
- return types;
- }
-}
+/*
+ * 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.databinding.sdo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+import commonj.sdo.Type;
+
+/**
+ * The model object for sdo.types
+ *
+ * @version $Rev$ $Date$
+ *
+ * This extends the META-INF/sca-contribution.xml to register SDO types from static factory classes or WSDL/XSD files
+ *
+ * &lt;contribution xmlns=&quot;http://tuscany.apache.org/xmlns/sca/1.1&quot;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;xmlns:tuscany=&quot;http://tuscany.apache.org/xmlns/sca/1.0&quot;&gt;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;&lt;tuscany:sdo.types namespace=&quot;http://helloworld&quot; location=&quot;wsdl/helloworld.wsdl&quot;/&gt;<br>
+ * &lt;/contribution&gt;
+ *
+ */
+public class SDOTypes {
+ public static final QName SDO_TYPES = new QName(Base.SCA11_TUSCANY_NS, "sdo.types");
+
+ private String factory;
+ private String schemaLocation;
+ private String namespace;
+
+ private List<Type> types = new ArrayList<Type>();
+
+ private boolean unresolved;
+
+ public SDOTypes() {
+ super();
+ setUnresolved(true);
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the factoryClassName
+ */
+ public String getFactory() {
+ return factory;
+ }
+
+ /**
+ * @param factoryClassName the factoryClassName to set
+ */
+ public void setFactory(String factoryClassName) {
+ this.factory = factoryClassName;
+ }
+
+ /**
+ * @return the schemaLocation
+ */
+ public String getSchemaLocation() {
+ return schemaLocation;
+ }
+
+ /**
+ * @param schemaLocation the schemaLocation to set
+ */
+ public void setSchemaLocation(String schemaLocation) {
+ this.schemaLocation = schemaLocation;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public List<Type> getTypes() {
+ return types;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
index f9d66bf04e..020a8edd7d 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
@@ -1,234 +1,234 @@
-/*
- * 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.databinding.sdo.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.contribution.Artifact;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ContributionFactory;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.resolver.ClassReference;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
-import org.apache.tuscany.sca.xsd.XSDFactory;
-import org.apache.tuscany.sca.xsd.XSDefinition;
-import org.apache.tuscany.sdo.api.SDOUtil;
-
-import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.XSDHelper;
-
-/**
- * SDO types model resolver that aggregates the SDO type registration for an SCA contribution
- */
-public class SDOTypesModelResolver implements ModelResolver {
- private Contribution contribution;
- private HelperContext helperContext;
- private List<SDOTypes> sdoTypes = new ArrayList<SDOTypes>();
- private ContributionFactory contributionFactory;
- private XSDFactory xsdFactory;
- private ProcessorContext context;
-
- public SDOTypesModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
- super();
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
- this.contribution = contribution;
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- if (helperContext == null) {
- helperContext = SDOUtil.createHelperContext();
- }
- this.context = context;
- SDOTypes types = (SDOTypes)resolved;
- try {
- loadSDOTypes(types, contribution.getModelResolver());
- } catch (ContributionResolveException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- sdoTypes.add(types);
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- SDOTypes types = (SDOTypes)resolved;
-
- return sdoTypes.remove(types);
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
- SDOTypes types = (SDOTypes)unresolved;
- String ns = types.getNamespace();
- this.context = context;
- for (SDOTypes t : sdoTypes) {
- if (t.getNamespace().equals(types.getNamespace())) {
- try {
- loadSDOTypes(types, contribution.getModelResolver());
- } catch (ContributionResolveException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return (T)t;
- }
- }
- return (T)types;
- }
-
- private static void register(Class<?> factoryClass, HelperContext helperContext) throws Exception {
- Field field = factoryClass.getField("INSTANCE");
- Object factory = field.get(null);
- Method method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
- method.invoke(factory, new Object[] {helperContext});
- }
-
- private void defineFromFactory(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
- String factoryName = importSDO.getFactory();
- if (factoryName != null) {
- ClassReference reference = new ClassReference(factoryName);
- ClassReference resolved = resolver.resolveModel(ClassReference.class, reference, context);
- if (resolved != null && !resolved.isUnresolved()) {
- try {
- Class<?> factoryClass = resolved.getJavaClass();
- // Get the namespace
- Field field = factoryClass.getField("NAMESPACE_URI");
- importSDO.setNamespace((String)field.get(null));
- register(factoryClass, helperContext);
- importSDO.setUnresolved(false);
- } catch (Exception e) {
- ContributionResolveException ce = new ContributionResolveException(e);
- error(context.getMonitor(), "ContributionResolveException", resolver, ce);
- //throw ce;
- }
- } else {
- error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
- //ContributionResolveException loaderException =
- //new ContributionResolveException("Fail to resolve class: " + factoryName);
- //throw loaderException;
- }
- }
- }
-
- private void defineFromXSD(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
- String location = importSDO.getSchemaLocation();
- if (location != null) {
- try {
- Artifact artifact = contributionFactory.createArtifact();
- artifact.setURI(location);
- artifact = resolver.resolveModel(Artifact.class, artifact, context);
- if (artifact.getLocation() != null) {
- String wsdlURL = artifact.getLocation();
- URLConnection connection = new URL(wsdlURL).openConnection();
- connection.setUseCaches(false);
- InputStream xsdInputStream = connection.getInputStream();
- try {
- XSDHelper xsdHelper = helperContext.getXSDHelper();
- List<Type> sdoTypes = xsdHelper.define(xsdInputStream, wsdlURL);
- for (Type t : sdoTypes) {
- importSDO.setNamespace(t.getURI());
- break;
- }
- importSDO.getTypes().addAll(sdoTypes);
- } finally {
- xsdInputStream.close();
- }
- importSDO.setUnresolved(false);
- } else {
- error(context.getMonitor(), "FailToResolveLocation", resolver, location);
- //ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
- //throw loaderException;
- }
- } catch (IOException e) {
- ContributionResolveException ce = new ContributionResolveException(e);
- error(context.getMonitor(), "ContributionResolveException", resolver, ce);
- //throw ce;
- }
- } else {
- String ns = importSDO.getNamespace();
- if (ns != null) {
- XSDefinition xsd = xsdFactory.createXSDefinition();
- xsd.setUnresolved(true);
- xsd.setNamespace(ns);
- xsd = resolver.resolveModel(XSDefinition.class, xsd, context);
- if (!xsd.isUnresolved()) {
- XSDHelper xsdHelper = helperContext.getXSDHelper();
- xsdHelper.define(xsd.getLocation().toString());
- }
- }
- }
- }
-
- private void loadSDOTypes(SDOTypes types, ModelResolver resolver) throws ContributionResolveException {
- synchronized (types) {
- if (types.isUnresolved()) {
- defineFromFactory(types, resolver);
- defineFromXSD(types, resolver);
- types.setUnresolved(false);
- }
- }
- }
-
- /**
- * Report a exception.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(Monitor monitor, String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem =
- new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
- message, model, message, ex);
- monitor.problem(problem);
- }
- }
-
- /**
- * Report a error.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem =
- new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
- message, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
-}
+/*
+ * 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.databinding.sdo.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * SDO types model resolver that aggregates the SDO type registration for an SCA contribution
+ */
+public class SDOTypesModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private HelperContext helperContext;
+ private List<SDOTypes> sdoTypes = new ArrayList<SDOTypes>();
+ private ContributionFactory contributionFactory;
+ private XSDFactory xsdFactory;
+ private ProcessorContext context;
+
+ public SDOTypesModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ super();
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ if (helperContext == null) {
+ helperContext = SDOUtil.createHelperContext();
+ }
+ this.context = context;
+ SDOTypes types = (SDOTypes)resolved;
+ try {
+ loadSDOTypes(types, contribution.getModelResolver());
+ } catch (ContributionResolveException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ sdoTypes.add(types);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ SDOTypes types = (SDOTypes)resolved;
+
+ return sdoTypes.remove(types);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ SDOTypes types = (SDOTypes)unresolved;
+ String ns = types.getNamespace();
+ this.context = context;
+ for (SDOTypes t : sdoTypes) {
+ if (t.getNamespace().equals(types.getNamespace())) {
+ try {
+ loadSDOTypes(types, contribution.getModelResolver());
+ } catch (ContributionResolveException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return (T)t;
+ }
+ }
+ return (T)types;
+ }
+
+ private static void register(Class<?> factoryClass, HelperContext helperContext) throws Exception {
+ Field field = factoryClass.getField("INSTANCE");
+ Object factory = field.get(null);
+ Method method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
+ method.invoke(factory, new Object[] {helperContext});
+ }
+
+ private void defineFromFactory(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
+ String factoryName = importSDO.getFactory();
+ if (factoryName != null) {
+ ClassReference reference = new ClassReference(factoryName);
+ ClassReference resolved = resolver.resolveModel(ClassReference.class, reference, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ try {
+ Class<?> factoryClass = resolved.getJavaClass();
+ // Get the namespace
+ Field field = factoryClass.getField("NAMESPACE_URI");
+ importSDO.setNamespace((String)field.get(null));
+ register(factoryClass, helperContext);
+ importSDO.setUnresolved(false);
+ } catch (Exception e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
+ //ContributionResolveException loaderException =
+ //new ContributionResolveException("Fail to resolve class: " + factoryName);
+ //throw loaderException;
+ }
+ }
+ }
+
+ private void defineFromXSD(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
+ String location = importSDO.getSchemaLocation();
+ if (location != null) {
+ try {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(location);
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (artifact.getLocation() != null) {
+ String wsdlURL = artifact.getLocation();
+ URLConnection connection = new URL(wsdlURL).openConnection();
+ connection.setUseCaches(false);
+ InputStream xsdInputStream = connection.getInputStream();
+ try {
+ XSDHelper xsdHelper = helperContext.getXSDHelper();
+ List<Type> sdoTypes = xsdHelper.define(xsdInputStream, wsdlURL);
+ for (Type t : sdoTypes) {
+ importSDO.setNamespace(t.getURI());
+ break;
+ }
+ importSDO.getTypes().addAll(sdoTypes);
+ } finally {
+ xsdInputStream.close();
+ }
+ importSDO.setUnresolved(false);
+ } else {
+ error(context.getMonitor(), "FailToResolveLocation", resolver, location);
+ //ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
+ //throw loaderException;
+ }
+ } catch (IOException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ String ns = importSDO.getNamespace();
+ if (ns != null) {
+ XSDefinition xsd = xsdFactory.createXSDefinition();
+ xsd.setUnresolved(true);
+ xsd.setNamespace(ns);
+ xsd = resolver.resolveModel(XSDefinition.class, xsd, context);
+ if (!xsd.isUnresolved()) {
+ XSDHelper xsdHelper = helperContext.getXSDHelper();
+ xsdHelper.define(xsd.getLocation().toString());
+ }
+ }
+ }
+ }
+
+ private void loadSDOTypes(SDOTypes types, ModelResolver resolver) throws ContributionResolveException {
+ synchronized (types) {
+ if (types.isUnresolved()) {
+ defineFromFactory(types, resolver);
+ defineFromXSD(types, resolver);
+ types.setUnresolved(false);
+ }
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
index 76e2955f06..b851d38dae 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
@@ -1,109 +1,109 @@
-/*
- * 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.databinding.sdo.xml;
-
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
-
-
-/**
- * Loader that handles &lt;import.sdo&gt; elements.
- *
- * @version $Rev: 667376 $ $Date: 2008-06-12 23:29:16 -0700 (Thu, 12 Jun 2008) $
- */
-public class SDOTypesProcessor implements StAXArtifactProcessor<SDOTypes> {
-
- public SDOTypesProcessor(ExtensionPointRegistry registry) {
- }
-
- public QName getXMLType() {
- return SDOTypes.SDO_TYPES;
- }
-
- public SDOTypes read(XMLStreamReader reader,ProcessorContext context) throws ContributionReadException, XMLStreamException {
- assert SDOTypes.SDO_TYPES.equals(reader.getName());
-
- // FIXME: How do we associate the application HelperContext with the one
- // imported by the composite
- SDOTypes sdoTypes = new SDOTypes();
- String factoryName = reader.getAttributeValue(null, "factory");
- if (factoryName != null) {
- sdoTypes.setFactory(factoryName);
- }
- String location = reader.getAttributeValue(null, "location");
- if (location != null) {
- sdoTypes.setSchemaLocation(location);
- }
- String ns = reader.getAttributeValue(null, "namespace");
- sdoTypes.setNamespace(ns);
-
- // Skip to end element
- while (reader.hasNext()) {
- if (reader.next() == END_ELEMENT && SDOTypes.SDO_TYPES.equals(reader.getName())) {
- break;
- }
- }
- return sdoTypes;
- }
-
- public QName getArtifactType() {
- return SDOTypes.SDO_TYPES;
- }
-
- public void write(SDOTypes model, XMLStreamWriter writer,ProcessorContext context) throws ContributionWriteException {
- try {
- writer.writeStartElement(SDOTypes.SDO_TYPES.getNamespaceURI(), SDOTypes.SDO_TYPES.getLocalPart());
- if (model.getNamespace() != null) {
- writer.writeAttribute("namespace", model.getNamespace());
- }
- if (model.getSchemaLocation() != null) {
- writer.writeAttribute("location", model.getSchemaLocation());
- }
- if (model.getFactory() != null) {
- writer.writeAttribute("factory", model.getFactory());
- }
- writer.writeEndElement();
- } catch (XMLStreamException e) {
- throw new ContributionWriteException(e);
- }
- }
-
- public Class<SDOTypes> getModelType() {
- return SDOTypes.class;
- }
-
- public void resolve(SDOTypes types, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
- // Defer the resolution to SDOTypesResolver which aggragates the type registrations into an instance of HelperContext
- resolver.addModel(types,context);
- }
-
-}
+/*
+ * 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.databinding.sdo.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
+
+
+/**
+ * Loader that handles &lt;import.sdo&gt; elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOTypesProcessor implements StAXArtifactProcessor<SDOTypes> {
+
+ public SDOTypesProcessor(ExtensionPointRegistry registry) {
+ }
+
+ public QName getXMLType() {
+ return SDOTypes.SDO_TYPES;
+ }
+
+ public SDOTypes read(XMLStreamReader reader,ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ assert SDOTypes.SDO_TYPES.equals(reader.getName());
+
+ // FIXME: How do we associate the application HelperContext with the one
+ // imported by the composite
+ SDOTypes sdoTypes = new SDOTypes();
+ String factoryName = reader.getAttributeValue(null, "factory");
+ if (factoryName != null) {
+ sdoTypes.setFactory(factoryName);
+ }
+ String location = reader.getAttributeValue(null, "location");
+ if (location != null) {
+ sdoTypes.setSchemaLocation(location);
+ }
+ String ns = reader.getAttributeValue(null, "namespace");
+ sdoTypes.setNamespace(ns);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && SDOTypes.SDO_TYPES.equals(reader.getName())) {
+ break;
+ }
+ }
+ return sdoTypes;
+ }
+
+ public QName getArtifactType() {
+ return SDOTypes.SDO_TYPES;
+ }
+
+ public void write(SDOTypes model, XMLStreamWriter writer,ProcessorContext context) throws ContributionWriteException {
+ try {
+ writer.writeStartElement(SDOTypes.SDO_TYPES.getNamespaceURI(), SDOTypes.SDO_TYPES.getLocalPart());
+ if (model.getNamespace() != null) {
+ writer.writeAttribute("namespace", model.getNamespace());
+ }
+ if (model.getSchemaLocation() != null) {
+ writer.writeAttribute("location", model.getSchemaLocation());
+ }
+ if (model.getFactory() != null) {
+ writer.writeAttribute("factory", model.getFactory());
+ }
+ writer.writeEndElement();
+ } catch (XMLStreamException e) {
+ throw new ContributionWriteException(e);
+ }
+ }
+
+ public Class<SDOTypes> getModelType() {
+ return SDOTypes.class;
+ }
+
+ public void resolve(SDOTypes types, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
+ // Defer the resolution to SDOTypesResolver which aggragates the type registrations into an instance of HelperContext
+ resolver.addModel(types,context);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/pom.xml b/sca-java-2.x/trunk/modules/domain-node/pom.xml
index 86d7c96684..e30e17b652 100644
--- a/sca-java-2.x/trunk/modules/domain-node/pom.xml
+++ b/sca-java-2.x/trunk/modules/domain-node/pom.xml
@@ -1,61 +1,61 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-domain-node</artifactId>
- <name>Apache Tuscany SCA Domain Node</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-node-impl</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-client-impl</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-domain-node</artifactId>
+ <name>Apache Tuscany SCA Domain Node</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
index e538ea9f53..8a30cf2f71 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
@@ -1,179 +1,179 @@
-/*
- * 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.domain.node;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
-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.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-public class DomainNode {
-
- private static final String DEFAULT_DOMAIN_SCHEME = "vm";
- private static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
- private static final String DEFAULT_CONFIG_URI = DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME;
-
- private String domainName;
- private String domainRegistryURI;
-
- private Map<String, Node> nodes = new HashMap<String, Node>();
-
- public DomainNode() {
- this(DEFAULT_CONFIG_URI, new String[]{});
- }
-
- public DomainNode(String... contributionLocations) {
- this(DEFAULT_CONFIG_URI, contributionLocations);
- }
-
- public DomainNode(String configURI, String[] contributionLocations) {
- this.domainRegistryURI = configURI;
- initDomainName(configURI);
- if (contributionLocations == null || contributionLocations.length == 0) {
- addContribution(null, "_null");
- } else {
- for (String loc : contributionLocations) {
- addContribution(loc);
- }
- }
- }
-
- public void stop() {
- for (Node node : nodes.values()) {
- node.stop();
- }
- }
-
- public String addContribution(String location) {
- String uri = location;
- addContribution(uri, location);
- return uri;
- }
-
- public void addContribution(String location, String uri) {
- if (nodes.containsKey(uri)) {
- throw new IllegalArgumentException("contribution already added: " + uri);
- }
- NodeConfiguration configuration = NodeFactory.getInstance().createNodeConfiguration();
- if (location != null) {
- configuration.addContribution(uri, location);
- }
- configuration.setDomainRegistryURI(domainRegistryURI);
- configuration.setDomainURI(domainName);
- configuration.setURI(uri); //???
- Node node = NodeFactory.getInstance().createNode(configuration).start();
- nodes.put(uri, node);
- }
-
- public void removeContribution(String uri) {
- if (!nodes.containsKey(uri)) {
- throw new IllegalArgumentException("contribution not found: " + uri);
- }
- Node node = nodes.remove(uri);
- node.stop();
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public String getDomainConfigURI() {
- return domainRegistryURI;
- }
-
- public List<String> getServiceNames() {
- List<String> serviceNames = new ArrayList<String>();
- if (nodes.size() > 0) {
- ExtensionPointRegistry extensionsRegistry = ((NodeImpl)nodes.values().iterator().next()).getExtensionPointRegistry();
- DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
- EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(getDomainConfigURI(), getDomainName());
- for (Endpoint endpoint : endpointRegistry.getEndpoints()) {
- // Would be nice if Endpoint.getURI() returned this:
- String name = endpoint.getComponent().getName() + "/" + endpoint.getService().getName();
- if (endpoint.getBinding() != null) {
- // TODO: shouldn't the binding name be null if its not explicitly specified?
- // For now don't include it if the same as the default
- if (!endpoint.getService().getName().equals(endpoint.getBinding().getName())) {
- name += "/" + endpoint.getBinding().getName();
- }
- }
- serviceNames.add(name);
- }
- }
- return serviceNames;
- }
-
- public <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException {
- try {
- return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, uri);
- } catch (NoSuchDomainException e) {
- throw new IllegalStateException(e);
- }
- }
-
- protected void initDomainName(String configURI) {
-// URI uri = URI.create(fixScheme(configURI));
-// String dn = uri.getHost();
-// if (dn == null || dn.length() < 1) {
-// dn = DEFAULT_DOMAIN_NAME;
-// }
- if (configURI.startsWith("tuscany:vm:")) {
- domainName = configURI.substring("tuscany:vm:".length());
- } else if (configURI.startsWith("tuscany:")) {
- int i = configURI.indexOf('?');
- if (i == -1) {
- domainName = configURI.substring("tuscany:".length());
- } else{
- domainName = configURI.substring("tuscany:".length(), i);
- }
- } else {
- domainName = configURI;
- }
- }
-
- /**
- * I keep typing the scheme part with just a colon instead of colon slash slash
- * which URI doesn't parse properly which irritates me so fix it up here
- */
- protected String fixScheme(String uri) {
- int i = uri.indexOf(":");
- if (i > -1 && uri.charAt(i+1) != '/') {
- uri = uri.replaceFirst(":", ":/");
- }
- if (i > -1 && uri.charAt(i+2) != '/') {
- uri = uri.replaceFirst(":/", "://");
- }
- return uri;
- }
-}
+/*
+ * 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.domain.node;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+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.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class DomainNode {
+
+ private static final String DEFAULT_DOMAIN_SCHEME = "vm";
+ private static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_CONFIG_URI = DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME;
+
+ private String domainName;
+ private String domainRegistryURI;
+
+ private Map<String, Node> nodes = new HashMap<String, Node>();
+
+ public DomainNode() {
+ this(DEFAULT_CONFIG_URI, new String[]{});
+ }
+
+ public DomainNode(String... contributionLocations) {
+ this(DEFAULT_CONFIG_URI, contributionLocations);
+ }
+
+ public DomainNode(String configURI, String[] contributionLocations) {
+ this.domainRegistryURI = configURI;
+ initDomainName(configURI);
+ if (contributionLocations == null || contributionLocations.length == 0) {
+ addContribution(null, "_null");
+ } else {
+ for (String loc : contributionLocations) {
+ addContribution(loc);
+ }
+ }
+ }
+
+ public void stop() {
+ for (Node node : nodes.values()) {
+ node.stop();
+ }
+ }
+
+ public String addContribution(String location) {
+ String uri = location;
+ addContribution(uri, location);
+ return uri;
+ }
+
+ public void addContribution(String location, String uri) {
+ if (nodes.containsKey(uri)) {
+ throw new IllegalArgumentException("contribution already added: " + uri);
+ }
+ NodeConfiguration configuration = NodeFactory.getInstance().createNodeConfiguration();
+ if (location != null) {
+ configuration.addContribution(uri, location);
+ }
+ configuration.setDomainRegistryURI(domainRegistryURI);
+ configuration.setDomainURI(domainName);
+ configuration.setURI(uri); //???
+ Node node = NodeFactory.getInstance().createNode(configuration).start();
+ nodes.put(uri, node);
+ }
+
+ public void removeContribution(String uri) {
+ if (!nodes.containsKey(uri)) {
+ throw new IllegalArgumentException("contribution not found: " + uri);
+ }
+ Node node = nodes.remove(uri);
+ node.stop();
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public String getDomainConfigURI() {
+ return domainRegistryURI;
+ }
+
+ public List<String> getServiceNames() {
+ List<String> serviceNames = new ArrayList<String>();
+ if (nodes.size() > 0) {
+ ExtensionPointRegistry extensionsRegistry = ((NodeImpl)nodes.values().iterator().next()).getExtensionPointRegistry();
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(getDomainConfigURI(), getDomainName());
+ for (Endpoint endpoint : endpointRegistry.getEndpoints()) {
+ // Would be nice if Endpoint.getURI() returned this:
+ String name = endpoint.getComponent().getName() + "/" + endpoint.getService().getName();
+ if (endpoint.getBinding() != null) {
+ // TODO: shouldn't the binding name be null if its not explicitly specified?
+ // For now don't include it if the same as the default
+ if (!endpoint.getService().getName().equals(endpoint.getBinding().getName())) {
+ name += "/" + endpoint.getBinding().getName();
+ }
+ }
+ serviceNames.add(name);
+ }
+ }
+ return serviceNames;
+ }
+
+ public <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException {
+ try {
+ return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, uri);
+ } catch (NoSuchDomainException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ protected void initDomainName(String configURI) {
+// URI uri = URI.create(fixScheme(configURI));
+// String dn = uri.getHost();
+// if (dn == null || dn.length() < 1) {
+// dn = DEFAULT_DOMAIN_NAME;
+// }
+ if (configURI.startsWith("tuscany:vm:")) {
+ domainName = configURI.substring("tuscany:vm:".length());
+ } else if (configURI.startsWith("tuscany:")) {
+ int i = configURI.indexOf('?');
+ if (i == -1) {
+ domainName = configURI.substring("tuscany:".length());
+ } else{
+ domainName = configURI.substring("tuscany:".length(), i);
+ }
+ } else {
+ domainName = configURI;
+ }
+ }
+
+ /**
+ * I keep typing the scheme part with just a colon instead of colon slash slash
+ * which URI doesn't parse properly which irritates me so fix it up here
+ */
+ protected String fixScheme(String uri) {
+ int i = uri.indexOf(":");
+ if (i > -1 && uri.charAt(i+1) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (i > -1 && uri.charAt(i+2) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ return uri;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
index ac0672fb2c..0d9f4172f2 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
@@ -1,67 +1,67 @@
-/*
- * 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.domain.node;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-
-public class DomainNodeMain {
-
- /**
- * Start an SCA domain node
- * @param args a list of contribution jars for the node to run
- */
- public static void main(String[] args) throws Exception {
-
- String configURI = "uri:default";
-
- List<String> contributions = new ArrayList<String>();
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("vm:") || args[i].startsWith("tribes:") || args[i].startsWith("tuscany:") || args[i].startsWith("uri:") || args[i].startsWith("properties:")) {
- configURI = args[i];
- } else{
- File f = new File(args[i]);
- if (!f.exists()) {
- System.err.println("contribution not found: " + f);
- System.exit(1);
- }
- contributions.add(f.toURI().toString());
- }
- }
-
- Node node = NodeFactory.newInstance(configURI).createNode((String)null, contributions.toArray(new String[contributions.size()]));
- node.start();
-
- System.out.println("Hit enter to stop node...");
- if (System.in.read() == -1) {
- // no sysin so wait for ever letting caller do the terminate
- Object lock = new Object();
- synchronized (lock) {
- lock.wait();
- }
- }
-
- node.stop();
- }
-}
+/*
+ * 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.domain.node;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class DomainNodeMain {
+
+ /**
+ * Start an SCA domain node
+ * @param args a list of contribution jars for the node to run
+ */
+ public static void main(String[] args) throws Exception {
+
+ String configURI = "uri:default";
+
+ List<String> contributions = new ArrayList<String>();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("vm:") || args[i].startsWith("tribes:") || args[i].startsWith("tuscany:") || args[i].startsWith("uri:") || args[i].startsWith("properties:")) {
+ configURI = args[i];
+ } else{
+ File f = new File(args[i]);
+ if (!f.exists()) {
+ System.err.println("contribution not found: " + f);
+ System.exit(1);
+ }
+ contributions.add(f.toURI().toString());
+ }
+ }
+
+ Node node = NodeFactory.newInstance(configURI).createNode((String)null, contributions.toArray(new String[contributions.size()]));
+ node.start();
+
+ System.out.println("Hit enter to stop node...");
+ if (System.in.read() == -1) {
+ // no sysin so wait for ever letting caller do the terminate
+ Object lock = new Object();
+ synchronized (lock) {
+ lock.wait();
+ }
+ }
+
+ node.stop();
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
index ee15dfba12..76f8d4400d 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
@@ -1,29 +1,29 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package itest.nodes;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface Helloworld {
-
- String sayHello(String name);
-
-}
+/*
+ * 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 itest.nodes;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
index 596febe393..0a5d99ae7c 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
@@ -1,84 +1,84 @@
-/*
- * 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.domain.node;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import itest.nodes.Helloworld;
-
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * This shows how to test the Calculator service component.
- */
-@Ignore("TUSCANY-3391")
-public class GetServiceTestCase{
-
- private static DomainNode clientNode;
- private static DomainNode serviceNode;
-
- @Test
- public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
-
- Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
-
- Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- }
-
- @Test
- public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
-
- clientNode = new DomainNode("vm://barDomain", new String[] {"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
- Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
-
- try {
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- fail();
- } catch (ServiceRuntimeException e) {
- // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
- // expected
- }
- }
-
- @After
- public void tearDownAfterClass() throws Exception {
- if (clientNode != null) {
- clientNode.stop();
- }
- if (serviceNode != null) {
- serviceNode.stop();
- }
- }
-}
+/*
+ * 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class GetServiceTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testTwoNodesDifferentDomains() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ clientNode = new DomainNode("vm://barDomain", new String[] {"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (ServiceRuntimeException e) {
+ // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
index 3583b1be15..617876586b 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
@@ -1,87 +1,87 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.domain.node;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import itest.nodes.Helloworld;
-
-import java.net.URI;
-
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-/**
- * This shows how to test the Calculator service component.
- */
-@Ignore("TUSCANY-3391")
-public class MultipleNodesPerJVMTestCase{
-
- private static DomainNode clientNode;
- private static DomainNode serviceNode;
-
- @Test
- public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
-
- Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
-
- Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- }
-
- @Test
- public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
-
- clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
- Helloworld client = SCAClientFactory.newInstance(URI.create("vm://barDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
-
- try {
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- fail();
- } catch (ServiceRuntimeException e) {
- // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
- // expected
- }
- }
-
- @After
- public void tearDownAfterClass() throws Exception {
- if (clientNode != null) {
- clientNode.stop();
- }
- if (serviceNode != null) {
- serviceNode.stop();
- }
- }
-}
+/*
+ * 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class MultipleNodesPerJVMTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testTwoNodesDifferentDomains() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://barDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (ServiceRuntimeException e) {
+ // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
index 3a224a8aa5..10803cd880 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
@@ -1,105 +1,105 @@
-/*
- * 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.domain.node;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import itest.nodes.Helloworld;
-
-import java.net.URI;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-/**
- * This shows how to test the Calculator service component.
- */
-@Ignore("TUSCANY-3391")
-public class OneNodeTestCase{
-
- private static DomainNode domain;
- private static String serviceContributionUri;
-
- @Before
- public void setUpBeforeClass() throws Exception {
- domain = new DomainNode();
- serviceContributionUri = domain.addContribution("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- domain.addContribution("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
- }
-
- @Test
- public void testService() throws Exception {
- Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
- }
-
- @Test
- public void testClient() throws Exception {
- Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- }
-
- @Test
- public void testRemovingServiceContribution() throws Exception {
- domain.removeContribution(serviceContributionUri);
- try {
- SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
- // FIXME: should this be NoSuchServiceException or ServiceNotFoundException?
- } catch (NoSuchServiceException e) {
- // expected
- }
-
- Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- try {
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- fail();
- } catch (Exception e) {
- // FIXME: this gives an NPE, would be better to be something like ServiceNotFoundException
- // expected
- }
- }
-
- @Test
- public void testStoppingDomainNode() throws Exception {
- domain.stop();
- try {
- SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
- fail();
- } catch (NoSuchDomainException e) {
- // expected
- }
- }
-
- @After
- public void tearDownAfterClass() throws Exception {
- if (domain != null) {
- domain.stop();
- }
- }
-}
+/*
+ * 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class OneNodeTestCase{
+
+ private static DomainNode domain;
+ private static String serviceContributionUri;
+
+ @Before
+ public void setUpBeforeClass() throws Exception {
+ domain = new DomainNode();
+ serviceContributionUri = domain.addContribution("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ domain.addContribution("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ }
+
+ @Test
+ public void testService() throws Exception {
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testRemovingServiceContribution() throws Exception {
+ domain.removeContribution(serviceContributionUri);
+ try {
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ // FIXME: should this be NoSuchServiceException or ServiceNotFoundException?
+ } catch (NoSuchServiceException e) {
+ // expected
+ }
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (Exception e) {
+ // FIXME: this gives an NPE, would be better to be something like ServiceNotFoundException
+ // expected
+ }
+ }
+
+ @Test
+ public void testStoppingDomainNode() throws Exception {
+ domain.stop();
+ try {
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ fail();
+ } catch (NoSuchDomainException e) {
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (domain != null) {
+ domain.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
index fa16128cc7..4a29822069 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
@@ -1,82 +1,82 @@
-/*
- * 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.domain.node;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import itest.nodes.Helloworld;
-
-import java.net.URI;
-
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-/**
- * This shows how to test the Calculator service component.
- */
-@Ignore("TUSCANY-3391")
-public class StopStartNodesTestCase{
-
- private static DomainNode clientNode;
- private static DomainNode serviceNode;
-
- @Test
- public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
-
- Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
- assertNotNull(service);
- assertEquals("Hello Petra", service.sayHello("Petra"));
-
- Helloworld client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
-
- serviceNode.stop();
-
- client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- try {
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- fail();
- } catch (Exception e) {
- // expected
- }
-
- serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
- client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
- assertNotNull(client);
- assertEquals("Hi Hello Petra", client.sayHello("Petra"));
- }
-
- @After
- public void tearDownAfterClass() throws Exception {
- if (clientNode != null) {
- clientNode.stop();
- }
- if (serviceNode != null) {
- serviceNode.stop();
- }
- }
-}
+/*
+ * 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class StopStartNodesTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ serviceNode.stop();
+
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (Exception e) {
+ // expected
+ }
+
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
index 78e76810e9..1eb7e48b76 100644
--- a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
+++ b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
@@ -1,235 +1,235 @@
-/*
- * 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.something;
-
-import java.io.Reader;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.deployment.Deployer;
-import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.oasisopen.sca.NoSuchServiceException;
-
-public interface Section10 {
-
- /**
- * 4577 10.5.1 install Contribution & update Contribution
- * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
- * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
- * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
- * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
- * 4582 of the contribution.
- * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
- * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
- * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
- * 4586 from each one.
- * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
- * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
- * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
- * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
- * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
- * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
- * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
- * 4594 the dependent contribution list.
- * 4595 [ASM12009]
- * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
- * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
- * 4598 this list to be generated by tooling. *
- * @param uri
- * @param contributionURL
- * @throws ContributionReadException
- * @throws ActivationException
- * @throws ValidationException
- */
- void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
- void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
-
- /* Useful short forms of that for when you don't care or have the others (but leave out for now to keep as simple as possible):
- String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
- void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
- String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException;
- */
-
- /**
- * 4577 10.5.1 install Contribution & update Contribution
- * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
- * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
- * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
- * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
- * 4582 of the contribution.
- * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
- * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
- * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
- * 4586 from each one.
- * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
- * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
- * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
- * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
- * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
- * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
- * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
- * 4594 the dependent contribution list.
- * 4595 [ASM12009]
- * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
- * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
- * 4598 this list to be generated by tooling.
- *
- * @param uri
- * @param contributionURL
- */
- void updateContribution(String uri, String contributionURL);
- void updateContribution(Contribution contribution);
-
- /**
- * 4599 10.5.2 add Deployment Composite & update Deployment Composite
- * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" – a data
- * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
- * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
- * 4603 attribute of the composite, with a “.composite” suffix. Since all composites run within the context of a
- * 4604 installed contribution (any component implementations or other definitions are resolved within that
- * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
- * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
- * 4607 contents of the root contribution.
- * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
- * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
- * 4610 into the installed contribution, without having to modify the packaging. *
- *
- * @param uri
- * @param compositeXML
- * @return
- * @throws XMLStreamException
- * @throws ContributionReadException
- * @throws ActivationException
- * @throws ValidationException
- */
- String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
- String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException;
-
- /**
- * 4599 10.5.2 add Deployment Composite & update Deployment Composite
- * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" – a data
- * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
- * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
- * 4603 attribute of the composite, with a “.composite” suffix. Since all composites run within the context of a
- * 4604 installed contribution (any component implementations or other definitions are resolved within that
- * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
- * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
- * 4607 contents of the root contribution.
- * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
- * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
- * 4610 into the installed contribution, without having to modify the packaging. *
- *
- * @param uri
- * @param compositeXML
- * @return
- */
- String updateDeploymentComposite(String uri, Reader compositeXML);
- String updateDeploymentComposite(String uri, Composite composite);
-
- /**
- * 4611 11.4.310.5.3 remove Contribution
- * 4612 Removes the deployed contribution identified by a supplied contribution URI.
- *
- * @param contributionURI
- * @return List of contribution URIs (includes dependent contributions) which were removed
- * @throws ActivationException
- */
- List<String> removeContribution(String contributionURI) throws ActivationException;
-
- /**
- * 4677 10.7.1 add To Domain-Level Composite
- * 4678 This functionality adds the composite identified by a supplied URI to the Domain Level Composite. The
- * 4679 supplied composite URI refers to a composite within an installed contribution. The composite's installed
- * 4680 contribution determines how the composite’s artifacts are resolved (directly and indirectly). The supplied
- * 4681 composite is added to the domain composite with semantics that correspond to the domain-level
- * 4683 components become top-level components and the component services become externally visible
- * 4684 services (eg. they would be present in a WSDL description of the Domain). The meaning of any promoted
- * 4685 services and references in the supplied composite is not defined; since there is no composite scope
- * 4686 outside the domain composite, the usual idea of promotion has no utility.
- *
- * @param compositeURI
- * @throws ActivationException
- */
- void addToDomainLevelComposite(String compositeURI) throws ActivationException;
-
- /**
- * 4687 10.7.2 remove From Domain-Level Composite
- * 4688 Removes from the Domain Level composite the elements corresponding to the composite identified by a
- * 4689 supplied composite URI. This means that the removal of the components, wires, services and references
- * 4690 originally added to the domain level composite by the identified composite. *
- * @param compositeURI
- * @throws ActivationException
- */
- void removeFromDomainLevelComposite(String compositeURI) throws ActivationException;
-
- /**
- * 10.7.3 get Domain-Level Composite
- * Returns a <composite> definition that has an <include> line for each composite that had been added to
- * the domain level composite. It is important to note that, in dereferencing the included composites, any
- * referenced artifacts are resolved in terms of that installed composite.
- *
- * @return
- */
- Composite getDomainLevelComposite();
-
- /* that previous one returns a Composte object but not sure what would be most appropriate, and having one return a string seems convenient: */
- String getDomainLevelCompositeAsString();
-
- /**
- * 4695 10.7.4 get QName Definition
- * 4696 In order to make sense of the domain-level composite (as returned by get Domain-Level Composite), it
- * 4697 needs to be possible to get the definitions for named artifacts in the included composites. This
- * 4698 functionality takes the supplied URI of an installed contribution (which provides the context), a supplied
- * 4699 qualified name of a definition to look up, and a supplied symbol space (as a QName, e.g.
- * 4700 wsdl:PortTypeportType). The result is a single definition, in whatever form is appropriate for that
- * 4701 definition type.
- * 4702 Note that this, like all the other domain-level operations, is a conceptual operation. Its capabilities need to
- * 4703 exist in some form, but not necessarily as a service operation with exactly this signature. *
- * @param contributionURI
- * @param definition
- * @param symbolSpace
- * @return
- */
- Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace);
-
- /**
- * Probably want to be able to stop it all at once so a method called stop or shutdown or destroy
- * though i guess it could be argued that this method may be somewhere else
- * @throws ActivationException
- */
- void shutdown() throws ActivationException;
-
- /**
- * Would also be convenient to get service proxys as from SCAClientFactory
- */
- <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException;
-
- /* do we also need these following ones that are mentioned only indirectly in the spec? */
-
- List<String> getDeployedCompostes(String contributionURI);
- List<String> getInstalledContributions();
- Deployer getDeployer();
-}
+/*
+ * 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.something;
+
+import java.io.Reader;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public interface Section10 {
+
+ /**
+ * 4577 10.5.1 install Contribution & update Contribution
+ * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
+ * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
+ * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
+ * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
+ * 4582 of the contribution.
+ * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
+ * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
+ * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
+ * 4586 from each one.
+ * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
+ * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
+ * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
+ * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
+ * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
+ * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
+ * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
+ * 4594 the dependent contribution list.
+ * 4595 [ASM12009]
+ * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
+ * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
+ * 4598 this list to be generated by tooling. *
+ * @param uri
+ * @param contributionURL
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
+ void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
+
+ /* Useful short forms of that for when you don't care or have the others (but leave out for now to keep as simple as possible):
+ String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
+ void installContribution(String uri, String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
+ String installContribution(String contributionURL, boolean autoDeploy) throws ContributionReadException, ActivationException, ValidationException;
+ */
+
+ /**
+ * 4577 10.5.1 install Contribution & update Contribution
+ * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
+ * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
+ * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
+ * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
+ * 4582 of the contribution.
+ * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
+ * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
+ * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
+ * 4586 from each one.
+ * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
+ * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
+ * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
+ * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
+ * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
+ * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
+ * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
+ * 4594 the dependent contribution list.
+ * 4595 [ASM12009]
+ * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
+ * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
+ * 4598 this list to be generated by tooling.
+ *
+ * @param uri
+ * @param contributionURL
+ */
+ void updateContribution(String uri, String contributionURL);
+ void updateContribution(Contribution contribution);
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" – a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a “.composite” suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param uri
+ * @param compositeXML
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
+ String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException;
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" – a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a “.composite” suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param uri
+ * @param compositeXML
+ * @return
+ */
+ String updateDeploymentComposite(String uri, Reader compositeXML);
+ String updateDeploymentComposite(String uri, Composite composite);
+
+ /**
+ * 4611 11.4.310.5.3 remove Contribution
+ * 4612 Removes the deployed contribution identified by a supplied contribution URI.
+ *
+ * @param contributionURI
+ * @return List of contribution URIs (includes dependent contributions) which were removed
+ * @throws ActivationException
+ */
+ List<String> removeContribution(String contributionURI) throws ActivationException;
+
+ /**
+ * 4677 10.7.1 add To Domain-Level Composite
+ * 4678 This functionality adds the composite identified by a supplied URI to the Domain Level Composite. The
+ * 4679 supplied composite URI refers to a composite within an installed contribution. The composite's installed
+ * 4680 contribution determines how the composite’s artifacts are resolved (directly and indirectly). The supplied
+ * 4681 composite is added to the domain composite with semantics that correspond to the domain-level
+ * 4683 components become top-level components and the component services become externally visible
+ * 4684 services (eg. they would be present in a WSDL description of the Domain). The meaning of any promoted
+ * 4685 services and references in the supplied composite is not defined; since there is no composite scope
+ * 4686 outside the domain composite, the usual idea of promotion has no utility.
+ *
+ * @param compositeURI
+ * @throws ActivationException
+ */
+ void addToDomainLevelComposite(String compositeURI) throws ActivationException;
+
+ /**
+ * 4687 10.7.2 remove From Domain-Level Composite
+ * 4688 Removes from the Domain Level composite the elements corresponding to the composite identified by a
+ * 4689 supplied composite URI. This means that the removal of the components, wires, services and references
+ * 4690 originally added to the domain level composite by the identified composite. *
+ * @param compositeURI
+ * @throws ActivationException
+ */
+ void removeFromDomainLevelComposite(String compositeURI) throws ActivationException;
+
+ /**
+ * 10.7.3 get Domain-Level Composite
+ * Returns a <composite> definition that has an <include> line for each composite that had been added to
+ * the domain level composite. It is important to note that, in dereferencing the included composites, any
+ * referenced artifacts are resolved in terms of that installed composite.
+ *
+ * @return
+ */
+ Composite getDomainLevelComposite();
+
+ /* that previous one returns a Composte object but not sure what would be most appropriate, and having one return a string seems convenient: */
+ String getDomainLevelCompositeAsString();
+
+ /**
+ * 4695 10.7.4 get QName Definition
+ * 4696 In order to make sense of the domain-level composite (as returned by get Domain-Level Composite), it
+ * 4697 needs to be possible to get the definitions for named artifacts in the included composites. This
+ * 4698 functionality takes the supplied URI of an installed contribution (which provides the context), a supplied
+ * 4699 qualified name of a definition to look up, and a supplied symbol space (as a QName, e.g.
+ * 4700 wsdl:PortTypeportType). The result is a single definition, in whatever form is appropriate for that
+ * 4701 definition type.
+ * 4702 Note that this, like all the other domain-level operations, is a conceptual operation. Its capabilities need to
+ * 4703 exist in some form, but not necessarily as a service operation with exactly this signature. *
+ * @param contributionURI
+ * @param definition
+ * @param symbolSpace
+ * @return
+ */
+ Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace);
+
+ /**
+ * Probably want to be able to stop it all at once so a method called stop or shutdown or destroy
+ * though i guess it could be argued that this method may be somewhere else
+ * @throws ActivationException
+ */
+ void shutdown() throws ActivationException;
+
+ /**
+ * Would also be convenient to get service proxys as from SCAClientFactory
+ */
+ <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException;
+
+ /* do we also need these following ones that are mentioned only indirectly in the spec? */
+
+ List<String> getDeployedCompostes(String contributionURI);
+ List<String> getInstalledContributions();
+ Deployer getDeployer();
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
index 8822af178e..0849b70dea 100644
--- a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
+++ b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
@@ -1,97 +1,97 @@
-/*
- * 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.something;
-
-import java.util.Properties;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-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.ModuleActivatorExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
-import org.apache.tuscany.sca.deployment.Deployer;
-import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
-import org.apache.tuscany.sca.runtime.RuntimeProperties;
-import org.apache.tuscany.sca.something.impl.Section10Impl;
-import org.apache.tuscany.sca.work.WorkScheduler;
-
-public class Section10Factory {
-
- private Deployer deployer;
- private ExtensionPointRegistry extensionPointRegistry;
- private CompositeActivator compositeActivator;
- private ExtensibleDomainRegistryFactory domainRegistryFactory;
-
- // TODO: keep this method?
- public static Section10 createSection10() {
- return new Section10Factory().createSection10("default");
- }
-
- public Section10Factory() {
- init(null);
- }
-
- public Section10Factory(Properties config) {
- init(config);
- }
-
- public Section10 createSection10(String domainName) {
- EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", domainName);
- return new Section10Impl(domainName, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
- }
-
- public void shutdown() {
- deployer.stop();
- extensionPointRegistry.stop();
- }
-
- protected void init(Properties config) {
- if (config == null) {
- config = new Properties();
- config.setProperty("defaultScheme", "vm");
- config.setProperty("defaultDomainName", "default");
- }
- this.extensionPointRegistry = new DefaultExtensionPointRegistry();
- extensionPointRegistry.start();
-
- FactoryExtensionPoint modelFactories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
- modelFactories.addFactory(assemblyFactory);
-
- UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
- this.compositeActivator = utilities.getUtility(CompositeActivator.class);
- this.deployer = utilities.getUtility(Deployer.class);
- utilities.getUtility(RuntimeProperties.class).setProperties(config);
- utilities.getUtility(WorkScheduler.class);
-
- // Initialize the Tuscany module activators
- // The module activators will be started
- extensionPointRegistry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
-
- this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
-// DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
-// domainRegistryFactory.getEndpointRegistry(config.getProperty("reguri"), config.getProperty("defaultDomainName"));
-
- }
-}
+/*
+ * 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.something;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.ModuleActivatorExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.apache.tuscany.sca.something.impl.Section10Impl;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class Section10Factory {
+
+ private Deployer deployer;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private CompositeActivator compositeActivator;
+ private ExtensibleDomainRegistryFactory domainRegistryFactory;
+
+ // TODO: keep this method?
+ public static Section10 createSection10() {
+ return new Section10Factory().createSection10("default");
+ }
+
+ public Section10Factory() {
+ init(null);
+ }
+
+ public Section10Factory(Properties config) {
+ init(config);
+ }
+
+ public Section10 createSection10(String domainName) {
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", domainName);
+ return new Section10Impl(domainName, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
+ }
+
+ public void shutdown() {
+ deployer.stop();
+ extensionPointRegistry.stop();
+ }
+
+ protected void init(Properties config) {
+ if (config == null) {
+ config = new Properties();
+ config.setProperty("defaultScheme", "vm");
+ config.setProperty("defaultDomainName", "default");
+ }
+ this.extensionPointRegistry = new DefaultExtensionPointRegistry();
+ extensionPointRegistry.start();
+
+ FactoryExtensionPoint modelFactories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
+ modelFactories.addFactory(assemblyFactory);
+
+ UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+ this.deployer = utilities.getUtility(Deployer.class);
+ utilities.getUtility(RuntimeProperties.class).setProperties(config);
+ utilities.getUtility(WorkScheduler.class);
+
+ // Initialize the Tuscany module activators
+ // The module activators will be started
+ extensionPointRegistry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+
+ this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
+// DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
+// domainRegistryFactory.getEndpointRegistry(config.getProperty("reguri"), config.getProperty("defaultDomainName"));
+
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
index dfd4c9b9ba..6a08a1cfbc 100644
--- a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
+++ b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/DeployedComposite.java
@@ -1,138 +1,138 @@
-/*
- * 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.something.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.contribution.Artifact;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.deployment.Deployer;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-
-public class DeployedComposite {
-
- private String uri;
- private Composite composite;
- private InstalledContribution installedContribution;
- private List<Contribution> dependedOnContributions;
- private Composite domainComposite; // TODO: this is misleadingly named
-
- private CompositeActivator compositeActivator;
- private CompositeContext compositeContext;
- private Deployer deployer;
- private EndpointRegistry endpointRegistry;
- private ExtensionPointRegistry extensionPointRegistry;
-
- public DeployedComposite(Composite composite,
- InstalledContribution ic,
- List<Contribution> dependedOnContributions,
- Deployer deployer,
- CompositeActivator compositeActivator,
- EndpointRegistry endpointRegistry,
- ExtensionPointRegistry extensionPointRegistry) throws ActivationException {
- this.composite = composite;
- this.installedContribution = ic;
- this.dependedOnContributions = dependedOnContributions;
- this.deployer = deployer;
- this.compositeActivator = compositeActivator;
- this.endpointRegistry = endpointRegistry;
- this.extensionPointRegistry = extensionPointRegistry;
- try {
- init();
- } catch (Exception e) {
- throw new ActivationException(e);
- }
- }
-
- protected void init() throws ValidationException, ContributionResolveException, CompositeBuilderException, ActivationException {
-
- List<Contribution> contribution = new ArrayList<Contribution>();
- contribution.add(installedContribution.getContribution());
- contribution.get(0).getDeployables().clear();
- contribution.get(0).getDeployables().add(composite);
-
- Monitor monitor = deployer.createMonitor();
-// TODO: is the ContextMonitor neccessary here?
-// Monitor tcm = monitorFactory.setContextMonitor(monitor);
-// try {
-
- domainComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor);
- monitor.analyzeProblems();
-
-// } finally {
-// monitorFactory.setContextMonitor(tcm);
-// }
-
- compositeContext = new CompositeContext(extensionPointRegistry,
- endpointRegistry,
- domainComposite,
- null, // nothing appears to use the domain name in CompositeContext
- null, // don't need node uri
- deployer.getSystemDefinitions());
-
- CompositeContext.setThreadCompositeContext(compositeContext); // TODO: what is this doing?
-
- compositeActivator.activate(compositeContext, domainComposite);
- compositeActivator.start(compositeContext, domainComposite);
-
- this.uri = getCompositeURI(composite, installedContribution);
- }
-
- public void unDeploy() throws ActivationException {
- compositeActivator.stop(compositeContext, domainComposite);
- compositeActivator.deactivate(domainComposite);
- }
-
- public String getURI() {
- return uri;
- }
-
- /**
- * Deployable composites don't have the uri set so get it from the artifact in the contribution
- * // TODO: fix the Tuscany code so this uri is correctly set and this method isn't needed
- */
- protected String getCompositeURI(Composite c, InstalledContribution ic) {
- for (Artifact a : ic.getContribution().getArtifacts()) {
- if (a.getModel() != null) {
- if (a.getModel() instanceof Composite) {
- Composite cm = a.getModel();
- if (c.getName().equals(cm.getName())) {
- return cm.getURI();
- }
- }
- }
- }
- // shouldn't ever happen
- throw new IllegalStateException("can't determine composte uri");
- }
-}
+/*
+ * 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.something.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+public class DeployedComposite {
+
+ private String uri;
+ private Composite composite;
+ private InstalledContribution installedContribution;
+ private List<Contribution> dependedOnContributions;
+ private Composite domainComposite; // TODO: this is misleadingly named
+
+ private CompositeActivator compositeActivator;
+ private CompositeContext compositeContext;
+ private Deployer deployer;
+ private EndpointRegistry endpointRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+
+ public DeployedComposite(Composite composite,
+ InstalledContribution ic,
+ List<Contribution> dependedOnContributions,
+ Deployer deployer,
+ CompositeActivator compositeActivator,
+ EndpointRegistry endpointRegistry,
+ ExtensionPointRegistry extensionPointRegistry) throws ActivationException {
+ this.composite = composite;
+ this.installedContribution = ic;
+ this.dependedOnContributions = dependedOnContributions;
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.endpointRegistry = endpointRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ try {
+ init();
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ protected void init() throws ValidationException, ContributionResolveException, CompositeBuilderException, ActivationException {
+
+ List<Contribution> contribution = new ArrayList<Contribution>();
+ contribution.add(installedContribution.getContribution());
+ contribution.get(0).getDeployables().clear();
+ contribution.get(0).getDeployables().add(composite);
+
+ Monitor monitor = deployer.createMonitor();
+// TODO: is the ContextMonitor neccessary here?
+// Monitor tcm = monitorFactory.setContextMonitor(monitor);
+// try {
+
+ domainComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor);
+ monitor.analyzeProblems();
+
+// } finally {
+// monitorFactory.setContextMonitor(tcm);
+// }
+
+ compositeContext = new CompositeContext(extensionPointRegistry,
+ endpointRegistry,
+ domainComposite,
+ null, // nothing appears to use the domain name in CompositeContext
+ null, // don't need node uri
+ deployer.getSystemDefinitions());
+
+ CompositeContext.setThreadCompositeContext(compositeContext); // TODO: what is this doing?
+
+ compositeActivator.activate(compositeContext, domainComposite);
+ compositeActivator.start(compositeContext, domainComposite);
+
+ this.uri = getCompositeURI(composite, installedContribution);
+ }
+
+ public void unDeploy() throws ActivationException {
+ compositeActivator.stop(compositeContext, domainComposite);
+ compositeActivator.deactivate(domainComposite);
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Deployable composites don't have the uri set so get it from the artifact in the contribution
+ * // TODO: fix the Tuscany code so this uri is correctly set and this method isn't needed
+ */
+ protected String getCompositeURI(Composite c, InstalledContribution ic) {
+ for (Artifact a : ic.getContribution().getArtifacts()) {
+ if (a.getModel() != null) {
+ if (a.getModel() instanceof Composite) {
+ Composite cm = a.getModel();
+ if (c.getName().equals(cm.getName())) {
+ return cm.getURI();
+ }
+ }
+ }
+ }
+ // shouldn't ever happen
+ throw new IllegalStateException("can't determine composte uri");
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java
index 69dc9e6992..fe8c6812ae 100644
--- a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java
+++ b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/InstalledContribution.java
@@ -1,60 +1,60 @@
-/*
- * 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.something.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.Contribution;
-
-public class InstalledContribution {
-
- private String uri;
- private String url;
- private Contribution contribution;
- private List<Composite> defaultDeployables = new ArrayList<Composite>();
- private List<DeployedComposite> deployedComposites = new ArrayList<DeployedComposite>();
-
- public InstalledContribution(String uri, String url, Contribution contribution) {
- this.uri = uri;
- this.url = url;
- this.contribution = contribution;
- this.defaultDeployables = contribution.getDeployables();
- }
- public Contribution getContribution() {
- return contribution;
- }
- public void setContribution(Contribution contribution) {
- this.contribution = contribution;
- }
- public String getURI() {
- return uri;
- }
- public String getURL() {
- return url;
- }
- public List<Composite> getDefaultDeployables() {
- return defaultDeployables;
- }
- public List<DeployedComposite> getDeployedComposites() {
- return deployedComposites;
- }
-}
+/*
+ * 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.something.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+
+public class InstalledContribution {
+
+ private String uri;
+ private String url;
+ private Contribution contribution;
+ private List<Composite> defaultDeployables = new ArrayList<Composite>();
+ private List<DeployedComposite> deployedComposites = new ArrayList<DeployedComposite>();
+
+ public InstalledContribution(String uri, String url, Contribution contribution) {
+ this.uri = uri;
+ this.url = url;
+ this.contribution = contribution;
+ this.defaultDeployables = contribution.getDeployables();
+ }
+ public Contribution getContribution() {
+ return contribution;
+ }
+ public void setContribution(Contribution contribution) {
+ this.contribution = contribution;
+ }
+ public String getURI() {
+ return uri;
+ }
+ public String getURL() {
+ return url;
+ }
+ public List<Composite> getDefaultDeployables() {
+ return defaultDeployables;
+ }
+ public List<DeployedComposite> getDeployedComposites() {
+ return deployedComposites;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
index 55b716e5a6..15cc714896 100644
--- a/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
+++ b/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
@@ -1,278 +1,278 @@
-/*
- * 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.something.impl;
-
-import java.io.Reader;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.common.java.io.IOHelper;
-import org.apache.tuscany.sca.contribution.Artifact;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ContributionMetadata;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.deployment.Deployer;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.something.Section10;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-public class Section10Impl implements Section10 {
-
- private String domainName;
- private Deployer deployer;
- private Map<String, InstalledContribution> installedContributions = new HashMap<String, InstalledContribution>();
- private CompositeActivator compositeActivator;
- private EndpointRegistry endpointRegistry;
- private ExtensionPointRegistry extensionPointRegistry;
-
- public Section10Impl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry) {
- this.domainName = domainName;
- this.deployer = deployer;
- this.compositeActivator = compositeActivator;
- this.endpointRegistry = endpointRegistry;
- this.extensionPointRegistry = extensionPointRegistry;
- }
-
- public void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
- Monitor monitor = deployer.createMonitor();
- Contribution contribution = deployer.loadContribution(URI.create(uri), IOHelper.getLocationAsURL(contributionURL), monitor);
- monitor.analyzeProblems();
- if (metaDataURL != null) {
- mergeContributionMetaData(metaDataURL, contribution);
- }
- installContribution(contribution, dependentContributionURIs, deployDeployables);
- }
-
- private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
- ContributionMetadata metaData;
- Monitor monitor = deployer.createMonitor();
- try {
- metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
- } catch (Exception e) {
- throw new ValidationException(e);
- }
- monitor.analyzeProblems();
- contribution.getDeployables().addAll(metaData.getDeployables());
- contribution.getImports().addAll(metaData.getImports());
- contribution.getExports().addAll(metaData.getExports());
- }
-
- public void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
- // TODO: dependentContributionURIs
- InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution);
- installedContributions.put(contribution.getURI(), ic);
- if (deployDeployables) {
- for (Composite c : ic.getDefaultDeployables()) {
- deployComposite(c, ic);
- }
- }
- }
-
- public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException {
- Monitor monitor = deployer.createMonitor();
- Composite composite = deployer.loadXMLDocument(compositeXML, monitor);
- monitor.analyzeProblems();
- return addDeploymentComposite(contributionURI, composite);
- }
-
- public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException {
- InstalledContribution ic = installedContributions.get(contributionURI);
- if (ic == null) {
- throw new IllegalArgumentException("contribution not installed: " + contributionURI);
- }
- String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
- deployComposite(composite, ic);
- return compositeArtifcatURI;
- }
-
- public void addToDomainLevelComposite(String compositeURI) throws ActivationException {
- String contributionURI = getContributionUriForArtifact(compositeURI);
- InstalledContribution ic = installedContributions.get(contributionURI);
- if (ic == null) {
- throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
- }
- String relativeURI = compositeURI.substring(contributionURI.length()+1);
- for (Artifact a : ic.getContribution().getArtifacts()) {
- if (a.getURI().equals(relativeURI)) {
- deployComposite((Composite) a.getModel(), ic);
- return;
- }
- }
- throw new IllegalArgumentException("composite not found: " + compositeURI);
- }
-
- public void removeFromDomainLevelComposite(String compositeURI) throws ActivationException {
- String contributionURI = getContributionUriForArtifact(compositeURI);
- InstalledContribution ic = installedContributions.get(contributionURI);
- String relativeURI = compositeURI.substring(contributionURI.length()+1);
- for (DeployedComposite dc : ic.getDeployedComposites()) {
- if (relativeURI.equals(dc.getURI())) {
- ic.getDeployedComposites().remove(dc);
- dc.unDeploy();
- return;
- }
- }
- throw new IllegalStateException("composite not deployed: " + compositeURI);
- }
-
- public Composite getDomainLevelComposite() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getDomainLevelCompositeAsString() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<String> removeContribution(String contributionURI) throws ActivationException {
- List<String> removedContributionURIs = new ArrayList<String>();
- InstalledContribution ic = installedContributions.get(contributionURI);
- if (ic != null) {
- removedContributionURIs.add(ic.getURI());
- for (String dependent : getDependentContributions(contributionURI)) {
- removedContributionURIs.addAll(removeContribution(dependent));
- }
- installedContributions.remove(contributionURI);
- for (DeployedComposite dc : ic.getDeployedComposites()) {
- dc.unDeploy();
- }
- ic.getDeployedComposites().clear();
- }
- return removedContributionURIs;
- }
-
- public void updateContribution(String uri, String contributionURL) {
- // TODO Auto-generated method stub
- // is this just removeContribution/installContribution?
- }
- public void updateContribution(Contribution contribution) {
- // TODO Auto-generated method stub
- }
-
- public String updateDeploymentComposite(String uri, Reader compositeXML) {
- // TODO Auto-generated method stub
- // is this removeFromDomainLevelComposite/addDeploymentComposite
- return null;
- }
- public String updateDeploymentComposite(String uri, Composite composite) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void shutdown() throws ActivationException {
- for (String uri : installedContributions.keySet()) {
- removeContribution(uri);
- }
- }
-
- public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
- try {
- return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, serviceURI);
- } catch (NoSuchDomainException e) {
- // shouldn't ever happen as we know this is the domain so it must exist
- throw new IllegalStateException(e);
- }
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public List<String> getDeployedCompostes(String contributionURI) {
- ArrayList<String> compositeURIs = new ArrayList<String>();
- for (InstalledContribution ic : installedContributions.values()) {
- for (DeployedComposite dc : ic.getDeployedComposites()) {
- compositeURIs.add(ic.getURI() + "/" + dc.getURI());
- }
- }
- return compositeURIs;
- }
-
- public List<String> getInstalledContributions() {
- return new ArrayList<String>(installedContributions.keySet());
- }
-
- protected String getContributionUriForArtifact(String artifactURI) {
- String contributionURI = null;
- for (String uri : installedContributions.keySet()) {
- if (artifactURI.startsWith(uri)) {
- contributionURI = uri;
- break;
- }
- }
- if (contributionURI == null) {
- throw new IllegalArgumentException("no contribution found for: " + artifactURI);
- }
- return contributionURI;
- }
-
- protected void deployComposite(Composite c, InstalledContribution ic) throws ActivationException {
- List<Contribution> dependentContributions = new ArrayList<Contribution>();
- for (InstalledContribution ics : installedContributions.values()) {
- dependentContributions.add(ics.getContribution());
- }
-
- DeployedComposite dc = new DeployedComposite(c, ic, dependentContributions, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
- ic.getDeployedComposites().add(dc);
- }
-
- public Set<String> getDependentContributions(String contributionURI) {
- InstalledContribution ic = installedContributions.get(contributionURI);
- if (ic == null) {
- throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
- }
- Set<String> dependentContributionURIs = new HashSet<String>();
- for (InstalledContribution icx : installedContributions.values()) {
- if (ic != icx) {
- List<Contribution> dependencies = icx.getContribution().getDependencies();
- if (dependencies != null && dependencies.contains(ic.getContribution())) {
- dependentContributionURIs.addAll(getDependentContributions(icx.getURI()));
- }
- }
- }
- return dependentContributionURIs;
- }
-
- public Deployer getDeployer() {
- return deployer;
- }
-}
+/*
+ * 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.something.impl;
+
+import java.io.Reader;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.something.Section10;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class Section10Impl implements Section10 {
+
+ private String domainName;
+ private Deployer deployer;
+ private Map<String, InstalledContribution> installedContributions = new HashMap<String, InstalledContribution>();
+ private CompositeActivator compositeActivator;
+ private EndpointRegistry endpointRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+
+ public Section10Impl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry) {
+ this.domainName = domainName;
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.endpointRegistry = endpointRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ }
+
+ public void installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(URI.create(uri), IOHelper.getLocationAsURL(contributionURL), monitor);
+ monitor.analyzeProblems();
+ if (metaDataURL != null) {
+ mergeContributionMetaData(metaDataURL, contribution);
+ }
+ installContribution(contribution, dependentContributionURIs, deployDeployables);
+ }
+
+ private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
+ ContributionMetadata metaData;
+ Monitor monitor = deployer.createMonitor();
+ try {
+ metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
+ } catch (Exception e) {
+ throw new ValidationException(e);
+ }
+ monitor.analyzeProblems();
+ contribution.getDeployables().addAll(metaData.getDeployables());
+ contribution.getImports().addAll(metaData.getImports());
+ contribution.getExports().addAll(metaData.getExports());
+ }
+
+ public void installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException {
+ // TODO: dependentContributionURIs
+ InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution);
+ installedContributions.put(contribution.getURI(), ic);
+ if (deployDeployables) {
+ for (Composite c : ic.getDefaultDeployables()) {
+ deployComposite(c, ic);
+ }
+ }
+ }
+
+ public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException {
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(compositeXML, monitor);
+ monitor.analyzeProblems();
+ return addDeploymentComposite(contributionURI, composite);
+ }
+
+ public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("contribution not installed: " + contributionURI);
+ }
+ String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
+ deployComposite(composite, ic);
+ return compositeArtifcatURI;
+ }
+
+ public void addToDomainLevelComposite(String compositeURI) throws ActivationException {
+ String contributionURI = getContributionUriForArtifact(compositeURI);
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ String relativeURI = compositeURI.substring(contributionURI.length()+1);
+ for (Artifact a : ic.getContribution().getArtifacts()) {
+ if (a.getURI().equals(relativeURI)) {
+ deployComposite((Composite) a.getModel(), ic);
+ return;
+ }
+ }
+ throw new IllegalArgumentException("composite not found: " + compositeURI);
+ }
+
+ public void removeFromDomainLevelComposite(String compositeURI) throws ActivationException {
+ String contributionURI = getContributionUriForArtifact(compositeURI);
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ String relativeURI = compositeURI.substring(contributionURI.length()+1);
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ if (relativeURI.equals(dc.getURI())) {
+ ic.getDeployedComposites().remove(dc);
+ dc.unDeploy();
+ return;
+ }
+ }
+ throw new IllegalStateException("composite not deployed: " + compositeURI);
+ }
+
+ public Composite getDomainLevelComposite() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getDomainLevelCompositeAsString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> removeContribution(String contributionURI) throws ActivationException {
+ List<String> removedContributionURIs = new ArrayList<String>();
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic != null) {
+ removedContributionURIs.add(ic.getURI());
+ for (String dependent : getDependentContributions(contributionURI)) {
+ removedContributionURIs.addAll(removeContribution(dependent));
+ }
+ installedContributions.remove(contributionURI);
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ dc.unDeploy();
+ }
+ ic.getDeployedComposites().clear();
+ }
+ return removedContributionURIs;
+ }
+
+ public void updateContribution(String uri, String contributionURL) {
+ // TODO Auto-generated method stub
+ // is this just removeContribution/installContribution?
+ }
+ public void updateContribution(Contribution contribution) {
+ // TODO Auto-generated method stub
+ }
+
+ public String updateDeploymentComposite(String uri, Reader compositeXML) {
+ // TODO Auto-generated method stub
+ // is this removeFromDomainLevelComposite/addDeploymentComposite
+ return null;
+ }
+ public String updateDeploymentComposite(String uri, Composite composite) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void shutdown() throws ActivationException {
+ for (String uri : installedContributions.keySet()) {
+ removeContribution(uri);
+ }
+ }
+
+ public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
+ try {
+ return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, serviceURI);
+ } catch (NoSuchDomainException e) {
+ // shouldn't ever happen as we know this is the domain so it must exist
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public List<String> getDeployedCompostes(String contributionURI) {
+ ArrayList<String> compositeURIs = new ArrayList<String>();
+ for (InstalledContribution ic : installedContributions.values()) {
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ compositeURIs.add(ic.getURI() + "/" + dc.getURI());
+ }
+ }
+ return compositeURIs;
+ }
+
+ public List<String> getInstalledContributions() {
+ return new ArrayList<String>(installedContributions.keySet());
+ }
+
+ protected String getContributionUriForArtifact(String artifactURI) {
+ String contributionURI = null;
+ for (String uri : installedContributions.keySet()) {
+ if (artifactURI.startsWith(uri)) {
+ contributionURI = uri;
+ break;
+ }
+ }
+ if (contributionURI == null) {
+ throw new IllegalArgumentException("no contribution found for: " + artifactURI);
+ }
+ return contributionURI;
+ }
+
+ protected void deployComposite(Composite c, InstalledContribution ic) throws ActivationException {
+ List<Contribution> dependentContributions = new ArrayList<Contribution>();
+ for (InstalledContribution ics : installedContributions.values()) {
+ dependentContributions.add(ics.getContribution());
+ }
+
+ DeployedComposite dc = new DeployedComposite(c, ic, dependentContributions, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
+ ic.getDeployedComposites().add(dc);
+ }
+
+ public Set<String> getDependentContributions(String contributionURI) {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ Set<String> dependentContributionURIs = new HashSet<String>();
+ for (InstalledContribution icx : installedContributions.values()) {
+ if (ic != icx) {
+ List<Contribution> dependencies = icx.getContribution().getDependencies();
+ if (dependencies != null && dependencies.contains(ic.getContribution())) {
+ dependentContributionURIs.addAll(getDependentContributions(icx.getURI()));
+ }
+ }
+ }
+ return dependentContributionURIs;
+ }
+
+ public Deployer getDeployer() {
+ return deployer;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java b/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
index b07a70b950..a3daf4a5c6 100644
--- a/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
@@ -1,75 +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 org.apache.tuscany.sca.something;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.List;
-
-import javax.xml.stream.XMLStreamException;
-
-import junit.framework.Assert;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.deployment.Deployer;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.junit.Test;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-
-public class DeployerTestCase {
-
- @Test
- public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
- Section10 section10 = Section10Factory.createSection10();
-
- Deployer deployer = section10.getDeployer();
- Monitor monitor = deployer.createMonitor();
- Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
- monitor.analyzeProblems();
-
- section10.installContribution(contribution, null, true);
- List<String> ics = section10.getInstalledContributions();
- Assert.assertEquals(1, ics.size());
- Assert.assertEquals("foo", ics.get(0));
- }
-
- @Test
- public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
- Section10 section10 = Section10Factory.createSection10();
-
- section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
-
- Deployer deployer = section10.getDeployer();
- Monitor monitor = deployer.createMonitor();
- Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
- monitor.analyzeProblems();
- composite.setURI("helloworld2.composite");
- section10.addDeploymentComposite("foo", composite);
- List<String> dcs = section10.getDeployedCompostes("foo");
- Assert.assertEquals(1, dcs.size());
- Assert.assertEquals("foo/helloworld2.composite", dcs.get(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 org.apache.tuscany.sca.something;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class DeployerTestCase {
+
+ @Test
+ public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
+ Section10 section10 = Section10Factory.createSection10();
+
+ Deployer deployer = section10.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+
+ section10.installContribution(contribution, null, true);
+ List<String> ics = section10.getInstalledContributions();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
+ Section10 section10 = Section10Factory.createSection10();
+
+ section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+
+ Deployer deployer = section10.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+ composite.setURI("helloworld2.composite");
+ section10.addDeploymentComposite("foo", composite);
+ List<String> dcs = section10.getDeployedCompostes("foo");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("foo/helloworld2.composite", dcs.get(0));
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java b/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
index e0ec581157..373421adc1 100644
--- a/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
+++ b/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
@@ -1,114 +1,114 @@
-/*
- * 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.something;
-
-import java.net.MalformedURLException;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.monitor.ValidationException;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.apache.tuscany.sca.something.impl.Section10Impl;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-
-public class Section10TestCase {
-
- @Test
- public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
-
-// Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
-// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
- }
-
- @Ignore("TODO: fails with Sun JDK due to SCA properties issue")
- @Test
- public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar", null, null, true);
- section10.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
-
-// Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
-// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
- }
-
- @Test
- public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
-
-// SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
-// try {
-// scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
-// Assert.fail();
-// } catch (NoSuchServiceException e) {
-// // expected as there is no deployables
-// }
-
- section10.addToDomainLevelComposite("helloworld" + "/helloworld.composite");
-// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
-// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
- }
-
- @Test
- public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
- List<String> ics = section10.getInstalledContributions();
- Assert.assertEquals(1, ics.size());
- Assert.assertEquals("foo", ics.get(0));
- }
-
- @Test
- public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
- List<String> dcs = section10.getDeployedCompostes("foo");
- Assert.assertEquals(1, dcs.size());
- Assert.assertEquals("foo/helloworld.composite", dcs.get(0));
- }
-
- @Test
- public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
- section10.removeFromDomainLevelComposite("foo/helloworld.composite");
- List<String> dcs = section10.getDeployedCompostes("foo");
- Assert.assertEquals(0, dcs.size());
- }
-
- @Test
- public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException {
- Section10 section10 = Section10Factory.createSection10();
- ((Section10Impl)section10).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
-
- List<String> dcs = section10.getDeployedCompostes("helloworld");
- Assert.assertEquals(1, dcs.size());
- Assert.assertEquals("helloworld/helloworld.composite", dcs.get(0));
-
-// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
-// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
- }
-}
+/*
+ * 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.something;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.something.impl.Section10Impl;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class Section10TestCase {
+
+ @Test
+ public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
+
+// Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Ignore("TODO: fails with Sun JDK due to SCA properties issue")
+ @Test
+ public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar", null, null, true);
+ section10.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
+
+// Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+
+// SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
+// try {
+// scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.fail();
+// } catch (NoSuchServiceException e) {
+// // expected as there is no deployables
+// }
+
+ section10.addToDomainLevelComposite("helloworld" + "/helloworld.composite");
+// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+ List<String> ics = section10.getInstalledContributions();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+ List<String> dcs = section10.getDeployedCompostes("foo");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("foo/helloworld.composite", dcs.get(0));
+ }
+
+ @Test
+ public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+ section10.removeFromDomainLevelComposite("foo/helloworld.composite");
+ List<String> dcs = section10.getDeployedCompostes("foo");
+ Assert.assertEquals(0, dcs.size());
+ }
+
+ @Test
+ public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException {
+ Section10 section10 = Section10Factory.createSection10();
+ ((Section10Impl)section10).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
+
+ List<String> dcs = section10.getDeployedCompostes("helloworld");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld/helloworld.composite", dcs.get(0));
+
+// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/test/java/sample/Helloworld.java b/sca-java-2.x/trunk/modules/domain/src/test/java/sample/Helloworld.java
index 438804975e..ea65a1e58c 100644
--- a/sca-java-2.x/trunk/modules/domain/src/test/java/sample/Helloworld.java
+++ b/sca-java-2.x/trunk/modules/domain/src/test/java/sample/Helloworld.java
@@ -1,24 +1,24 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package sample;
-
-public interface Helloworld {
- String sayHello(String name);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample;
+
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml b/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
index 5b3d81cb97..8e20561dc3 100644
--- a/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
+++ b/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
@@ -1,23 +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:helloworld"/>
-</contribution>
+<?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:helloworld"/>
+</contribution>
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/pom.xml b/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/pom.xml
index be52242073..7553c09045 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/pom.xml
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/pom.xml
@@ -1,45 +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.
--->
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
- <name>Apache Tuscany SCA EndPoint Registry using Hazelcast Native Client</name>
-
- <dependencies>
- <dependency>
- <groupId>com.hazelcast</groupId>
- <artifactId>hazelcast-client</artifactId>
- <version>1.8.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-endpoint-hazelcast</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <name>Apache Tuscany SCA EndPoint Registry using Hazelcast Native Client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast-client</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java
index 78b06f0adc..8b9e49ecd3 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java
@@ -1,120 +1,120 @@
-/*
- * 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.endpoint.hazelcast.client;
-
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.ServerSocket;
-import java.util.Enumeration;
-import java.util.Map;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
-import org.apache.tuscany.sca.endpoint.hazelcast.RegistryConfig;
-import org.apache.tuscany.sca.runtime.RuntimeProperties;
-
-import com.hazelcast.client.HazelcastClient;
-import com.hazelcast.core.HazelcastInstance;
-
-/**
- * An EndpointRegistry using a Hazelcast Native Client
- */
-public class HazelcastClientEndpointRegistry extends HazelcastEndpointRegistry {
-
- HazelcastClient hazelcastClient;
-
- public HazelcastClientEndpointRegistry(ExtensionPointRegistry registry,
- Map<String, String> attributes,
- String domainRegistryURI,
- String domainURI) {
- super(registry, attributes, domainRegistryURI, domainURI);
- }
-
- @Override
- public void start() {
- if (endpointMap != null) {
- throw new IllegalStateException("The registry has already been started");
- }
- initHazelcastClientInstance();
- endpointMap = hazelcastClient.getMap(domainURI + "/Endpoints");
- endpointOwners = hazelcastClient.getMultiMap(domainURI + "/EndpointOwners");
- }
-
- @Override
- public void stop() {
- if (hazelcastClient != null) {
- hazelcastClient.shutdown();
- hazelcastClient = null;
- endpointMap = null;
- }
- }
-
- private void initHazelcastClientInstance() {
- this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
- RegistryConfig rc = new RegistryConfig(properties);
- if (rc.getWKAs().size() < 1) {
- String ip = getDefaultWKA();
- if (ip != null) {
- rc.getWKAs().add(ip);
- }
- }
- if (rc.getWKAs().size() < 1) {
- throw new IllegalArgumentException("Must specify remote IP address(es) for domain");
- }
- this.domainURI = properties.getProperty("defaultDomainName", "default");
- this.hazelcastClient = HazelcastClient.newHazelcastClient(rc.getUserid(), rc.getPassword(), rc.getWKAs().toArray(new String[0]));
- }
-
- @Override
- public HazelcastInstance getHazelcastInstance() {
- return hazelcastClient;
- }
-
- /**
- * See if there's a local IP listening on port 14820
- */
- protected static String getDefaultWKA() {
- try {
- Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
- while (nis.hasMoreElements()) {
- NetworkInterface ni = nis.nextElement();
- Enumeration<InetAddress> ips = ni.getInetAddresses();
- while (ips.hasMoreElements()) {
- InetAddress addr = ips.nextElement();
- ServerSocket ss = null;
- try {
- ss = new ServerSocket(14820, 0, addr);
- } catch (BindException e) {
- return addr.getHostAddress() + ":14820";
- } finally {
- if (ss != null) {
- ss.close();
- }
- }
- }
- }
- } catch (Exception e) {
- }
- return null;
- }
-
-}
+/*
+ * 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.endpoint.hazelcast.client;
+
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.ServerSocket;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
+import org.apache.tuscany.sca.endpoint.hazelcast.RegistryConfig;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+import com.hazelcast.client.HazelcastClient;
+import com.hazelcast.core.HazelcastInstance;
+
+/**
+ * An EndpointRegistry using a Hazelcast Native Client
+ */
+public class HazelcastClientEndpointRegistry extends HazelcastEndpointRegistry {
+
+ HazelcastClient hazelcastClient;
+
+ public HazelcastClientEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ super(registry, attributes, domainRegistryURI, domainURI);
+ }
+
+ @Override
+ public void start() {
+ if (endpointMap != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+ initHazelcastClientInstance();
+ endpointMap = hazelcastClient.getMap(domainURI + "/Endpoints");
+ endpointOwners = hazelcastClient.getMultiMap(domainURI + "/EndpointOwners");
+ }
+
+ @Override
+ public void stop() {
+ if (hazelcastClient != null) {
+ hazelcastClient.shutdown();
+ hazelcastClient = null;
+ endpointMap = null;
+ }
+ }
+
+ private void initHazelcastClientInstance() {
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ RegistryConfig rc = new RegistryConfig(properties);
+ if (rc.getWKAs().size() < 1) {
+ String ip = getDefaultWKA();
+ if (ip != null) {
+ rc.getWKAs().add(ip);
+ }
+ }
+ if (rc.getWKAs().size() < 1) {
+ throw new IllegalArgumentException("Must specify remote IP address(es) for domain");
+ }
+ this.domainURI = properties.getProperty("defaultDomainName", "default");
+ this.hazelcastClient = HazelcastClient.newHazelcastClient(rc.getUserid(), rc.getPassword(), rc.getWKAs().toArray(new String[0]));
+ }
+
+ @Override
+ public HazelcastInstance getHazelcastInstance() {
+ return hazelcastClient;
+ }
+
+ /**
+ * See if there's a local IP listening on port 14820
+ */
+ protected static String getDefaultWKA() {
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ ServerSocket ss = null;
+ try {
+ ss = new ServerSocket(14820, 0, addr);
+ } catch (BindException e) {
+ return addr.getHostAddress() + ":14820";
+ } finally {
+ if (ss != null) {
+ ss.close();
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ return null;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/pom.xml b/sca-java-2.x/trunk/modules/endpoint-hazelcast/pom.xml
index 1d8f5f77b2..0b7857afa5 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/pom.xml
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/pom.xml
@@ -1,63 +1,63 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-endpoint-hazelcast</artifactId>
- <name>Apache Tuscany SCA EndPoint Registry using Hazelcast</name>
-
- <dependencies>
- <dependency>
- <groupId>com.hazelcast</groupId>
- <artifactId>hazelcast</artifactId>
- <version>1.8.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core-spi</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-deployment</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>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <name>Apache Tuscany SCA EndPoint Registry using Hazelcast</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</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>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
index c05c99c062..c041914de8 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
@@ -1,370 +1,370 @@
-/*
- * 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.endpoint.hazelcast;
-
-import java.io.FileNotFoundException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeProperties;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.NearCacheConfig;
-import com.hazelcast.config.TcpIpConfig;
-import com.hazelcast.config.XmlConfigBuilder;
-import com.hazelcast.core.EntryEvent;
-import com.hazelcast.core.EntryListener;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.core.ILock;
-import com.hazelcast.core.IMap;
-import com.hazelcast.core.Member;
-import com.hazelcast.core.MembershipEvent;
-import com.hazelcast.core.MembershipListener;
-import com.hazelcast.core.MultiMap;
-import com.hazelcast.core.Transaction;
-import com.hazelcast.nio.Address;
-
-/**
- * An EndpointRegistry using a Hazelcast
- */
-public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener, EntryListener<String, Endpoint>, MembershipListener {
- private final static Logger logger = Logger.getLogger(HazelcastEndpointRegistry.class.getName());
-
- private HazelcastInstance hazelcastInstance;
- protected Map<Object, Object> endpointMap;
- protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String, Endpoint>();
- protected MultiMap<String, String> endpointOwners;
- protected AssemblyFactory assemblyFactory;
- protected Object shutdownMutex = new Object();
- protected Properties properties;
-
- public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String domainURI) {
- super(registry, null, null, domainURI);
- this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
- this.properties = properties;
- }
-
- public HazelcastEndpointRegistry(ExtensionPointRegistry registry,
- Map<String, String> attributes,
- String domainRegistryURI,
- String domainURI) {
- super(registry, attributes, domainRegistryURI, domainURI);
- this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
- this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
- }
-
- public HazelcastInstance getHazelcastInstance() {
- return hazelcastInstance;
- }
-
- public void start() {
- if (endpointMap != null) {
- throw new IllegalStateException("The registry has already been started");
- }
-// if (configURI.toString().startsWith("tuscany:vm:")) {
-// endpointMap = new HashMap<Object, Object>();
-// } else {
- initHazelcastInstance();
- IMap imap = hazelcastInstance.getMap(domainURI + "/Endpoints");
- imap.addEntryListener(this, true);
- endpointMap = imap;
-
- endpointOwners = hazelcastInstance.getMultiMap(domainURI + "/EndpointOwners");
-
- hazelcastInstance.getCluster().addMembershipListener(this);
-// }
- }
-
- public void stop() {
- if (hazelcastInstance != null) {
- synchronized (shutdownMutex) {
- hazelcastInstance.shutdown();
- hazelcastInstance = null;
- endpointMap = null;
- endpointOwners = null;
- }
- }
- }
-
- private void initHazelcastInstance() {
- Config config = getHazelcastConfig();
-
- // do this when theres a way to have adders be the key owners
- // config.getMapConfig(configURI.getDomainName() + "/Endpoints").setBackupCount(0);
-
- // this caches reads locally
- config.getMapConfig("default").setNearCacheConfig(new NearCacheConfig(0, 0, "NONE", 0, true));
-
- // Disable the Hazelcast shutdown hook as Tuscany has its own and with both there are race conditions
- config.setProperty("hazelcast.shutdownhook.enabled",
- // GroupProperties.PROP_SHUTDOWNHOOK_ENABLED,
- "false");
-
- // By default this is 5 seconds, not sure what the implications are but dropping it down to 1 makes
- // things like the samples look much faster
- config.setProperty("hazelcast.wait.seconds.before.join",
- // GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN,
- "1");
-
- this.hazelcastInstance = Hazelcast.newHazelcastInstance(config);
- }
-
- protected Config getHazelcastConfig() {
- Config config;
- this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
- String configFile = properties.getProperty("hazelcastConfig");
- if (configFile != null) {
- try {
- config = new XmlConfigBuilder(configFile).build();
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException(configFile, e);
- }
- } else {
- config = new XmlConfigBuilder().build();
- RegistryConfig rc = new RegistryConfig(properties);
- config.setPort(rc.getBindPort());
- //config.setPortAutoIncrement(false);
-
- if (!rc.getBindAddress().equals("*")) {
- config.getNetworkConfig().getInterfaces().setEnabled(true);
- config.getNetworkConfig().getInterfaces().clear();
- config.getNetworkConfig().getInterfaces().addInterface(rc.getBindAddress());
- }
-
- config.getGroupConfig().setName(rc.getUserid());
- config.getGroupConfig().setPassword(rc.getPassword());
-
- if (rc.isMulticastDisabled()) {
- config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
- } else {
- config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
- config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(rc.getMulticastPort());
- config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(rc.getMulticastAddress());
- }
-
- if (rc.getWKAs().size() > 0) {
- TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
- tcpconfig.setEnabled(true);
- List<Address> lsMembers = tcpconfig.getAddresses();
- lsMembers.clear();
- for (String addr : rc.getWKAs()) {
- String[] ipNPort = addr.split(":");
- try {
- lsMembers.add(new Address(ipNPort[0], Integer.parseInt(ipNPort[1])));
- } catch (UnknownHostException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
- return config;
- }
-
- public void addEndpoint(Endpoint endpoint) {
- if (findEndpoint(endpoint.getURI()).size() > 0) {
- Member m = getOwningMember(endpoint.getURI());
- throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + domainURI + " at " + m.getInetSocketAddress());
- }
-
- String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
- String endpointURI = endpoint.getURI();
- Transaction txn = hazelcastInstance.getTransaction();
- txn.begin();
- try {
- endpointMap.put(endpointURI, endpoint);
- endpointOwners.put(localMemberAddr, endpointURI);
- txn.commit();
- } catch (Throwable e) {
- txn.rollback();
- throw new ServiceRuntimeException(e);
- }
- localEndpoints.put(endpointURI, endpoint);
- logger.info("Add endpoint - " + endpoint);
- }
-
- public List<Endpoint> findEndpoint(String uri) {
- List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
- for (Object v : endpointMap.values()) {
- Endpoint endpoint = (Endpoint)v;
- logger.fine("Matching against - " + endpoint);
- if (endpoint.matches(uri)) {
- if (!isLocal(endpoint)) {
- endpoint.setRemote(true);
- ((RuntimeEndpoint)endpoint).bind(registry, this);
- } else {
- // get the local version of the endpoint
- // this local version won't have been serialized
- // won't be marked as remote and will have the
- // full interface contract information
- endpoint = localEndpoints.get(endpoint.getURI());
- }
-
- foundEndpoints.add(endpoint);
- logger.fine("Found endpoint with matching service - " + endpoint);
- }
- }
- return foundEndpoints;
- }
-
-
- private boolean isLocal(Endpoint endpoint) {
- return localEndpoints.containsKey(endpoint.getURI());
- }
-
- public Endpoint getEndpoint(String uri) {
- return (Endpoint)endpointMap.get(uri);
- }
-
- public List<Endpoint> getEndpoints() {
- return new ArrayList(endpointMap.values());
- }
-
- public void removeEndpoint(Endpoint endpoint) {
- if (hazelcastInstance == null) {
- return;
- }
- synchronized (shutdownMutex) {
- String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
- String endpointURI = endpoint.getURI();
-
-// TODO: seems to be a txn bug in Hazelcast, see http://code.google.com/p/hazelcast/issues/detail?id=258
-// Transaction txn = hazelcastInstance.getTransaction();
-// txn.begin();
-// try {
- endpointOwners.remove(localMemberAddr, endpointURI);
- endpointMap.remove(endpointURI);
-// txn.commit();
-// } catch (Throwable e) {
-// txn.rollback();
-// throw new ServiceRuntimeException(e);
-// }
- localEndpoints.remove(endpointURI);
- logger.info("Removed endpoint - " + endpoint);
- }
- }
-
-
- public void entryAdded(EntryEvent<String, Endpoint> event) {
- entryAdded(event.getKey(), event.getValue());
- }
-
- public void entryEvicted(EntryEvent<String, Endpoint> event) {
- // Should not happen
- }
-
- public void entryRemoved(EntryEvent<String, Endpoint> event) {
- entryRemoved(event.getKey(), event.getValue());
- }
-
- public void entryUpdated(EntryEvent<String, Endpoint> event) {
- entryUpdated(event.getKey(), null, event.getValue());
- }
-
- public void entryAdded(Object key, Object value) {
- Endpoint newEp = (Endpoint)value;
- if (!isLocal(newEp)) {
- logger.info(" Remote endpoint added: " + newEp);
- }
- endpointAdded(newEp);
- }
-
- public void entryRemoved(Object key, Object value) {
- Endpoint oldEp = (Endpoint)value;
- if (!isLocal(oldEp)) {
- logger.info(" Remote endpoint removed: " + value);
- }
- endpointRemoved(oldEp);
- }
-
- public void entryUpdated(Object key, Object oldValue, Object newValue) {
- Endpoint oldEp = (Endpoint)oldValue;
- Endpoint newEp = (Endpoint)newValue;
- if (!isLocal(newEp)) {
- logger.info(" Remote endpoint updated: " + newEp);
- }
- endpointUpdated(oldEp, newEp);
- }
-
- public void memberAdded(MembershipEvent event) {
- }
-
- public void memberRemoved(MembershipEvent event) {
- try {
- String memberAddr = event.getMember().getInetSocketAddress().toString();
- if (endpointOwners.containsKey(memberAddr)) {
- synchronized (shutdownMutex) {
- ILock lock = hazelcastInstance.getLock("EndpointOwners/" + memberAddr);
- lock.lock();
- try {
- if (endpointOwners.containsKey(memberAddr)) {
- Collection<String> keys = endpointOwners.remove(memberAddr);
- for (Object k : keys) {
- endpointMap.remove(k);
- }
- }
- } finally {
- lock.unlock();
- }
- }
- }
- } catch (Exception e) {
- if (e.getCause() != null && e.getCause().getCause() != null) {
- // ignore hazelcast already shutdown exception
- if (!"Hazelcast Instance is not active!".equals(e.getCause().getCause().getMessage())) {
- throw new ServiceRuntimeException(e);
- }
- }
- }
- }
-
- public Member getOwningMember(String serviceURI) {
- for (String memberAddr : endpointOwners.keySet()) {
- for (String service : endpointOwners.get(memberAddr)) {
- Endpoint ep = assemblyFactory.createEndpoint();
- ep.setURI(service);
- if (ep.matches(serviceURI)) {
- for (Member m : getHazelcastInstance().getCluster().getMembers()) {
- if (memberAddr.equals(m.getInetSocketAddress().toString())) {
- return m;
- }
- }
- }
- }
- }
- return null;
- }
-}
+/*
+ * 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.endpoint.hazelcast;
+
+import java.io.FileNotFoundException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.NearCacheConfig;
+import com.hazelcast.config.TcpIpConfig;
+import com.hazelcast.config.XmlConfigBuilder;
+import com.hazelcast.core.EntryEvent;
+import com.hazelcast.core.EntryListener;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.ILock;
+import com.hazelcast.core.IMap;
+import com.hazelcast.core.Member;
+import com.hazelcast.core.MembershipEvent;
+import com.hazelcast.core.MembershipListener;
+import com.hazelcast.core.MultiMap;
+import com.hazelcast.core.Transaction;
+import com.hazelcast.nio.Address;
+
+/**
+ * An EndpointRegistry using a Hazelcast
+ */
+public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener, EntryListener<String, Endpoint>, MembershipListener {
+ private final static Logger logger = Logger.getLogger(HazelcastEndpointRegistry.class.getName());
+
+ private HazelcastInstance hazelcastInstance;
+ protected Map<Object, Object> endpointMap;
+ protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String, Endpoint>();
+ protected MultiMap<String, String> endpointOwners;
+ protected AssemblyFactory assemblyFactory;
+ protected Object shutdownMutex = new Object();
+ protected Properties properties;
+
+ public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String domainURI) {
+ super(registry, null, null, domainURI);
+ this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
+ this.properties = properties;
+ }
+
+ public HazelcastEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ super(registry, attributes, domainRegistryURI, domainURI);
+ this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ }
+
+ public HazelcastInstance getHazelcastInstance() {
+ return hazelcastInstance;
+ }
+
+ public void start() {
+ if (endpointMap != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+// if (configURI.toString().startsWith("tuscany:vm:")) {
+// endpointMap = new HashMap<Object, Object>();
+// } else {
+ initHazelcastInstance();
+ IMap imap = hazelcastInstance.getMap(domainURI + "/Endpoints");
+ imap.addEntryListener(this, true);
+ endpointMap = imap;
+
+ endpointOwners = hazelcastInstance.getMultiMap(domainURI + "/EndpointOwners");
+
+ hazelcastInstance.getCluster().addMembershipListener(this);
+// }
+ }
+
+ public void stop() {
+ if (hazelcastInstance != null) {
+ synchronized (shutdownMutex) {
+ hazelcastInstance.shutdown();
+ hazelcastInstance = null;
+ endpointMap = null;
+ endpointOwners = null;
+ }
+ }
+ }
+
+ private void initHazelcastInstance() {
+ Config config = getHazelcastConfig();
+
+ // do this when theres a way to have adders be the key owners
+ // config.getMapConfig(configURI.getDomainName() + "/Endpoints").setBackupCount(0);
+
+ // this caches reads locally
+ config.getMapConfig("default").setNearCacheConfig(new NearCacheConfig(0, 0, "NONE", 0, true));
+
+ // Disable the Hazelcast shutdown hook as Tuscany has its own and with both there are race conditions
+ config.setProperty("hazelcast.shutdownhook.enabled",
+ // GroupProperties.PROP_SHUTDOWNHOOK_ENABLED,
+ "false");
+
+ // By default this is 5 seconds, not sure what the implications are but dropping it down to 1 makes
+ // things like the samples look much faster
+ config.setProperty("hazelcast.wait.seconds.before.join",
+ // GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN,
+ "1");
+
+ this.hazelcastInstance = Hazelcast.newHazelcastInstance(config);
+ }
+
+ protected Config getHazelcastConfig() {
+ Config config;
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ String configFile = properties.getProperty("hazelcastConfig");
+ if (configFile != null) {
+ try {
+ config = new XmlConfigBuilder(configFile).build();
+ } catch (FileNotFoundException e) {
+ throw new IllegalArgumentException(configFile, e);
+ }
+ } else {
+ config = new XmlConfigBuilder().build();
+ RegistryConfig rc = new RegistryConfig(properties);
+ config.setPort(rc.getBindPort());
+ //config.setPortAutoIncrement(false);
+
+ if (!rc.getBindAddress().equals("*")) {
+ config.getNetworkConfig().getInterfaces().setEnabled(true);
+ config.getNetworkConfig().getInterfaces().clear();
+ config.getNetworkConfig().getInterfaces().addInterface(rc.getBindAddress());
+ }
+
+ config.getGroupConfig().setName(rc.getUserid());
+ config.getGroupConfig().setPassword(rc.getPassword());
+
+ if (rc.isMulticastDisabled()) {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
+ } else {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(rc.getMulticastPort());
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(rc.getMulticastAddress());
+ }
+
+ if (rc.getWKAs().size() > 0) {
+ TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
+ tcpconfig.setEnabled(true);
+ List<Address> lsMembers = tcpconfig.getAddresses();
+ lsMembers.clear();
+ for (String addr : rc.getWKAs()) {
+ String[] ipNPort = addr.split(":");
+ try {
+ lsMembers.add(new Address(ipNPort[0], Integer.parseInt(ipNPort[1])));
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ return config;
+ }
+
+ public void addEndpoint(Endpoint endpoint) {
+ if (findEndpoint(endpoint.getURI()).size() > 0) {
+ Member m = getOwningMember(endpoint.getURI());
+ throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + domainURI + " at " + m.getInetSocketAddress());
+ }
+
+ String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+ String endpointURI = endpoint.getURI();
+ Transaction txn = hazelcastInstance.getTransaction();
+ txn.begin();
+ try {
+ endpointMap.put(endpointURI, endpoint);
+ endpointOwners.put(localMemberAddr, endpointURI);
+ txn.commit();
+ } catch (Throwable e) {
+ txn.rollback();
+ throw new ServiceRuntimeException(e);
+ }
+ localEndpoints.put(endpointURI, endpoint);
+ logger.info("Add endpoint - " + endpoint);
+ }
+
+ public List<Endpoint> findEndpoint(String uri) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+ for (Object v : endpointMap.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ logger.fine("Matching against - " + endpoint);
+ if (endpoint.matches(uri)) {
+ if (!isLocal(endpoint)) {
+ endpoint.setRemote(true);
+ ((RuntimeEndpoint)endpoint).bind(registry, this);
+ } else {
+ // get the local version of the endpoint
+ // this local version won't have been serialized
+ // won't be marked as remote and will have the
+ // full interface contract information
+ endpoint = localEndpoints.get(endpoint.getURI());
+ }
+
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ }
+ }
+ return foundEndpoints;
+ }
+
+
+ private boolean isLocal(Endpoint endpoint) {
+ return localEndpoints.containsKey(endpoint.getURI());
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ return (Endpoint)endpointMap.get(uri);
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return new ArrayList(endpointMap.values());
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ if (hazelcastInstance == null) {
+ return;
+ }
+ synchronized (shutdownMutex) {
+ String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+ String endpointURI = endpoint.getURI();
+
+// TODO: seems to be a txn bug in Hazelcast, see http://code.google.com/p/hazelcast/issues/detail?id=258
+// Transaction txn = hazelcastInstance.getTransaction();
+// txn.begin();
+// try {
+ endpointOwners.remove(localMemberAddr, endpointURI);
+ endpointMap.remove(endpointURI);
+// txn.commit();
+// } catch (Throwable e) {
+// txn.rollback();
+// throw new ServiceRuntimeException(e);
+// }
+ localEndpoints.remove(endpointURI);
+ logger.info("Removed endpoint - " + endpoint);
+ }
+ }
+
+
+ public void entryAdded(EntryEvent<String, Endpoint> event) {
+ entryAdded(event.getKey(), event.getValue());
+ }
+
+ public void entryEvicted(EntryEvent<String, Endpoint> event) {
+ // Should not happen
+ }
+
+ public void entryRemoved(EntryEvent<String, Endpoint> event) {
+ entryRemoved(event.getKey(), event.getValue());
+ }
+
+ public void entryUpdated(EntryEvent<String, Endpoint> event) {
+ entryUpdated(event.getKey(), null, event.getValue());
+ }
+
+ public void entryAdded(Object key, Object value) {
+ Endpoint newEp = (Endpoint)value;
+ if (!isLocal(newEp)) {
+ logger.info(" Remote endpoint added: " + newEp);
+ }
+ endpointAdded(newEp);
+ }
+
+ public void entryRemoved(Object key, Object value) {
+ Endpoint oldEp = (Endpoint)value;
+ if (!isLocal(oldEp)) {
+ logger.info(" Remote endpoint removed: " + value);
+ }
+ endpointRemoved(oldEp);
+ }
+
+ public void entryUpdated(Object key, Object oldValue, Object newValue) {
+ Endpoint oldEp = (Endpoint)oldValue;
+ Endpoint newEp = (Endpoint)newValue;
+ if (!isLocal(newEp)) {
+ logger.info(" Remote endpoint updated: " + newEp);
+ }
+ endpointUpdated(oldEp, newEp);
+ }
+
+ public void memberAdded(MembershipEvent event) {
+ }
+
+ public void memberRemoved(MembershipEvent event) {
+ try {
+ String memberAddr = event.getMember().getInetSocketAddress().toString();
+ if (endpointOwners.containsKey(memberAddr)) {
+ synchronized (shutdownMutex) {
+ ILock lock = hazelcastInstance.getLock("EndpointOwners/" + memberAddr);
+ lock.lock();
+ try {
+ if (endpointOwners.containsKey(memberAddr)) {
+ Collection<String> keys = endpointOwners.remove(memberAddr);
+ for (Object k : keys) {
+ endpointMap.remove(k);
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (e.getCause() != null && e.getCause().getCause() != null) {
+ // ignore hazelcast already shutdown exception
+ if (!"Hazelcast Instance is not active!".equals(e.getCause().getCause().getMessage())) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+ }
+
+ public Member getOwningMember(String serviceURI) {
+ for (String memberAddr : endpointOwners.keySet()) {
+ for (String service : endpointOwners.get(memberAddr)) {
+ Endpoint ep = assemblyFactory.createEndpoint();
+ ep.setURI(service);
+ if (ep.matches(serviceURI)) {
+ for (Member m : getHazelcastInstance().getCluster().getMembers()) {
+ if (memberAddr.equals(m.getInetSocketAddress().toString())) {
+ return m;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
index c6b1ccaa21..79bffd3b21 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
@@ -1,179 +1,179 @@
-/*
- * 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.endpoint.hazelcast;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-
-/**
- * Utility to parse the config properties.
- *
- * bind - ip[:port] - defines the local bind address and port, it defaults to the network interface with the widest
- * class (ie class A is wider than class B) on port 14820 and if that port in use it will try
- * incrementing by one till a free port is found.
- *
- * multicast - groupip:port | off - defines if multicast discovery is used and if so what multicast ip group and port is used
- * defaults to 224.5.12.10:51482. A value of off means multicast is disabled.
- *
- * wka - ip[:port] - a comma separated list of ip address and port for remote nodes in the domain group. The port defaults to 14820.
- *
- * userid - is the userid other nodes must use to connect to this domain group. The default is the default domain name.
- *
- * password - is the password other nodes must use to connect to this domain group. The default is 'tuscany'.
- *
- * client - true means this is an SCAClient call
- *
- */
-public class RegistryConfig {
-
- private String bindAddress = "*";
- private int bindPort = 14820;
- private boolean multicastDisabled = false;
- private String multicastAddress = "224.5.12.10";
- private int multicastPort = 51482;
- private List<String> wkas = new ArrayList<String>();
- private String userid;
- private String password;
- boolean client;
-
- public RegistryConfig(Properties properties) {
- init(properties);
- }
-
- private void init(Properties properties) {
-
- String bindValue = properties.getProperty("bind");
- if (bindValue == null) {
- InetAddress addr = chooseLocalAddress();
- if (addr != null) {
- this.bindAddress = addr.getHostAddress();
- }
- } else {
- if (bindValue.indexOf(":") == -1) {
- this.bindAddress = bindValue;
- } else {
- String[] addr = bindValue.split(":");
- this.bindAddress = addr[0];
- this.bindPort = Integer.parseInt(addr[1]);
- }
- }
-
- String multicastValue = properties.getProperty("multicast");
- if (multicastValue != null) {
- if ("off".equalsIgnoreCase(multicastValue)) {
- this.multicastDisabled = true;
- } else {
- if (multicastValue.indexOf(":") == -1) {
- this.multicastAddress = multicastValue;
- } else {
- String[] addr = multicastValue.split(":");
- this.multicastAddress = addr[0];
- this.multicastPort = Integer.parseInt(addr[1]);
- }
- }
- }
-
- String wkaValue = properties.getProperty("wka");
- if (wkaValue != null) {
- String[] ips = wkaValue.split(",");
- for (String ip : ips) {
- if (ip.indexOf(":") == -1) {
- wkas.add(ip + ":14820");
- } else {
- wkas.add(ip);
- }
- }
- }
-
- this.client = Boolean.parseBoolean(properties.getProperty("client", "false"));
- this.password = properties.getProperty("password", "tuscany");
- this.userid = properties.getProperty("userid", properties.getProperty("defaultDomainName", "default"));
-
- }
-
- public String getBindAddress() {
- return bindAddress;
- }
-
- public int getBindPort() {
- return bindPort;
- }
-
- public boolean isMulticastDisabled() {
- return multicastDisabled;
- }
-
- public String getMulticastAddress() {
- return multicastAddress;
- }
-
- public int getMulticastPort() {
- return multicastPort;
- }
-
- public List<String> getWKAs() {
- return wkas;
- }
-
- public String getUserid() {
- return userid;
- }
- public String getPassword() {
- return password;
- }
-
- /**
- * Use the NIC address with the widest class, ie class A instead of class B or C.
- * Bit crude but in a lot of environments a class A address (eg 10.x.x.x) is likely
- * a better choice than a class C address (eg 192.x.x.x). And the alternative to
- * this is to just choose the first address of the first network interface which
- * likely isn't a better choice than this approach.
- */
- protected InetAddress chooseLocalAddress() {
- InetAddress chosen = null;
- try {
- Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
- while (nis.hasMoreElements()) {
- NetworkInterface ni = nis.nextElement();
- Enumeration<InetAddress> ips = ni.getInetAddresses();
- while (ips.hasMoreElements()) {
- InetAddress addr = ips.nextElement();
- if (!addr.isLoopbackAddress()) {
- if (chosen == null) {
- chosen = addr;
- } else {
- if (((int) addr.getAddress()[0] & 0xFF) < ((int) chosen.getAddress()[0] & 0xFF)) {
- chosen = addr;
- }
- }
- }
- }
- }
- } catch (Exception e) {
- // ignore
- }
- return chosen;
- }
-}
+/*
+ * 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.endpoint.hazelcast;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * Utility to parse the config properties.
+ *
+ * bind - ip[:port] - defines the local bind address and port, it defaults to the network interface with the widest
+ * class (ie class A is wider than class B) on port 14820 and if that port in use it will try
+ * incrementing by one till a free port is found.
+ *
+ * multicast - groupip:port | off - defines if multicast discovery is used and if so what multicast ip group and port is used
+ * defaults to 224.5.12.10:51482. A value of off means multicast is disabled.
+ *
+ * wka - ip[:port] - a comma separated list of ip address and port for remote nodes in the domain group. The port defaults to 14820.
+ *
+ * userid - is the userid other nodes must use to connect to this domain group. The default is the default domain name.
+ *
+ * password - is the password other nodes must use to connect to this domain group. The default is 'tuscany'.
+ *
+ * client - true means this is an SCAClient call
+ *
+ */
+public class RegistryConfig {
+
+ private String bindAddress = "*";
+ private int bindPort = 14820;
+ private boolean multicastDisabled = false;
+ private String multicastAddress = "224.5.12.10";
+ private int multicastPort = 51482;
+ private List<String> wkas = new ArrayList<String>();
+ private String userid;
+ private String password;
+ boolean client;
+
+ public RegistryConfig(Properties properties) {
+ init(properties);
+ }
+
+ private void init(Properties properties) {
+
+ String bindValue = properties.getProperty("bind");
+ if (bindValue == null) {
+ InetAddress addr = chooseLocalAddress();
+ if (addr != null) {
+ this.bindAddress = addr.getHostAddress();
+ }
+ } else {
+ if (bindValue.indexOf(":") == -1) {
+ this.bindAddress = bindValue;
+ } else {
+ String[] addr = bindValue.split(":");
+ this.bindAddress = addr[0];
+ this.bindPort = Integer.parseInt(addr[1]);
+ }
+ }
+
+ String multicastValue = properties.getProperty("multicast");
+ if (multicastValue != null) {
+ if ("off".equalsIgnoreCase(multicastValue)) {
+ this.multicastDisabled = true;
+ } else {
+ if (multicastValue.indexOf(":") == -1) {
+ this.multicastAddress = multicastValue;
+ } else {
+ String[] addr = multicastValue.split(":");
+ this.multicastAddress = addr[0];
+ this.multicastPort = Integer.parseInt(addr[1]);
+ }
+ }
+ }
+
+ String wkaValue = properties.getProperty("wka");
+ if (wkaValue != null) {
+ String[] ips = wkaValue.split(",");
+ for (String ip : ips) {
+ if (ip.indexOf(":") == -1) {
+ wkas.add(ip + ":14820");
+ } else {
+ wkas.add(ip);
+ }
+ }
+ }
+
+ this.client = Boolean.parseBoolean(properties.getProperty("client", "false"));
+ this.password = properties.getProperty("password", "tuscany");
+ this.userid = properties.getProperty("userid", properties.getProperty("defaultDomainName", "default"));
+
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public int getBindPort() {
+ return bindPort;
+ }
+
+ public boolean isMulticastDisabled() {
+ return multicastDisabled;
+ }
+
+ public String getMulticastAddress() {
+ return multicastAddress;
+ }
+
+ public int getMulticastPort() {
+ return multicastPort;
+ }
+
+ public List<String> getWKAs() {
+ return wkas;
+ }
+
+ public String getUserid() {
+ return userid;
+ }
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Use the NIC address with the widest class, ie class A instead of class B or C.
+ * Bit crude but in a lot of environments a class A address (eg 10.x.x.x) is likely
+ * a better choice than a class C address (eg 192.x.x.x). And the alternative to
+ * this is to just choose the first address of the first network interface which
+ * likely isn't a better choice than this approach.
+ */
+ protected InetAddress chooseLocalAddress() {
+ InetAddress chosen = null;
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ if (!addr.isLoopbackAddress()) {
+ if (chosen == null) {
+ chosen = addr;
+ } else {
+ if (((int) addr.getAddress()[0] & 0xFF) < ((int) chosen.getAddress()[0] & 0xFF)) {
+ chosen = addr;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ return chosen;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java
index edfe186667..12b420f010 100644
--- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java
+++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java
@@ -1,142 +1,142 @@
-/*
- * 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.endpoint.hazelcast;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.TcpIpConfig;
-import com.hazelcast.config.XmlConfigBuilder;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.core.IMap;
-import com.hazelcast.nio.Address;
-
-@Ignore
-public class RegistryTestCase {
-
- @Test
- public void test1() throws UnknownHostException {
-
- HazelcastInstance h1 = create("54327", 9001);
-
- IMap<Object, Object> h1map = h1.getMap("mymap");
- h1map.put("key1", "bla1");
- Assert.assertEquals("bla1", h1map.get("key1"));
-
- HazelcastInstance h2 = create("false", 9002, 9001);
- IMap<Object, Object> h2map = h2.getMap("mymap");
- Assert.assertEquals("bla1", h2map.get("key1"));
-
- HazelcastInstance h3 = create("false", 9003, 9002);
- IMap<Object, Object> h3map = h3.getMap("mymap");
- Assert.assertEquals("bla1", h3map.get("key1"));
-
- h3map.put("k3", "v3");
- h2map.put("k2", "v2");
-
- Assert.assertEquals("v2", h1map.get("k2"));
- Assert.assertEquals("v3", h1map.get("k3"));
- Assert.assertEquals("v2", h2map.get("k2"));
- Assert.assertEquals("v3", h2map.get("k3"));
- Assert.assertEquals("v2", h3map.get("k2"));
- Assert.assertEquals("v3", h3map.get("k3"));
-
- HazelcastInstance h4 = create("54328", 9004, 9001);
- IMap<Object, Object> h4map = h4.getMap("mymap");
-// Assert.assertNull(h4map.get("k2"));
-// Assert.assertNull(h4map.get("k3"));
- Assert.assertEquals("v2", h4map.get("k2"));
- Assert.assertEquals("v3", h4map.get("k3"));
-
-// HazelcastInstance h5 = create("false", 9005, 9003, 9004);
- HazelcastInstance h5 = create("54328", 9005);
-
-// Assert.assertEquals("v2", h4map.get("k2"));
-// Assert.assertEquals("v3", h4map.get("k3"));
-
- IMap<Object, Object> h5map = h5.getMap("mymap");
- Assert.assertEquals("v2", h5map.get("k2"));
- Assert.assertEquals("v3", h5map.get("k3"));
-
- h1.shutdown();
-
- Assert.assertEquals("v2", h2map.get("k2"));
- Assert.assertEquals("v3", h2map.get("k3"));
- Assert.assertEquals("v2", h3map.get("k2"));
- Assert.assertEquals("v3", h3map.get("k3"));
- Assert.assertEquals("v2", h4map.get("k2"));
- Assert.assertEquals("v3", h4map.get("k3"));
-
- h3map.put("key1a", "bla1a");
-
- Assert.assertEquals("bla1a", h2map.get("key1a"));
- Assert.assertEquals("bla1a", h3map.get("key1a"));
- Assert.assertEquals("bla1a", h4map.get("key1a"));
-
-// HazelcastInstance h4 = create(true, 9004, 9003);
-// HazelcastInstance h5 = create(true, 9005);
-// IMap<Object, Object> h5map = h5.getMap("mymap");
-// Assert.assertEquals("bla1", h5map.get("key1"));
-
-// HazelcastInstance h6 = create(false, 9006, 9005);
-// IMap<Object, Object> h6map = h6.getMap("mymap");
-// Assert.assertEquals("bla1", h6map.get("key1"));
-
- }
-
- private HazelcastInstance create(String multicast, int listenPort, int... connectPorts) throws UnknownHostException {
- Config config = new XmlConfigBuilder().build();
- config.setPort(listenPort);
- config.setPortAutoIncrement(false);
-
- // declare the interface Hazelcast should bind to
- config.getNetworkConfig().getInterfaces().clear();
- config.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
- config.getNetworkConfig().getInterfaces().setEnabled(true);
-
- if ("false".equals(multicast)) {
- config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
- } else {
- config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(Integer.parseInt(multicast));
- }
-
- if (connectPorts.length > 0) {
- TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
- tcpconfig.setEnabled(true);
-
- List<Address> lsMembers = tcpconfig.getAddresses();
- lsMembers.clear();
- for (int p : connectPorts) {
- lsMembers.add(new Address(InetAddress.getLocalHost(), p));
- }
- }
-
- return Hazelcast.newHazelcastInstance(config);
- }
-
-}
+/*
+ * 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.endpoint.hazelcast;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.TcpIpConfig;
+import com.hazelcast.config.XmlConfigBuilder;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.IMap;
+import com.hazelcast.nio.Address;
+
+@Ignore
+public class RegistryTestCase {
+
+ @Test
+ public void test1() throws UnknownHostException {
+
+ HazelcastInstance h1 = create("54327", 9001);
+
+ IMap<Object, Object> h1map = h1.getMap("mymap");
+ h1map.put("key1", "bla1");
+ Assert.assertEquals("bla1", h1map.get("key1"));
+
+ HazelcastInstance h2 = create("false", 9002, 9001);
+ IMap<Object, Object> h2map = h2.getMap("mymap");
+ Assert.assertEquals("bla1", h2map.get("key1"));
+
+ HazelcastInstance h3 = create("false", 9003, 9002);
+ IMap<Object, Object> h3map = h3.getMap("mymap");
+ Assert.assertEquals("bla1", h3map.get("key1"));
+
+ h3map.put("k3", "v3");
+ h2map.put("k2", "v2");
+
+ Assert.assertEquals("v2", h1map.get("k2"));
+ Assert.assertEquals("v3", h1map.get("k3"));
+ Assert.assertEquals("v2", h2map.get("k2"));
+ Assert.assertEquals("v3", h2map.get("k3"));
+ Assert.assertEquals("v2", h3map.get("k2"));
+ Assert.assertEquals("v3", h3map.get("k3"));
+
+ HazelcastInstance h4 = create("54328", 9004, 9001);
+ IMap<Object, Object> h4map = h4.getMap("mymap");
+// Assert.assertNull(h4map.get("k2"));
+// Assert.assertNull(h4map.get("k3"));
+ Assert.assertEquals("v2", h4map.get("k2"));
+ Assert.assertEquals("v3", h4map.get("k3"));
+
+// HazelcastInstance h5 = create("false", 9005, 9003, 9004);
+ HazelcastInstance h5 = create("54328", 9005);
+
+// Assert.assertEquals("v2", h4map.get("k2"));
+// Assert.assertEquals("v3", h4map.get("k3"));
+
+ IMap<Object, Object> h5map = h5.getMap("mymap");
+ Assert.assertEquals("v2", h5map.get("k2"));
+ Assert.assertEquals("v3", h5map.get("k3"));
+
+ h1.shutdown();
+
+ Assert.assertEquals("v2", h2map.get("k2"));
+ Assert.assertEquals("v3", h2map.get("k3"));
+ Assert.assertEquals("v2", h3map.get("k2"));
+ Assert.assertEquals("v3", h3map.get("k3"));
+ Assert.assertEquals("v2", h4map.get("k2"));
+ Assert.assertEquals("v3", h4map.get("k3"));
+
+ h3map.put("key1a", "bla1a");
+
+ Assert.assertEquals("bla1a", h2map.get("key1a"));
+ Assert.assertEquals("bla1a", h3map.get("key1a"));
+ Assert.assertEquals("bla1a", h4map.get("key1a"));
+
+// HazelcastInstance h4 = create(true, 9004, 9003);
+// HazelcastInstance h5 = create(true, 9005);
+// IMap<Object, Object> h5map = h5.getMap("mymap");
+// Assert.assertEquals("bla1", h5map.get("key1"));
+
+// HazelcastInstance h6 = create(false, 9006, 9005);
+// IMap<Object, Object> h6map = h6.getMap("mymap");
+// Assert.assertEquals("bla1", h6map.get("key1"));
+
+ }
+
+ private HazelcastInstance create(String multicast, int listenPort, int... connectPorts) throws UnknownHostException {
+ Config config = new XmlConfigBuilder().build();
+ config.setPort(listenPort);
+ config.setPortAutoIncrement(false);
+
+ // declare the interface Hazelcast should bind to
+ config.getNetworkConfig().getInterfaces().clear();
+ config.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
+ config.getNetworkConfig().getInterfaces().setEnabled(true);
+
+ if ("false".equals(multicast)) {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
+ } else {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(Integer.parseInt(multicast));
+ }
+
+ if (connectPorts.length > 0) {
+ TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
+ tcpconfig.setEnabled(true);
+
+ List<Address> lsMembers = tcpconfig.getAddresses();
+ lsMembers.clear();
+ for (int p : connectPorts) {
+ lsMembers.add(new Address(InetAddress.getLocalHost(), p));
+ }
+ }
+
+ return Hazelcast.newHazelcastInstance(config);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java
index 4c311e36b3..1e4d3af50d 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java
@@ -1,41 +1,41 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.endpoint.tribes;
-
-import org.apache.catalina.tribes.Channel;
-import org.apache.catalina.tribes.ChannelException;
-import org.apache.catalina.tribes.group.ChannelInterceptorBase;
-
-/**
- * A static interceptor to disables multicast.
- * Can be removed when/if the function gets added to Tribes.
- * See Tomcat email http://markmail.org/message/doqu7pfl2hvvdfcl
- */
-public class DisableMcastInterceptor extends ChannelInterceptorBase {
-
- public DisableMcastInterceptor() {
- super();
- }
-
- public void start(int svc) throws ChannelException {
- svc = (svc & (~Channel.MBR_TX_SEQ));
- super.start(svc);
- }
-}
+/*
+ * 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.endpoint.tribes;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.group.ChannelInterceptorBase;
+
+/**
+ * A static interceptor to disables multicast.
+ * Can be removed when/if the function gets added to Tribes.
+ * See Tomcat email http://markmail.org/message/doqu7pfl2hvvdfcl
+ */
+public class DisableMcastInterceptor extends ChannelInterceptorBase {
+
+ public DisableMcastInterceptor() {
+ super();
+ }
+
+ public void start(int svc) throws ChannelException {
+ svc = (svc & (~Channel.MBR_TX_SEQ));
+ super.start(svc);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java
index a470c47ba0..aa445f3ce7 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java
@@ -1,169 +1,169 @@
-/*
- * 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.endpoint.tribes;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
-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.runtime.EndpointListener;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-// Ignore so its not run in the build yet till its working
-public class MultiRegTestCase implements EndpointListener {
- private static ExtensionPointRegistry extensionPoints;
- private static AssemblyFactory assemblyFactory;
- private static SCABindingFactory scaBindingFactory;
-
- @BeforeClass
- public static void init() {
- extensionPoints = new DefaultExtensionPointRegistry();
- FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- assemblyFactory = factories.getFactory(AssemblyFactory.class);
- scaBindingFactory = factories.getFactory(SCABindingFactory.class);
- }
-
- @Test
- public void testReplication() throws Exception {
- RuntimeEndpoint ep1 = createEndpoint("ep1uri");
-
- String host = InetAddress.getLocalHost().getHostAddress();
- String bind = null; // "9.65.158.31";
- String port1 = "8085";
- String port2 = "8086";
- String port3 = "8087";
- String range = "1";
-
- Map<String, String> attrs1 = new HashMap<String, String>();
- // attrs1.put("nomcast", "true");
- attrs1.put("bind", bind);
- attrs1.put("receiverPort", port1);
- attrs1.put("receiverAutoBind", range);
- // attrs1.put("routes", host + ":" + port2 + " " + host + ":" + port3);
- ReplicatedEndpointRegistry reg1 = new ReplicatedEndpointRegistry(extensionPoints, attrs1, "foo", "bar");
- reg1.addListener(this);
- reg1.start();
-
- Map<String, String> attrs2 = new HashMap<String, String>();
- // attrs2.put("nomcast", "true");
- attrs1.put("bind", bind);
- attrs2.put("receiverPort", port2);
- attrs2.put("receiverAutoBind", range);
- // attrs2.put("routes", host + ":"+port1);
- ReplicatedEndpointRegistry reg2 = new ReplicatedEndpointRegistry(extensionPoints, attrs2, "foo", "bar");
- reg2.addListener(this);
- reg2.start();
-
- Map<String, String> attrs3 = new HashMap<String, String>();
- // attrs3.put("nomcast", "true");
- attrs1.put("bind", bind);
- attrs3.put("receiverPort", port3);
- attrs3.put("receiverAutoBind", range);
- // attrs3.put("routes", host + ":"+port1);
- ReplicatedEndpointRegistry reg3 = new ReplicatedEndpointRegistry(extensionPoints, attrs3, "foo", "bar");
- reg3.addListener(this);
- reg3.start();
-
- ep1.bind(extensionPoints, reg1);
- reg1.addEndpoint(ep1);
- assertExists(reg1, "ep1uri");
- assertExists(reg2, "ep1uri");
- assertExists(reg3, "ep1uri");
-
- RuntimeEndpoint ep2 = createEndpoint("ep2uri");
- ep2.bind(extensionPoints, reg2);
- reg2.addEndpoint(ep2);
- assertExists(reg2, "ep2uri");
- assertExists(reg1, "ep2uri");
- assertExists(reg3, "ep2uri");
-
- reg1.stop();
- Thread.sleep(6000);
- Assert.assertNull(reg2.getEndpoint("ep1uri"));
- Assert.assertNull(reg3.getEndpoint("ep1uri"));
- assertExists(reg2, "ep2uri");
- assertExists(reg3, "ep2uri");
-
- reg1.start();
- ep1.bind(extensionPoints, reg1);
- reg1.addEndpoint(ep1);
- assertExists(reg1, "ep1uri");
- assertExists(reg2, "ep1uri");
- assertExists(reg3, "ep1uri");
-
- reg1.stop();
- reg2.stop();
- reg3.stop();
- System.out.println(); // closed
- }
-
- private Endpoint assertExists(ReplicatedEndpointRegistry reg, String uri) throws InterruptedException {
- Endpoint ep = null;
- int count = 0;
- while (ep == null && count < 15) {
- ep = reg.getEndpoint(uri);
- Thread.sleep(1000);
- count++;
- System.out.println(reg + ": tries=" + count);
- }
- Assert.assertNotNull(ep);
- Assert.assertEquals(uri, ep.getURI());
- return ep;
- }
-
- private RuntimeEndpoint createEndpoint(String uri) {
- RuntimeEndpoint ep = (RuntimeEndpoint) assemblyFactory.createEndpoint();
- Component comp = assemblyFactory.createComponent();
- ep.setComponent(comp);
- ep.setService(assemblyFactory.createComponentService());
- Binding b = scaBindingFactory.createSCABinding();
- ep.setBinding(b);
- ep.setURI(uri);
- return ep;
- }
-
- private void print(String prefix, Endpoint ep) {
- System.out.println(prefix + ": "+ep);
- }
-
- public void endpointAdded(Endpoint endpoint) {
- print("Added", endpoint);
- }
-
- public void endpointRemoved(Endpoint endpoint) {
- print("Removed", endpoint);
- }
-
- public void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint) {
- print("Updated", newEndpoint);
- }
-
-}
+/*
+ * 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.endpoint.tribes;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+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.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// Ignore so its not run in the build yet till its working
+public class MultiRegTestCase implements EndpointListener {
+ private static ExtensionPointRegistry extensionPoints;
+ private static AssemblyFactory assemblyFactory;
+ private static SCABindingFactory scaBindingFactory;
+
+ @BeforeClass
+ public static void init() {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ }
+
+ @Test
+ public void testReplication() throws Exception {
+ RuntimeEndpoint ep1 = createEndpoint("ep1uri");
+
+ String host = InetAddress.getLocalHost().getHostAddress();
+ String bind = null; // "9.65.158.31";
+ String port1 = "8085";
+ String port2 = "8086";
+ String port3 = "8087";
+ String range = "1";
+
+ Map<String, String> attrs1 = new HashMap<String, String>();
+ // attrs1.put("nomcast", "true");
+ attrs1.put("bind", bind);
+ attrs1.put("receiverPort", port1);
+ attrs1.put("receiverAutoBind", range);
+ // attrs1.put("routes", host + ":" + port2 + " " + host + ":" + port3);
+ ReplicatedEndpointRegistry reg1 = new ReplicatedEndpointRegistry(extensionPoints, attrs1, "foo", "bar");
+ reg1.addListener(this);
+ reg1.start();
+
+ Map<String, String> attrs2 = new HashMap<String, String>();
+ // attrs2.put("nomcast", "true");
+ attrs1.put("bind", bind);
+ attrs2.put("receiverPort", port2);
+ attrs2.put("receiverAutoBind", range);
+ // attrs2.put("routes", host + ":"+port1);
+ ReplicatedEndpointRegistry reg2 = new ReplicatedEndpointRegistry(extensionPoints, attrs2, "foo", "bar");
+ reg2.addListener(this);
+ reg2.start();
+
+ Map<String, String> attrs3 = new HashMap<String, String>();
+ // attrs3.put("nomcast", "true");
+ attrs1.put("bind", bind);
+ attrs3.put("receiverPort", port3);
+ attrs3.put("receiverAutoBind", range);
+ // attrs3.put("routes", host + ":"+port1);
+ ReplicatedEndpointRegistry reg3 = new ReplicatedEndpointRegistry(extensionPoints, attrs3, "foo", "bar");
+ reg3.addListener(this);
+ reg3.start();
+
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ RuntimeEndpoint ep2 = createEndpoint("ep2uri");
+ ep2.bind(extensionPoints, reg2);
+ reg2.addEndpoint(ep2);
+ assertExists(reg2, "ep2uri");
+ assertExists(reg1, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ reg1.stop();
+ Thread.sleep(6000);
+ Assert.assertNull(reg2.getEndpoint("ep1uri"));
+ Assert.assertNull(reg3.getEndpoint("ep1uri"));
+ assertExists(reg2, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ reg1.start();
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ reg1.stop();
+ reg2.stop();
+ reg3.stop();
+ System.out.println(); // closed
+ }
+
+ private Endpoint assertExists(ReplicatedEndpointRegistry reg, String uri) throws InterruptedException {
+ Endpoint ep = null;
+ int count = 0;
+ while (ep == null && count < 15) {
+ ep = reg.getEndpoint(uri);
+ Thread.sleep(1000);
+ count++;
+ System.out.println(reg + ": tries=" + count);
+ }
+ Assert.assertNotNull(ep);
+ Assert.assertEquals(uri, ep.getURI());
+ return ep;
+ }
+
+ private RuntimeEndpoint createEndpoint(String uri) {
+ RuntimeEndpoint ep = (RuntimeEndpoint) assemblyFactory.createEndpoint();
+ Component comp = assemblyFactory.createComponent();
+ ep.setComponent(comp);
+ ep.setService(assemblyFactory.createComponentService());
+ Binding b = scaBindingFactory.createSCABinding();
+ ep.setBinding(b);
+ ep.setURI(uri);
+ return ep;
+ }
+
+ private void print(String prefix, Endpoint ep) {
+ System.out.println(prefix + ": "+ep);
+ }
+
+ public void endpointAdded(Endpoint endpoint) {
+ print("Added", endpoint);
+ }
+
+ public void endpointRemoved(Endpoint endpoint) {
+ print("Removed", endpoint);
+ }
+
+ public void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint) {
+ print("Updated", newEndpoint);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
index 28158d55f5..35d00fbba8 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
@@ -1,79 +1,79 @@
-/*
- * 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.endpoint.tribes;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class ReplicatedEndpointRegistryTestCase {
-
- @Test
- @Ignore("Ignore this test case for now as it might be sensitive to the multicast settings for a multi-homed machine")
- public void testReplicate() throws InterruptedException {
- DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
- FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
-
- ReplicatedEndpointRegistry ep1 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
- System.out.println("ep1 is: " + ep1);
- ep1.start();
-
- Endpoint e1 = assemblyFactory.createEndpoint();
- e1.setURI("e1uri");
- ((RuntimeEndpoint) e1).bind(extensionPoints, ep1);
- ep1.addEndpoint(e1);
-
- Endpoint e1p = ep1.getEndpoint("e1uri");
- System.out.println("EP1 in Registry 1: " + e1p);
- Assert.assertNotNull(e1p);
-
- ReplicatedEndpointRegistry ep2 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
- System.out.println("ep2 is: " + ep2);
- ep2.start();
- Thread.sleep(5000);
-
- Endpoint e1p2 = ep2.getEndpoint("e1uri");
- System.out.println("EP1 in Registry 2: " + e1p2);
- Assert.assertNotNull(e1p2);
-
- ReplicatedEndpointRegistry ep3 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
- System.out.println("ep3 is: " + ep3);
- ep3.start();
- Thread.sleep(5000);
-
- Endpoint e1p3 = ep3.getEndpoint("e1uri");
- System.out.println("EP1 in Registry 3: " + e1p3);
- Assert.assertNotNull(e1p3);
-
- ep1.stop();
- ep2.stop();
- ep3.stop();
- }
-
- public static void main(String[] args) throws Exception {
- new ReplicatedEndpointRegistryTestCase().testReplicate();
- }
-}
+/*
+ * 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.endpoint.tribes;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ReplicatedEndpointRegistryTestCase {
+
+ @Test
+ @Ignore("Ignore this test case for now as it might be sensitive to the multicast settings for a multi-homed machine")
+ public void testReplicate() throws InterruptedException {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ ReplicatedEndpointRegistry ep1 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
+ System.out.println("ep1 is: " + ep1);
+ ep1.start();
+
+ Endpoint e1 = assemblyFactory.createEndpoint();
+ e1.setURI("e1uri");
+ ((RuntimeEndpoint) e1).bind(extensionPoints, ep1);
+ ep1.addEndpoint(e1);
+
+ Endpoint e1p = ep1.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 1: " + e1p);
+ Assert.assertNotNull(e1p);
+
+ ReplicatedEndpointRegistry ep2 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
+ System.out.println("ep2 is: " + ep2);
+ ep2.start();
+ Thread.sleep(5000);
+
+ Endpoint e1p2 = ep2.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 2: " + e1p2);
+ Assert.assertNotNull(e1p2);
+
+ ReplicatedEndpointRegistry ep3 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
+ System.out.println("ep3 is: " + ep3);
+ ep3.start();
+ Thread.sleep(5000);
+
+ Endpoint e1p3 = ep3.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 3: " + e1p3);
+ Assert.assertNotNull(e1p3);
+
+ ep1.stop();
+ ep2.stop();
+ ep3.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+ new ReplicatedEndpointRegistryTestCase().testReplicate();
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java
index 5b925f5b2c..10c6d8706c 100644
--- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java
+++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java
@@ -1,36 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.host.http;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-
-/**
- *
- * @tuscany.spi.extension.asclient
- *
- */
-
-public class ServletHostHelper {
-
- public static ServletHost getServletHost(ExtensionPointRegistry extensionPoints) {
- ExtensibleServletHost host = ExtensibleServletHost.getInstance(extensionPoints);
- return host.getDefaultServletHost();
- }
-}
+/*
+ * 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.host.http;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+
+public class ServletHostHelper {
+
+ public static ServletHost getServletHost(ExtensionPointRegistry extensionPoints) {
+ ExtensibleServletHost host = ExtensibleServletHost.getInstance(extensionPoints);
+ return host.getDefaultServletHost();
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml b/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
index c7aac1a19c..3b1ff92fba 100644
--- a/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-script-runtime/pom.xml
@@ -1,189 +1,189 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-implementation-script-runtime</artifactId>
- <name>Apache Tuscany SCA Script Implementation Extension</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-script</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-databinding</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.bsf</groupId>
- <artifactId>bsf-all</artifactId>
- <version>3.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-interface-wsdl</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-api</artifactId>
- <exclusions>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- </exclusions>
- <version>1.2.8</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom-impl</artifactId>
- <version>1.2.8</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>test</scope>
- </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>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
-<!-- TODO: big hack to add script engine dependencies till extension dependencies fixed -->
-
- <dependency>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
- <version>1.7R2</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jruby</groupId>
- <artifactId>jruby-complete</artifactId>
- <version>1.4.0</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm-commons</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.python</groupId>
- <artifactId>jython</artifactId>
- <version>2.2.1</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>1.7.1</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.fusesource.jansi</groupId>
- <artifactId>jansi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <name>Apache Tuscany SCA Script Implementation Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-all</artifactId>
+ <version>3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ <version>1.2.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </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>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+<!-- TODO: big hack to add script engine dependencies till extension dependencies fixed -->
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.7R2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby-complete</artifactId>
+ <version>1.4.0</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ <version>2.2.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.7.1</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.fusesource.jansi</groupId>
+ <artifactId>jansi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java b/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java
index f84faa7bb4..0938462c49 100644
--- a/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java
+++ b/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java
@@ -51,7 +51,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
* An ImplementationProvider for Script implementations.
*
- * @version $Rev: $ $Date: $
+ * @version $Rev$ $Date$
*/
public class ScriptImplementationProvider implements ImplementationProvider {
diff --git a/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java b/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java
index 5bed70cbc7..67d4a5493c 100644
--- a/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java
@@ -31,7 +31,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* An ImplementationProviderFactory for Script implementations.
*
- * @version $Rev: $ $Date: $
+ * @version $Rev$ $Date$
*/
public class ScriptImplementationProviderFactory implements ImplementationProviderFactory<ScriptImplementation> {
diff --git a/sca-java-2.x/trunk/modules/implementation-script/pom.xml b/sca-java-2.x/trunk/modules/implementation-script/pom.xml
index 84b81a57d7..0aad4c121d 100644
--- a/sca-java-2.x/trunk/modules/implementation-script/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-script/pom.xml
@@ -1,48 +1,48 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-implementation-script</artifactId>
- <name>Apache Tuscany SCA Script Implementation Model</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xml</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-script</artifactId>
+ <name>Apache Tuscany SCA Script Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java b/sca-java-2.x/trunk/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java
index 273306894b..a3f302d4fc 100644
--- a/sca-java-2.x/trunk/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java
@@ -47,7 +47,7 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* ScriptImplementationProcessor
*
- * @version $Rev: $ $Date: $
+ * @version $Rev$ $Date$
*/
public class ScriptImplementationProcessor implements StAXArtifactProcessor<ScriptImplementation> {
private static final QName IMPLEMENTATION_SCRIPT = ScriptImplementation.TYPE;
diff --git a/sca-java-2.x/trunk/modules/implementation-web-client/pom.xml b/sca-java-2.x/trunk/modules/implementation-web-client/pom.xml
index 96feda6d75..15b1a1b76b 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-client/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-web-client/pom.xml
@@ -1,68 +1,68 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-implementation-web-client</artifactId>
- <name>Apache Tuscany SCA Web Implementation Client</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-web-runtime</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.directwebremoting</groupId>
- <artifactId>dwr</artifactId>
- <version>2.0.3</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <name>Apache Tuscany SCA Web Implementation Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.directwebremoting</groupId>
+ <artifactId>dwr</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
index 5316efeef0..f827c56241 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
@@ -1,259 +1,259 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.implementation.web.client;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.directwebremoting.Container;
-import org.directwebremoting.create.AbstractCreator;
-import org.directwebremoting.extend.CreatorManager;
-import org.directwebremoting.extend.Handler;
-import org.directwebremoting.extend.Remoter;
-import org.directwebremoting.servlet.DwrServlet;
-import org.directwebremoting.servlet.EngineHandler;
-import org.directwebremoting.servlet.PathConstants;
-import org.directwebremoting.servlet.UrlProcessor;
-
-/**
- * Tuscany customized DWR Servlet to implement support for the DWR binding
- *
- * Handles requests for SCA services and references that use <binding.dwr>
- */
-public class ClientServlet extends DwrServlet {
- private static final long serialVersionUID = 1L;
-
- private transient Map<String, RuntimeEndpointReference> serviceRefs;
-// private transient List<String> referenceNames;
- private transient boolean initialized;
- private transient Map<String, String> initParams;
-
- public static final String SCRIPT_PATH = "/org.oasisopen.sca.componentContext.js";
-
- public ClientServlet() {
- this.serviceRefs = new HashMap<String, RuntimeEndpointReference>();
-// this.referenceNames = new ArrayList<String>();
-
- this.initParams = new HashMap<String, String>();
- // maybe use <binding.dwr> attributes to define the init params
- initParams.put("activeReverseAjaxEnabled", "true");
- }
-
- @Override
- public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- super.service(req, res);
- }
-
- /**
- * Initialize the Servlet
- * There is a single instance of this Servlet which is registered
- * for multiple path mappings, but the init should only run once.
- */
- @Override
- public void init(ServletConfig servletConfig) throws ServletException {
- if (!initialized) {
- super.init(patchConfig(servletConfig));
- addScriptHandler();
- // initServices();
- initialized = true;
- }
- }
-
- /**
- * Add in the handler to process the HTTP get for /sca/scaDomain.js
- *
- * This wrappers the DWR Engine handler which returns the DWR engine.js script,
- * this wrappers that handler so as to add Tuscany specific header and footer code
- * to the DWR engine.js to define the Tuscany SCADomain control functions and
- * functions for each SCA service and reference that use <binding.dwr>.
- */
- private void addScriptHandler() {
-
- UrlProcessor urlProcessor = (UrlProcessor)getContainer().getBean(UrlProcessor.class.getName());
-
- final EngineHandler engineHandler =
- (EngineHandler)getContainer().getBean(PathConstants.URL_PREFIX + "/engine.js");
-
- final Handler scaDomainScriptHandler = new Handler() {
- public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
- PrintWriter out = response.getWriter();
- out.println("/** Apache Tuscany componentContext.js Header */");
-
- engineHandler.handle(request, response);
-
- tuscanyFooter(request, out);
- }
-
- };
-
- // add the scaDomainScriptHandler to the urlProcessor
- // bit of a hack, there's probably cleaner way to get it registered
- urlProcessor.afterContainerSetup(new Container() {
- public Object getBean(String name) {
- return scaDomainScriptHandler;
- }
- public Collection<?> getBeanNames() {
- return Arrays.asList(new String[] {PathConstants.URL_PREFIX + SCRIPT_PATH});
- }
- });
- }
-
- /**
- * Adds the JavaScript defining SCADomain, its control functions,
- * and functions for all the available SCA services and references.
- */
- private void tuscanyFooter(HttpServletRequest request, PrintWriter out) {
- out.println("if (SCA == undefined) var SCA = new Object();");
- out.println("if (SCA.componentContext == undefined) {");
- out.println(" SCA.componentContext = new Object();");
- out.println(" SCA.componentContext.serviceNames = [];");
- out.println(" SCA.componentContext.serviceProxys = [];");
- out.println(" SCA.componentContext.getService = function(serviceName){");
- out.println(" var i = SCA.componentContext.serviceNames.indexOf(serviceName);");
- out.println(" return SCA.componentContext.serviceProxys[i];");
- out.println(" };");
- out.println(" if (componentContext == undefined) var componentContext = SCA.componentContext;");
- out.println("}");
-
-// out.println("/** Apache Tuscany scaDomain.js Footer */");
-// out.println();
-// out.println("function scaDomain() { }");
-// out.println();
-// out.println("// SCA services");
-
- // Use the DWR remoter to generate the JavaScipt function for each SCA service
- Remoter remoter = (Remoter)getContainer().getBean(Remoter.class.getName());
-
-
- for (String serviceName : serviceRefs.keySet()) {
- String path = request.getServletPath() + "/" + serviceName;
- String serviceScript = remoter.generateInterfaceScript(serviceName, path);
- out.println(serviceScript);
- out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
- out.println("SCA.componentContext.serviceProxys.push(" + serviceName + ");");
-// ServiceHolder s = services.get(serviceName);
-// final Class<?> iface = ((JavaInterface)s.cr.getInterfaceContract().getInterface()).getJavaClass();
-// for (Method m : iface.getMethods()) {
-// out.println("if (" + serviceName + " == null) var " + serviceName + " = {};");
-// out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
-//// out.println("SCA.componentContext.serviceProxys.push(new JSONRpcClient('" + serviceName + "').Service);");
-// out.println(serviceName + "." + m.getName() + " = function(p0, callback) {");
-// out.println(" dwr.engine._execute(" + serviceName + "._path, '" + serviceName + "', '" + m.getName() + "', p0, callback);");
-// out.println(" }");
-// }
- }
-
-// if (referenceNames.size() > 0) {
-//
-// out.println("// SCA reverse ajax control functions");
-// out.println();
-// out.println("scaDomain.open = function() { dwr.engine.setActiveReverseAjax(true); };");
-// out.println("scaDomain.close = function() { dwr.engine.setActiveReverseAjax(false); };");
-//
-// out.println();
-// out.println("// SCA references");
-// out.println();
-//
-// // the JavaScript function for SCA references has an
-// // empty impl as it uses DWR severside "push"
-// for (String referenceName : referenceNames) {
-// out.println("function " + referenceName + "() { }");
-// }
-// }
-
- out.println();
- out.println("/** End of Apache Tuscany componentContext.js */");
- out.println();
- }
-
-// /**
-// * Add an SCA reference to be added to the DWR runtime
-// */
-// public void addReference(String name) {
-// referenceNames.add(name);
-// }
-
- /**
- * Add an SCA service to be added to the DWR runtime
- */
- public void addService(RuntimeEndpointReference epr) {
-
- CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
- addService(creatorManager, epr);
- serviceRefs.put(epr.getReference().getName(), epr);
- }
-
- private void addService(CreatorManager creatorManager, final RuntimeEndpointReference epr) {
- final Class<?> iface = ((JavaInterface)epr.getComponentTypeReferenceInterfaceContract().getInterface()).getJavaClass();
-
- creatorManager.addCreator(epr.getReference().getName(), new AbstractCreator() {
- public Class<?> getType() {
- return iface;
- }
-
- public Object getInstance() throws InstantiationException {
- ExtensionPointRegistry registry = epr.getCompositeContext().getExtensionPointRegistry();
- ExtensibleProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
- return proxyFactory.createProxy(iface, epr);
- }
- });
- }
-
- /**
- * Patch the ServletConfig to enable setting init params for DWR
- * and so DWR can't see the Tuscany servlet's init params.
- */
- private ServletConfig patchConfig(final ServletConfig servletConfig) {
- ServletConfig patchedContext = new ServletConfig() {
- public String getInitParameter(String name) {
- return initParams.get(name);
- }
- public Enumeration<?> getInitParameterNames() {
- return Collections.enumeration(initParams.keySet());
- }
- public ServletContext getServletContext() {
- return servletConfig.getServletContext();
- }
- public String getServletName() {
- return servletConfig.getServletName();
- }
- };
- return patchedContext;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.client;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.directwebremoting.Container;
+import org.directwebremoting.create.AbstractCreator;
+import org.directwebremoting.extend.CreatorManager;
+import org.directwebremoting.extend.Handler;
+import org.directwebremoting.extend.Remoter;
+import org.directwebremoting.servlet.DwrServlet;
+import org.directwebremoting.servlet.EngineHandler;
+import org.directwebremoting.servlet.PathConstants;
+import org.directwebremoting.servlet.UrlProcessor;
+
+/**
+ * Tuscany customized DWR Servlet to implement support for the DWR binding
+ *
+ * Handles requests for SCA services and references that use <binding.dwr>
+ */
+public class ClientServlet extends DwrServlet {
+ private static final long serialVersionUID = 1L;
+
+ private transient Map<String, RuntimeEndpointReference> serviceRefs;
+// private transient List<String> referenceNames;
+ private transient boolean initialized;
+ private transient Map<String, String> initParams;
+
+ public static final String SCRIPT_PATH = "/org.oasisopen.sca.componentContext.js";
+
+ public ClientServlet() {
+ this.serviceRefs = new HashMap<String, RuntimeEndpointReference>();
+// this.referenceNames = new ArrayList<String>();
+
+ this.initParams = new HashMap<String, String>();
+ // maybe use <binding.dwr> attributes to define the init params
+ initParams.put("activeReverseAjaxEnabled", "true");
+ }
+
+ @Override
+ public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
+ super.service(req, res);
+ }
+
+ /**
+ * Initialize the Servlet
+ * There is a single instance of this Servlet which is registered
+ * for multiple path mappings, but the init should only run once.
+ */
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ if (!initialized) {
+ super.init(patchConfig(servletConfig));
+ addScriptHandler();
+ // initServices();
+ initialized = true;
+ }
+ }
+
+ /**
+ * Add in the handler to process the HTTP get for /sca/scaDomain.js
+ *
+ * This wrappers the DWR Engine handler which returns the DWR engine.js script,
+ * this wrappers that handler so as to add Tuscany specific header and footer code
+ * to the DWR engine.js to define the Tuscany SCADomain control functions and
+ * functions for each SCA service and reference that use <binding.dwr>.
+ */
+ private void addScriptHandler() {
+
+ UrlProcessor urlProcessor = (UrlProcessor)getContainer().getBean(UrlProcessor.class.getName());
+
+ final EngineHandler engineHandler =
+ (EngineHandler)getContainer().getBean(PathConstants.URL_PREFIX + "/engine.js");
+
+ final Handler scaDomainScriptHandler = new Handler() {
+ public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ PrintWriter out = response.getWriter();
+ out.println("/** Apache Tuscany componentContext.js Header */");
+
+ engineHandler.handle(request, response);
+
+ tuscanyFooter(request, out);
+ }
+
+ };
+
+ // add the scaDomainScriptHandler to the urlProcessor
+ // bit of a hack, there's probably cleaner way to get it registered
+ urlProcessor.afterContainerSetup(new Container() {
+ public Object getBean(String name) {
+ return scaDomainScriptHandler;
+ }
+ public Collection<?> getBeanNames() {
+ return Arrays.asList(new String[] {PathConstants.URL_PREFIX + SCRIPT_PATH});
+ }
+ });
+ }
+
+ /**
+ * Adds the JavaScript defining SCADomain, its control functions,
+ * and functions for all the available SCA services and references.
+ */
+ private void tuscanyFooter(HttpServletRequest request, PrintWriter out) {
+ out.println("if (SCA == undefined) var SCA = new Object();");
+ out.println("if (SCA.componentContext == undefined) {");
+ out.println(" SCA.componentContext = new Object();");
+ out.println(" SCA.componentContext.serviceNames = [];");
+ out.println(" SCA.componentContext.serviceProxys = [];");
+ out.println(" SCA.componentContext.getService = function(serviceName){");
+ out.println(" var i = SCA.componentContext.serviceNames.indexOf(serviceName);");
+ out.println(" return SCA.componentContext.serviceProxys[i];");
+ out.println(" };");
+ out.println(" if (componentContext == undefined) var componentContext = SCA.componentContext;");
+ out.println("}");
+
+// out.println("/** Apache Tuscany scaDomain.js Footer */");
+// out.println();
+// out.println("function scaDomain() { }");
+// out.println();
+// out.println("// SCA services");
+
+ // Use the DWR remoter to generate the JavaScipt function for each SCA service
+ Remoter remoter = (Remoter)getContainer().getBean(Remoter.class.getName());
+
+
+ for (String serviceName : serviceRefs.keySet()) {
+ String path = request.getServletPath() + "/" + serviceName;
+ String serviceScript = remoter.generateInterfaceScript(serviceName, path);
+ out.println(serviceScript);
+ out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
+ out.println("SCA.componentContext.serviceProxys.push(" + serviceName + ");");
+// ServiceHolder s = services.get(serviceName);
+// final Class<?> iface = ((JavaInterface)s.cr.getInterfaceContract().getInterface()).getJavaClass();
+// for (Method m : iface.getMethods()) {
+// out.println("if (" + serviceName + " == null) var " + serviceName + " = {};");
+// out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
+//// out.println("SCA.componentContext.serviceProxys.push(new JSONRpcClient('" + serviceName + "').Service);");
+// out.println(serviceName + "." + m.getName() + " = function(p0, callback) {");
+// out.println(" dwr.engine._execute(" + serviceName + "._path, '" + serviceName + "', '" + m.getName() + "', p0, callback);");
+// out.println(" }");
+// }
+ }
+
+// if (referenceNames.size() > 0) {
+//
+// out.println("// SCA reverse ajax control functions");
+// out.println();
+// out.println("scaDomain.open = function() { dwr.engine.setActiveReverseAjax(true); };");
+// out.println("scaDomain.close = function() { dwr.engine.setActiveReverseAjax(false); };");
+//
+// out.println();
+// out.println("// SCA references");
+// out.println();
+//
+// // the JavaScript function for SCA references has an
+// // empty impl as it uses DWR severside "push"
+// for (String referenceName : referenceNames) {
+// out.println("function " + referenceName + "() { }");
+// }
+// }
+
+ out.println();
+ out.println("/** End of Apache Tuscany componentContext.js */");
+ out.println();
+ }
+
+// /**
+// * Add an SCA reference to be added to the DWR runtime
+// */
+// public void addReference(String name) {
+// referenceNames.add(name);
+// }
+
+ /**
+ * Add an SCA service to be added to the DWR runtime
+ */
+ public void addService(RuntimeEndpointReference epr) {
+
+ CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
+ addService(creatorManager, epr);
+ serviceRefs.put(epr.getReference().getName(), epr);
+ }
+
+ private void addService(CreatorManager creatorManager, final RuntimeEndpointReference epr) {
+ final Class<?> iface = ((JavaInterface)epr.getComponentTypeReferenceInterfaceContract().getInterface()).getJavaClass();
+
+ creatorManager.addCreator(epr.getReference().getName(), new AbstractCreator() {
+ public Class<?> getType() {
+ return iface;
+ }
+
+ public Object getInstance() throws InstantiationException {
+ ExtensionPointRegistry registry = epr.getCompositeContext().getExtensionPointRegistry();
+ ExtensibleProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ return proxyFactory.createProxy(iface, epr);
+ }
+ });
+ }
+
+ /**
+ * Patch the ServletConfig to enable setting init params for DWR
+ * and so DWR can't see the Tuscany servlet's init params.
+ */
+ private ServletConfig patchConfig(final ServletConfig servletConfig) {
+ ServletConfig patchedContext = new ServletConfig() {
+ public String getInitParameter(String name) {
+ return initParams.get(name);
+ }
+ public Enumeration<?> getInitParameterNames() {
+ return Collections.enumeration(initParams.keySet());
+ }
+ public ServletContext getServletContext() {
+ return servletConfig.getServletContext();
+ }
+ public String getServletName() {
+ return servletConfig.getServletName();
+ }
+ };
+ return patchedContext;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
index 049cda2eb8..9c95eaea3b 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
@@ -1,70 +1,70 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.implementation.web.client;
-
-import org.apache.tuscany.sca.assembly.ComponentReference;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.host.http.ServletHostHelper;
-import org.apache.tuscany.sca.implementation.web.WebImplementation;
-import org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-
-public class JSClientExtensionPointImpl implements ClientExtensionPoint {
-
- private ServletHost servletHost;
-
- public JSClientExtensionPointImpl(ExtensionPointRegistry extensionPoints) {
- this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
- }
-
- public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) {
- ClientServlet clientServlet = new ClientServlet();
- servletHost.addServletMapping(ClientServlet.SCRIPT_PATH, clientServlet);
- servletHost.addServletMapping(ClientServlet.SCRIPT_PATH + "/" + component.getName() + "/*", clientServlet);
-
- if (component.getReferences().size() > 0) {
- for (ComponentReference cr : component.getReferences()) {
- for (EndpointReference epr : cr.getEndpointReferences()) {
- clientServlet.addService((RuntimeEndpointReference)epr);
- }
- }
- }
-
- return new ImplementationProvider() {
- public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {
- return null;
- }
- public void start() {
- }
- public void stop() {
- }
- public boolean supportsOneWayInvocation() {
- return false;
- }
- };
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.client;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class JSClientExtensionPointImpl implements ClientExtensionPoint {
+
+ private ServletHost servletHost;
+
+ public JSClientExtensionPointImpl(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) {
+ ClientServlet clientServlet = new ClientServlet();
+ servletHost.addServletMapping(ClientServlet.SCRIPT_PATH, clientServlet);
+ servletHost.addServletMapping(ClientServlet.SCRIPT_PATH + "/" + component.getName() + "/*", clientServlet);
+
+ if (component.getReferences().size() > 0) {
+ for (ComponentReference cr : component.getReferences()) {
+ for (EndpointReference epr : cr.getEndpointReferences()) {
+ clientServlet.addService((RuntimeEndpointReference)epr);
+ }
+ }
+ }
+
+ return new ImplementationProvider() {
+ public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {
+ return null;
+ }
+ public void start() {
+ }
+ public void stop() {
+ }
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+ };
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java b/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java
index ed66c6efed..0829cfeca5 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java
@@ -1,30 +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 org.apache.tuscany.sca.implementation.web.runtime;
-
-import org.apache.tuscany.sca.implementation.web.WebImplementation;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-public interface ClientExtensionPoint {
-
- public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.runtime;
+
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public interface ClientExtensionPoint {
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation);
+
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java b/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java
index 798b3e704c..64622ee76c 100644
--- a/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java
+++ b/sca-java-2.x/trunk/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java
@@ -1,85 +1,85 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.implementation.web.runtime;
-
-import java.util.Collection;
-
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.oasisopen.sca.ComponentContext;
-import org.oasisopen.sca.RequestContext;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Proxy ComponentContext wrappering a RuntimeComponent as the
- * RuntimeComponent ComponentContext has not been created till later
- */
-public class ComponentContextProxy implements ComponentContext {
-
- protected RuntimeComponent runtimeComponent;
-
- public ComponentContextProxy(RuntimeComponent runtimeComponent) {
- this.runtimeComponent = runtimeComponent;
- }
-
- protected ComponentContext getComponentContext() {
- return runtimeComponent.getComponentContext();
- }
-
- public <B> ServiceReference<B> cast(B target) throws IllegalArgumentException {
- return getComponentContext().cast(target);
- }
-
- public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
- return getComponentContext().createSelfReference(businessInterface);
- }
-
- public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
- return getComponentContext().createSelfReference(businessInterface, serviceName);
- }
-
- public <B> B getProperty(Class<B> type, String propertyName) {
- return getComponentContext().getProperty(type, propertyName);
- }
-
- public RequestContext getRequestContext() {
- return getComponentContext().getRequestContext();
- }
-
- public <B> B getService(Class<B> businessInterface, String referenceName) {
- return getComponentContext().getService(businessInterface, referenceName);
- }
-
- public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
- return getComponentContext().getServiceReference(businessInterface, referenceName);
- }
-
- public <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName) {
- return getComponentContext().getServiceReferences(businessInterface, referenceName);
- }
-
- public <B> Collection<B> getServices(Class<B> businessInterface, String referenceName) {
- return getComponentContext().getServices(businessInterface, referenceName);
- }
-
- public String getURI() {
- return getComponentContext().getURI();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.runtime;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Proxy ComponentContext wrappering a RuntimeComponent as the
+ * RuntimeComponent ComponentContext has not been created till later
+ */
+public class ComponentContextProxy implements ComponentContext {
+
+ protected RuntimeComponent runtimeComponent;
+
+ public ComponentContextProxy(RuntimeComponent runtimeComponent) {
+ this.runtimeComponent = runtimeComponent;
+ }
+
+ protected ComponentContext getComponentContext() {
+ return runtimeComponent.getComponentContext();
+ }
+
+ public <B> ServiceReference<B> cast(B target) throws IllegalArgumentException {
+ return getComponentContext().cast(target);
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
+ return getComponentContext().createSelfReference(businessInterface);
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
+ return getComponentContext().createSelfReference(businessInterface, serviceName);
+ }
+
+ public <B> B getProperty(Class<B> type, String propertyName) {
+ return getComponentContext().getProperty(type, propertyName);
+ }
+
+ public RequestContext getRequestContext() {
+ return getComponentContext().getRequestContext();
+ }
+
+ public <B> B getService(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServiceReference(businessInterface, referenceName);
+ }
+
+ public <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServiceReferences(businessInterface, referenceName);
+ }
+
+ public <B> Collection<B> getServices(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServices(businessInterface, referenceName);
+ }
+
+ public String getURI() {
+ return getComponentContext().getURI();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java b/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java
index 9fffd93dca..e1891e6c0b 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java
@@ -34,7 +34,7 @@ import java.util.Map;
import org.objectweb.asm.Opcodes;
/**
- * @version $Rev: 673298 $ $Date: 2008-07-01 23:47:40 -0700 (Tue, 01 Jul 2008) $
+ * @version $Rev$ $Date$
*/
public class CodeGenerationHelper {
/**
diff --git a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
index 47975870bf..368893dd68 100644
--- a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
+++ b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
@@ -1,40 +1,40 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.monitor;
-
-public class ValidationException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public ValidationException() {
- super();
- }
-
- public ValidationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ValidationException(String message) {
- super(message);
- }
-
- public ValidationException(Throwable cause) {
- super(cause);
- }
-}
+/*
+ * 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.monitor;
+
+public class ValidationException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ValidationException() {
+ super();
+ }
+
+ public ValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ValidationException(String message) {
+ super(message);
+ }
+
+ public ValidationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java
index fe7f779f5e..1192b16778 100644
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java
+++ b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java
@@ -1,46 +1,46 @@
-/*
- * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-package org.oasisopen.sca;
-
-import java.util.Map;
-
-/**
- *
- * The following defines the ResponseDispatch interface, used to return a response
- * message asynchronously from a service implementation method.
- *
- * @param <T> the type of the Response message returned by the service implementation method
- */
-public interface ResponseDispatch<T> {
-
- /**
- * Sends the response message from an asynchronous service method.
- * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
- * if sendFault has previously been invoked for the same ResponseDispatch object.
- * @param res an instance of the response message returned by the service operation
- * @exception InvalidStateException if this method is called more than once for the same service
- * operation.
- */
- void sendResponse(T res);
-
- /**
- * Sends an exception as a fault from an asynchronous service method.
- * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
- * if sendResponse has previously been invoked for the same ResponseDispatch object.
- * @param e an instance of an exception returned by the service operation
- * @exception InvalidStateException if this method is called more than once for the same service
- * operation.
- */
- void sendFault(Throwable e);
-
- /**
- * Obtains the context object for the ResponseDispatch method
- * @return a Map which is is the context object for the ResponseDispatch object.
- * The invoker can update the context object with appropriate context information, prior to invoking
- * either the sendResponse method or the sendFault method
- */
- Map<String, Object> getContext();
-}
-
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+import java.util.Map;
+
+/**
+ *
+ * The following defines the ResponseDispatch interface, used to return a response
+ * message asynchronously from a service implementation method.
+ *
+ * @param <T> the type of the Response message returned by the service implementation method
+ */
+public interface ResponseDispatch<T> {
+
+ /**
+ * Sends the response message from an asynchronous service method.
+ * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
+ * if sendFault has previously been invoked for the same ResponseDispatch object.
+ * @param res an instance of the response message returned by the service operation
+ * @exception InvalidStateException if this method is called more than once for the same service
+ * operation.
+ */
+ void sendResponse(T res);
+
+ /**
+ * Sends an exception as a fault from an asynchronous service method.
+ * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
+ * if sendResponse has previously been invoked for the same ResponseDispatch object.
+ * @param e an instance of an exception returned by the service operation
+ * @exception InvalidStateException if this method is called more than once for the same service
+ * operation.
+ */
+ void sendFault(Throwable e);
+
+ /**
+ * Obtains the context object for the ResponseDispatch method
+ * @return a Map which is is the context object for the ResponseDispatch object.
+ * The invoker can update the context object with appropriate context information, prior to invoking
+ * either the sendResponse method or the sendFault method
+ */
+ Map<String, Object> getContext();
+}
+
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java
index 6f36f97bff..278e8ead57 100644
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java
+++ b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java
@@ -1,27 +1,27 @@
-/*
- * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-package org.oasisopen.sca.annotation;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * The @AsyncFault annotation is used to indicate the faults/exceptions which are returned by
- * the asynchronous service method which it annotates.
- *
- */
-@Inherited
-@Target({METHOD})
-@Retention(RUNTIME)
-public @interface AsyncFault {
-
- Class<?>[] value() default {};
-
-}
-
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @AsyncFault annotation is used to indicate the faults/exceptions which are returned by
+ * the asynchronous service method which it annotates.
+ *
+ */
+@Inherited
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface AsyncFault {
+
+ Class<?>[] value() default {};
+
+}
+
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java
index 43233e9747..c6a4147afd 100644
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java
+++ b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java
@@ -1,29 +1,29 @@
-/*
- * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-package org.oasisopen.sca.annotation;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static org.oasisopen.sca.Constants.SCA_PREFIX;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * The @AsyncInvocation annotation is used to indicate that the operations of a Java interface
- * uses the long-running request-response pattern as described in the SCA Assembly specification.
- *
- */
-@Inherited
-@Target({TYPE, METHOD})
-@Retention(RUNTIME)
-@Intent(AsyncInvocation.ASYNCINVOCATION)
-public @interface AsyncInvocation {
- String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation";
-
- boolean value() default true;
-}
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @AsyncInvocation annotation is used to indicate that the operations of a Java interface
+ * uses the long-running request-response pattern as described in the SCA Assembly specification.
+ *
+ */
+@Inherited
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+@Intent(AsyncInvocation.ASYNCINVOCATION)
+public @interface AsyncInvocation {
+ String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation";
+
+ boolean value() default true;
+}
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java
index 795fe30714..54a73fc023 100644
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java
+++ b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java
@@ -1,35 +1,35 @@
-/*
- * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-
-package org.oasisopen.sca.client;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.oasisopen.sca.NoSuchDomainException;
-
-/* A Service Provider Interface representing a SCAClientFactory finder.
- * SCA provides a default reference implementation of this interface.
- * SCA runtime vendors can create alternative implementations of this
- * interface that use different class loading or lookup mechanisms.
- */
-public interface SCAClientFactoryFinder {
-
- /**
- * Method for finding the SCAClientFactory for a given Domain URI using
- * a specified set of properties and a a specified ClassLoader
- * @param properties - properties to use - may be null
- * @param classLoader - ClassLoader to use - may be null
- * @param domainURI - the Domain URI - must be a valid SCA Domain URI
- * @return - the SCAClientFactory or null if the factory could not be
- * @throws - NoSuchDomainException if the domainURI does not reference
- * a valid SCA Domain
- * found
- */
- SCAClientFactory find(Properties properties,
- ClassLoader classLoader,
- URI domainURI )
- throws NoSuchDomainException ;
-}
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+
+package org.oasisopen.sca.client;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+
+/* A Service Provider Interface representing a SCAClientFactory finder.
+ * SCA provides a default reference implementation of this interface.
+ * SCA runtime vendors can create alternative implementations of this
+ * interface that use different class loading or lookup mechanisms.
+ */
+public interface SCAClientFactoryFinder {
+
+ /**
+ * Method for finding the SCAClientFactory for a given Domain URI using
+ * a specified set of properties and a a specified ClassLoader
+ * @param properties - properties to use - may be null
+ * @param classLoader - ClassLoader to use - may be null
+ * @param domainURI - the Domain URI - must be a valid SCA Domain URI
+ * @return - the SCAClientFactory or null if the factory could not be
+ * @throws - NoSuchDomainException if the domainURI does not reference
+ * a valid SCA Domain
+ * found
+ */
+ SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI )
+ throws NoSuchDomainException ;
+}
diff --git a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java
index 4aa312f6b5..0f5eae7603 100644
--- a/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java
@@ -1,289 +1,289 @@
-/*
- * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-package org.oasisopen.sca.client.impl;
-
-import org.oasisopen.sca.client.SCAClientFactoryFinder;
-
-import java.io.BufferedReader;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.net.URI;
-import java.net.URL;
-import java.util.Properties;
-
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.oasisopen.sca.client.SCAClientFactory;
-
-/**
- * This is a default implementation of an SCAClientFactoryFinder which is
- * used to find an implementation of the SCAClientFactory interface.
- *
- * @see SCAClientFactoryFinder
- * @see SCAClientFactory
- *
- * @author OASIS Open
- */
-public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
-
- /**
- * The name of the System Property used to determine the SPI
- * implementation to use for the SCAClientFactory.
- */
- private static final String SCA_CLIENT_FACTORY_PROVIDER_KEY =
- SCAClientFactory.class.getName();
-
- /**
- * The name of the file loaded from the ClassPath to determine
- * the SPI implementation to use for the SCAClientFactory.
- */
- private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE
- = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY;
-
- /**
- * Public Constructor
- */
- public SCAClientFactoryFinderImpl() {
- }
-
- /**
- * Creates an instance of the SCAClientFactorySPI implementation.
- * This discovers the SCAClientFactorySPI Implementation and instantiates
- * the provider's implementation.
- *
- * @param properties Properties that may be used when creating a new
- * instance of the SCAClient
- * @param classLoader ClassLoader that may be used when creating a new
- * instance of the SCAClient
- * @return new instance of the SCAClientFactory
- * @throws ServiceRuntimeException Failed to create SCAClientFactory
- * Implementation.
- */
- public SCAClientFactory find(Properties properties,
- ClassLoader classLoader,
- URI domainURI )
- throws NoSuchDomainException, ServiceRuntimeException {
- if (classLoader == null) {
- classLoader = getThreadContextClassLoader ();
- }
- final String factoryImplClassName =
- discoverProviderFactoryImplClass(properties, classLoader);
- final Class<? extends SCAClientFactory> factoryImplClass
- = loadProviderFactoryClass(factoryImplClassName,
- classLoader);
- final SCAClientFactory factory =
- instantiateSCAClientFactoryClass(factoryImplClass,
- domainURI );
- return factory;
- }
-
- /**
- * Gets the Context ClassLoader for the current Thread.
- *
- * @return The Context ClassLoader for the current Thread.
- */
- private static ClassLoader getThreadContextClassLoader () {
- final ClassLoader threadClassLoader =
- Thread.currentThread().getContextClassLoader();
- return threadClassLoader;
- }
-
- /**
- * Attempts to discover the class name for the SCAClientFactorySPI
- * implementation from the specified Properties, the System Properties
- * or the specified ClassLoader.
- *
- * @return The class name of the SCAClientFactorySPI implementation
- * @throw ServiceRuntimeException Failed to find implementation for
- * SCAClientFactorySPI.
- */
- private static String
- discoverProviderFactoryImplClass(Properties properties,
- ClassLoader classLoader)
- throws ServiceRuntimeException {
- String providerClassName =
- checkPropertiesForSPIClassName(properties);
- if (providerClassName != null) {
- return providerClassName;
- }
-
- providerClassName =
- checkPropertiesForSPIClassName(System.getProperties());
- if (providerClassName != null) {
- return providerClassName;
- }
-
- providerClassName = checkMETAINFServicesForSPIClassName(classLoader);
- if (providerClassName == null) {
- throw new ServiceRuntimeException(
- "Failed to find implementation for SCAClientFactory");
- }
-
- return providerClassName;
- }
-
- /**
- * Attempts to find the class name for the SCAClientFactorySPI
- * implementation from the specified Properties.
- *
- * @return The class name for the SCAClientFactorySPI implementation
- * or <code>null</code> if not found.
- */
- private static String
- checkPropertiesForSPIClassName(Properties properties) {
- if (properties == null) {
- return null;
- }
-
- final String providerClassName =
- properties.getProperty(SCA_CLIENT_FACTORY_PROVIDER_KEY);
- if (providerClassName != null && providerClassName.length() > 0) {
- return providerClassName;
- }
-
- return null;
- }
-
- /**
- * Attempts to find the class name for the SCAClientFactorySPI
- * implementation from the META-INF/services directory
- *
- * @return The class name for the SCAClientFactorySPI implementation or
- * <code>null</code> if not found.
- */
- private static String checkMETAINFServicesForSPIClassName(ClassLoader cl)
- {
- final URL url =
- cl.getResource(SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE);
- if (url == null) {
- return null;
- }
-
- InputStream in = null;
- try {
- in = url.openStream();
- BufferedReader reader = null;
- try {
- reader =
- new BufferedReader(new InputStreamReader(in, "UTF-8"));
-
- String line;
- while ((line = readNextLine(reader)) != null) {
- if (!line.startsWith("#") && line.length() > 0) {
- return line;
- }
- }
-
- return null;
- } finally {
- closeStream(reader);
- }
- } catch (IOException ex) {
- throw new ServiceRuntimeException(
- "Failed to discover SCAClientFactory provider", ex);
- } finally {
- closeStream(in);
- }
- }
-
- /**
- * Reads the next line from the reader and returns the trimmed version
- * of that line
- *
- * @param reader The reader from which to read the next line
- * @return The trimmed next line or <code>null</code> if the end of the
- * stream has been reached
- * @throws IOException I/O error occurred while reading from Reader
- */
- private static String readNextLine(BufferedReader reader)
- throws IOException {
-
- String line = reader.readLine();
- if (line != null) {
- line = line.trim();
- }
- return line;
- }
-
- /**
- * Loads the specified SCAClientFactory Implementation class.
- *
- * @param factoryImplClassName The name of the SCAClientFactory
- * Implementation class to load
- * @return The specified SCAClientFactory Implementation class
- * @throws ServiceRuntimeException Failed to load the SCAClientFactory
- * Implementation class
- */
- private static Class<? extends SCAClientFactory>
- loadProviderFactoryClass(String factoryImplClassName,
- ClassLoader classLoader)
- throws ServiceRuntimeException {
-
- try {
- final Class<?> providerClass =
- classLoader.loadClass(factoryImplClassName);
- final Class<? extends SCAClientFactory> providerFactoryClass =
- providerClass.asSubclass(SCAClientFactory.class);
- return providerFactoryClass;
- } catch (ClassNotFoundException ex) {
- throw new ServiceRuntimeException(
- "Failed to load SCAClientFactory implementation class "
- + factoryImplClassName, ex);
- } catch (ClassCastException ex) {
- throw new ServiceRuntimeException(
- "Loaded SCAClientFactory implementation class "
- + factoryImplClassName
- + " is not a subclass of "
- + SCAClientFactory.class.getName() , ex);
- }
- }
-
- /**
- * Instantiate an instance of the specified SCAClientFactorySPI
- * Implementation class.
- *
- * @param factoryImplClass The SCAClientFactorySPI Implementation
- * class to instantiate.
- * @return An instance of the SCAClientFactorySPI Implementation class
- * @throws ServiceRuntimeException Failed to instantiate the specified
- * specified SCAClientFactorySPI Implementation class
- */
- private static SCAClientFactory instantiateSCAClientFactoryClass(
- Class<? extends SCAClientFactory> factoryImplClass,
- URI domainURI)
- throws NoSuchDomainException, ServiceRuntimeException {
-
- try {
- Constructor<? extends SCAClientFactory> URIConstructor =
- factoryImplClass.getConstructor(domainURI.getClass());
- SCAClientFactory provider =
- URIConstructor.newInstance( domainURI );
- return provider;
- } catch (Throwable ex) {
- throw new ServiceRuntimeException(
- "Failed to instantiate SCAClientFactory implementation class "
- + factoryImplClass, ex);
- }
- }
-
- /**
- * Utility method for closing Closeable Object.
- *
- * @param closeable The Object to close.
- */
- private static void closeStream(Closeable closeable) {
- if (closeable != null) {
- try{
- closeable.close();
- } catch (IOException ex) {
- throw new ServiceRuntimeException("Failed to close stream",
- ex);
- }
- }
- }
-}
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.client.impl;
+
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This is a default implementation of an SCAClientFactoryFinder which is
+ * used to find an implementation of the SCAClientFactory interface.
+ *
+ * @see SCAClientFactoryFinder
+ * @see SCAClientFactory
+ *
+ * @author OASIS Open
+ */
+public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
+
+ /**
+ * The name of the System Property used to determine the SPI
+ * implementation to use for the SCAClientFactory.
+ */
+ private static final String SCA_CLIENT_FACTORY_PROVIDER_KEY =
+ SCAClientFactory.class.getName();
+
+ /**
+ * The name of the file loaded from the ClassPath to determine
+ * the SPI implementation to use for the SCAClientFactory.
+ */
+ private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE
+ = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY;
+
+ /**
+ * Public Constructor
+ */
+ public SCAClientFactoryFinderImpl() {
+ }
+
+ /**
+ * Creates an instance of the SCAClientFactorySPI implementation.
+ * This discovers the SCAClientFactorySPI Implementation and instantiates
+ * the provider's implementation.
+ *
+ * @param properties Properties that may be used when creating a new
+ * instance of the SCAClient
+ * @param classLoader ClassLoader that may be used when creating a new
+ * instance of the SCAClient
+ * @return new instance of the SCAClientFactory
+ * @throws ServiceRuntimeException Failed to create SCAClientFactory
+ * Implementation.
+ */
+ public SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI )
+ throws NoSuchDomainException, ServiceRuntimeException {
+ if (classLoader == null) {
+ classLoader = getThreadContextClassLoader ();
+ }
+ final String factoryImplClassName =
+ discoverProviderFactoryImplClass(properties, classLoader);
+ final Class<? extends SCAClientFactory> factoryImplClass
+ = loadProviderFactoryClass(factoryImplClassName,
+ classLoader);
+ final SCAClientFactory factory =
+ instantiateSCAClientFactoryClass(factoryImplClass,
+ domainURI );
+ return factory;
+ }
+
+ /**
+ * Gets the Context ClassLoader for the current Thread.
+ *
+ * @return The Context ClassLoader for the current Thread.
+ */
+ private static ClassLoader getThreadContextClassLoader () {
+ final ClassLoader threadClassLoader =
+ Thread.currentThread().getContextClassLoader();
+ return threadClassLoader;
+ }
+
+ /**
+ * Attempts to discover the class name for the SCAClientFactorySPI
+ * implementation from the specified Properties, the System Properties
+ * or the specified ClassLoader.
+ *
+ * @return The class name of the SCAClientFactorySPI implementation
+ * @throw ServiceRuntimeException Failed to find implementation for
+ * SCAClientFactorySPI.
+ */
+ private static String
+ discoverProviderFactoryImplClass(Properties properties,
+ ClassLoader classLoader)
+ throws ServiceRuntimeException {
+ String providerClassName =
+ checkPropertiesForSPIClassName(properties);
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ providerClassName =
+ checkPropertiesForSPIClassName(System.getProperties());
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ providerClassName = checkMETAINFServicesForSPIClassName(classLoader);
+ if (providerClassName == null) {
+ throw new ServiceRuntimeException(
+ "Failed to find implementation for SCAClientFactory");
+ }
+
+ return providerClassName;
+ }
+
+ /**
+ * Attempts to find the class name for the SCAClientFactorySPI
+ * implementation from the specified Properties.
+ *
+ * @return The class name for the SCAClientFactorySPI implementation
+ * or <code>null</code> if not found.
+ */
+ private static String
+ checkPropertiesForSPIClassName(Properties properties) {
+ if (properties == null) {
+ return null;
+ }
+
+ final String providerClassName =
+ properties.getProperty(SCA_CLIENT_FACTORY_PROVIDER_KEY);
+ if (providerClassName != null && providerClassName.length() > 0) {
+ return providerClassName;
+ }
+
+ return null;
+ }
+
+ /**
+ * Attempts to find the class name for the SCAClientFactorySPI
+ * implementation from the META-INF/services directory
+ *
+ * @return The class name for the SCAClientFactorySPI implementation or
+ * <code>null</code> if not found.
+ */
+ private static String checkMETAINFServicesForSPIClassName(ClassLoader cl)
+ {
+ final URL url =
+ cl.getResource(SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE);
+ if (url == null) {
+ return null;
+ }
+
+ InputStream in = null;
+ try {
+ in = url.openStream();
+ BufferedReader reader = null;
+ try {
+ reader =
+ new BufferedReader(new InputStreamReader(in, "UTF-8"));
+
+ String line;
+ while ((line = readNextLine(reader)) != null) {
+ if (!line.startsWith("#") && line.length() > 0) {
+ return line;
+ }
+ }
+
+ return null;
+ } finally {
+ closeStream(reader);
+ }
+ } catch (IOException ex) {
+ throw new ServiceRuntimeException(
+ "Failed to discover SCAClientFactory provider", ex);
+ } finally {
+ closeStream(in);
+ }
+ }
+
+ /**
+ * Reads the next line from the reader and returns the trimmed version
+ * of that line
+ *
+ * @param reader The reader from which to read the next line
+ * @return The trimmed next line or <code>null</code> if the end of the
+ * stream has been reached
+ * @throws IOException I/O error occurred while reading from Reader
+ */
+ private static String readNextLine(BufferedReader reader)
+ throws IOException {
+
+ String line = reader.readLine();
+ if (line != null) {
+ line = line.trim();
+ }
+ return line;
+ }
+
+ /**
+ * Loads the specified SCAClientFactory Implementation class.
+ *
+ * @param factoryImplClassName The name of the SCAClientFactory
+ * Implementation class to load
+ * @return The specified SCAClientFactory Implementation class
+ * @throws ServiceRuntimeException Failed to load the SCAClientFactory
+ * Implementation class
+ */
+ private static Class<? extends SCAClientFactory>
+ loadProviderFactoryClass(String factoryImplClassName,
+ ClassLoader classLoader)
+ throws ServiceRuntimeException {
+
+ try {
+ final Class<?> providerClass =
+ classLoader.loadClass(factoryImplClassName);
+ final Class<? extends SCAClientFactory> providerFactoryClass =
+ providerClass.asSubclass(SCAClientFactory.class);
+ return providerFactoryClass;
+ } catch (ClassNotFoundException ex) {
+ throw new ServiceRuntimeException(
+ "Failed to load SCAClientFactory implementation class "
+ + factoryImplClassName, ex);
+ } catch (ClassCastException ex) {
+ throw new ServiceRuntimeException(
+ "Loaded SCAClientFactory implementation class "
+ + factoryImplClassName
+ + " is not a subclass of "
+ + SCAClientFactory.class.getName() , ex);
+ }
+ }
+
+ /**
+ * Instantiate an instance of the specified SCAClientFactorySPI
+ * Implementation class.
+ *
+ * @param factoryImplClass The SCAClientFactorySPI Implementation
+ * class to instantiate.
+ * @return An instance of the SCAClientFactorySPI Implementation class
+ * @throws ServiceRuntimeException Failed to instantiate the specified
+ * specified SCAClientFactorySPI Implementation class
+ */
+ private static SCAClientFactory instantiateSCAClientFactoryClass(
+ Class<? extends SCAClientFactory> factoryImplClass,
+ URI domainURI)
+ throws NoSuchDomainException, ServiceRuntimeException {
+
+ try {
+ Constructor<? extends SCAClientFactory> URIConstructor =
+ factoryImplClass.getConstructor(domainURI.getClass());
+ SCAClientFactory provider =
+ URIConstructor.newInstance( domainURI );
+ return provider;
+ } catch (Throwable ex) {
+ throw new ServiceRuntimeException(
+ "Failed to instantiate SCAClientFactory implementation class "
+ + factoryImplClass, ex);
+ }
+ }
+
+ /**
+ * Utility method for closing Closeable Object.
+ *
+ * @param closeable The Object to close.
+ */
+ private static void closeStream(Closeable closeable) {
+ if (closeable != null) {
+ try{
+ closeable.close();
+ } catch (IOException ex) {
+ throw new ServiceRuntimeException("Failed to close stream",
+ ex);
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java
index 81152cf0a7..b8830d4d60 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java
@@ -1,49 +1,49 @@
-/*
- * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
- * OASIS trademark, IPR and other policies apply.
- */
-package org.apache.tuscany.sca.client.impl;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.oasisopen.sca.client.SCAClientFactory;
-import org.oasisopen.sca.client.SCAClientFactoryFinder;
-
-/**
- * A Tuscany specific implementation of an SCAClientFactoryFinder which finds
- * hard codes the use of the Tuscany SCAClientFactory instead of doscovering it.
- *
- * @see SCAClientFactoryFinder
- * @see SCAClientFactory
- */
-public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
-
- /**
- * Public Constructor
- */
- public SCAClientFactoryFinderImpl() {
- }
-
- /**
- * Creates an instance of the SCAClientFactorySPI implementation.
- * This discovers the SCAClientFactorySPI Implementation and instantiates
- * the provider's implementation.
- *
- * @param properties Properties that may be used when creating a new
- * instance of the SCAClient
- * @param classLoader ClassLoader that may be used when creating a new
- * instance of the SCAClient
- * @return new instance of the SCAClientFactory
- * @throws ServiceRuntimeException Failed to create SCAClientFactory
- * Implementation.
- */
- public SCAClientFactory find(Properties properties,
- ClassLoader classLoader,
- URI domainURI ) throws NoSuchDomainException, ServiceRuntimeException {
- return new SCAClientFactoryImpl2(domainURI);
- }
-
-}
+/*
+ * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.apache.tuscany.sca.client.impl;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+/**
+ * A Tuscany specific implementation of an SCAClientFactoryFinder which finds
+ * hard codes the use of the Tuscany SCAClientFactory instead of doscovering it.
+ *
+ * @see SCAClientFactoryFinder
+ * @see SCAClientFactory
+ */
+public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
+
+ /**
+ * Public Constructor
+ */
+ public SCAClientFactoryFinderImpl() {
+ }
+
+ /**
+ * Creates an instance of the SCAClientFactorySPI implementation.
+ * This discovers the SCAClientFactorySPI Implementation and instantiates
+ * the provider's implementation.
+ *
+ * @param properties Properties that may be used when creating a new
+ * instance of the SCAClient
+ * @param classLoader ClassLoader that may be used when creating a new
+ * instance of the SCAClient
+ * @return new instance of the SCAClientFactory
+ * @throws ServiceRuntimeException Failed to create SCAClientFactory
+ * Implementation.
+ */
+ public SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI ) throws NoSuchDomainException, ServiceRuntimeException {
+ return new SCAClientFactoryImpl2(domainURI);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
index b1f7b37f8f..8626927097 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
@@ -1,77 +1,77 @@
-/*
- * 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.client.impl;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.net.URI;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
-import org.apache.tuscany.sca.node.impl.NodeImpl;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.client.SCAClientFactory;
-import org.oasisopen.sca.client.SCAClientFactoryFinder;
-
-public class SCAClientFactoryImpl2 extends SCAClientFactory {
-
- public static void setSCAClientFactoryFinder(SCAClientFactoryFinder factoryFinder) {
- SCAClientFactory.factoryFinder = factoryFinder;
- }
-
- public SCAClientFactoryImpl2(URI domainURI) throws NoSuchDomainException {
- super(domainURI);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
-
- boolean foundDomain = false;
- for (NodeFactory nodeFactory : NodeFactory.getNodeFactories()) {
- for (Node node : ((NodeFactoryImpl)nodeFactory).getNodesInDomain(getDomainName())) {
- foundDomain = true;
- for (Endpoint ep : ((NodeImpl)node).getServiceEndpoints()) {
- if (ep.matches(serviceName)) {
- return node.getService(serviceInterface, serviceName);
- }
- }
- }
- }
-
- // assume that if a local node with the looked for domain name is found then that will
- // know about all services in the domain so if the service isn't found then it doesn't exist
- if (foundDomain) {
- throw new NoSuchServiceException(serviceName);
- }
-
- InvocationHandler handler = new SCAClientHandler(getDomainURI().toString(), serviceName, serviceInterface);
- return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler);
- }
-
- private String getDomainName() {
- // TODO: if the domain URI encodes config (eg uri:someDomain?bla=etc) then need to parse the domain name
- String domainName = getDomainURI().toString();
- return domainName;
- }
-}
+/*
+ * 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.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+public class SCAClientFactoryImpl2 extends SCAClientFactory {
+
+ public static void setSCAClientFactoryFinder(SCAClientFactoryFinder factoryFinder) {
+ SCAClientFactory.factoryFinder = factoryFinder;
+ }
+
+ public SCAClientFactoryImpl2(URI domainURI) throws NoSuchDomainException {
+ super(domainURI);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
+
+ boolean foundDomain = false;
+ for (NodeFactory nodeFactory : NodeFactory.getNodeFactories()) {
+ for (Node node : ((NodeFactoryImpl)nodeFactory).getNodesInDomain(getDomainName())) {
+ foundDomain = true;
+ for (Endpoint ep : ((NodeImpl)node).getServiceEndpoints()) {
+ if (ep.matches(serviceName)) {
+ return node.getService(serviceInterface, serviceName);
+ }
+ }
+ }
+ }
+
+ // assume that if a local node with the looked for domain name is found then that will
+ // know about all services in the domain so if the service isn't found then it doesn't exist
+ if (foundDomain) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
+ InvocationHandler handler = new SCAClientHandler(getDomainURI().toString(), serviceName, serviceInterface);
+ return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler);
+ }
+
+ private String getDomainName() {
+ // TODO: if the domain URI encodes config (eg uri:someDomain?bla=etc) then need to parse the domain name
+ String domainName = getDomainURI().toString();
+ return domainName;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
index 4fb38e4ca6..b8cb5732fc 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
@@ -1,210 +1,210 @@
-/*
- * 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.client.impl;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.List;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-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.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.context.CompositeContext;
-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.invocation.ExtensibleProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
-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.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.apache.tuscany.sca.runtime.RuntimeProperties;
-import org.oasisopen.sca.NoSuchDomainException;
-import org.oasisopen.sca.NoSuchServiceException;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-public class SCAClientHandler implements InvocationHandler {
-
- private String domainURI;
- private String serviceName;
- private Class<?> serviceInterface;
-
- public SCAClientHandler(String domainURI, String serviceName, Class<?> serviceInterface) {
- this.domainURI = domainURI;
- this.serviceName = serviceName;
- this.serviceInterface = serviceInterface;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
- try {
- nodeFactory.init();
-
- ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
- Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
- props.setProperty("client", "true");
- DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
-
- String registryURI = domainURI;
-
- // TODO: theres better ways to do this but this gets things working for now
- if (registryURI.indexOf(":") == -1) {
- registryURI = "tuscanyclient:" + registryURI;
- }
- if (registryURI.startsWith("uri:")) {
- registryURI = "tuscanyclient:" + registryURI.substring(4);
- }
- if (registryURI.startsWith("tuscany:")) {
- registryURI = "tuscanyclient:" + registryURI.substring(8);
- }
-
- EndpointRegistry endpointRegistry;
- try {
- endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
- } catch (Exception e) {
- throw new NoSuchDomainException(domainURI, e);
- }
-
- FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
- JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
- ProxyFactory proxyFactory = new ExtensibleProxyFactory(extensionsRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
-
- String client = "sca.client." + UUID.randomUUID();
- CompositeContext compositeContext =
- new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, nodeFactory.getDeployer().getSystemDefinitions());
-
- List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
- if (eps == null || eps.size() < 1) {
- throw new NoSuchServiceException(serviceName);
- }
- Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
-
- RuntimeEndpointReference epr;
- try {
- epr = createEndpointReference(javaInterfaceFactory, compositeContext, assemblyFactory, endpoint, serviceInterface);
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
-
- InvocationHandler handler = Proxy.getInvocationHandler(proxyFactory.createProxy(serviceInterface, epr));
- return handler.invoke(proxy, method, args);
-
- } finally {
- nodeFactory.destroy();
- }
- }
-
- private RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory, CompositeContext compositeContext, AssemblyFactory assemblyFactory, Endpoint endpoint, Class<?> businessInterface) throws CloneNotSupportedException, InvalidInterfaceException {
- Component component = endpoint.getComponent();
- ComponentService service = endpoint.getService();
- ComponentReference componentReference = assemblyFactory.createComponentReference();
- componentReference.setName("sca.client." + service.getName());
-
- componentReference.setCallback(service.getCallback());
- componentReference.getTargets().add(service);
- componentReference.getPolicySets().addAll(service.getPolicySets());
- componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
- componentReference.getBindings().add(endpoint.getBinding());
-
- InterfaceContract interfaceContract = service.getInterfaceContract();
- Service componentTypeService = service.getService();
- if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
- interfaceContract = componentTypeService.getInterfaceContract();
- }
- interfaceContract = getInterfaceContract(javaInterfaceFactory, interfaceContract, businessInterface);
- componentReference.setInterfaceContract(interfaceContract);
- componentReference.setMultiplicity(Multiplicity.ONE_ONE);
- // component.getReferences().add(componentReference);
-
- // create endpoint reference
- EndpointReference endpointReference = assemblyFactory.createEndpointReference();
- endpointReference.setComponent(component);
- endpointReference.setReference(componentReference);
- endpointReference.setBinding(endpoint.getBinding());
- endpointReference.setUnresolved(false);
- endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
-
- endpointReference.setTargetEndpoint(endpoint);
-
- componentReference.getEndpointReferences().add(endpointReference);
- ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
- ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
-
- return (RuntimeEndpointReference) endpointReference;
- }
-
- /**
- * @param interfaceContract
- * @param businessInterface
- * @return
- * @throws CloneNotSupportedException
- * @throws InvalidInterfaceException
- */
- private InterfaceContract getInterfaceContract(JavaInterfaceFactory javaInterfaceFactory, InterfaceContract interfaceContract, Class<?> businessInterface)
- throws CloneNotSupportedException, InvalidInterfaceException {
- if (businessInterface == null) {
- return interfaceContract;
- }
- boolean compatible = false;
- if (interfaceContract != null && interfaceContract.getInterface() != null) {
- Interface interfaze = interfaceContract.getInterface();
- if (interfaze instanceof JavaInterface) {
- Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
- if (cls != null && businessInterface.isAssignableFrom(cls)) {
- compatible = true;
- }
- }
- }
-
- if (!compatible) {
- // The interface is not assignable from the interface contract
- interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
- interfaceContract.setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
- .getCallbackClass()));
- }
- }
-
- return interfaceContract;
- }
-
-}
+/*
+ * 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.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+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.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class SCAClientHandler implements InvocationHandler {
+
+ private String domainURI;
+ private String serviceName;
+ private Class<?> serviceInterface;
+
+ public SCAClientHandler(String domainURI, String serviceName, Class<?> serviceInterface) {
+ this.domainURI = domainURI;
+ this.serviceName = serviceName;
+ this.serviceInterface = serviceInterface;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
+ try {
+ nodeFactory.init();
+
+ ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
+ Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ props.setProperty("client", "true");
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+
+ String registryURI = domainURI;
+
+ // TODO: theres better ways to do this but this gets things working for now
+ if (registryURI.indexOf(":") == -1) {
+ registryURI = "tuscanyclient:" + registryURI;
+ }
+ if (registryURI.startsWith("uri:")) {
+ registryURI = "tuscanyclient:" + registryURI.substring(4);
+ }
+ if (registryURI.startsWith("tuscany:")) {
+ registryURI = "tuscanyclient:" + registryURI.substring(8);
+ }
+
+ EndpointRegistry endpointRegistry;
+ try {
+ endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
+ } catch (Exception e) {
+ throw new NoSuchDomainException(domainURI, e);
+ }
+
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ ProxyFactory proxyFactory = new ExtensibleProxyFactory(extensionsRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
+
+ String client = "sca.client." + UUID.randomUUID();
+ CompositeContext compositeContext =
+ new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, nodeFactory.getDeployer().getSystemDefinitions());
+
+ List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
+ if (eps == null || eps.size() < 1) {
+ throw new NoSuchServiceException(serviceName);
+ }
+ Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
+
+ RuntimeEndpointReference epr;
+ try {
+ epr = createEndpointReference(javaInterfaceFactory, compositeContext, assemblyFactory, endpoint, serviceInterface);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ InvocationHandler handler = Proxy.getInvocationHandler(proxyFactory.createProxy(serviceInterface, epr));
+ return handler.invoke(proxy, method, args);
+
+ } finally {
+ nodeFactory.destroy();
+ }
+ }
+
+ private RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory, CompositeContext compositeContext, AssemblyFactory assemblyFactory, Endpoint endpoint, Class<?> businessInterface) throws CloneNotSupportedException, InvalidInterfaceException {
+ Component component = endpoint.getComponent();
+ ComponentService service = endpoint.getService();
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("sca.client." + service.getName());
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.getBindings().add(endpoint.getBinding());
+
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ Service componentTypeService = service.getService();
+ if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
+ interfaceContract = componentTypeService.getInterfaceContract();
+ }
+ interfaceContract = getInterfaceContract(javaInterfaceFactory, interfaceContract, businessInterface);
+ componentReference.setInterfaceContract(interfaceContract);
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ // component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+ ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
+ ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
+
+ return (RuntimeEndpointReference) endpointReference;
+ }
+
+ /**
+ * @param interfaceContract
+ * @param businessInterface
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private InterfaceContract getInterfaceContract(JavaInterfaceFactory javaInterfaceFactory, InterfaceContract interfaceContract, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ if (businessInterface == null) {
+ return interfaceContract;
+ }
+ boolean compatible = false;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (cls != null && businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
+ }
+ }
+
+ if (!compatible) {
+ // The interface is not assignable from the interface contract
+ interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+ interfaceContract.setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
+ .getCallbackClass()));
+ }
+ }
+
+ return interfaceContract;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java
index c5913070e8..bc1d151d7d 100644
--- a/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java
+++ b/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java
@@ -1,76 +1,76 @@
-/*
- * 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.client.impl;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.oasisopen.sca.NoSuchServiceException;
-
-/**
- * TODO: What this wants is a way to create a generic invoker for an arbitrary binding
- * that could mean extending the BindingProvider API to include something like a
- * createClient method which creates an Invoker for an Endpoint
- */
-public class SCAClientProxyHandler implements InvocationHandler {
-
- protected EndpointRegistry endpointRegistry;
- protected EndpointReference endpointReference;
- protected String serviceName;
-
- public SCAClientProxyHandler(String serviceName, ExtensionPointRegistry extensionsRegistry, EndpointRegistry endpointRegistry) {
- this.endpointRegistry = endpointRegistry;
- this.serviceName = serviceName;
-
-// RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
-// this.rmiHost = new ExtensibleRMIHost(rmiHosts);
-
- FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
-
- this.endpointReference = assemblyFactory.createEndpointReference();
- endpointReference.setReference(assemblyFactory.createComponentReference());
- Endpoint targetEndpoint = assemblyFactory.createEndpoint();
- targetEndpoint.setURI(serviceName);
- endpointReference.setTargetEndpoint(targetEndpoint);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-
- List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
- if (endpoints.size() <1 ) {
- throw new NoSuchServiceException(serviceName);
- }
-
- String uri = endpoints.get(0).getBinding().getURI();
-// RMIBindingInvoker invoker = new RMIBindingInvoker(rmiHost, uri, method);
-//
-// return invoker.invokeTarget(args);
- return null;
- }
-
-}
+/*
+ * 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.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.oasisopen.sca.NoSuchServiceException;
+
+/**
+ * TODO: What this wants is a way to create a generic invoker for an arbitrary binding
+ * that could mean extending the BindingProvider API to include something like a
+ * createClient method which creates an Invoker for an Endpoint
+ */
+public class SCAClientProxyHandler implements InvocationHandler {
+
+ protected EndpointRegistry endpointRegistry;
+ protected EndpointReference endpointReference;
+ protected String serviceName;
+
+ public SCAClientProxyHandler(String serviceName, ExtensionPointRegistry extensionsRegistry, EndpointRegistry endpointRegistry) {
+ this.endpointRegistry = endpointRegistry;
+ this.serviceName = serviceName;
+
+// RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
+// this.rmiHost = new ExtensibleRMIHost(rmiHosts);
+
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ this.endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setReference(assemblyFactory.createComponentReference());
+ Endpoint targetEndpoint = assemblyFactory.createEndpoint();
+ targetEndpoint.setURI(serviceName);
+ endpointReference.setTargetEndpoint(targetEndpoint);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ if (endpoints.size() <1 ) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
+ String uri = endpoints.get(0).getBinding().getURI();
+// RMIBindingInvoker invoker = new RMIBindingInvoker(rmiHost, uri, method);
+//
+// return invoker.invokeTarget(args);
+ return null;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/wink/pom.xml b/sca-java-2.x/trunk/modules/wink/pom.xml
index 5444bdb8b5..b000effbf8 100644
--- a/sca-java-2.x/trunk/modules/wink/pom.xml
+++ b/sca-java-2.x/trunk/modules/wink/pom.xml
@@ -1,69 +1,69 @@
-<?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-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>tuscany-wink</artifactId>
- <name>Apache Tuscany SCA Apache Wink JAX-RS Integration</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-webapp</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-web-runtime</artifactId>
- <version>2.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.wink</groupId>
- <artifactId>wink-server</artifactId>
- <version>1.1-incubating</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.wink</groupId>
- <artifactId>wink-common</artifactId>
- <version>1.1-incubating</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
-</project>
+<?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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-wink</artifactId>
+ <name>Apache Tuscany SCA Apache Wink JAX-RS Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-server</artifactId>
+ <version>1.1-incubating</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-common</artifactId>
+ <version>1.1-incubating</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java
index b0dfb0c100..dd21302cfa 100644
--- a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java
+++ b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java
@@ -1,66 +1,66 @@
-/*
- * 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.wink;
-
-import java.beans.Introspector;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.lang.reflect.Type;
-
-import javax.servlet.ServletContext;
-
-import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
-import org.apache.wink.common.RuntimeContext;
-import org.apache.wink.common.internal.registry.Injectable;
-import org.oasisopen.sca.annotation.Property;
-
-public class PropertyInjectable extends Injectable {
-
- private String name;
-
- public PropertyInjectable(Property propertyAnnotation,
- ParamType paramType,
- Class<?> type,
- Type genericType,
- Annotation[] annotations,
- Member member) {
- super(paramType, type, genericType, annotations, member);
- this.name = getPropertyName(propertyAnnotation.name(), member);
- }
-
- @Override
- public Object getValue(RuntimeContext runtimeContext) throws IOException {
- return ContextHelper.getProperty(name, runtimeContext.getAttribute(ServletContext.class));
- }
-
- private String getPropertyName(String annotationName, Member member) {
- String name;
- if (annotationName != null && !annotationName.equals("")) {
- name = annotationName;
- } else {
- name = getMember().getName();
- if (name.startsWith("set")) {
- name = Introspector.decapitalize(name.substring(3));
- }
- }
- return name;
- }
-}
+/*
+ * 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.wink;
+
+import java.beans.Introspector;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.apache.wink.common.RuntimeContext;
+import org.apache.wink.common.internal.registry.Injectable;
+import org.oasisopen.sca.annotation.Property;
+
+public class PropertyInjectable extends Injectable {
+
+ private String name;
+
+ public PropertyInjectable(Property propertyAnnotation,
+ ParamType paramType,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ Member member) {
+ super(paramType, type, genericType, annotations, member);
+ this.name = getPropertyName(propertyAnnotation.name(), member);
+ }
+
+ @Override
+ public Object getValue(RuntimeContext runtimeContext) throws IOException {
+ return ContextHelper.getProperty(name, runtimeContext.getAttribute(ServletContext.class));
+ }
+
+ private String getPropertyName(String annotationName, Member member) {
+ String name;
+ if (annotationName != null && !annotationName.equals("")) {
+ name = annotationName;
+ } else {
+ name = getMember().getName();
+ if (name.startsWith("set")) {
+ name = Introspector.decapitalize(name.substring(3));
+ }
+ }
+ return name;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java
index 1cb0d0c2f2..7a58e97fb9 100644
--- a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java
+++ b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java
@@ -1,66 +1,66 @@
-/*
- * 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.wink;
-
-import java.beans.Introspector;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.lang.reflect.Type;
-
-import javax.servlet.ServletContext;
-
-import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
-import org.apache.wink.common.RuntimeContext;
-import org.apache.wink.common.internal.registry.Injectable;
-import org.oasisopen.sca.annotation.Reference;
-
-public class ReferenceInjectable extends Injectable {
-
- private String referenceName;
-
- public ReferenceInjectable(Reference referenceAnnotation,
- ParamType paramType,
- Class<?> type,
- Type genericType,
- Annotation[] annotations,
- Member member) {
- super(paramType, type, genericType, annotations, member);
- this.referenceName = getReferenceName(referenceAnnotation.name(), member);
- }
-
- @Override
- public Object getValue(RuntimeContext runtimeContext) throws IOException {
- return ContextHelper.getReference(referenceName, (Class<?>)getGenericType(), runtimeContext.getAttribute(ServletContext.class));
- }
-
- private String getReferenceName(String annotationName, Member member) {
- String name;
- if (annotationName != null && !annotationName.equals("")) {
- name = annotationName;
- } else {
- name = getMember().getName();
- if (name.startsWith("set")) {
- name = Introspector.decapitalize(name.substring(3));
- }
- }
- return name;
- }
-}
+/*
+ * 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.wink;
+
+import java.beans.Introspector;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.apache.wink.common.RuntimeContext;
+import org.apache.wink.common.internal.registry.Injectable;
+import org.oasisopen.sca.annotation.Reference;
+
+public class ReferenceInjectable extends Injectable {
+
+ private String referenceName;
+
+ public ReferenceInjectable(Reference referenceAnnotation,
+ ParamType paramType,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ Member member) {
+ super(paramType, type, genericType, annotations, member);
+ this.referenceName = getReferenceName(referenceAnnotation.name(), member);
+ }
+
+ @Override
+ public Object getValue(RuntimeContext runtimeContext) throws IOException {
+ return ContextHelper.getReference(referenceName, (Class<?>)getGenericType(), runtimeContext.getAttribute(ServletContext.class));
+ }
+
+ private String getReferenceName(String annotationName, Member member) {
+ String name;
+ if (annotationName != null && !annotationName.equals("")) {
+ name = annotationName;
+ } else {
+ name = getMember().getName();
+ if (name.startsWith("set")) {
+ name = Introspector.decapitalize(name.substring(3));
+ }
+ }
+ return name;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java
index 8aef24fa40..dc7ef3fc2c 100644
--- a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java
+++ b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java
@@ -1,38 +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 org.apache.tuscany.sca.wink;
-
-import org.apache.wink.common.internal.registry.InjectableFactory;
-import org.apache.wink.server.internal.DeploymentConfiguration;
-
-/**
- * Subclass the default Wink DeploymentConfiguration and override
- * the initRegistries method so the InjectableFactory instance can
- * be set to the Tuscany one.
- */
-public class TuscanyDeploymentConfiguration extends DeploymentConfiguration {
-
- @Override
- protected void initRegistries() {
- super.initRegistries();
- InjectableFactory.setInstance(new TuscanyInjectableFactory());
- }
-
-}
+/*
+ * 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.wink;
+
+import org.apache.wink.common.internal.registry.InjectableFactory;
+import org.apache.wink.server.internal.DeploymentConfiguration;
+
+/**
+ * Subclass the default Wink DeploymentConfiguration and override
+ * the initRegistries method so the InjectableFactory instance can
+ * be set to the Tuscany one.
+ */
+public class TuscanyDeploymentConfiguration extends DeploymentConfiguration {
+
+ @Override
+ protected void initRegistries() {
+ super.initRegistries();
+ InjectableFactory.setInstance(new TuscanyInjectableFactory());
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java
index 3410ecd804..ca71856a3b 100644
--- a/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java
+++ b/sca-java-2.x/trunk/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java
@@ -1,52 +1,52 @@
-/*
- * 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.wink;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.lang.reflect.Type;
-
-import org.apache.wink.common.internal.registry.Injectable;
-import org.apache.wink.server.internal.registry.ServerInjectableFactory;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
-
-/**
- * Subclass the Wink default ServerInjectableFactory to look
- * for SCA @Reference or @Property annotations.
- */
-public class TuscanyInjectableFactory extends ServerInjectableFactory {
-
- @Override
- public Injectable create(Type genericType,
- Annotation[] annotations,
- Member member,
- boolean encoded,
- String defaultValue) {
- for (Annotation a : annotations) {
- if (a instanceof Reference) {
- return new ReferenceInjectable((Reference)a, null, null, genericType, annotations, member);
- } else if (a instanceof Property) {
- return new PropertyInjectable((Property)a, null, null, genericType, annotations, member);
- }
- }
- return super.create(genericType, annotations, member, encoded, defaultValue);
- }
-}
+/*
+ * 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.wink;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import org.apache.wink.common.internal.registry.Injectable;
+import org.apache.wink.server.internal.registry.ServerInjectableFactory;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Subclass the Wink default ServerInjectableFactory to look
+ * for SCA @Reference or @Property annotations.
+ */
+public class TuscanyInjectableFactory extends ServerInjectableFactory {
+
+ @Override
+ public Injectable create(Type genericType,
+ Annotation[] annotations,
+ Member member,
+ boolean encoded,
+ String defaultValue) {
+ for (Annotation a : annotations) {
+ if (a instanceof Reference) {
+ return new ReferenceInjectable((Reference)a, null, null, genericType, annotations, member);
+ } else if (a instanceof Property) {
+ return new PropertyInjectable((Property)a, null, null, genericType, annotations, member);
+ }
+ }
+ return super.create(genericType, annotations, member, encoded, defaultValue);
+ }
+}