You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2011/11/07 11:48:12 UTC

svn commit: r1198697 - in /aries/trunk/application: ./ application-itests/ application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/ application-itests/src/test/java/org/apache/aries/isolated/config/ application-itests/src/test...

Author: timothyjward
Date: Mon Nov  7 10:48:11 2011
New Revision: 1198697

URL: http://svn.apache.org/viewvc?rev=1198697&view=rev
Log:
ARIES-773: changes to application runtime for supporting isolated blueprint config admin

Added:
    aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/
    aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java
    aries/trunk/application/application-itests/src/test/resources/isolated/config/
    aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF
    aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF
    aries/trunk/application/application-itests/src/test/resources/isolated/config/blueprint.xml
    aries/trunk/application/application-resolve-transform-cm/
    aries/trunk/application/application-resolve-transform-cm-itests/
    aries/trunk/application/application-resolve-transform-cm-itests/LICENSE
    aries/trunk/application/application-resolve-transform-cm-itests/NOTICE
    aries/trunk/application/application-resolve-transform-cm-itests/pom.xml
    aries/trunk/application/application-resolve-transform-cm-itests/src/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/
    aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java
    aries/trunk/application/application-resolve-transform-cm/LICENSE
    aries/trunk/application/application-resolve-transform-cm/NOTICE
    aries/trunk/application/application-resolve-transform-cm/pom.xml
    aries/trunk/application/application-resolve-transform-cm/src/
    aries/trunk/application/application-resolve-transform-cm/src/main/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/
    aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java
    aries/trunk/application/application-resolve-transform-cm/src/main/resources/
    aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/
    aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/
    aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Modified:
    aries/trunk/application/application-itests/pom.xml
    aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java
    aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java
    aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
    aries/trunk/application/pom.xml

