tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r572844 - in /incubator/tuscany/java/sca: itest/properties/src/main/java/mysca/ itest/properties/src/main/java/mysca/test/ itest/properties/src/main/java/mysca/test/myservice/ itest/properties/src/main/java/mysca/test/myservice/impl/ itest/...
Date Wed, 05 Sep 2007 00:28:37 GMT
Author: rfeng
Date: Tue Sep  4 17:28:37 2007
New Revision: 572844

URL: http://svn.apache.org/viewvc?rev=572844&view=rev
Log:
Fix an issue for the nesting property and add an itest

Added:
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
  (with props)
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
  (with props)
    incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
  (with props)
    incubator/tuscany/java/sca/itest/properties/src/main/resources/Outer.composite
    incubator/tuscany/java/sca/itest/properties/src/main/resources/mySimpleService.composite
    incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
  (with props)
Modified:
    incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeConfigurationBuilderImpl.java

Added: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
(added)
+++ incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
Tue Sep  4 17:28:37 2007
@@ -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 mysca.test.myservice.impl;
+
+
+public interface MyService {
+    String getLocation();
+
+    String getYear();
+}

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
(added)
+++ incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
Tue Sep  4 17:28:37 2007
@@ -0,0 +1,73 @@
+/*
+ * 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 mysca.test.myservice.impl;
+
+import java.util.logging.Logger;
+
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Service;
+
+@Service(MyService.class)
+public class MyServiceImpl implements MyService {
+
+    @Property(name = "location")
+    protected String location = "RTP";
+
+    @Property(name = "year")
+    protected String year = "2006";
+
+    @ComponentName
+    private String componentName;
+
+
+    private Logger logger;
+
+    public MyServiceImpl() {
+        logger = Logger.getAnonymousLogger();
+        logger.info("creating service instance...");
+    }
+
+    @Init
+    public void start() {
+        logger.info("Start service..");
+    }
+
+    @Destroy
+    public void stop() {
+        logger.info("Stop service..");
+
+    }
+
+    public String getComponentName() {
+        return componentName;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public String getYear() {
+        return year;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
(added)
+++ incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
Tue Sep  4 17:28:37 2007
@@ -0,0 +1,39 @@
+/*
+ * 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 mysca.test.myservice.impl;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(MyService.class)
+public class MyTotalServiceImpl implements MyService {
+
+    // default required==true so it is 1:1
+    @Reference
+    public MyService myService;
+
+    public String getLocation() {
+        return myService.getLocation();
+    }
+
+    public String getYear() {
+        return myService.getYear();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/properties/src/main/resources/Outer.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/main/resources/Outer.composite?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/main/resources/Outer.composite (added)
+++ incubator/tuscany/java/sca/itest/properties/src/main/resources/Outer.composite Tue Sep
 4 17:28:37 2007
@@ -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
+ * 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.osoa.org/xmlns/sca/1.0"
+    xmlns:foo="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0"
name="Iteration3Composite"
+    targetNamespace="http://foo" local="true" autowire="false" requires="cns:confidentiality"
policySets="sns:secure">
+
+    <property name="newLocation" type="anyURI">Raleigh</property>
+    <property name="newYear" type="anyURI">2008</property>
+    <component name="MyServiceComponent">
+        <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+    </component>
+    <component name="MyServiceComponentNew">
+        <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+        <property name="location" source="$newLocation" />
+        <property name="year" source="$newYear" />
+    </component>
+    <component name="MyTotalServiceNewComponent">
+        <implementation.java class="mysca.test.myservice.impl.MyTotalServiceImpl" />
+        <reference name="myService" target="MyServiceComponentNew/MyService" />
+    </component>
+    <component name="MySimpleServiceInRecursiveAnother">
+        <implementation.composite name="foo:MySimpleService" />
+        <property name="newLocation">Durham</property>
+        <property name="newYear">2009</property>
+    </component>
+</composite>
\ No newline at end of file

Added: incubator/tuscany/java/sca/itest/properties/src/main/resources/mySimpleService.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/main/resources/mySimpleService.composite?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/main/resources/mySimpleService.composite
(added)
+++ incubator/tuscany/java/sca/itest/properties/src/main/resources/mySimpleService.composite
Tue Sep  4 17:28:37 2007
@@ -0,0 +1,40 @@
+<?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 autowire="false" local="true" name="MySimpleService" policySets="sns:secure"
requires="cns:confidentiality"
+    targetNamespace="http://foo" xmlns:foo="http://foo" xmlns="http://www.osoa.org/xmlns/sca/1.0"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0
">
+
+
+    <service name="MyServiceNew1" promote="MyServiceComponentNew/MyService">
+        <interface.java interface="mysca.test.myservice.impl.MyService" />
+    </service>
+
+    <property name="newLocation" type="anyURI">Raleigh</property>
+    <property name="newYear" type="anyURI">2008</property>
+
+
+    <component name="MyServiceComponentNew">
+        <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+        <property name="location" source="$newLocation" />
+        <property name="year" source="$newYear" />
+    </component>
+
+</composite>

Added: incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java?rev=572844&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
(added)
+++ incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
Tue Sep  4 17:28:37 2007
@@ -0,0 +1,52 @@
+
+package org.apache.tuscany.sca.itest;
+import static junit.framework.Assert.assertEquals;
+import mysca.test.myservice.impl.MyService;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MyTotalServiceTestCase {
+    private static MyService service1;
+    private static MyService service2;
+    private static MyService service3;
+
+    private static SCADomain domain;
+
+    @Test
+    public void testPropertyDefault() {
+        assertEquals("RTP", service1.getLocation());
+        assertEquals("2006", service1.getYear());
+    }
+    
+    @Test
+    public void testPropertyOverride() {
+        assertEquals("Raleigh", service2.getLocation());
+        assertEquals("2008", service2.getYear());
+    }    
+
+    @Test
+    public void testPropertyNestedOverride() {
+        assertEquals("Durham", service3.getLocation());
+        assertEquals("2009", service3.getYear());
+    }
+
+    @BeforeClass
+    /**
+     * Sets up for the test case execution such as locating services.
+     */
+    public static void setUp() throws Exception {
+        
+        domain = SCADomain.newInstance("Outer.composite");
+        service1 = domain.getService(MyService.class, "MyServiceComponent/MyService");
+        service2 = domain.getService(MyService.class, "MyServiceComponentNew/MyService");
+        service3 = domain.getService(MyService.class, "MySimpleServiceInRecursiveAnother");
+    }
+   
+    @AfterClass
+    public static void tearDown() {
+        domain.close();
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeConfigurationBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeConfigurationBuilderImpl.java?rev=572844&r1=572843&r2=572844&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeConfigurationBuilderImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeConfigurationBuilderImpl.java
Tue Sep  4 17:28:37 2007
@@ -388,6 +388,11 @@
                 if (componentProperty.getValue() == null) {
                     componentProperty.setValue(property.getValue());
                 }
+                
+                // Override the property value for the composite
+                if(component.getImplementation() instanceof Composite) {
+                    property.setValue(componentProperty.getValue());
+                }
 
                 // Check that a value is supplied
                 if (componentProperty.getValue() == null && property.isMustSupply())
{



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message