You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/20 23:14:33 UTC
svn commit: r558146 - in /incubator/tuscany/java/sca:
itest/recursive/src/main/java/test1/
itest/recursive/src/main/java/test1/composite/
itest/recursive/src/main/resources/test1/
itest/recursive/src/test/java/test1/ itest/recursive/src/test/java/test1...
Author: rfeng
Date: Fri Jul 20 14:14:28 2007
New Revision: 558146
URL: http://svn.apache.org/viewvc?view=rev&rev=558146
Log:
Fix and test case for TUSCANY-1405
Added:
incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/
incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/
incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java (with props)
incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java (with props)
incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java (with props)
incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/
incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/InnerComposite.composite
incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/OuterComposite.composite
incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/
incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/
incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java (with props)
Modified:
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
Added: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java Fri Jul 20 14:14:28 2007
@@ -0,0 +1,23 @@
+/*
+ * 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 test1.composite;
+
+public interface Target {
+ String hello(String arg);
+}
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/Target.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java Fri Jul 20 14:14:28 2007
@@ -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 test1.composite;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(Target.class)
+public class TargetOne implements Target {
+
+ public String hello(String arg) {
+ return "TargetOne: Hello " + arg + "!";
+ }
+}
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetOne.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java Fri Jul 20 14:14:28 2007
@@ -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 test1.composite;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(Target.class)
+public class TargetTwo implements Target {
+
+ public String hello(String arg) {
+ return "TargetTwo: Hello " + arg + "!";
+ }
+}
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/recursive/src/main/java/test1/composite/TargetTwo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/InnerComposite.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/InnerComposite.composite?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/InnerComposite.composite (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/InnerComposite.composite Fri Jul 20 14:14:28 2007
@@ -0,0 +1,39 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample1"
+ xmlns:sample1="http://sample1"
+ name="InnerComposite">
+
+ <service name="Service_One" promote="ComponentOne">
+ <interface.java interface="test1.composite.Target"/>
+ </service>
+ <service name="Service_Two" promote="ComponentTwo">
+ <interface.java interface="test1.composite.Target"/>
+ </service>
+
+ <component name="ComponentOne">
+ <implementation.java class="test1.composite.TargetOne"/>
+ </component>
+ <component name="ComponentTwo">
+ <implementation.java class="test1.composite.TargetTwo"/>
+ </component>
+
+</composite>
Added: incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/OuterComposite.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/OuterComposite.composite?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/OuterComposite.composite (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/resources/test1/OuterComposite.composite Fri Jul 20 14:14:28 2007
@@ -0,0 +1,27 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample1"
+ xmlns:sample1="http://sample1"
+ name="OuterComposite">
+ <component name="TargetComponent">
+ <implementation.composite name="sample1:InnerComposite"/>
+ </component>
+</composite>
Added: incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java?view=auto&rev=558146
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java (added)
+++ incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java Fri Jul 20 14:14:28 2007
@@ -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 test1.composite;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * Simple client program that invokes the components that we wired together.
+ */
+public class CompositeClientTestCase extends TestCase {
+
+ public void testComposite() throws Exception {
+ SCADomain scaDomain = SCADomain.newInstance("test1/OuterComposite.composite");
+ Target target = scaDomain.getService(Target.class, "TargetComponent/Service_Two");
+ String res = target.hello("Wang Feng");
+ assertEquals("TargetTwo: Hello Wang Feng!", res);
+ scaDomain.close();
+ }
+}
Propchange: incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/recursive/src/test/java/test1/composite/CompositeClientTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java?view=diff&rev=558146&r1=558145&r2=558146
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java Fri Jul 20 14:14:28 2007
@@ -1189,6 +1189,13 @@
// FIXME: [rfeng] Set the service to promoted
newComponentService.setService(promotedService.getService());
+
+ // Create a self-reference for the promoted service
+ ComponentReference selfRef = createSelfReference(promotedComponent, newComponentService);
+ Binding binding = resolveBindings(selfRef, newComponentService);
+ selfRef.getBindings().clear();
+ selfRef.getBindings().add(binding);
+ selfRef.getTargets().clear();
// Change the composite service to now promote the newly
// created component service directly
@@ -1553,20 +1560,33 @@
*/
private void createSelfReferences(Component component) {
for (ComponentService service : component.getServices()) {
- ComponentReference componentReference = assemblyFactory.createComponentReference();
- componentReference.setName("$self$." + service.getName());
- componentReference.getBindings().addAll(service.getBindings());
- componentReference.setCallback(service.getCallback());
- ComponentService componentService = assemblyFactory.createComponentService();
- componentService.setName(component.getName() + "/" + service.getName());
- componentService.setUnresolved(true);
- componentReference.getTargets().add(componentService);
- componentReference.getPolicySets().addAll(service.getPolicySets());
- componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
- componentReference.setInterfaceContract(service.getInterfaceContract());
- componentReference.setMultiplicity(Multiplicity.ONE_ONE);
- component.getReferences().add(componentReference);
+ createSelfReference(component, service);
}
+ }
+
+ /**
+ * Create a self-reference for a component service
+ * @param component
+ * @param service
+ */
+ private ComponentReference createSelfReference(Component component, ComponentService service) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("$self$." + service.getName());
+ componentReference.getBindings().addAll(service.getBindings());
+ componentReference.setCallback(service.getCallback());
+ /*
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setName(component.getName() + "/" + service.getName());
+ componentService.setUnresolved(true);
+ componentReference.getTargets().add(componentService);
+ */
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.setInterfaceContract(service.getInterfaceContract());
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ component.getReferences().add(componentReference);
+ return componentReference;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org