felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r744039 - in /felix/trunk/ipojo: core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ tests/core/service-providing/src/main...
Date Fri, 13 Feb 2009 08:53:24 GMT
Author: clement
Date: Fri Feb 13 08:53:23 2009
New Revision: 744039

URL: http://svn.apache.org/viewvc?rev=744039&view=rev
Log:
Improve error handling in the ProvidedService handler
Commit test about the exposition of abstract and concrete classes as services.

Added:
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
  (with props)
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
  (with props)
Modified:
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/resources/metadata.xml

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java?rev=744039&r1=744038&r2=744039&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
(original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
Fri Feb 13 08:53:23 2009
@@ -28,6 +28,7 @@
 import org.apache.felix.ipojo.ConfigurationException;
 import org.apache.felix.ipojo.HandlerFactory;
 import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.Pojo;
 import org.apache.felix.ipojo.PrimitiveHandler;
 import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
 import org.apache.felix.ipojo.architecture.HandlerDescription;
@@ -533,9 +534,11 @@
             if (serviceSpecificationStr != null) {
                 List itfs = ParseUtils.parseArraysAsList(serviceSpecificationStr);
                 for (int j = 0; j < itfs.size(); j++) {
-                    if (! all.contains(itfs.get(j)) && ! parent.equals((String) itfs.get(i)))
{
-                        desc.getFactory().getLogger().log(Logger.WARNING, "The specification
" + itfs.get(j) + " is not implemented by " + metadata.getAttribute("classname") + 
-                                " it might be a superclass.");
+                    if (! all.contains(itfs.get(j))) {
+                        if (parent == null || (parent != null && ! parent.equals((String)
itfs.get(j)))) {
+                            desc.getFactory().getLogger().log(Logger.WARNING, "The specification
" + itfs.get(j) + " is not implemented by " + metadata.getAttribute("classname") + 
+                                " it might be a superclass or the class itself.");
+                        }
                     }
                 }
                 all = new HashSet(itfs);
@@ -547,6 +550,7 @@
 
             StringBuffer specs = null;
             Set set = new HashSet(all);
+            set.remove(Pojo.class.getName()); // Remove POJO.
             Iterator iterator = set.iterator(); 
             while (iterator.hasNext()) {
                 String spec = (String) iterator.next();

Added: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java?rev=744039&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
(added)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
Fri Feb 13 08:53:23 2009
@@ -0,0 +1,82 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.component.inherited;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+
+public class ProcessImplementation4 extends ProcessImplementation2  implements FooService
{
+
+    public void processChild() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void processParent1() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void processParentParent() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void processParent2() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean foo() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public Properties fooProps() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean getBoolean() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public double getDouble() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public int getInt() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public long getLong() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public Boolean getObject() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java?rev=744039&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
(added)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
Fri Feb 13 08:53:23 2009
@@ -0,0 +1,94 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.ps;
+
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation;
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class ClassTest extends OSGiTestCase {
+    
+    private Factory pi4, pi5, pi6, pi7;
+    
+    private IPOJOHelper helper;
+    
+    public void setUp() {
+        helper = new IPOJOHelper(this);
+        pi4 = helper.getFactory("PS-PI4");
+        pi5 = helper.getFactory("PS-PI5");
+        pi6 = helper.getFactory("PS-PI6");
+        pi7 = helper.getFactory("PS-PI7");
+    }
+    
+    public void tearDown() {
+        helper.dispose();
+    }
+    
+    
+    public void testIP4() {
+       helper.createComponentInstance( pi4.getName(), "ci");
+        
+       ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation",
"ci");
+       assertNotNull("Check itself", ref1);
+        
+       ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
+       
+        itself.processChild();
+    }
+    
+    public void testIP5() {
+        helper.createComponentInstance( pi5.getName(), "ci");
+        
+        ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation",
"ci");
+        assertNotNull("Check parent", ref1);
+         
+        ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
+        
+         itself.processChild();
+        
+    }
+    
+    public void testIP6() {
+        helper.createComponentInstance( pi6.getName(), "ci");
+        
+        ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation",
"ci");
+        assertNotNull("Check parent-parent", ref1);
+         
+        ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
+        
+         itself.processChild();
+    }
+    
+    public void testIP7() {
+       helper.createComponentInstance( pi7.getName(), "ci");
+        
+        ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation",
"ci");
+        assertNotNull("Check parent-parent", ref1);
+         
+        ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
+        
+         itself.processChild();
+         
+         ServiceReference ref5 = helper.getServiceReferenceByName( FooService.class.getName(),
"ci");
+         assertNotNull("Check FS", ref5);
+    }
+}

Propchange: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java?rev=744039&r1=744038&r2=744039&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
(original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
Fri Feb 13 08:53:23 2009
@@ -36,6 +36,7 @@
 		ots.addTestSuite(DynamicPropsReconfiguration.class);
 		ots.addTestSuite(InheritedTest.class);
 		ots.addTestSuite(ProvidedServiceArchitectureTest.class);
+		ots.addTestSuite(ClassTest.class);
 		return ots;
 	}
 

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/resources/metadata.xml?rev=744039&r1=744038&r2=744039&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/resources/metadata.xml (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/resources/metadata.xml Fri Feb
13 08:53:23 2009
@@ -136,4 +136,27 @@
 		name="PS-PI3" architecture="true">
 		<provides />
 	</component>
+	
+	<!-- Concrete and abstract class -->
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"
+		name="PS-PI4" architecture="true">
+		<provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
+	</component>
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"
+		name="PS-PI5" architecture="true">
+		<provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
+	</component>
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation4"
+		name="PS-PI6" architecture="true">
+		<provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
+	</component>
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"
+		name="PS-PI7" architecture="true">
+		<provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation,

+					org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>
+	</component>
 </ipojo>



Mime
View raw message