felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1059383 - in /felix/trunk/ipojo: core/doc/ core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ tests/core/service-providing/src/main/ipojo/ tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/co...
Date Sat, 15 Jan 2011 18:15:59 GMT
Author: clement
Date: Sat Jan 15 18:15:59 2011
New Revision: 1059383

URL: http://svn.apache.org/viewvc?rev=1059383&view=rev
Log:
Fix FELIX-2781 Expose the implementation class as service when no interfaces are found in
the hierachy

Update the changelog
Add tests to check FELIX-2781

Added:
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
Modified:
    felix/trunk/ipojo/core/doc/changelog.txt
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java

Modified: felix/trunk/ipojo/core/doc/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/doc/changelog.txt?rev=1059383&r1=1059382&r2=1059383&view=diff
==============================================================================
--- felix/trunk/ipojo/core/doc/changelog.txt (original)
+++ felix/trunk/ipojo/core/doc/changelog.txt Sat Jan 15 18:15:59 2011
@@ -5,6 +5,7 @@ Changes from the 1.6.8 to 1.8.0
     * [FELIX-2716] - [iPOJO] Failure when creating proxies for classes in java.* packages
 
 ** Improvement
+    * [FELIX-2781] - Expose the implementation class as service when no interfaces are found
in the hierarchy
     * [FELIX-1424] - Constructor Injection
     * [FELIX-1428] - Constructor injection of Configuration properties
     * [FELIX-2461] - Allow specifying the targeted service interface in the @ServiceController

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=1059383&r1=1059382&r2=1059383&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
Sat Jan 15 18:15:59 2011
@@ -596,7 +596,8 @@ public class ProvidedServiceHandler exte
             }
 
             if (all.isEmpty()) {
-                throw new ConfigurationException("Service Providing: Cannot instantiate a
provided service : no specifications found (no interfaces implemented by the pojo)");
+            	warn("No service interface found in the class hierarchy, use the implementation
class");
+                all.add(desc.getFactory().getClassName());
             }
 
             StringBuffer specs = null;

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml?rev=1059383&r1=1059382&r2=1059383&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml Sat
Jan 15 18:15:59 2011
@@ -25,4 +25,9 @@
         <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation,
org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>
     </component>
 
+	<component
+	classname="org.apache.felix.ipojo.test.scenarios.component.SimpleClass">
+		<provides/>
+	</component>
+
 </ipojo>

Added: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java?rev=1059383&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
(added)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
Sat Jan 15 18:15:59 2011
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public class SimpleClass {
+
+	// This class do not implement any interface, it will be exposed as SimpleClass
+
+	public String hello() {
+		return "Hello";
+	}
+
+}

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java?rev=1059383&r1=1059382&r2=1059383&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
(original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
Sat Jan 15 18:15:59 2011
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -18,50 +18,62 @@
  */
 package org.apache.felix.ipojo.test.scenarios.ps;
 
+import org.apache.felix.ipojo.ComponentInstance;
 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.SimpleClass;
 import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
 import org.osgi.framework.ServiceReference;
 
 public class SimplePS extends OSGiTestCase {
-	
+
 	public void testPS() {
 	    IPOJOHelper helper = new IPOJOHelper(this);
-	    
+
 		String factName = "PS-FooProviderType-1";
 		String compName = "FooProvider-1";
 		ServiceReference ref = null;
-		
+
 		// Check that no Foo Service are available
 		ref = getServiceReference(FooService.class.getName());
-		
+
 		assertNull("FS already available", ref);
-	
+
 		// Get the factory to create a component instance
 		Factory fact = helper.getFactory(factName);
 		assertNotNull("Cannot find the factory FooProvider-1", fact);
-		
+
 		helper.createComponentInstance(factName, compName);
-		
+
 		// Get a FooService provider
 		ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName
+ ")");
 
 		assertNotNull("FS not available", ref);
-		
+
 		// Test foo invocation
 		FooService fs = (FooService) getServiceObject(ref);
 		assertTrue("FooService invocation failed", fs.foo());
-		
+
 		helper.dispose();
 
-		
+
 		// Check that there is no more FooService
 		ref = getServiceReference(FooService.class.getName(), null);
-		
-		
+
+
 		assertNull("FS available, but component instance stopped", ref);
-		
+
+	}
+
+	public void testWhenNoInterface() {
+		IPOJOHelper helper = new IPOJOHelper(this);
+		String factoryName = "org.apache.felix.ipojo.test.scenarios.component.SimpleClass";
+		ComponentInstance ci = helper.createComponentInstance(factoryName);
+		waitForService(SimpleClass.class.getName(), null, 5000);
+		SimpleClass simple = (SimpleClass) getServiceObject(SimpleClass.class.getName(), null);
+		assertEquals("Hello", simple.hello());
+		ci.dispose();
 	}
 
 }



Mime
View raw message