From e5b7380c874745c989d1816b8f552504f038e1bc Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 26 Sep 2013 20:33:20 +0000 Subject: 2.0 branch for possible maintenance release git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1526672 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/binding/lifecycle/LifecycleBinding.java | 49 +++++++++++++++++ .../binding/lifecycle/LifecycleBindingFactory.java | 32 +++++++++++ .../lifecycle/LifecycleBindingProviderFactory.java | 47 ++++++++++++++++ .../LifecycleReferenceBindingProvider.java | 63 ++++++++++++++++++++++ .../lifecycle/LifecycleReferenceInvoker.java | 48 +++++++++++++++++ .../lifecycle/LifecycleServiceBindingProvider.java | 56 +++++++++++++++++++ .../binding/lifecycle/LifecycleServiceInvoker.java | 40 ++++++++++++++ 7 files changed, 335 insertions(+) create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java (limited to 'sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle') diff --git a/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java new file mode 100644 index 0000000000..ecd4393e4d --- /dev/null +++ b/sca-java-2.x/branches/2.0/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/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java new file mode 100644 index 0000000000..4fdf09bdf0 --- /dev/null +++ b/sca-java-2.x/branches/2.0/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/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java new file mode 100644 index 0000000000..f197578e84 --- /dev/null +++ b/sca-java-2.x/branches/2.0/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 { + + public LifecycleBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public Class 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/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java new file mode 100644 index 0000000000..5c2ca0bf77 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.assembly.impl.EndpointImpl; +import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl; +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.appendStatus("Reference binding start", + ((EndpointReferenceImpl)endpoint).toStringWithoutHash()); + } + + public void stop() { + StatusImpl.appendStatus("Reference binding stop", + ((EndpointReferenceImpl)endpoint).toStringWithoutHash()); + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java new file mode 100644 index 0000000000..023be8613b --- /dev/null +++ b/sca-java-2.x/branches/2.0/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/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java new file mode 100644 index 0000000000..158aa27201 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package binding.lifecycle; + +import helloworld.StatusImpl; + +import org.apache.tuscany.sca.assembly.impl.EndpointImpl; +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.appendStatus("Service binding start", + ((EndpointImpl)endpoint).toStringWithoutHash()); + } + + public void stop() { + StatusImpl.appendStatus("Service binding stop", + ((EndpointImpl)endpoint).toStringWithoutHash()); + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java b/sca-java-2.x/branches/2.0/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java new file mode 100644 index 0000000000..09ca7a051e --- /dev/null +++ b/sca-java-2.x/branches/2.0/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); + } + +} -- cgit v1.2.3