aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1074150 - in /aries/trunk/application: application-api/src/main/java/org/apache/aries/application/management/spi/resolve/ application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/ application-...
Date Thu, 24 Feb 2011 13:43:38 GMT
Author: not
Date: Thu Feb 24 13:43:37 2011
New Revision: 1074150

URL: http://svn.apache.org/viewvc?rev=1074150&view=rev
Log:
ARIES-586 Fix the isolation resolution process so you can deploy the hellow world blueprint
sample as an EBA.

Added:
    aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java
  (with props)
    aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java
  (with props)
Modified:
    aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
    aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
    aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
    aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
    aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
    aries/trunk/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml
    aries/trunk/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java
    aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java
    aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java

Added: aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java?rev=1074150&view=auto
==============================================================================
--- aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java
(added)
+++ aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java
Thu Feb 24 13:43:37 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR 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.management.spi.resolve;
+
+import java.util.Collection;
+
+import org.apache.aries.application.modelling.ModelledResource;
+
+/**
+ * This interface allows a pre resolve hook to add customizats
+ * into the OBR resolve operation.
+ */
+public interface PreResolveHook 
+{
+  /**
+   * Depending on the environment it may be necessary to add
+   * resources to the resolve operation which you do not wish
+   * to provision. These may be resources that already exist 
+   * and are available, or are sourced in a different way. Any
+   * resources returned by this method are resolved against, but
+   * not placed in the deployment.mf. This may result in problems
+   * if a fake resource is provided, but the capabilities are not
+   * provided at runtime.
+   * 
+   * @param resources A mutable collection of ModelledResources that can have
+   *                  more elements added or removed.
+   */
+  public void collectFakeResources(Collection<ModelledResource> resources);
+}
\ No newline at end of file

Propchange: aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/PreResolveHook.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
(original)
+++ aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
Thu Feb 24 13:43:37 2011
@@ -51,6 +51,7 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
 import org.apache.aries.application.management.spi.resolve.DeploymentManifestManager;
 import org.apache.aries.application.management.spi.resolve.PostResolveTransformer;
+import org.apache.aries.application.management.spi.resolve.PreResolveHook;
 import org.apache.aries.application.management.spi.runtime.LocalPlatform;
 import org.apache.aries.application.modelling.DeployedBundles;
 import org.apache.aries.application.modelling.ExportedPackage;
@@ -84,6 +85,7 @@ public class DeploymentManifestManagerIm
   private LocalPlatform localPlatform;
   private ModellingManager modellingManager;
   private ModellingHelper modellingHelper;
+  private List<PreResolveHook> preResolveHooks;
 
   public void setModellingManager (ModellingManager m) {
     modellingManager = m; 
@@ -102,6 +104,11 @@ public class DeploymentManifestManagerIm
   {
     this.localPlatform = localPlatform;
   }
+  
+  public void setPreResolveHooks(List<PreResolveHook> hooks)
+  {
+    preResolveHooks = hooks;
+  }
 
   public ModelledResourceManager getModelledResourceManager()
   {
@@ -201,6 +208,13 @@ public class DeploymentManifestManagerIm
     }
     byValueBundles.add(fakeBundleResource);
     
+    Collection<ModelledResource> fakeResources = new ArrayList<ModelledResource>();
+    for (PreResolveHook hook : preResolveHooks) {
+      hook.collectFakeResources(fakeResources);
+    }
+    
+    byValueBundles.addAll(fakeResources);
+    
     String appSymbolicName = appMetadata.getApplicationSymbolicName();
     String appVersion = appMetadata.getApplicationVersion().toString();
     String uniqueName = appSymbolicName + "_" + appVersion;
@@ -208,7 +222,7 @@ public class DeploymentManifestManagerIm
     DeployedBundles deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName,
appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
     Collection<ModelledResource> bundlesToBeProvisioned = resolver.resolve(
         appSymbolicName, appVersion, byValueBundles, bundlesToResolve);
-    pruneFakeBundleFromResults (bundlesToBeProvisioned);
+    pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);
 
     if (bundlesToBeProvisioned.isEmpty()) {
       throw new ResolverException(MessageUtil.getMessage("EMPTY_DEPLOYMENT_CONTENT",uniqueName));
@@ -228,7 +242,7 @@ public class DeploymentManifestManagerIm
       bundlesToResolve.addAll(toContent(slimmedDownUseBundle));
       bundlesToBeProvisioned = resolver.resolve(appSymbolicName, appVersion,
           byValueBundles, bundlesToResolve);
-       pruneFakeBundleFromResults (bundlesToBeProvisioned);
+       pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);
       for (ModelledResource rbm : bundlesToBeProvisioned)
       {
         deployedBundles.addBundle(rbm);
@@ -472,15 +486,21 @@ public class DeploymentManifestManagerIm
     return fakeBundle;
   }
 
