From a40e527938d76ba71f211da7e327adb50384ba69 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:26:33 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/itest/callableref/AComponent.java | 35 +++++++++ .../sca/itest/callableref/AComponentImpl.java | 88 ++++++++++++++++++++++ .../tuscany/sca/itest/callableref/BComponent.java | 30 ++++++++ .../sca/itest/callableref/BComponentImpl.java | 38 ++++++++++ .../tuscany/sca/itest/callableref/CComponent.java | 27 +++++++ .../sca/itest/callableref/CComponentImpl.java | 30 ++++++++ .../tuscany/sca/itest/callableref/DComponent.java | 28 +++++++ .../sca/itest/callableref/DComponentImpl.java | 52 +++++++++++++ 8 files changed, 328 insertions(+) create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java create mode 100644 sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java (limited to 'sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache') diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java new file mode 100644 index 0000000000..fa63d975a6 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.callableref; + +public interface AComponent { + String foo(); + + String fooB(); + String fooB1(); + + String fooC(); + String fooC1(); + + String fooD(); + + String fooBC(); + + DComponent getDReference(); +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java new file mode 100644 index 0000000000..af3e624dc7 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(AComponent.class) +public class AComponentImpl implements AComponent { + + @Context + protected ComponentContext componentContext; + + @Reference(name = "bReference") + protected BComponent b; + + @Reference + protected CComponent cReference; + + @Reference + protected ServiceReference cServiceReference; + + @Reference(required=false) + protected DComponent dReference; + + protected DComponent dReference1; + + @Reference(name = "dReference1") + public void setDReference(DComponent dReference) { + this.dReference1 = dReference; + } + + public String foo() { + return "AComponent"; + } + + public String fooB() { + return b.foo(); + } + + public String fooB1() { + CallableReference bRef = componentContext.cast(b); + return bRef.getService().foo(); + } + + public String fooC() { + return cReference.foo(); + } + + public String fooC1() { + return cServiceReference.getService().foo(); + } + + public String fooBC() { + CallableReference cReference = componentContext.getServiceReference(CComponent.class, "cReference"); + return b.fooC(cReference); + } + + public String fooD() { + CallableReference aReference = componentContext.createSelfReference(AComponent.class); + return dReference1.foo(aReference); + } + + public DComponent getDReference() { + return dReference; + } + +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java new file mode 100644 index 0000000000..ade672b0ab --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.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 org.apache.tuscany.sca.itest.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface BComponent { + + String foo(); + + String fooC(CallableReference cComponent); +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java new file mode 100644 index 0000000000..518e77d3a8 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Service; + +@Service(BComponent.class) +public class BComponentImpl implements BComponent { + + public BComponentImpl() { + } + + public String foo() { + return "BComponent"; + } + + public String fooC(CallableReference cReference) { + return "B" + cReference.getService().foo(); + } + +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java new file mode 100644 index 0000000000..fdf80cc1c8 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java @@ -0,0 +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.itest.callableref; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CComponent { + + String foo(); +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java new file mode 100644 index 0000000000..cc8ec8f000 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.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 org.apache.tuscany.sca.itest.callableref; + +import org.osoa.sca.annotations.Service; + +@Service(CComponent.class) +public class CComponentImpl implements CComponent { + + public String foo() { + return "CComponent"; + } + +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java new file mode 100644 index 0000000000..3b25d351ae --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface DComponent { + + String foo(CallableReference aReference); +} diff --git a/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java new file mode 100644 index 0000000000..1ab1973476 --- /dev/null +++ b/sca-java-1.x/tags/1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.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 org.apache.tuscany.sca.itest.callableref; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.RequestContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Service; + +@Service(DComponent.class) +public class DComponentImpl implements DComponent { + + @Context + protected RequestContext requestContext; + + public String foo(CallableReference aReference) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(aReference); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); + Object obj = ois.readObject(); + aReference = (CallableReference) obj; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Invoking service: " + requestContext.getServiceName()); + return "D" + aReference.getService().foo(); + } + +} -- cgit v1.2.3