diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-24 11:08:30 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-24 11:08:30 +0000 |
commit | ace7daceb0d0e7e555d401751b567faf41114cdf (patch) | |
tree | 7936b1086299741ce963781dc49a114e6679a5f1 /sca-java-2.x/trunk/testing/itest | |
parent | af12ca24a1aaba377099b2117aa38507ec0a039d (diff) |
TUSCANY-3867 - start of a test to check various lifecycle events.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1126977 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest')
19 files changed, 744 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml b/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml new file mode 100644 index 0000000000..618c25a031 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-lifecycle</artifactId>
+ <name>Apache Tuscany SCA iTest Lifecycle</name>
+ <version>2.0-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime-pom</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java new file mode 100644 index 0000000000..ecd4393e4d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java @@ -0,0 +1,49 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 binding.lifecycle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.provider.BaseBindingImpl;
+
+/**
+ * Represents a binding to a Sample service.
+ */
+public class LifecycleBinding extends BaseBindingImpl {
+
+ public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.lifecycle");
+
+ private String someAttr;
+
+ public LifecycleBinding() {
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public String getSomeAttr() {
+ return someAttr;
+ }
+
+ public void setSomeAttr(String someAttr) {
+ this.someAttr = someAttr;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java new file mode 100644 index 0000000000..4fdf09bdf0 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java @@ -0,0 +1,32 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 binding.lifecycle;
+
+
+/**
+ * Factory implementation to create Sample Models
+ */
+public class LifecycleBindingFactory {
+
+ public LifecycleBinding createLifecycleBinding() {
+ return new LifecycleBinding();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java new file mode 100644 index 0000000000..f197578e84 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java @@ -0,0 +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 binding.lifecycle;
+
+import binding.lifecycle.LifecycleBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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 LifecycleBindingProviderFactory implements BindingProviderFactory<LifecycleBinding> {
+
+ public LifecycleBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ }
+
+ public Class<LifecycleBinding> getModelType() {
+ return LifecycleBinding.class;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) {
+ return new LifecycleReferenceBindingProvider(endpoint);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new LifecycleServiceBindingProvider(endpoint);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java new file mode 100644 index 0000000000..5709de7747 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java @@ -0,0 +1,59 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package binding.lifecycle;
+
+import helloworld.StatusImpl;
+
+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 LifecycleReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpoint;
+ private InterfaceContract contract;
+
+ public LifecycleReferenceBindingProvider(EndpointReference endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new LifecycleReferenceInvoker(operation, endpoint);
+ }
+
+ public void start() {
+ StatusImpl.statusString += "Reference binding start ";
+ }
+
+ public void stop() {
+ StatusImpl.statusString += "Reference binding stop ";
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return contract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java new file mode 100644 index 0000000000..023be8613b --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java @@ -0,0 +1,48 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package binding.lifecycle;
+
+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;
+
+public class LifecycleReferenceInvoker implements Invoker {
+
+ protected Operation operation;
+ protected EndpointReference endpoint;
+
+ public LifecycleReferenceInvoker(Operation operation, EndpointReference endpoint) {
+ this.operation = operation;
+ this.endpoint = endpoint;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object[] body = msg.getBody();
+ msg.setBody(body[0]);
+ return msg;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java new file mode 100644 index 0000000000..0f62e13aed --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java @@ -0,0 +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 binding.lifecycle;
+
+import helloworld.StatusImpl;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class LifecycleServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private InterfaceContract contract;
+
+ public LifecycleServiceBindingProvider(RuntimeEndpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public void start() {
+ StatusImpl.statusString += "Service binding start ";
+ }
+
+ public void stop() {
+ StatusImpl.statusString += "Service binding stop ";
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return contract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java new file mode 100644 index 0000000000..09ca7a051e --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java @@ -0,0 +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 binding.lifecycle;
+
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class LifecycleServiceInvoker {
+
+ private RuntimeEndpoint wire;
+
+ public LifecycleServiceInvoker(RuntimeEndpoint wire) {
+ this.wire = wire;
+ }
+
+ /**
+ * Send the request down the wire to invoke the service
+ */
+ public Message invokeService(Message msg) {
+ return wire.invoke(msg);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java new file mode 100644 index 0000000000..73030e16d3 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java @@ -0,0 +1,29 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name) throws Exception;
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java new file mode 100644 index 0000000000..a1c06afbb5 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java @@ -0,0 +1,50 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldClientImpl implements Helloworld {
+
+ @Reference
+ public Helloworld service;
+
+ @Init
+ public void initialize() throws Exception{
+ StatusImpl.statusString += "HelloworldClientImpl init ";
+ System.out.println(">>>>>> " + sayHello("init"));
+ }
+
+ @Destroy
+ public void destroy() throws Exception{
+ StatusImpl.statusString += "HelloworldClientImpl destroy ";
+ }
+
+ public String sayHello(String name) throws Exception {
+ return "Hi " + service.sayHello(name);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java new file mode 100644 index 0000000000..d761dd4350 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java @@ -0,0 +1,30 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+public class HelloworldServiceImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ String response = "Hello " + name;
+ System.out.println("At service - " + response);
+ return response;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java new file mode 100644 index 0000000000..a18633ca74 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java @@ -0,0 +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 helloworld;
+
+public class StatusImpl {
+
+ public static String statusString = "";
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory new file mode 100644 index 0000000000..357cf65727 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+binding.lifecycle.LifecycleBindingFactory
+
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..6536e872e1 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.lifecycle,model=binding.lifecycle.LifecycleBinding,factory=binding.lifecycle.LifecycleBindingFactory
+
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..4e577c2728 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+binding-lifecycle.xsd
+
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..9a814793b2 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+binding.lifecycle.LifecycleBindingProviderFactory;model=binding.lifecycle.LifecycleBinding
+
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd new file mode 100644 index 0000000000..b798446c26 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd @@ -0,0 +1,37 @@ +<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" />
+
+ <element name="binding.lifecycle" type="t:BindingLifecycle" substitutionGroup="sca:binding"/>
+
+ <complexType name="BindingLifecycle">
+ <complexContent>
+ <extension base="sca:Binding">
+ <attribute name="someAttr" type="string" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite new file mode 100644 index 0000000000..2284d0920f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="domainview">
+
+ <component name="HelloworldService">
+ <implementation.java class="helloworld.HelloworldServiceImpl"/>
+ <service name="Helloworld">
+ <tuscany:binding.lifecycle name="lifecycle"/>
+ </service>
+ </component>
+
+ <component name="HelloworldClient">
+ <implementation.java class="helloworld.HelloworldClientImpl"/>
+ <reference name="service" target="HelloworldService"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java new file mode 100644 index 0000000000..4342dd63bd --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java @@ -0,0 +1,86 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.lifecycle;
+
+
+import helloworld.StatusImpl;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class LifecycleTestCase {
+
+ public Node node = null;
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void test1() throws Exception{
+
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+
+ // create a Tuscany node
+ node = tuscanyRuntime.createNode();
+
+ // install a contribution
+ node.installContribution("HelloworldContrib", "target/classes", null, null);
+
+ // start a composite
+ node.startComposite("HelloworldContrib", "lifecycle.composite");
+
+ // stop a composite
+ node.stopComposite("HelloworldContrib", "lifecycle.composite");
+
+ // uninstall a constribution
+ node.uninstallContribution("HelloworldContrib");
+
+ // stop a Tuscany node
+ node.stop();
+
+ // stop the runtime
+ tuscanyRuntime.stop();
+
+ // see what happened
+ System.out.println(StatusImpl.statusString);
+ Assert.assertEquals("Service binding start " +
+ "HelloworldClientImpl init " +
+ "Reference binding start " +
+ "Service binding stop " +
+ "Reference binding stop " +
+ "HelloworldClientImpl destroy ",
+ StatusImpl.statusString);
+
+ }
+
+}
|