felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1575838 - in /felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/ipojo/ src/main...
Date Mon, 10 Mar 2014 06:17:44 GMT
Author: clement
Date: Mon Mar 10 06:17:43 2014
New Revision: 1575838

URL: http://svn.apache.org/r1575838
Log:
Add test about the @Context handler

Added:
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/   (with props)
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/pom.xml
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingConstructor.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingField.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingMethod.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInConstructor.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInField.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInMethod.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithThreeConstructorParams.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoConstructorParams.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoFields.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoSetters.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInConstructor.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInField.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInMethod.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties1.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties2.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/metadata.xml
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromAnnotations.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromXML.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingComponentAndInstanceContext.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingContextAndProperties.java
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/
    felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/exam.properties

Propchange: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 10 06:17:43 2014
@@ -0,0 +1,2 @@
+target
+*.iml

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/pom.xml?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/pom.xml (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/pom.xml Mon Mar 10 06:17:43 2014
@@ -0,0 +1,35 @@
+<?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.11.2-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>ipojo-core-context-injection-test</artifactId>
+
+    <name>${project.artifactId}</name>
+
+</project>

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingConstructor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingConstructor.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingConstructor.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingConstructor.java Mon Mar 10 06:17:43 2014
@@ -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.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using constructor injection to retrieve the bundle context.
+ */
+public class ComponentUsingConstructor implements CheckService {
+
+
+    private BundleContext context;
+
+    public ComponentUsingConstructor(BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingField.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingField.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingField.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,49 @@
+/*
+* 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.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using field injection to retrieve the bundle context.
+ */
+public class ComponentUsingField implements CheckService {
+
+    // Injected.
+    private BundleContext context;
+
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingMethod.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingMethod.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ComponentUsingMethod.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,51 @@
+/*
+* 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.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using method injection to retrieve the bundle context.
+ */
+public class ComponentUsingMethod implements CheckService {
+
+    private BundleContext context;
+
+    public void setContext(BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInConstructor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInConstructor.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInConstructor.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInConstructor.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,60 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using constructor injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class ComponentBundleContextInjectionInConstructor implements CheckService {
+
+
+    private BundleContext context;
+
+    /**
+     * @param context no parameter, as component is the default.
+     */
+    public ComponentBundleContextInjectionInConstructor(@Context BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInField.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInField.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInField.java Mon Mar 10 06:17:43 2014
@@ -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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using field injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class ComponentBundleContextInjectionInField implements CheckService {
+
+    @Context(Context.Source.COMPONENT)
+    private BundleContext context;
+
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInMethod.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInMethod.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentBundleContextInjectionInMethod.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,57 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using method injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class ComponentBundleContextInjectionInMethod implements CheckService {
+
+    private BundleContext context;
+
+    @Context
+    public void setContext(BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithThreeConstructorParams.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithThreeConstructorParams.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithThreeConstructorParams.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithThreeConstructorParams.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,69 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component receiving both bundle context.
+ */
+@Component
+@Provides
+public class ComponentWithThreeConstructorParams implements CheckService {
+
+    private final BundleContext bc;
+    private BundleContext instance;
+
+    private BundleContext component;
+
+    public ComponentWithThreeConstructorParams(BundleContext bc, @Context(Context.Source.INSTANCE) BundleContext
+            instance,
+                                               @Context BundleContext component) {
+        this.instance = instance;
+        this.component = component;
+        this.bc = bc;
+    }
+
+    @Override
+    public boolean check() {
+        return instance != null  && component != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (instance != null) {
+            map.put("instance", instance);
+        }
+        if (component != null) {
+            map.put("component", component);
+        }
+        if (bc != null) {
+            map.put("bc", bc);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoConstructorParams.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoConstructorParams.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoConstructorParams.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoConstructorParams.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,63 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component receiving both bundle context.
+ */
+@Component
+@Provides
+public class ComponentWithTwoConstructorParams implements CheckService {
+
+    private BundleContext instance;
+
+    private BundleContext component;
+
+    public ComponentWithTwoConstructorParams(@Context(Context.Source.INSTANCE) BundleContext instance,
+                                             @Context BundleContext component) {
+        this.instance = instance;
+        this.component = component;
+    }
+
+    @Override
+    public boolean check() {
+        return instance != null  && component != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (instance != null) {
+            map.put("instance", instance);
+        }
+        if (component != null) {
+            map.put("component", component);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoFields.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoFields.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoFields.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoFields.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,60 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component receiving both bundle context.
+ */
+@Component
+@Provides
+public class ComponentWithTwoFields implements CheckService {
+
+    @Context(Context.Source.INSTANCE)
+    private BundleContext instance;
+
+    @Context(Context.Source.COMPONENT)
+    private BundleContext component;
+
+
+    @Override
+    public boolean check() {
+        return instance != null  && component != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (instance != null) {
+            map.put("instance", instance);
+        }
+        if (component != null) {
+            map.put("component", component);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoSetters.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoSetters.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoSetters.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/ComponentWithTwoSetters.java Mon Mar 10 06:17:43 2014
@@ -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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component receiving both bundle context.
+ */
+@Component
+@Provides
+public class ComponentWithTwoSetters implements CheckService {
+
+    private BundleContext instance;
+    private BundleContext component;
+
+    @Context(Context.Source.INSTANCE)
+    public void setInstanceContext(BundleContext context) {
+        this.instance = context;
+    }
+
+    @Context(Context.Source.COMPONENT)
+    public void setComponentContext(BundleContext context) {
+        this.component = context;
+    }
+
+    @Override
+    public boolean check() {
+        return instance != null  && component != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (instance != null) {
+            map.put("instance", instance);
+        }
+        if (component != null) {
+            map.put("component", component);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInConstructor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInConstructor.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInConstructor.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInConstructor.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,57 @@
+/*
+ * 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using constructor injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class InstanceBundleContextInjectionInConstructor implements CheckService {
+
+
+    private BundleContext context;
+
+    public InstanceBundleContextInjectionInConstructor(@Context(Context.Source.INSTANCE) BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInField.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInField.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInField.java Mon Mar 10 06:17:43 2014
@@ -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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using field injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class InstanceBundleContextInjectionInField implements CheckService {
+
+    @Context(Context.Source.INSTANCE)
+    private BundleContext context;
+
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInMethod.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInMethod.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/annotations/InstanceBundleContextInjectionInMethod.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,57 @@
+/*
+* 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.annotations;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using method injection to retrieve the bundle context.
+ */
+@Component
+@Provides
+public class InstanceBundleContextInjectionInMethod implements CheckService {
+
+    private BundleContext context;
+
+    @Context(Context.Source.INSTANCE)
+    public void setContext(BundleContext context) {
+        this.context = context;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, BundleContext> map = new HashMap<String, BundleContext>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties1.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties1.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties1.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,64 @@
+/*
+* 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.mix;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using constructor injection to retrieve the bundle context and a property.
+ * In this component the property is first.
+ */
+@Component
+@Provides
+public class MixWithProperties1 implements CheckService {
+
+
+    private final String message;
+    private final BundleContext context;
+
+    public MixWithProperties1(@Property(name = "message") String message, @Context BundleContext context) {
+        this.context = context;
+        this.message = message;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        if (message != null) {
+            map.put("message", message);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties2.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties2.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties2.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/mix/MixWithProperties2.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,64 @@
+/*
+* 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.mix;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Context;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A component using constructor injection to retrieve the bundle context and a property.
+ * In this component the property is last.
+ */
+@Component
+@Provides
+public class MixWithProperties2 implements CheckService {
+
+
+    private final String message;
+    private final BundleContext context;
+
+    public MixWithProperties2(@Context BundleContext context, @Property(name = "message") String message) {
+        this.context = context;
+        this.message = message;
+    }
+
+    @Override
+    public boolean check() {
+        return context != null;
+    }
+
+    @Override
+    public Map map() {
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (context != null) {
+            map.put("context", context);
+        }
+        if (message != null) {
+            map.put("message", message);
+        }
+        return map;
+    }
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java Mon Mar 10 06:17:43 2014
@@ -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.runtime.core.services;
+
+import java.util.Map;
+
+public interface CheckService {
+
+	public boolean check();
+	
+	public Map map();
+
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/metadata.xml?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/main/resources/metadata.xml Mon Mar 10 06:17:43 2014
@@ -0,0 +1,65 @@
+<!--
+  ~ 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.
+  -->
+
+<ipojo>
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingField"
+            name="CTX-Field-Component" architecture="true">
+        <provides/>
+        <!-- component is default -->
+        <context field="context"/>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingField"
+            name="CTX-Field-Instance" architecture="true">
+        <provides/>
+        <context field="context" context="instance"/>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingMethod"
+            name="CTX-Method-Component" architecture="true">
+        <provides/>
+        <!-- component is default -->
+        <context method="setContext"/>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingMethod"
+            name="CTX-Method-Instance" architecture="true">
+        <provides/>
+        <!-- component is default -->
+        <context method="setContext" context="instance"/>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingConstructor"
+            name="CTX-Constructor-Component" architecture="true">
+        <provides/>
+        <context constructor-parameter="0" context="component"/>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.ComponentUsingConstructor"
+            name="CTX-Constructor-Instance" architecture="true">
+        <provides/>
+        <context constructor-parameter="0" context="instance"/>
+    </component>
+</ipojo>

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,30 @@
+/*
+ * 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 org.ow2.chameleon.testing.helpers.BaseTest;
+
+/**
+ * Bootstrap the test from this project
+ */
+public class Common extends BaseTest {
+
+    // No custom configuration required.
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromAnnotations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromAnnotations.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromAnnotations.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromAnnotations.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,119 @@
+/*
+* 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 org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Checks that contexts are correctly injected.
+ * For instance bundle context, we use the 'instance.bundle.context' hidden configuration
+ * property. We use the BundleContext from the iPOJO bundle context, as a mark for testing, it is obviously,
+ * not recommended.
+ *
+ * These test cases are using Annotation descriptions.
+ */
+public class TestContextInjectionFromAnnotations extends Common {
+
+    @Test
+    public void testFieldInjectionOfComponentBundleContext() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentBundleContextInjectionInField");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testFieldInjectionOfInstanceBundleContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.InstanceBundleContextInjectionInField", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testMethodInjectionOfComponentBundleContext() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentBundleContextInjectionInMethod");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testMethodInjectionOfInstanceBundleContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.InstanceBundleContextInjectionInMethod", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testConstructorInjectionOfComponentBundleContext() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentBundleContextInjectionInConstructor");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testConstructorInjectionOfInstanceBundleContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.InstanceBundleContextInjectionInConstructor", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromXML.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromXML.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromXML.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestContextInjectionFromXML.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,113 @@
+/*
+* 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 org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Checks that contexts are correctly injected.
+ * For instance bundle context, we use the 'instance.bundle.context' hidden configuration
+ * property. We use the BundleContext from the iPOJO bundle context, as a mark for testing, it is obviously,
+ * not recommended.
+ *
+ * These test cases are using XML descriptions.
+ */
+public class TestContextInjectionFromXML extends Common {
+
+    @Test
+    public void testFieldInjectionOfComponentBundleContextUsingXML() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Field-Component");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testFieldInjectionOfInstanceBundleContextUsingXML() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Field-Instance", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testMethodInjectionOfComponentBundleContextUsingXML() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Method-Component");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testMethodInjectionOfInstanceBundleContextUsingXML() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Method-Instance", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testConstructorInjectionOfComponentBundleContextUsingXML() {
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Constructor-Component");
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+    @Test
+    public void testConstructorInjectionOfInstanceBundleContextUsingXML() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Constructor-Instance", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingComponentAndInstanceContext.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingComponentAndInstanceContext.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingComponentAndInstanceContext.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingComponentAndInstanceContext.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,128 @@
+/*
+* 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 org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Checks that component can retrieve both contexts.
+ * For instance bundle context, we use the 'instance.bundle.context' hidden configuration
+ * property. We use the BundleContext from the iPOJO bundle context, as a mark for testing, it is obviously,
+ * not recommended.
+ *
+ * These test cases are using Annotation descriptions.
+ */
+public class TestInjectingComponentAndInstanceContext extends Common {
+
+    @Test
+    public void testSetterInjectionOfBothContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentWithTwoSetters", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("component");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        context = (BundleContext) check.map().get("instance");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testFieldInjectionOfBothContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentWithTwoFields", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("component");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        context = (BundleContext) check.map().get("instance");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    @Test
+    public void testConstructorInjectionOfBothContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentWithTwoConstructorParams", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("component");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        context = (BundleContext) check.map().get("instance");
+        assertNotNull(context);
+        assertEquals(bc, context);
+    }
+
+    /**
+     * Mix bundle context injection with the default bc injection (legacy).
+     */
+    @Test
+    public void testConstructorInjectionOfThreeContext() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.annotations.ComponentWithThreeConstructorParams", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("component");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        context = (BundleContext) check.map().get("instance");
+        assertNotNull(context);
+        assertEquals(bc, context);
+
+        context = (BundleContext) check.map().get("bc");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingContextAndProperties.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingContextAndProperties.java?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingContextAndProperties.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestInjectingContextAndProperties.java Mon Mar 10 06:17:43 2014
@@ -0,0 +1,76 @@
+/*
+* 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 org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Checks that component can mix property and context in constructor parameters.
+ *
+ * These test cases are using Annotation descriptions.
+ */
+public class TestInjectingContextAndProperties extends Common {
+
+    @Test
+    public void testWhenPropertyIsFirst() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        configuration.put("message", "hello");
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.mix.MixWithProperties1", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        assertEquals("hello", check.map().get("message"));
+    }
+
+    @Test
+    public void testWhenPropertyIsLast() {
+        BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
+        Properties configuration = new Properties();
+        configuration.put("instance.bundle.context", bc);
+        configuration.put("message", "hello");
+        ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" +
+                ".components.mix.MixWithProperties2", configuration);
+
+        CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
+        assertNotNull(check);
+
+        BundleContext context = (BundleContext) check.map().get("context");
+        assertNotNull(context);
+        assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
+
+        assertEquals("hello", check.map().get("message"));
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/exam.properties
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/exam.properties?rev=1575838&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/exam.properties (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-context-injection-test/src/test/resources/exam.properties Mon Mar 10 06:17:43 2014
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+



Mime
View raw message