-  private void pruneFakeBundleFromResults (Collection<ModelledResource> results) {

+  private void pruneFakeBundlesFromResults (Collection<ModelledResource> results, Collection<ModelledResource>
fakeResources) { 
     _logger.debug(LOG_ENTRY, "pruneFakeBundleFromResults", new Object[]{results});
-    boolean fakeBundleRemoved = false;
+    
+    List<String> fakeBundles = new ArrayList<String>();
+    
+    fakeBundles.add(FAKE_BUNDLE_NAME);
+    for (ModelledResource resource : fakeResources) {
+      fakeBundles.add(resource.getSymbolicName());
+    }
+    
     Iterator<ModelledResource> it = results.iterator();
-    while (!fakeBundleRemoved && it.hasNext()) { 
+    while (it.hasNext()) { 
       ModelledResource mr = it.next();
-      if (mr.getExportedBundle().getSymbolicName().equals(FAKE_BUNDLE_NAME)) { 
+      if (fakeBundles.contains(mr.getSymbolicName())) { 
         it.remove();
-        fakeBundleRemoved = true;
       }
     }
     _logger.debug(LOG_EXIT, "pruneFakeBundleFromResults");

Modified: aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
(original)
+++ aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
Thu Feb 24 13:43:37 2011
@@ -27,6 +27,7 @@
     <property name="localPlatform" ref="localPlatform"/>
     <property name="modellingManager" ref="modellingManager"/>
     <property name="modellingHelper" ref="modellingHelper"/>
+    <property name="preResolveHooks" ref="preResolveHook"/>
   </bean>
   
   <bean id="default-postresolve-transformer" class="org.apache.aries.application.deployment.management.impl.DefaultPostResolveTransformer"/>
@@ -38,7 +39,7 @@
   <reference id="resolver" interface="org.apache.aries.application.management.spi.resolve.AriesApplicationResolver"/>
   <reference id="postResolveTransformer" interface="org.apache.aries.application.management.spi.resolve.PostResolveTransformer"
                availability="optional" ext:default="default-postresolve-transformer"/>
-  
+  <reference-list id="preResolveHook" availability="optional" interface="org.apache.aries.application.management.spi.resolve.PreResolveHook"/>
   <service id ="deploymentManifestManager-Service" ref="deploymentManifestManager" interface="org.apache.aries.application.management.spi.resolve.DeploymentManifestManager"/>
     
 </blueprint>
\ No newline at end of file

Modified: aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
(original)
+++ aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
Thu Feb 24 13:43:37 2011
@@ -45,6 +45,7 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.ResolveConstraint;
 import org.apache.aries.application.management.ResolverException;
 import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
+import org.apache.aries.application.management.spi.resolve.PreResolveHook;
 import org.apache.aries.application.management.spi.runtime.LocalPlatform;
 import org.apache.aries.application.modelling.DeployedBundles;
 import org.apache.aries.application.modelling.ExportedPackage;
@@ -192,6 +193,7 @@ public class DeploymentGeneratorTest
     deplMFMgr.setLocalPlatform(localPlatform);
     deplMFMgr.setModellingManager(modellingManager);
     deplMFMgr.setModellingHelper(modellingHelper);
+    deplMFMgr.setPreResolveHooks(new ArrayList<PreResolveHook>());
   }
   
   private static ExportedPackage CAPABILITY_A;

Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
(original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
Thu Feb 24 13:43:37 2011
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertNul
 import static org.ops4j.pax.exam.CoreOptions.equinox;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -36,7 +38,6 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.spi.repository.RepositoryGenerator;
 import org.apache.aries.application.modelling.ModellingManager;
 import org.apache.aries.application.runtime.itests.util.IsolationTestUtils;
-import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.filesystem.FileSystem;
 import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
 import org.apache.aries.isolated.sample.HelloWorld;
@@ -66,6 +67,7 @@ public class IsolatedRuntimeTest extends
       .jar("sample.jar")
         .manifest().symbolicName("org.apache.aries.isolated.sample")
           .attribute("Bundle-Version", "1.0.0")
+          .attribute("Import-Package", "org.osgi.service.blueprint")
           .end()
         .binary("org/apache/aries/isolated/sample/HelloWorld.class", 
             IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
@@ -152,6 +154,7 @@ public class IsolatedRuntimeTest extends
   
   @Test
   public void testUninstallReinstall() throws Exception {
+    
     AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
     AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
     AriesApplicationContext ctx = manager.install(app);
@@ -228,6 +231,7 @@ public class IsolatedRuntimeTest extends
   @org.ops4j.pax.exam.junit.Configuration
   public static Option[] configuration() {
     Option[] options = options(
+        repository( "http://repository.ops4j.org/maven2" ),
         // Log
         mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
         mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
@@ -241,7 +245,6 @@ public class IsolatedRuntimeTest extends
         systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
 
         // do not provision against the local runtime
-        systemProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP).value("true"),
         // Bundles
         mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
         mavenBundle("asm", "asm-all"),
@@ -268,7 +271,7 @@ public class IsolatedRuntimeTest extends
         /*
          * vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5011"),
         waitForFrameworkStartup(),*/
-
+//        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5011"),
         /*
          * and add these imports:
         import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;

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=1074150&r1=1074149&r2=1074150&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
Thu Feb 24 13:43:37 2011
@@ -19,14 +19,23 @@
 
 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;
@@ -111,7 +120,7 @@ public class SharedBundleFramework
 
     return sharedFramework;
   }
-
+  
   /**
    * Wrapper for the basic framework configuration
    * @author cwilkin

Added: aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java?rev=1074150&view=auto
==============================================================================
--- aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java
(added)
+++ aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java
Thu Feb 24 13:43:37 2011
@@ -0,0 +1,170 @@
+/*
+ * 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 WARRANTIESOR 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.runtime.framework.management;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.application.InvalidAttributeException;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkManager;
+import org.apache.aries.application.management.spi.resolve.PreResolveHook;
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ImportedService;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.ModellingManager;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
+import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+public class SharedFrameworkPreResolveHook implements PreResolveHook
+{
+  private BundleFrameworkManager fwMgr;
+  private ModellingManager mgr;
+  
+  private static final class BundleInfoImpl implements BundleInfo
+  {
+    private Bundle compositeBundle;
+    
+    public BundleInfoImpl(Bundle bundle) {
+      compositeBundle = bundle;
+    }
+    
+    public String getSymbolicName()
+    {
+      return compositeBundle.getSymbolicName();
+    }
+
+    public Map<String, String> getBundleDirectives()
+    {
+      return Collections.emptyMap();
+    }
+
+    public Map<String, String> getBundleAttributes()
+    {
+      return Collections.emptyMap();
+    }
+
+    public Version getVersion()
+    {
+      return compositeBundle.getVersion();
+    }
+
+    public String getLocation()
+    {
+      return compositeBundle.getLocation();
+    }
+
+    public Set<Content> getImportPackage()
+    {
+      return Collections.emptySet();
+    }
+
+    public Set<Content> getRequireBundle()
+    {
+      return Collections.emptySet();
+    }
+
+    public Set<Content> getExportPackage()
+    {
+      String imports = (String) compositeBundle.getHeaders().get(Constants.IMPORT_PACKAGE);
+      
+      Set<Content> exports = new HashSet<Content>();
+      
+      Map<String, NameValueMap<String, String>> parsedImports = ManifestHeaderProcessor.parseImportString(imports);
+      for (Map.Entry<String, NameValueMap<String, String>> anImport : parsedImports.entrySet())
{
+        exports.add(ManifestHeaderProcessor.parseContent(anImport.getKey(), anImport.getValue()));
+      }
+      
+      return exports;
+    }
+
+    public Set<Content> getImportService()
+    {
+      return Collections.emptySet();
+    }
+
+    public Set<Content> getExportService()
+    {
+      return Collections.emptySet();
+    }
+
+    public Map<String, String> getHeaders()
+    {
+      Map<String, String> result = new HashMap<String, String>();
+      @SuppressWarnings("unchecked")
+      Dictionary<String, String> headers = compositeBundle.getHeaders();
+      Enumeration<String> keys = headers.keys();
+      while (keys.hasMoreElements()) {
+        String key = keys.nextElement();
+        String value = headers.get(key);
+//        if (Constants.IMPORT_PACKAGE.equals(key)) {
+//          result.put(Constants.EXPORT_PACKAGE, value);
+//        } else if (!!!Constants.EXPORT_PACKAGE.equals(key)) {
+//          result.put(key, value);
+//        }
+        result.put(key, value);
+      }
+      
+      return result;
+    }
+
+    public Attributes getRawAttributes()
+    {
+      return ManifestProcessor.mapToManifest(getHeaders()).getMainAttributes();
+    }
+    
+  }
+  
+  public void collectFakeResources(Collection<ModelledResource> resources)
+  {
+    Bundle b = fwMgr.getSharedBundleFramework().getIsolatedBundleContext().getBundle(1);
+    BundleInfo info = new BundleInfoImpl(b);
+    Collection<ImportedService> serviceImports = Collections.emptySet();
+    Collection<ExportedService> serviceExports = Collections.emptySet();
+    try {
+      resources.add(mgr.getModelledResource(info.getLocation(), info, serviceImports, serviceExports));
+    } catch (InvalidAttributeException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+  }
+  
+  public void setBundleFrameworkManager(BundleFrameworkManager bfm)
+  {
+    fwMgr = bfm;
+  }
+  
+  public void setModellingManager(ModellingManager manager)
+  {
+    mgr = manager;
+  }
+}
\ No newline at end of file

Propchange: aries/trunk/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedFrameworkPreResolveHook.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: aries/trunk/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml
(original)
+++ aries/trunk/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml
Thu Feb 24 13:43:37 2011
@@ -25,10 +25,19 @@
       <property name="bundleContext" ref="blueprintBundleContext"/>
       <property name="updateStrategies" ref="strategies" />
   </bean>
+  
+  <bean id="pre-resolve-hook" class="org.apache.aries.application.runtime.framework.management.SharedFrameworkPreResolveHook">
+      <property name="bundleFrameworkManager" ref="equinox-bundle-framework-manager"/>
+      <property name="modellingManager" ref="modelling-manager"/>
+  </bean>
 
   <service interface="org.apache.aries.application.management.spi.framework.BundleFrameworkManager"
             ref="equinox-bundle-framework-manager"
             ranking="-1"/>
+         
+  <service interface="org.apache.aries.application.management.spi.resolve.PreResolveHook"
ref="pre-resolve-hook"/>
+            
+  <reference id="modelling-manager" interface="org.apache.aries.application.modelling.ModellingManager"/>
         
             
   <reference id="bundle-framework-factory" interface="org.apache.aries.application.management.spi.framework.BundleFrameworkFactory"/>
   

Modified: aries/trunk/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java
(original)
+++ aries/trunk/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java
Thu Feb 24 13:43:37 2011
@@ -60,14 +60,14 @@ public class BundleFrameworkImpl impleme
   @Override
   public void start() throws BundleException
   {
-        _compositeBundle.start(Bundle.START_ACTIVATION_POLICY);
-  if ( _packageAdminTracker == null)
-  {
+    _compositeBundle.getCompositeFramework().init();
+    _compositeBundle.start(Bundle.START_ACTIVATION_POLICY);
+    if ( _packageAdminTracker == null)
+    {
       _packageAdminTracker = new ServiceTracker(_compositeBundle.getCompositeFramework().getBundleContext(),
           PackageAdmin.class.getName(), null);
       _packageAdminTracker.open();
-  }
-    
+    }
   }
   
   @Override
@@ -95,7 +95,12 @@ public class BundleFrameworkImpl impleme
       }
     }
 
-    _compositeBundle.stop();
+    // We used to call stop before uninstall but this seems to cause NPEs in equinox. It
isn't
+    // all the time, but I put in a change to resolution and it started NPEing all the time.
This
+    // was because stop caused everything to go back to the RESOLVED state, so equinox inited
the
+    // framework during uninstall and then tried to get the surrogate bundle, but init did
not
+    // create a surroage, so we got an NPE. I removed the stop and added this comment in
the hope
+    // that the stop doesn't get added back in. 
     _compositeBundle.uninstall();
   }
 

Modified: aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java
(original)
+++ aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java
Thu Feb 24 13:43:37 2011
@@ -77,9 +77,10 @@ public class ApplicationContextImpl impl
     _deploymentMF = _application.getDeploymentMetadata();
 
     if (_deploymentMF.getApplicationDeploymentContents() != null
-        && !_deploymentMF.getApplicationDeploymentContents().isEmpty())
+        && !_deploymentMF.getApplicationDeploymentContents().isEmpty()) {
       install();
-
+    }
+    
     LOGGER.debug(LOG_EXIT, "ApplicationContextImpl", this);
   }
 

Modified: aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java?rev=1074150&r1=1074149&r2=1074150&view=diff
==============================================================================
--- aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java
(original)
+++ aries/trunk/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java
Thu Feb 24 13:43:37 2011
@@ -39,6 +39,7 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.spi.framework.BundleFrameworkManager;
 import org.apache.aries.application.management.spi.repository.BundleRepositoryManager;
 import org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager;
+import org.apache.aries.application.utils.AppConstants;
 import org.osgi.framework.BundleException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,6 +58,13 @@ public class ApplicationContextManagerIm
     
     _appToContextMap = new ConcurrentHashMap<AriesApplication, AriesApplicationContext>();
     
+    // When doing isolated runtime support provisioning against the local repo is a really
bad idea
+    // it can result in trying to install things into the shared framework into the local
framework
+    // this doesn't work because we don't know how to install them into the shared framework
and
+    // we can't just use them because they are in the local framework, so if this class is
constructed
+    // we disable local provisioning.
+    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
+    
     LOGGER.debug(LOG_EXIT, "ApplicationContextImpl", this);
   }
 



Mime
View raw message