felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1471456 [1/2] - in /felix/trunk/ipojo/runtime: core-it/src/it/ipojo-core-configuration-processor-test/ core-it/src/it/ipojo-core-configuration-processor-test/src/ core-it/src/it/ipojo-core-configuration-processor-test/src/main/ core-it/src...
Date Wed, 24 Apr 2013 15:06:09 GMT
Author: clement
Date: Wed Apr 24 15:06:07 2013
New Revision: 1471456

URL: http://svn.apache.org/r1471456
Log:
Fix FELIX-4034

Define the DSL, the @Configuration annotation

Implement the processor looking at the @Configuration annotation and creating the instance declaration

Add some tests

I also introduce a couple of utility class to simplify reflection.

Added:
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/   (with props)
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/pom.xml
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Bean.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureAnotherInstance.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureNothing.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureOneInstance.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureThreeInstancesUsingMethods.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstances.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithInheritance.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithOverridding.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComplexComponent.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentConfiguration.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyComplexConfiguration.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyConfiguration.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/resources/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestEmptyConfiguration.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/resources/
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/configuration/
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/configuration/Configuration.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/configuration/Instance.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/processor/ConfigurationAnnotationScanner.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/processor/ConfigurationProcessor.java
      - copied, changed from r1465972, felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/processor/ComponentsBundleProcessor.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Fields.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/InvocationResult.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Methods.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Reflection.java
    felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/configuration/
    felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/configuration/InstanceDSLTest.java
Modified:
    felix/trunk/ipojo/runtime/core/pom.xml
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/Extender.java