Modified: aries/trunk/application/application-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/pom.xml?rev=1198697&r1=1198696&r2=1198697&view=diff
==============================================================================
--- aries/trunk/application/application-itests/pom.xml (original)
+++ aries/trunk/application/application-itests/pom.xml Mon Nov  7 10:48:11 2011
@@ -197,6 +197,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+		    <groupId>org.apache.aries.application</groupId>
+		    <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+		    <version>0.3.1-SNAPSHOT</version>
+       	</dependency>
+        <dependency>
              <groupId>org.apache.aries.application</groupId>
              <artifactId>org.apache.aries.application.default.local.platform</artifactId>
             <version>0.3.1-SNAPSHOT</version>

Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java?rev=1198697&r1=1198696&r2=1198697&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java (original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java Mon Nov  7 10:48:11 2011
@@ -20,8 +20,11 @@ package org.apache.aries.application.run
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Hashtable;
@@ -146,6 +149,42 @@ public class IsolationTestUtils {
     repoAdmin.addRepository(new File("repo.xml").toURI().toString());
   }
   
+  public static HelloWorld findHelloWorldService(BundleContext ctx) throws Exception
+  {
+	  if (ctx != null)
+	  {
+	      // Dive into the context and pull out the composite bundle for the app
+	      Filter osgiFilter = FrameworkUtil.createFilter("(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")");
+	      ServiceTracker tracker = new ServiceTracker(ctx, 
+	          osgiFilter,
+	          null);
+	      
+	      tracker.open();
+	      final Object hw = tracker.waitForService(DEFAULT_TIMEOUT);
+	      tracker.close();
+	
+	      if (hw != null) {
+	        // proxy because the class space between the sample app and the test bundle is not consistent
+	        return new HelloWorld() {
+	          public String getMessage() {
+	            try {
+	              Method m = hw.getClass().getMethod("getMessage");
+	              return (String) m.invoke(hw);
+	            } catch (Exception e) {
+	              throw new RuntimeException(e);
+	            }
+	          }
+	        };
+	      } else {
+	        return null;
+	      }	 
+	  }
+	  else
+	  {
+		  return null;
+	  }
+  }
+  
   /**
    * Find the {@link HelloWorld} service for the isolated app
    * @return the service object, suitably proxied so that it can be actually used, or null if the service is not present
@@ -156,34 +195,9 @@ public class IsolationTestUtils {
     BundleContext appContext = IsolationTestUtils.findIsolatedAppBundleContext(runtimeCtx, appName);
     
     if (appContext != null) {  
-      // Dive into the context and pull out the composite bundle for the app
-      Filter osgiFilter = FrameworkUtil.createFilter("(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")");
-      ServiceTracker tracker = new ServiceTracker(appContext, 
-          osgiFilter,
-          null);
-      
-      tracker.open();
-      final Object hw = tracker.waitForService(DEFAULT_TIMEOUT);
-      tracker.close();
-
-      if (hw != null) {
-        // proxy because the class space between the sample app and the test bundle is not consistent
-        return new HelloWorld() {
-          public String getMessage() {
-            try {
-              Method m = hw.getClass().getMethod("getMessage");
-              return (String) m.invoke(hw);
-            } catch (Exception e) {
-              throw new RuntimeException(e);
-            }
-          }
-        };
-      } else {
-        return null;
-      }
-
+    	return findHelloWorldService(appContext);
     } else {
       throw new IllegalStateException("Expected to find isolated app ctx, but didn't");
     }
   }
-}
+}
\ No newline at end of file

Added: aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java (added)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java Mon Nov  7 10:48:11 2011
@@ -0,0 +1,100 @@
+/*
+ * 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.aries.isolated.config;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.apache.aries.isolated.sample.HelloWorld;
+import org.apache.aries.isolated.sample.HelloWorldImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+public class HelloWorldManagedServiceImpl implements BundleActivator, ManagedService
+{
+	private BundleContext context;
+	private HelloWorldImpl hw;
+	private ServiceRegistration msRegistration;
+	private ServiceRegistration hwRegistration;
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception
+	{
+		Properties props = new Properties();
+		props.put(Constants.SERVICE_PID, "helloworld-mn");
+		this.context = context;
+		this.msRegistration = context.registerService(ManagedService.class.getName(), this, props);
+		this.hwRegistration = null;
+		
+		//manually call our update to make sure the HW service is exposed out
+		updated(null);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public synchronized void stop(BundleContext context) throws Exception 
+	{
+		this.msRegistration.unregister();
+		
+		if (this.hwRegistration != null)
+		{
+			this.hwRegistration.unregister();
+		}
+		
+		this.context = null;
+		this.hwRegistration = null;
+		this.msRegistration = null;
+	}
+
+	/**
+	 * This method will re-register the helloworld service to easily track when updates
+	 * occur to configuration.
+	 */
+	public synchronized void updated(Dictionary properties) throws ConfigurationException 
+	{
+		if (context != null) //means we have been stopped
+		{
+			if (hwRegistration != null)
+			{
+				hwRegistration.unregister();
+			}
+			
+			if (hw == null)
+			{
+				hw = new HelloWorldImpl();
+			}
+			
+			if (properties != null)
+			{
+				hw.setMessage((String)properties.get("message"));
+			}
+			
+			hwRegistration = context.registerService(HelloWorld.class.getName(), hw, null);
+		}
+	}
+}

Added: aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF (added)
+++ aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF Mon Nov  7 10:48:11 2011
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: HelloWorld BluePrint
+Application-SymbolicName: org.apache.aries.helloworldbpapp
+Application-Version: 1.0
+Application-Content: org.apache.aries.isolated.helloworldbp;version=1.0.0,
+ org.apache.felix.configadmin
+

Added: aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF (added)
+++ aries/trunk/application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF Mon Nov  7 10:48:11 2011
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: HelloWorld Manual
+Application-SymbolicName: org.apache.aries.helloworldmnapp
+Application-Version: 1.0
+Application-Content: org.apache.aries.isolated.helloworldmn;version=1.0.0,
+ org.apache.felix.configadmin
+

Added: aries/trunk/application/application-itests/src/test/resources/isolated/config/blueprint.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/resources/isolated/config/blueprint.xml?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-itests/src/test/resources/isolated/config/blueprint.xml (added)
+++ aries/trunk/application/application-itests/src/test/resources/isolated/config/blueprint.xml Mon Nov  7 10:48:11 2011
@@ -0,0 +1,30 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+  
+  	<cm:property-placeholder persistent-id="helloworld-bp" update-strategy="reload"/>
+  	
+	<bean id="hello" class="org.apache.aries.isolated.sample.HelloWorldImpl">
+		<property name="message" value="${message}" />
+	</bean>
+	<service interface="org.apache.aries.isolated.sample.HelloWorld" ref="hello" />
+  
+</blueprint>

