Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,104 @@
+/* 
+ * 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.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import 
org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ */
+public class PrimitiveTypeTest extends OSGiTestCase {
+
+       ComponentInstance instance; // Instance under test
+       PrimitiveManipulationTestService prim;
+       ServiceReference prim_ref;
+       
+       public void setUp() {
+               Properties p1 = new Properties();
+               p1.put("instance.name","primitives");
+               instance = Utils.getComponentInstance(context, 
"ManipulationPrimitives-PrimitiveManipulationTester", p1);
+               assertTrue("check instance state", instance.getState() == 
ComponentInstance.VALID);
+               prim_ref = Utils.getServiceReferenceByName(context, 
PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+               assertNotNull("Check prim availability", prim_ref);
+               prim = (PrimitiveManipulationTestService) 
context.getService(prim_ref);
+       }
+       
+       public void tearDown() {
+               context.ungetService(prim_ref);
+               prim = null;
+               instance.dispose();
+               instance = null;
+       }
+       
+       public void testByte() {
+               assertEquals("Check - 1", prim.getByte(), 1);
+               prim.setByte((byte) 2);
+               assertEquals("Check - 2", prim.getByte(), 2);
+       }
+       
+       public void testShort() {
+               assertEquals("Check - 1", prim.getShort(), 1);
+               prim.setShort((short) 2);
+               assertEquals("Check - 2", prim.getShort(), 2);
+       }
+       
+       public void testInt() {
+               assertEquals("Check - 1", prim.getInt(), 1);
+               prim.setInt((int) 2);
+               assertEquals("Check - 2", prim.getInt(), 2);
+       }
+       
+       public void testLong() {
+               assertEquals("Check - 1", prim.getLong(), 1);
+               prim.setLong((long) 2);
+               assertEquals("Check - 2", prim.getLong(), 2);
+       }
+       
+       public void testFloat() {
+               assertEquals("Check - 1", prim.getFloat(), 1.1f);
+               prim.setFloat(2.2f);
+               assertEquals("Check - 2", prim.getFloat(), 2.2f);
+       }
+       
+       public void testDouble() {
+               assertEquals("Check - 1", prim.getDouble(), 1.1);
+               prim.setDouble(2.2);
+               assertEquals("Check - 2", prim.getDouble(), 2.2);
+       }
+       
+       public void testBoolean() {
+               assertFalse("Check - 1", prim.getBoolean());
+               prim.setBoolean(true);
+               assertTrue("Check - 2", prim.getBoolean());
+       }
+       
+       public void testChar() {
+               assertEquals("Check - 1", prim.getChar(), 'a');
+               prim.setChar('b');
+               assertEquals("Check - 2", prim.getChar(), 'b');
+       }
+       
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,114 @@
+/* 
+ * 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.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import 
org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ * The targeted implementation contains numbers.
+ */
+public class PrimitiveTypeTest2 extends OSGiTestCase {
+
+    ComponentInstance instance; // Instance under test
+
+    PrimitiveManipulationTestService prim;
+
+    ServiceReference prim_ref;
+
+    public void setUp() {
+        Properties p1 = new Properties();
+        p1.put("instance.name","primitives");
+        instance = Utils.getComponentInstance(context, 
"ManipulationPrimitives-PrimitiveManipulationTesterA", p1);
+        assertTrue("check instance state", instance.getState() == 
ComponentInstance.VALID);
+        prim_ref = Utils.getServiceReferenceByName(context, 
PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check prim availability", prim_ref);
+        prim = (PrimitiveManipulationTestService) context.getService(prim_ref);
+    }
+
+    public void tearDown() {
+        context.ungetService(prim_ref);
+        prim = null;
+        instance.dispose();
+        instance = null;
+    }
+
+    public void testByte() {
+        assertEquals("Check - 1", prim.getByte(), 1);
+        prim.setByte((byte) 2);
+        assertEquals("Check - 2", prim.getByte(), 2);
+    }
+
+    public void testShort() {
+        assertEquals("Check - 1", prim.getShort(), 1);
+        prim.setShort((short) 2);
+        assertEquals("Check - 2", prim.getShort(), 2);
+    }
+
+    public void testInt() {
+        assertEquals("Check - 1", prim.getInt(), 1);
+        prim.setInt((int) 2);
+        assertEquals("Check - 2", prim.getInt(), 2);
+    }
+
+    public void testLong() {
+        assertEquals("Check - 1", prim.getLong(), 1);
+        prim.setLong((long) 2);
+        assertEquals("Check - 2", prim.getLong(), 2);
+    }
+
+    public void testLong2() {
+        assertEquals("Check - 1", prim.getLong(), 1);
+        prim.setLong(2, "ss");
+        assertEquals("Check - 2", prim.getLong(), 2);
+    }
+
+
+
+    public void testFloat() {
+        assertEquals("Check - 1", prim.getFloat(), 1.1f);
+        prim.setFloat(2.2f);
+        assertEquals("Check - 2", prim.getFloat(), 2.2f);
+    }
+
+    public void testDouble() {
+        assertEquals("Check - 1", prim.getDouble(), 1.1);
+        prim.setDouble(2.2);
+        assertEquals("Check - 2", prim.getDouble(), 2.2);
+    }
+
+    public void testBoolean() {
+        assertFalse("Check - 1", prim.getBoolean());
+        prim.setBoolean(true);
+        assertTrue("Check - 2", prim.getBoolean());
+    }
+
+    public void testChar() {
+        assertEquals("Check - 1", prim.getChar(), 'a');
+        prim.setChar('b');
+        assertEquals("Check - 2", prim.getChar(), 'b');
+    }
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.manipulation.service.A123;
+
+public interface CheckService2 {
+       
+       public boolean check();
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
 Mon Oct  6 00:55:39 2008
@@ -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 org.apache.felix.ipojo.test.scenarios.manipulation.service;
+
+import java.util.Properties;
+
+public interface BarService {
+       
+       public boolean bar();
+       
+       public Properties getProps();
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,31 @@
+/* 
+ * 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.manipulation.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+    
+    public static final String foo = "foo";
+       
+       public boolean check();
+       
+       public Properties getProps();
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
 Mon Oct  6 00:55:39 2008
@@ -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 org.apache.felix.ipojo.test.scenarios.manipulation.service;
+
+import java.util.Properties;
+
+public interface FooService {
+
+       boolean foo();
+       
+       Properties fooProps();
+       
+       Boolean getObject();
+       
+       boolean getBoolean();
+       
+       int getInt();
+       
+       long getLong();
+       
+       double getDouble();
+       
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation.service;
+
+public interface Plop {
+    
+   Object getPlop();
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,75 @@
+/* 
+ * 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.manipulation.service;
+
+public interface PrimitiveManipulationTestService {
+       
+       byte getByte();
+       void setByte(byte b);
+       
+       short getShort();
+       void setShort(short s);
+       
+       int getInt();
+       void setInt(int i);
+       
+       long getLong();
+       void setLong(long l);
+       
+       float getFloat();
+       void setFloat(float f);
+       
+       double getDouble();
+       void setDouble(double d);
+       
+       char getChar();
+       void setChar(char c);
+       
+       boolean getBoolean();
+       void setBoolean(boolean b);
+       
+       // Array types
+       byte[] getBytes();
+       void setBytes(byte[] bs);
+       
+       short[] getShorts();
+       void setShorts(short[] ss);
+       
+       int[] getInts();
+       void setInts(int is[]);
+       
+       long[] getLongs();
+       void setLongs(long[] ls);
+       
+       float[] getFloats();
+       void setFloats(float[] fs);
+       
+       double[] getDoubles();
+       void setDoubles(double[] ds);
+       
+       char[] getChars();
+       void setChars(char[] cs);
+       
+       boolean[] getBooleans();
+       void setBooleans(boolean[] bs); 
+       
+       // This method has been added to test an issue when autoboxing.
+       void setLong(long l, String s);
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
 (added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
 Mon Oct  6 00:55:39 2008
@@ -0,0 +1,329 @@
+/* 
+ * 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.util;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerManagerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.architecture.Architecture;
+//import org.apache.felix.ipojo.composite.CompositeManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+public class Utils {
+
+    public static Factory getFactoryByName(BundleContext bc, String 
factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), 
"(factory.name=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " 
+ e.getMessage());
+            return null;
+        }
+    }
+
+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext 
bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(" + 
Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return (HandlerManagerFactory) bc.getService(refs[0]);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " 
+ e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(BundleContext bc, 
String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        // if(fact.isAcceptable(configuration)) {
+        try {
+            return fact.createComponentInstance(configuration);
+        } catch (Exception e) {
+            e.printStackTrace();
+            Assert.fail("Cannot create the instance from " + factoryName + " : 
" + e.getMessage());
+            return null;
+        }
+        // }
+        // else {
+        // System.err.println("Configuration not accepted by : " + 
factoryName);
+        // return null;
+        // }
+    }
+
+    public static ComponentInstance getComponentInstanceByName(BundleContext 
bc, String factoryName, String name) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        try {
+            Properties props = new Properties();
+            props.put("instance.name",name);
+            return fact.createComponentInstance(props);
+        } catch (Exception e) {
+            System.err.println("Cannot create the instance from " + 
factoryName + " : " + e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(BundleContext bc, 
String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(BundleContext bc, 
String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(BundleContext bc, 
String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || 
itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else if (itf.equals(Architecture.class.getName())) {
+            filter = "(" + "architecture.instance" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+    
+    public static ServiceReference getServiceReferenceByPID(BundleContext bc, 
String itf, String pid) {
+        ServiceReference[] refs = null;
+        String filter = "(" + "service.pid" + "=" + pid + ")";
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else if (refs.length == 1) {
+            return refs[0];
+        } else {
+            Assert.fail("A service lookup by PID returned several providers (" 
+ refs.length + ")" + " for " + itf + " with " + pid);
+            return null;
+        }
+    }
+
+    public static Object getServiceObject(BundleContext bc, String itf, String 
filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(BundleContext bc, String itf, 
String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+//    public static ServiceContext getServiceContext(ComponentInstance ci) {
+//        if (ci instanceof CompositeManager) {
+//            return ((CompositeManager) ci).getServiceContext();
+//        } else {
+//            throw new RuntimeException("Cannot get the service context form 
an non composite instance");
+//        }
+//    }
+
+    public static Factory getFactoryByName(ServiceContext bc, String 
factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), 
"(factory.name=" + factoryName + ")");
+            if (refs == null) { return null; }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " 
+ e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(ServiceContext bc, 
String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) { return null; }
+
+        if (fact.isAcceptable(configuration)) {
+            try {
+                return fact.createComponentInstance(configuration);
+            } catch (Exception e) {
+                System.err.println(e.getMessage());
+                e.printStackTrace();
+                return null;
+            }
+        } else {
+            System.err.println("Configuration not accepted by : " + 
factoryName);
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(ServiceContext bc, 
String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(ServiceContext bc, 
String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(ServiceContext 
bc, String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || 
itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static Object getServiceObject(ServiceContext bc, String itf, 
String filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(ServiceContext bc, String itf, 
String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+    
+    public static boolean contains(String string, String[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] != null  && array[i].equals(string)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public static boolean contains(int value, int[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] == value) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

Added: 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml?rev=701978&view=auto
==============================================================================
--- 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml 
(added)
+++ 
felix/trunk/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml 
Mon Oct  6 00:55:39 2008
@@ -0,0 +1,22 @@
+<ipojo
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="org.apache.felix.ipojo 
http://people.apache.org/~clement/ipojo/schemas/core.xsd";
+    xmlns="org.apache.felix.ipojo"
+>
+       
+       <!-- Manipulation -->
+       <component
+               
classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"
+               name="ManipulationPrimitives-PrimitiveManipulationTester" 
architecture="true">
+               <provides />
+       </component>
+
+       <!-- Manipulation with numbers -->
+       <component
+               
classname="org.apache.felix.ipojo.test.scenarios.component.A123.Manipulation23Tester"
+               name="ManipulationPrimitives-PrimitiveManipulationTesterA" 
architecture="true">
+               <provides />
+       </component>
+       
+
+</ipojo>

Modified: felix/trunk/ipojo/tests/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/pom.xml?rev=701978&r1=701977&r2=701978&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/pom.xml (original)
+++ felix/trunk/ipojo/tests/pom.xml Mon Oct  6 00:55:39 2008
@@ -26,6 +26,9 @@
   
   <modules>
     <module>manipulator/manipulation</module>
+    <module>manipulator/metadata</module>
+    <module>manipulator/primitives</module>
+    <module>manipulator/creation</module>
        <module>core/factories</module>
        <module>core/lifecycle-controller</module>
        <module>core/service-providing</module>
@@ -54,6 +57,7 @@
                </activation>
                <modules>
                        <module>core/annotations</module>
+                       <module>manipulator/manipulator-java5</module>
                </modules>
        </profile>
        <profile>
@@ -63,6 +67,7 @@
                </activation>
                <modules>
                        <module>core/annotations</module>
+                       <module>manipulator/manipulator-java5</module>
                </modules>
        </profile>
   </profiles>


Reply via email to