Propchange: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr 24 15:06:07 2013
@@ -0,0 +1,3 @@
+target
+*.iml
+

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/pom.xml?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/pom.xml (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/pom.xml Wed Apr 24 15:06:07 2013
@@ -0,0 +1,38 @@
+<?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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.core-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>ipojo-core-configuration-processor-test</artifactId>
+
+    <name>${project.artifactId}</name>
+    
+</project>
\ No newline at end of file

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Bean.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Bean.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Bean.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Bean.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.runtime.core.components;
+
+/**
+ * A bean
+ */
+public class Bean {
+
+    private String message;
+
+    private int count;
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureAnotherInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureAnotherInstance.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureAnotherInstance.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureAnotherInstance.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration
+ */
+@Configuration
+public class ConfigureAnotherInstance {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance anotherInstance = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureNothing.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureNothing.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureNothing.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureNothing.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,32 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+
+/**
+ * Nothing happen in this class..
+ */
+@Configuration
+public class ConfigureNothing {
+
+    // Nothing on purpose
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureOneInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureOneInstance.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureOneInstance.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureOneInstance.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration
+ */
+@Configuration
+public class ConfigureOneInstance {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance myInstance = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureThreeInstancesUsingMethods.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureThreeInstancesUsingMethods.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureThreeInstancesUsingMethods.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureThreeInstancesUsingMethods.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,66 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration using methods and fields.
+ */
+@Configuration
+public class ConfigureThreeInstancesUsingMethods {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance myInstance = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+
+    Instance instance1() {
+        return instance().of(MyComponent.class)
+                .with("floating").setto("1.0")
+                .with("message").setto("foo")
+                .with("bool").setto(true)
+                .with("number").setto(1l)
+                .with("integer").setto(1)
+                .with("props").setto(new Properties());
+    }
+
+    Instance instance2(BundleContext bc) {
+        return instance().of(MyComponent.class)
+                .with("floating").setto("1.0")
+                .with("message").setto("foo")
+                .with("bool").setto(true)
+                .with("number").setto(1l)
+                .with("integer").setto(bc.getBundles().length)
+                .with("props").setto(new Properties());
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstances.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstances.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstances.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstances.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration
+ */
+@Configuration
+public class ConfigureTwoInstances {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance myInstance1 = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+
+    // Declare an instance of MyComponent named hello
+    Instance myInstance2 = instance().of(MyComponent.class)
+            .named("hello")
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithInheritance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithInheritance.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithInheritance.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithInheritance.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration
+ */
+@Configuration
+public class ConfigureTwoInstancesWithInheritance extends ParentConfiguration {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance myInstance1 = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithOverridding.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithOverridding.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithOverridding.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ConfigureTwoInstancesWithOverridding.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration
+ */
+@Configuration
+public class ConfigureTwoInstancesWithOverridding extends ParentConfiguration {
+
+    // Declare an instance of MyComponent named myInstance
+    Instance myInstance1 = instance().of(MyComponent.class)
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+
+    protected Instance myInstance2 = instance().of(MyComponent.class)
+            .named("hello-over")
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComplexComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComplexComponent.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComplexComponent.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComplexComponent.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,106 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * A complex component
+ */
+@Component
+@Provides
+public class MyComplexComponent implements FooService {
+
+    @Property
+    private File file;
+    @Property
+    private Bean bean;
+    @Property
+    private Map<String, String> map;
+
+    @Override
+    public boolean foo() {
+        return file != null;
+    }
+
+    @Override
+    public Properties fooProps() {
+        String content;
+        try {
+            content = read();
+        } catch (IOException e) {
+            throw new IllegalStateException("unexpected error", e);
+        }
+        Properties props = new Properties();
+        props.put("map", map);
+        props.put("content", content);
+        props.put("bean", bean);
+        return props;
+    }
+
+    private String read() throws IOException {
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+        String line;
+        StringBuilder stringBuilder = new StringBuilder();
+        String ls = System.getProperty("line.separator");
+
+        while ((line = reader.readLine()) != null) {
+            stringBuilder.append(line);
+            stringBuilder.append(ls);
+        }
+
+        return stringBuilder.toString();
+    }
+
+    @Override
+    public Boolean getObject() {
+        return false;
+    }
+
+    @Override
+    public boolean getBoolean() {
+        return false;
+    }
+
+    @Override
+    public int getInt() {
+        return 0;
+    }
+
+    @Override
+    public long getLong() {
+        return 1;
+    }
+
+    @Override
+    public double getDouble() {
+        return 1;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.annotations.ServiceProperty;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+/**
+ * A simple component
+ */
+@Component
+@Provides
+public class MyComponent implements FooService {
+
+    @Property
+    private Boolean bool;
+
+    @Property
+    private Properties props;
+
+    @ServiceProperty
+    private String message;
+
+    @Property
+    private long number;
+
+    @Property
+    private int integer;
+
+    @Property
+    private double floating;
+
+    @Override
+    public boolean foo() {
+        return message != null;
+    }
+
+    @Override
+    public Properties fooProps() {
+        return props;
+    }
+
+    @Override
+    public Boolean getObject() {
+        return bool;
+    }
+
+    @Override
+    public boolean getBoolean() {
+       return bool;
+    }
+
+    @Override
+    public int getInt() {
+        return integer;
+    }
+
+    @Override
+    public long getLong() {
+        return number;
+    }
+
+    @Override
+    public double getDouble() {
+        return floating;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentConfiguration.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentConfiguration.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentConfiguration.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,54 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.configuration.Instance;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * This configuration is a parent configuration.
+ */
+public class ParentConfiguration {
+
+    // Inherited fields must be public.
+    protected Instance myInstance2 = instance().of(MyComponent.class)
+            .named("hello")
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+
+    private Instance hidden = instance().of(MyComponent.class)
+            .named("hello")
+            .with("floating").setto("1.0")
+            .with("message").setto("hidden")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyComplexConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyComplexConfiguration.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyComplexConfiguration.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyComplexConfiguration.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,77 @@
+/*
+ * 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.runtime.core.components.configuration;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+import org.apache.felix.ipojo.runtime.core.components.Bean;
+import org.apache.felix.ipojo.runtime.core.components.MyComplexComponent;
+import org.osgi.framework.BundleContext;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+
+import static org.apache.felix.ipojo.configuration.Instance.*;
+
+/**
+ * A complex configuration creating two instances of MyComplex component
+ */
+@Configuration
+public class MyComplexConfiguration {
+
+    Instance complex1(BundleContext bc) throws FileNotFoundException {
+
+        File file = bc.getBundle().getDataFile("file1.txt");
+        write(file, "I'm file 1");
+
+        Bean bean = new Bean();
+        bean.setMessage("I'm 1");
+        bean.setCount(1);
+
+        return instance().of(MyComplexComponent.class)
+                .with("file").setto(file)
+                .with("bean").setto(bean)
+                .with("map").setto(map(pair("a", "b"), pair("c", "d")));
+
+    }
+
+    Instance complex2(BundleContext bc) throws FileNotFoundException {
+
+        File file = bc.getBundle().getDataFile("file2.txt");
+        write(file, "I'm file 2");
+
+        Bean bean = new Bean();
+        bean.setMessage("I'm 2");
+        bean.setCount(2);
+
+        return instance().of(MyComplexComponent.class)
+                .with("file").setto(file)
+                .with("bean").setto(bean)
+                .with("map").setto(map(pair("a", "b2"), pair("c", "d2")));
+
+    }
+
+    private void write(File file, String message) throws FileNotFoundException {
+        PrintWriter out = new PrintWriter(file);
+        out.println(message);
+        out.close();
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyConfiguration.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyConfiguration.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/configuration/MyConfiguration.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.runtime.core.components.configuration;
+
+import org.apache.felix.ipojo.configuration.Configuration;
+import org.apache.felix.ipojo.configuration.Instance;
+import org.apache.felix.ipojo.runtime.core.components.MyComponent;
+
+import java.util.Properties;
+
+import static org.apache.felix.ipojo.configuration.Instance.instance;
+
+/**
+ * Simple configuration in another package.
+ */
+@Configuration
+public class MyConfiguration {
+
+    // Declare an instance of MyComponent named myInstance
+    // We use the factory name to avoid import-export package.
+    Instance myInstance = instance().of("org.apache.felix.ipojo.runtime.core.components.MyComponent")
+            .with("floating").setto("1.0")
+            .with("message").setto("foo")
+            .with("bool").setto(true)
+            .with("number").setto(1l)
+            .with("integer").setto(1)
+            .with("props").setto(new Properties());
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java Wed Apr 24 15:06:07 2013
@@ -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.runtime.core.services;
+
+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/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,349 @@
+/*
+ * 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.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+    @Inject
+    protected
+    BundleContext bc;
+    protected OSGiHelper osgiHelper;
+    protected IPOJOHelper ipojoHelper;
+    protected boolean deployTestedBundle = true;
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito without Hamcrest and Objenesis
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+    public static void dump(BundleContext bc, File output) throws IOException {
+        if (!output.exists()) {
+            output.mkdirs();
+        }
+
+        for (Bundle bundle : bc.getBundles()) {
+            if (bundle.getBundleId() == 0) {
+                continue;
+            }
+            System.out.println("Location : " + bundle.getLocation());
+            if ("local".equals(bundle.getLocation())) {
+                continue; // Pax Exam, when you hug me, I feel so...
+            }
+            URL location = new URL(bundle.getLocation());
+            FileOutputStream outputStream = null;
+            if (bundle.getVersion() != null) {
+                outputStream = new FileOutputStream(new File(output,
+                        bundle.getSymbolicName() + "-" + bundle.getVersion().toString() + ".jar"));
+            } else {
+                outputStream = new FileOutputStream(new File(output, bundle.getSymbolicName() + ".jar"));
+            }
+
+            int read = 0;
+            byte[] bytes = new byte[1024];
+
+            InputStream inputStream = location.openStream();
+            while ((read = inputStream.read(bytes)) != -1) {
+                outputStream.write(bytes, 0, read);
+            }
+            inputStream.close();
+            outputStream.close();
+        }
+    }
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        if (deployTestedBundle) {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    testedBundle(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        } else {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        }
+    }
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+
+        waitForStability(bc);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // harmcrest-all
+                //mavenBundle("de.twentyeleven.skysail", "org.hamcrest.hamcrest-all-osgi").versionAsInProject(),
+                // configuration admin
+                mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+        if (out.exists()) {
+            return bundle(out.toURI().toURL().toExternalForm());
+        }
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        // Export the inherited package, components and strategies
+        String export = "org.apache.felix.ipojo.runtime.core.components.inherited";
+        export += ", org.apache.felix.ipojo.runtime.core.components";
+        export += ", org.apache.felix.ipojo.runtime.core.components.strategies";
+        // Inheritance.
+        export += ", org.apache.felix.ipojo.runtime.core.components.inheritance.a";
+        export += ", org.apache.felix.ipojo.runtime.core.components.inheritance.b";
+        for (File file : services) {
+            if (export.length() > 0) {
+                export += ", ";
+            }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.IMPORT_PACKAGE, "*")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+    /**
+     * Waits for stability:
+     * <ul>
+     * <li>all bundles are activated
+     * <li>service count is stable
+     * </ul>
+     * If the stability can't be reached after a specified time,
+     * the method throws a {@link IllegalStateException}.
+     *
+     * @param context the bundle context
+     * @throws IllegalStateException when the stability can't be reach after a several attempts.
+     */
+    private void waitForStability(BundleContext context) throws IllegalStateException {
+        // Wait for bundle initialization.
+        boolean bundleStability = getBundleStability(context);
+        int count = 0;
+        while (!bundleStability && count < 500) {
+            try {
+                Thread.sleep(5);
+            } catch (InterruptedException e) {
+                // Interrupted
+            }
+            count++;
+            bundleStability = getBundleStability(context);
+        }
+
+        if (count == 500) {
+            System.err.println("Bundle stability isn't reached after 500 tries");
+            throw new IllegalStateException("Cannot reach the bundle stability");
+        }
+
+        boolean serviceStability = false;
+        count = 0;
+        int count1 = 0;
+        int count2 = 0;
+        while (!serviceStability && count < 500) {
+            try {
+                ServiceReference[] refs = context.getServiceReferences((String) null, null);
+                count1 = refs.length;
+                Thread.sleep(500);
+                refs = context.getServiceReferences((String) null, null);
+                count2 = refs.length;
+                serviceStability = count1 == count2;
+            } catch (Exception e) {
+                System.err.println(e);
+                serviceStability = false;
+                // Nothing to do, while recheck the condition
+            }
+            count++;
+        }
+
+        if (count == 500) {
+            System.err.println("Service stability isn't reached after 500 tries (" + count1 + " != " + count2);
+            throw new IllegalStateException("Cannot reach the service stability");
+        }
+    }
+
+    /**
+     * Are bundle stables.
+     *
+     * @param bc the bundle context
+     * @return <code>true</code> if every bundles are activated.
+     */
+    private boolean getBundleStability(BundleContext bc) {
+        boolean stability = true;
+        Bundle[] bundles = bc.getBundles();
+        for (Bundle bundle : bundles) {
+            stability = stability && (bundle.getState() == Bundle.ACTIVE);
+        }
+        return stability;
+    }
+
+    public boolean isKF() {
+        return bc.getClass().toString().contains("knopflerfish");
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,147 @@
+/*
+ * 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.runtime.core;
+
+import junit.framework.Assert;
+import org.apache.felix.ipojo.runtime.core.components.Bean;
+import org.apache.felix.ipojo.runtime.core.components.MyComplexComponent;
+import org.apache.felix.ipojo.runtime.core.components.MyComponent;
+import org.apache.felix.ipojo.runtime.core.components.configuration.MyComplexConfiguration;
+import org.apache.felix.ipojo.runtime.core.components.configuration.MyConfiguration;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+/**
+ * Check @Configuration embedded in another bundle using complex configurations.
+ */
+public class TestComplexConfigurations extends Common {
+
+    @Configuration
+    public Option[] config() throws IOException {
+        deployTestedBundle = false;
+        Option[] options = super.config();
+
+        // Build a service bundle
+        return OptionUtils.combine(options,
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(FooService.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface")
+                                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.services")
+                                .build(withBnd())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(MyComplexComponent.class)
+                                .add(Bean.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "MyComponent")
+                                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.components")
+                                .build(IPOJOStrategy.withiPOJO())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(MyComplexConfiguration.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "Configuration")
+                                .build(IPOJOStrategy.withiPOJO())
+                )
+        );
+    }
+
+    /**
+     * <ol>
+     * <li>Check when all bundles are deployed</li>
+     * <li>Check when the configuration bundle is stopped</li>
+     * <li>Check when the configuration is restarted</li>
+     * <li>Check when the component bundle is stopped</li>
+     * <li>Check when the component bundle is restarted</li>
+     * </ol>
+     */
+    @Test
+    public void testDynamism() throws BundleException {
+        if (isKF()) {
+            return; // Test disabled on KF
+        }
+        //1)
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+
+        //2) Stopping configuration bundle
+        osgiHelper.getBundle("Configuration").stop();
+        Assert.assertNull(osgiHelper.getServiceReference(FooService.class));
+
+        //3) Restart configuration bundle
+        osgiHelper.getBundle("Configuration").start();
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+
+        //4) Stop the component bundle
+        osgiHelper.getBundle("MyComponent").stop();
+        Assert.assertNull(osgiHelper.getServiceReference(FooService.class));
+
+        //5) Restart the component bundle
+        osgiHelper.getBundle("MyComponent").start();
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+    }
+
+    @Test
+    public void testConfiguration() {
+        if (isKF()) {
+            return; // Test disabled on KF
+        }
+        osgiHelper.waitForService(FooService.class, null, 10000);
+
+        ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "complex1");
+        Assert.assertNotNull(ref1);
+        FooService fs1 = (FooService) osgiHelper.getServiceObject(ref1);
+        Properties props1 = fs1.fooProps();
+        Assert.assertTrue(((String)props1.get("content")).contains("I'm file 1"));
+        Assert.assertEquals(((Bean)props1.get("bean")).getMessage(), "I'm 1");
+        Assert.assertEquals(((Bean)props1.get("bean")).getCount(), 1);
+        Assert.assertEquals(((Map<String, String>)props1.get("map")).get("a"), "b");
+
+        ServiceReference ref2 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "complex2");
+        Assert.assertNotNull(ref2);
+        FooService fs2 = (FooService) osgiHelper.getServiceObject(ref2);
+        Properties props2 = fs2.fooProps();
+        Assert.assertTrue(((String)props2.get("content")).contains("I'm file 2"));
+        Assert.assertEquals(((Bean)props2.get("bean")).getMessage(), "I'm 2");
+        Assert.assertEquals(((Bean)props2.get("bean")).getCount(), 2);
+        Assert.assertEquals(((Map<String, String>)props2.get("map")).get("a"), "b2");
+
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,112 @@
+/*
+ * 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.runtime.core;
+
+import junit.framework.Assert;
+import org.apache.felix.ipojo.runtime.core.components.MyComponent;
+import org.apache.felix.ipojo.runtime.core.components.configuration.MyConfiguration;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+
+import java.io.IOException;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+/**
+ * Check @Configuration embedded in another bundle.
+ */
+public class TestConfigurationInAnotherBundle extends Common {
+
+    @Configuration
+    public Option[] config() throws IOException {
+        deployTestedBundle = false;
+        Option[] options = super.config();
+
+        // Build a service bundle
+        return OptionUtils.combine(options,
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(FooService.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface")
+                                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.services")
+                                .build(withBnd())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(MyComponent.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "MyComponent")
+                                .build(IPOJOStrategy.withiPOJO())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(MyConfiguration.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "Configuration")
+                                .build(IPOJOStrategy.withiPOJO())
+                )
+        );
+    }
+
+    /**
+     * <ol>
+     * <li>Check when all bundles are deployed</li>
+     * <li>Check when the configuration bundle is stopped</li>
+     * <li>Check when the configuration is restarted</li>
+     * <li>Check when the component bundle is stopped</li>
+     * <li>Check when the component bundle is restarted</li>
+     * </ol>
+     */
+    @Test
+    public void testDynamism() throws BundleException {
+        if (isKF()) {
+            return; // Test disabled on KF
+        }
+        //1)
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+
+        //2) Stopping configuration bundle
+        osgiHelper.getBundle("Configuration").stop();
+        Assert.assertNull(osgiHelper.getServiceReference(FooService.class));
+
+        //3) Restart configuration bundle
+        osgiHelper.getBundle("Configuration").start();
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+
+        //4) Stop the component bundle
+        osgiHelper.getBundle("MyComponent").stop();
+        Assert.assertNull(osgiHelper.getServiceReference(FooService.class));
+
+        //5) Restart the component bundle
+        osgiHelper.getBundle("MyComponent").start();
+        osgiHelper.waitForService(FooService.class, null, 10000);
+        Assert.assertNotNull(osgiHelper.getServiceReference(FooService.class));
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,85 @@
+/*
+ * 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.runtime.core;
+
+import junit.framework.Assert;
+import org.apache.felix.ipojo.runtime.core.components.ConfigureOneInstance;
+import org.apache.felix.ipojo.runtime.core.components.MyComponent;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+
+import java.io.IOException;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+/**
+ * Check simple @Configuration
+ */
+public class TestConfigurationOfMyComponent extends Common {
+
+    @Configuration
+    public Option[] config() throws IOException {
+        deployTestedBundle = false;
+        Option[] options = super.config();
+
+        // Build a service bundle
+        return OptionUtils.combine(options,
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(FooService.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface")
+                                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.services")
+                                .build(withBnd())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(MyComponent.class)
+                                .add(ConfigureOneInstance.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "MyComponent")
+                                .build(IPOJOStrategy.withiPOJO())
+                )
+        );
+    }
+
+    @Test
+    public void testConfiguration() throws IOException {
+        if (isKF()) {
+            return; // Test disabled on KF
+        }
+
+        osgiHelper.waitForService(FooService.class, null, 10000);
+
+        // Check configuration
+        FooService fs = osgiHelper.getServiceObject(FooService.class);
+        Assert.assertTrue(fs.foo());
+        Assert.assertEquals(fs.getDouble(), 1.0, 0);
+        Assert.assertEquals(fs.getInt(), 1);
+        Assert.assertEquals(fs.getLong(), 1l);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java?rev=1471456&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java Wed Apr 24 15:06:07 2013
@@ -0,0 +1,97 @@
+/*
+ * 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.runtime.core;
+
+import junit.framework.Assert;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.components.ConfigureThreeInstancesUsingMethods;
+import org.apache.felix.ipojo.runtime.core.components.ConfigureTwoInstances;
+import org.apache.felix.ipojo.runtime.core.components.MyComponent;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+/**
+ * Check a @Configuration with 2 instances.
+ */
+public class TestConfigurationOfThreeInstancesUsingMethods extends Common {
+
+    @Configuration
+    public Option[] config() throws IOException {
+        deployTestedBundle = false;
+        Option[] options = super.config();
+
+        // Build a service bundle
+        return OptionUtils.combine(options,
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(FooService.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface")
+                                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.services")
+                                .build(withBnd())
+                ),
+                streamBundle(
+                        TinyBundles.bundle()
+                                .add(ConfigureThreeInstancesUsingMethods.class)
+                                .add(MyComponent.class)
+                                .set(Constants.BUNDLE_SYMBOLICNAME, "MyComponent")
+                                .build(IPOJOStrategy.withiPOJO())
+                )
+        );
+    }
+
+    @Test
+    public void testConfiguration() {
+        if (isKF()) {
+            return; // Test disabled on KF
+        }
+
+        osgiHelper.waitForService(FooService.class, null, 10000);
+
+        // Check we have two instances
+        ServiceReference[] refs = osgiHelper.getServiceReferences(FooService.class, null);
+        Assert.assertEquals(refs.length, 3);
+
+        List<Architecture> arch = osgiHelper.getServiceObjects(Architecture.class, null);
+        for (Architecture a : arch) {
+            System.out.println("Instance " + a.getInstanceDescription().getName());
+        }
+
+        // Check name
+        Assert.assertNotNull(ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "myInstance"));
+        Assert.assertNotNull(ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "instance1"));
+        Assert.assertNotNull(ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "instance2"));
+
+    }
+
+
+}



Mime
View raw message