Modified: aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java?rev=1198697&r1=1198696&r2=1198697&view=diff
==============================================================================
--- aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java (original)
+++ aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java Mon Nov  7 10:48:11 2011
@@ -323,6 +323,9 @@ abstract public class AbstractParserProx
 	      blacklisted |= iface.equals("javax.transaction.UserTransaction");
 	      blacklisted |= iface.equals("javax.transaction.TransactionSynchronizationRegistry");
 	      
+	      // ConfigurationAdmin - detect interface
+	      blacklisted |= iface.equals("org.osgi.service.cm.ConfigurationAdmin");
+	               
 	      // Don't provision against JNDI references
 	      if (blueprintFilter != null && blueprintFilter.trim().length() != 0) { 
 	        Map<String, String> filter = ManifestHeaderProcessor.parseFilter(blueprintFilter);

Added: aries/trunk/application/application-resolve-transform-cm-itests/LICENSE
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests/LICENSE?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm-itests/LICENSE (added)
+++ aries/trunk/application/application-resolve-transform-cm-itests/LICENSE Mon Nov  7 10:48:11 2011
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: aries/trunk/application/application-resolve-transform-cm-itests/NOTICE
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests/NOTICE?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm-itests/NOTICE (added)
+++ aries/trunk/application/application-resolve-transform-cm-itests/NOTICE Mon Nov  7 10:48:11 2011
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: aries/trunk/application/application-resolve-transform-cm-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests/pom.xml?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm-itests/pom.xml (added)
+++ aries/trunk/application/application-resolve-transform-cm-itests/pom.xml Mon Nov  7 10:48:11 2011
@@ -0,0 +1,177 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>java6-parent</artifactId>
+        <version>0.4</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.aries.application</groupId>
+    <artifactId>org.apache.aries.application.resolve.transform.cm.itests</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.3.1-SNAPSHOT</version>
+    <name>Apache Aries Application Resolve CM Transform iTests</name>
+    <description>Apache Aries Application Resolve CM Transformer iTests</description>
+     <scm>
+         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm-itests</connection>
+         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm-itests</developerConnection>
+         <url>http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests</url>
+     </scm>
+    <properties>
+        <aries.osgi.export.pkg>
+        </aries.osgi.export.pkg>
+        <aries.osgi.import.pkg>
+            org.apache.aries.*;version="$&lt;range;[==,=+)&gt;",
+            *
+        </aries.osgi.import.pkg>
+        <aries.osgi.private.pkg>
+            org.apache.aries.application.resolve.transform.cm.itests;
+        </aries.osgi.private.pkg>
+    </properties>
+    <dependencies>
+        <dependency>
+		    <groupId>org.apache.aries.application</groupId>
+		    <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+		    <version>0.3.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.api</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+			<groupId>org.apache.aries</groupId>
+			<artifactId>org.apache.aries.util</artifactId>
+            <version>0.4-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.blueprint</groupId>
+			<artifactId>org.apache.aries.blueprint</artifactId>
+            <version>0.3.2-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.proxy</groupId>
+			<artifactId>org.apache.aries.proxy</artifactId>
+            <version>0.4-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>asm</groupId>
+			<artifactId>asm-all</artifactId>
+            <version>3.2</version>
+			<scope>test</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>test</scope>
+        </dependency>       
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.eclipse</groupId>
+        	<artifactId>osgi</artifactId>
+        	<version>3.5.0.v20090520</version>
+        	<type>jar</type>
+        	<scope>test</scope>
+        </dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.logging</groupId>
+			<artifactId>pax-logging-api</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.logging</groupId>
+			<artifactId>pax-logging-service</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam-junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam-container-default</artifactId>
+			<scope>test</scope>
+		</dependency>
+        <dependency>
+	        <groupId>org.apache.aries.testsupport</groupId>
+	        <artifactId>org.apache.aries.testsupport.unit</artifactId>
+	        <version>0.4-SNAPSHOT</version>
+	        <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-depends-file</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                        <configuration>
+                            <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>pertest</forkMode>
+                    <excludes>
+                        <exclude>**/*$*</exclude>
+                        <exclude>**/Abstract*.java</exclude>
+                    </excludes>
+                    <includes>
+                        <include>**/Test*.java</include>
+                        <include>**/*Test.java</include>
+                    </includes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java (added)
+++ aries/trunk/application/application-resolve-transform-cm-itests/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java Mon Nov  7 10:48:11 2011
@@ -0,0 +1,312 @@
+/*
+ * 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.aries.application.resolve.transform.cm.itest;
+
+import static org.apache.aries.itest.ExtraOptions.mavenBundle;
+import static org.apache.aries.itest.ExtraOptions.paxLogging;
+import static org.apache.aries.itest.ExtraOptions.testOptions;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.spi.resolve.PostResolveTransformer;
+import org.apache.aries.application.modelling.DeployedBundles;
+import org.apache.aries.application.modelling.ExportedBundle;
+import org.apache.aries.application.modelling.ExportedPackage;
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ImportedBundle;
+import org.apache.aries.application.modelling.ImportedPackage;
+import org.apache.aries.application.modelling.ImportedService;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.Provider;
+import org.apache.aries.application.modelling.ResourceType;
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.itest.RichBundleContext;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class ConfigurationPostResolverTest extends AbstractIntegrationTest
+{
+    /**
+     * This test validates that the transformer is correctly detecting the config admin package. Checks
+     * are performed to validate that an existing import package is still honored etc.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void validatePostResolveTransform() throws Exception {
+        
+        RichBundleContext ctx = new RichBundleContext(bundleContext);
+        PostResolveTransformer transformer = ctx.getService(PostResolveTransformer.class);
+        Assert.assertNotNull("Unable to locate transformer", transformer);
+        
+        /**
+         * Try processing deployed content that doesn't have any import for the
+         * org.osgi.service.cm package, the resultant imports should be unaffected.
+         */
+        ApplicationMetadata mockApplicationMetadata = Skeleton.newMock(ApplicationMetadata.class);
+        MockDeployedBundles originalDeployedBundles = new MockDeployedBundles();
+        originalDeployedBundles.setDeployedContent(getNonConfigModelledResources());
+        DeployedBundles transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+        Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+        Assert.assertEquals(originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+        
+        /**
+         * Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
+         * modelled resources with an empty import package set in the mock deployed bundles instance.
+         */
+        originalDeployedBundles = new MockDeployedBundles();
+        originalDeployedBundles.setDeployedContent(getConfigModelledResources());
+        transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+        Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+        Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+        Assert.assertEquals("Missing config package", "org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
+        
+        /**
+         * Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
+         * modelled resources with a populated import package set in the mock deployed bundles instance.
+         */
+        originalDeployedBundles = new MockDeployedBundles();
+        originalDeployedBundles.setDeployedContent(getConfigModelledResources());
+        originalDeployedBundles.setImportPackage("org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\"");
+        transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+        Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+        Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+        Assert.assertEquals("Missing config package", "org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\",org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
+    }
+    
+    private static Collection<ModelledResource> getNonConfigModelledResources() {
+        Collection<ModelledResource> modelledResources = new ArrayList<ModelledResource>();
+        MockModelledResource ms1 = new MockModelledResource();
+        ms1.setImportedPackages(Arrays.asList(new MockImportedPackage("org.foo.bar", "1.0.0"), new MockImportedPackage("org.bar.foo", "1.0.0")));
+        
+        return modelledResources;
+    }
+    
+    private static Collection<ModelledResource> getConfigModelledResources() {
+        Collection<ModelledResource> resources = getNonConfigModelledResources();
+        MockModelledResource mmr1 = new MockModelledResource();
+        mmr1.setImportedPackages(Arrays.asList(new MockImportedPackage("org.osgi.service.cm", "1.2.0")));
+        resources.add(mmr1);
+        MockModelledResource mmr2 = new MockModelledResource();
+        mmr2.setImportedPackages(Arrays.asList(new MockImportedPackage("org.osgi.service.cm", "1.2.0")));
+        resources.add(mmr2);        
+        return resources;
+    }
+    /**
+     * Create the configuration for the PAX container
+     * 
+     * @return the various required options
+     * @throws Exception
+     */
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() throws Exception {
+        return testOptions(
+                repository("http://repository.ops4j.org/maven2"),
+                paxLogging("DEBUG"),
+                mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+                mavenBundle("asm", "asm-all"),
+                mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+                mavenBundle("org.apache.aries", "org.apache.aries.util"),
+                mavenBundle("org.osgi", "org.osgi.compendium"),
+                mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+                mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm"),
+                //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"), 
+                equinox().version("3.5.0"));
+    }
+    
+    private static class MockDeployedBundles implements DeployedBundles 
+    {
+        private Collection<ModelledResource> deployedContent;
+        private String importPackage;
+        
+        public void addBundle(ModelledResource arg0) {
+        }
+
+        public String getContent() {
+            return null;
+        }
+
+        public Collection<ModelledResource> getDeployedContent() {
+            return deployedContent;
+        }
+        
+        public void setDeployedContent(Collection<ModelledResource> deployedContent) {
+            this.deployedContent = deployedContent;
+        }
+
+        public String getDeployedImportService() {
+            return null;
+        }
+
+        public Collection<ModelledResource> getDeployedProvisionBundle() {
+            return null;
+        }
+
+        public Map<String, String> getExtraHeaders() {
+            return null;
+        }
+
+        public void setImportPackage(String importPackage) {
+            this.importPackage = importPackage;
+        }
+        
+        /**
+         * Used to reflect external packages required
+         */
+        public String getImportPackage() throws ResolverException {
+            return importPackage;
+        }
+
+        public String getProvisionBundle() {
+            return null;
+        }
+
+        public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException {
+            return null;
+        }
+
+        public String getUseBundle() {
+            return null;
+        }
+        
+    }
+    
+    private static class MockModelledResource implements ModelledResource {
+
+        private Collection<? extends ImportedPackage> importedPackages;
+        
+        public String toDeploymentString() {
+            return null;
+        }
+
+        public ExportedBundle getExportedBundle() {
+            return null;
+        }
+        
+        public Collection<? extends ExportedPackage> getExportedPackages() {
+            return null;
+        }
+
+        public Collection<? extends ExportedService> getExportedServices() {
+            return null;
+        }
+
+        public ImportedBundle getFragmentHost() {
+            return null;
+        }
+
+        public Collection<? extends ImportedPackage> getImportedPackages() {
+            return importedPackages;
+        }
+        
+        public void setImportedPackages(Collection<? extends ImportedPackage> importedPackages) {
+            this.importedPackages = importedPackages;
+        }
+
+        public Collection<? extends ImportedService> getImportedServices() {
+            return null;
+        }
+
+        public String getLocation() {
+            return null;
+        }
+
+        public Collection<? extends ImportedBundle> getRequiredBundles() {
+            return null;
+        }
+
+        public String getSymbolicName() {
+            return null;
+        }
+
+        public ResourceType getType() {
+            return null;
+        }
+
+        public String getVersion() {
+            return null;
+        }
+
+        public boolean isFragment() {
+            return false;
+        }
+        
+    }
+    
+    private static class MockImportedPackage implements ImportedPackage {
+
+        private String packageName;
+        private String versionRange;
+        
+        public MockImportedPackage(String packageName, String versionRange) {
+            this.packageName = packageName;
+            this.versionRange = versionRange;
+        }
+        
+        public String getAttributeFilter() {
+            return null;
+        }
+
+        public ResourceType getType() {
+            return null;
+        }
+
+        public boolean isMultiple() {
+            return false;
+        }
+
+        public boolean isOptional() {
+            return false;
+        }
+
+        public boolean isSatisfied(Provider provider) {
+            return false;
+        }
+
+        public String toDeploymentString() {
+            return packageName + ";version=\"" + versionRange + "\"";
+        }
+
+        public Map<String, String> getAttributes() {
+            return null;
+        }
+
+        public String getPackageName() {
+            return packageName;
+        }
+
+        public String getVersionRange() {
+            return versionRange;
+        }
+        
+    }
+}

Added: aries/trunk/application/application-resolve-transform-cm/LICENSE
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm/LICENSE?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm/LICENSE (added)
+++ aries/trunk/application/application-resolve-transform-cm/LICENSE Mon Nov  7 10:48:11 2011
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: aries/trunk/application/application-resolve-transform-cm/NOTICE
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm/NOTICE?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm/NOTICE (added)
+++ aries/trunk/application/application-resolve-transform-cm/NOTICE Mon Nov  7 10:48:11 2011
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: aries/trunk/application/application-resolve-transform-cm/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm/pom.xml?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm/pom.xml (added)
+++ aries/trunk/application/application-resolve-transform-cm/pom.xml Mon Nov  7 10:48:11 2011
@@ -0,0 +1,64 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>java6-parent</artifactId>
+        <version>0.4</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.aries.application</groupId>
+    <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.3.1-SNAPSHOT</version>
+    <name>Apache Aries Application Resolve CM Transform</name>
+    <description>Apache Aries Application Resolve CM Transformers</description>
+     <scm>
+         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm</connection>
+         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm</developerConnection>
+         <url>http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm</url>
+     </scm>
+    <properties>
+        <aries.osgi.export.pkg>
+        </aries.osgi.export.pkg>
+        <aries.osgi.import.pkg>
+    	    org.apache.aries.*;version="$&lt;range;[==,=+)&gt;",
+            *
+        </aries.osgi.import.pkg>
+        <aries.osgi.private.pkg>
+            org.apache.aries.application.resolve.transform.cm
+        </aries.osgi.private.pkg>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.api</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>

Added: aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java (added)
+++ aries/trunk/application/application-resolve-transform-cm/src/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java Mon Nov  7 10:48:11 2011
@@ -0,0 +1,131 @@
+/*
+ * 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.aries.application.resolve.transform.cm;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.spi.resolve.PostResolveTransformer;
+import org.apache.aries.application.modelling.DeployedBundles;
+import org.apache.aries.application.modelling.ImportedPackage;
+import org.apache.aries.application.modelling.ModelledResource;
+
+public class ConfigurationPostResolveTransformerImpl implements PostResolveTransformer 
+{
+    /*
+     * (non-Javadoc)
+     * @see org.apache.aries.application.management.spi.resolve.PostResolveTransformer#postResolveProcess(org.apache.aries.application.ApplicationMetadata, org.apache.aries.application.modelling.DeployedBundles)
+     */
+    public DeployedBundles postResolveProcess(ApplicationMetadata appMetaData, DeployedBundles deployedBundles) throws ResolverException {
+        return new ConfigAwareDeployedBundles(deployedBundles);
+    }
+    
+    /**
+     * This class serves as a wrapper for a DeployedBundles instance, if the delegate instance
+     * does not import the configuration management package and the deployed content contains the
+     * configuration admin bundle, then the necessary import will be added. This is required so that the
+     * blueprint-cm bundle will not encounter class casting issues from a ConfigurationAdmin service
+     * that has been loaded in an isolated application scope, rather all *.cm related classes are
+     * referenced by the same class loader.
+     * 
+     *
+     * @version $Rev$ $Date$
+     */
+    private static class ConfigAwareDeployedBundles implements DeployedBundles
+    {
+        private static final String CONFIG_PACKAGE = "org.osgi.service.cm";
+        
+        private DeployedBundles deployedBundles;
+        
+        public ConfigAwareDeployedBundles(DeployedBundles deployedBundles) {
+            this.deployedBundles = deployedBundles;
+        }
+        
+        public void addBundle(ModelledResource resource) {
+            deployedBundles.addBundle(resource);
+        }
+
+        public String getContent() {
+            return deployedBundles.getContent();
+        }
+
+        public Collection<ModelledResource> getDeployedContent() {
+            return deployedBundles.getDeployedContent();
+        }
+
+        public String getDeployedImportService() {
+            return deployedBundles.getDeployedImportService();
+        }
+
+        public Collection<ModelledResource> getDeployedProvisionBundle()  {
+            return deployedBundles.getDeployedProvisionBundle();
+        }
+
+        public Map<String, String> getExtraHeaders() {
+            return deployedBundles.getExtraHeaders();
+        }
+
+        public String getImportPackage() throws ResolverException {
+            String currentImportPackage = deployedBundles.getImportPackage();
+            StringBuffer rawImportPackage = new StringBuffer((currentImportPackage != null ? currentImportPackage : ""));
+            
+            if (! rawImportPackage.toString().contains(CONFIG_PACKAGE)) {
+                Collection<ModelledResource> deployedContent = deployedBundles.getDeployedContent();
+                
+                if (deployedContent != null) {
+                    modelledResourceCheck:
+                        for (ModelledResource mr : deployedContent) {
+                            Collection<? extends ImportedPackage> importedPackages = mr.getImportedPackages();
+                            
+                            if (importedPackages != null) {
+                                for (ImportedPackage importedPackage : importedPackages) {
+                                    if (CONFIG_PACKAGE.equals(importedPackage.getPackageName())) {
+                                        if (rawImportPackage.length() > 0) {
+                                            rawImportPackage.append(",");
+                                        }
+                                        
+                                        rawImportPackage.append(importedPackage.toDeploymentString());
+                                        break modelledResourceCheck;
+                                    }
+                                }
+                            }                    
+                        }
+                }
+            }
+            
+            return (rawImportPackage.length() > 0 ? rawImportPackage.toString() : currentImportPackage);
+        }
+
+        public String getProvisionBundle() {
+            return deployedBundles.getProvisionBundle();
+        }
+
+        public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException {
+            return deployedBundles.getRequiredUseBundle();
+        }
+
+        public String getUseBundle() {
+            return deployedBundles.getUseBundle();
+        }
+    }
+    
+}
\ No newline at end of file

Added: aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1198697&view=auto
==============================================================================
--- aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ aries/trunk/application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Nov  7 10:48:11 2011
@@ -0,0 +1,26 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="configPostTransformer" class="org.apache.aries.application.resolve.transform.cm.ConfigurationPostResolveTransformerImpl" scope="singleton"/>
+    <service id="configPostTransformer-service" ref="configPostTransformer" interface="org.apache.aries.application.management.spi.resolve.PostResolveTransformer"/>
+
+</blueprint>
+

Modified: aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java?rev=1198697&r1=1198696&r2=1198697&view=diff
==============================================================================
--- aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java (original)
+++ aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java Mon Nov  7 10:48:11 2011
@@ -19,23 +19,15 @@
 
 package org.apache.aries.application.runtime.framework.management;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
-import java.util.jar.Attributes;
 
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.aries.application.Content;
-import org.apache.aries.application.management.BundleInfo;
 import org.apache.aries.application.management.spi.framework.BundleFramework;
 import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
 import org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory;
@@ -57,7 +49,7 @@ public class SharedBundleFramework
    * org.osgi.service.blueprint package is deliberately unversioned as it is
    * not part of the osgi compendium.
    */
-  private static final String RUNTIME_PACKAGES = "org.osgi.service.blueprint,org.osgi.service.blueprint.container;version=\"[1.0.0,1.0.1]\",org.osgi.service.blueprint.reflect;version=\"[1.0.0,1.0.1]\",org.apache.aries.transaction.exception;version=\"[0.1,1.0.0)\"";
+  private static final String RUNTIME_PACKAGES = "org.osgi.service.blueprint,org.osgi.service.blueprint.container;version=\"[1.0.0,1.0.1]\",org.osgi.service.blueprint.reflect;version=\"[1.0.0,1.0.1]\",org.apache.aries.transaction.exception;version=\"[0.1,1.0.0)\",org.osgi.service.cm;resolution:=optional";
 
   /**
    * create using any bundle context in EBA App framework as we want to create
@@ -145,7 +137,7 @@ public class SharedBundleFramework
       Properties compositeManifest = basicConfig.getFrameworkManifest();
       
       compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, BundleFramework.SHARED_BUNDLE_FRAMEWORK);
-
+      
       // Add blueprint so that it is available to applications, unless configuration has already been provided.
       String existingImports = (String) compositeManifest.get(Constants.IMPORT_PACKAGE);
       if (existingImports == null){

Modified: aries/trunk/application/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/pom.xml?rev=1198697&r1=1198696&r2=1198697&view=diff
==============================================================================
--- aries/trunk/application/pom.xml (original)
+++ aries/trunk/application/pom.xml Mon Nov  7 10:48:11 2011
@@ -49,6 +49,8 @@
       <module>application-modeller-common-test</module>
       <module>application-noop-resolver</module>
       <module>application-obr-resolver</module>
+      <module>application-resolve-transform-cm</module>
+      <module>application-resolve-transform-cm-itests</module>
       <module>application-runtime</module>
 	    <module>application-runtime-isolated</module>
 	    <module>application-runtime-framework</module>