geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r809078 [7/12] - in /geronimo/sandbox/djencks/osgi/framework: ./ assemblies/ assemblies/geronimo-framework/ buildsupport/ buildsupport/buildsupport-maven-plugin/ buildsupport/car-maven-plugin/ buildsupport/car-maven-plugin/src/main/java/org...
Date Sat, 29 Aug 2009 00:51:37 GMT
Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ChildrenConfigurationClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ChildrenConfigurationClassLoader.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ChildrenConfigurationClassLoader.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ChildrenConfigurationClassLoader.java Sat Aug 29 00:51:12 2009
@@ -115,6 +115,6 @@
 
     @Override
     public String toString() {
-        return "ChildrenConfigurationClassLoader: " + getId();
+        return getClass().getName() + " wrapping " + getParent().toString();
     }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/Configuration.java Sat Aug 29 00:51:12 2009
@@ -18,7 +18,6 @@
 package org.apache.geronimo.kernel.config;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -46,6 +45,8 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * A Configuration represents a collection of runnable services that can be
@@ -122,7 +123,7 @@
     /**
      * Supplies classloader(s) for this configuration
      */
-    private final ClassLoaderHolder classLoaderHolder;
+//    private final ClassLoaderHolder classLoaderHolder;
 
     /**
      * Used to resolve dependecies and paths
@@ -172,7 +173,7 @@
     /**
      * Creates a configuration.
      *
-     * @param classLoaderHolder Classloaders for this configuration
+//     * @param classLoaderHolder Classloaders for this configuration
      * @param configurationData the module type, environment and classpath of the configuration
      * @param dependencyNode Class and Service parent ids
      * @param allServiceParents ordered list of transitive closure of service parents for gbean searches
@@ -181,16 +182,16 @@
      * @throws InvalidConfigException if this configuration turns out to have a problem.
      */
     public Configuration(
-            @ParamAttribute(name = "classLoaderHolder") ClassLoaderHolder classLoaderHolder,
+//            @ParamAttribute(name = "classLoaderHolder") ClassLoaderHolder classLoaderHolder,
             @ParamAttribute(name = "configurationData") ConfigurationData configurationData,
             @ParamAttribute(name = "dependencyNode") DependencyNode dependencyNode,
             @ParamAttribute(name = "allServiceParents") List<Configuration> allServiceParents,
             @ParamAttribute(name = "attributeStore") ManageableAttributeStore attributeStore,
             @ParamAttribute(name = "configurationResolver") ConfigurationResolver configurationResolver) throws InvalidConfigException {
-        if (classLoaderHolder == null) throw new NullPointerException("classLoaders are null");
+//        if (classLoaderHolder == null) throw new NullPointerException("classLoaders are null");
         if (configurationData == null) throw new NullPointerException("configurationData is null");
 
-        this.classLoaderHolder = classLoaderHolder;
+//        this.classLoaderHolder = classLoaderHolder;
         this.configurationData = configurationData;
         this.naming = configurationData.getNaming();
         this.attributeStore = attributeStore;
@@ -202,9 +203,10 @@
         try {
 
             // Deserialize the GBeans in the configurationData
-            Collection<GBeanData> gbeans = configurationData.getGBeans(classLoaderHolder.getInternalClassLoader());
+            Bundle bundle = configurationData.getBundleContext().getBundle();
+            Collection<GBeanData> gbeans = configurationData.getGBeans(bundle);
             if (attributeStore != null) {
-                gbeans = attributeStore.applyOverrides(dependencyNode.getId(), gbeans, classLoaderHolder.getInternalClassLoader());
+                gbeans = attributeStore.applyOverrides(dependencyNode.getId(), gbeans, bundle);
             }
             for (GBeanData gbeanData : gbeans) {
                 this.gbeans.put(gbeanData.getAbstractName(), gbeanData);
@@ -257,9 +259,9 @@
         return abstractName;
     }
 
-    public ClassLoaderHolder getClassLoaderHolder() {
-        return classLoaderHolder;
-    }
+//    public ClassLoaderHolder getClassLoaderHolder() {
+//        return classLoaderHolder;
+//    }
 
     /**
      * Gets the parent configurations used for class loading.
@@ -341,11 +343,14 @@
     /**
      * Gets the class loader for this configuration.
      *
-     * @return the class loader for this configuration
-     * @deprecated use the impl instead
+     * @return the bundle for this configuration
      */
-    public ClassLoader getConfigurationClassLoader() {
-        return getClassLoaderHolder().getInternalClassLoader();
+    public Bundle getBundle() {
+        return configurationData.getBundleContext().getBundle();
+    }
+    
+    public BundleContext getBundleContext() {
+        return configurationData.getBundleContext();
     }
 
     /**
@@ -599,7 +604,7 @@
         // clear references to GBeanDatas
         gbeans.clear();
 
-        classLoaderHolder.destroy();
+//        classLoaderHolder.destroy();
     }
 
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationData.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationData.java Sat Aug 29 00:51:12 2009
@@ -32,6 +32,8 @@
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
@@ -102,7 +104,9 @@
     /**
      * A transformer to transform the GBeans of this configuration. 
      */
-    private ConfigurationDataTransformer configurationDataTransformer;
+    private transient ConfigurationDataTransformer configurationDataTransformer;
+
+    private transient BundleContext bundleContext;
 
     public ConfigurationData(Artifact configId, Naming naming, GBeanState gbeanState) {
         this(new Environment(configId), naming, gbeanState);
@@ -172,13 +176,15 @@
         return Collections.unmodifiableList(new ArrayList<String>(classPath));
     }
 
-    public List<GBeanData> getGBeans(ClassLoader classLoader) throws InvalidConfigException {
-        if (classLoader == null) throw new NullPointerException("classLoader is null");
-        List<GBeanData> gbeans = gbeanState.getGBeans(classLoader);
+    public List<GBeanData> getGBeans(Bundle bundle) throws InvalidConfigException {
+        if (bundle == null) throw new NullPointerException("bundle is null");
+        List<GBeanData> gbeans = gbeanState.getGBeans(bundle);
         if (null == configurationDataTransformer) {
             return gbeans;
         }
-        return configurationDataTransformer.transformGBeans(classLoader, this, gbeans);
+        //TODO transforming broken
+//        return configurationDataTransformer.transformGBeans(bundle, this, gbeans);
+        return gbeans;
     }
 
     public void addGBean(GBeanData gbeanData) {
@@ -202,6 +208,17 @@
         return gbeanState;
     }
 
+    public BundleContext getBundleContext() {
+        if (bundleContext == null) {
+            throw new NullPointerException("bundleContext is null in configurationData: " + getId());
+        }
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
     /**
      * Gets a map of module name to ConfigurationData for nested
      * configurations (as in, a WAR within an EAR, not dependencies between

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java Sat Aug 29 00:51:12 2009
@@ -31,7 +31,7 @@
 public class ConfigurationModel {
     private final Map<Artifact, ConfigurationStatus> configurations = new TreeMap<Artifact, ConfigurationStatus>();
 
-    public void addConfiguation(Artifact configurationId, Set<Artifact> loadParentIds, Set<Artifact> startParentIds) throws NoSuchConfigException {
+    public void addConfiguration(Artifact configurationId, Set<Artifact> loadParentIds, Set<Artifact> startParentIds) throws NoSuchConfigException {
         Set<ConfigurationStatus> startParents = getStatuses(startParentIds);
 
         // load parents are a superset of start parents

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationParent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationParent.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationParent.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationParent.java Sat Aug 29 00:51:12 2009
@@ -17,11 +17,12 @@
 
 package org.apache.geronimo.kernel.config;
 
+import org.osgi.framework.Bundle;
 
 
 /**
  * @version $Rev$ $Date$
  */
 public interface ConfigurationParent {
-    ClassLoader getConfigurationClassLoader();
+    Bundle getBundle();
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Sat Aug 29 00:51:12 2009
@@ -56,6 +56,7 @@
 import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
 import org.apache.geronimo.kernel.repository.Maven2Repository;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev:386276 $ $Date$
@@ -158,23 +159,25 @@
         return configurationMarshaler.newGBeanState(gbeans);
     }
 
-    public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader) throws Exception {
-        return loadBootstrapConfiguration(kernel, in, classLoader, false);
+    public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext) throws Exception {
+        return loadBootstrapConfiguration(kernel, in, bundleContext, false);
     }
 
-    public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader, boolean enableBootRepo) throws Exception {
+    public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
         ConfigurationData configurationData = readConfigurationData(in);
-        return loadBootstrapConfiguration(kernel, configurationData, classLoader, enableBootRepo);
+        return loadBootstrapConfiguration(kernel, configurationData, bundleContext, enableBootRepo);
     }
 
-    public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, ClassLoader classLoader) throws Exception {
-        return loadBootstrapConfiguration(kernel, configurationData, classLoader, false);
+    public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext) throws Exception {
+        return loadBootstrapConfiguration(kernel, configurationData, bundleContext, false);
     }
 
-    public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, ClassLoader classLoader, boolean enableBootRepo) throws Exception {
+    public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
         if (kernel == null) throw new NullPointerException("kernel is null");
         if (configurationData == null) throw new NullPointerException("configurationData is null");
-        if (classLoader == null) throw new NullPointerException("classLoader is null");
+        if (bundleContext == null) throw new NullPointerException("bundle is null");
+
+        configurationData.setBundleContext(bundleContext);
 
         // build the gbean data
         Artifact configId = configurationData.getId();
@@ -209,7 +212,7 @@
 
 
         // load and start the gbean
-        kernel.loadGBean(gbeanData, classLoader);
+        kernel.loadGBean(gbeanData, bundleContext);
         kernel.startGBean(gbeanData.getAbstractName());
 
         Configuration configuration = (Configuration) kernel.getGBean(gbeanData.getAbstractName());
@@ -444,7 +447,7 @@
                 preprocessGBeanData(configurationName, configuration, gbeanData);
 
                 try {
-                    kernel.loadGBean(gbeanData, configuration.getConfigurationClassLoader());
+                    kernel.loadGBean(gbeanData, configuration.getBundleContext());
                     loaded.add(gbeanData.getAbstractName());
                 } catch (GBeanAlreadyExistsException e) {
                     throw new InvalidConfigException(e);

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java Sat Aug 29 00:51:12 2009
@@ -27,39 +27,48 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * Standard implementation of an editable ConfigurationManager.
  *
  * @version $Rev:386276 $ $Date$
  */
+@GBean(j2eeType = "ConfigurationManager")
 public class EditableKernelConfigurationManager extends KernelConfigurationManager implements EditableConfigurationManager {
     private final AbstractNameQuery defaultStoreNameQuery;
 
-    public EditableKernelConfigurationManager(Kernel kernel,
-            AbstractNameQuery defaultStoreNameQuery,
-            Collection stores,
-            ManageableAttributeStore attributeStore,
-            PersistentConfigurationList configurationList,
-            ArtifactManager artifactManager,
-            ArtifactResolver artifactResolver,
-            Collection repositories,
-            Collection watchers,
-            ClassLoader classLoader) {
+    public EditableKernelConfigurationManager(@ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+                                              @ParamAttribute(name = GBEAN_ATTR_DEFAULT_STORE_NAME_QUERY) AbstractNameQuery defaultStoreNameQuery,
+                                              @ParamReference(name = "ConfigurationStore") Collection<ConfigurationStore> stores,
+                                              @ParamReference(name = "AttributeStore") ManageableAttributeStore attributeStore,
+                                              @ParamReference(name = "PersistentConfigurationList") PersistentConfigurationList configurationList,
+                                              @ParamReference(name = "ArtifactManager") ArtifactManager artifactManager,
+                                              @ParamReference(name = "ArtifactResolver") ArtifactResolver artifactResolver,
+                                              @ParamReference(name = "Repositories") Collection<ListableRepository> repositories,
+                                              @ParamReference(name = "Watchers") Collection<DeploymentWatcher> watchers,
+                                              @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext) {
         super(kernel,
-            stores,
-            attributeStore,
-            configurationList,
-            artifactManager,
-            artifactResolver,
-            repositories,
-            watchers,
-            classLoader);
+                stores,
+                attributeStore,
+                configurationList,
+                artifactManager,
+                artifactResolver,
+                repositories,
+                watchers,
+                bundleContext);
         this.defaultStoreNameQuery = defaultStoreNameQuery;
         throw new RuntimeException("more than deprecated");
     }
@@ -69,7 +78,7 @@
         if (null == defaultStoreNameQuery) {
             return super.getStoreList();
         }
-        
+
         List<ConfigurationStore> storeList = new ArrayList<ConfigurationStore>();
         for (Iterator iterator = stores.iterator(); iterator.hasNext();) {
             ConfigurationStore configurationStore = (ConfigurationStore) iterator.next();
@@ -81,7 +90,7 @@
         }
         return storeList;
     }
-    
+
     public void addGBeanToConfiguration(Artifact configurationId, GBeanData gbean, boolean start) throws InvalidConfigException {
 //        Configuration configuration = getConfiguration(configurationId);
 //
@@ -185,32 +194,7 @@
 //        }
     }
 
-    public static final GBeanInfo GBEAN_INFO;
 
     public static final String GBEAN_ATTR_DEFAULT_STORE_NAME_QUERY = "defaultStoreNameQuery";
 
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(EditableKernelConfigurationManager.class, KernelConfigurationManager.GBEAN_INFO, "ConfigurationManager");
-        
-        infoFactory.addAttribute(GBEAN_ATTR_DEFAULT_STORE_NAME_QUERY, AbstractNameQuery.class, true);
-        
-        infoFactory.addInterface(EditableConfigurationManager.class);
-        
-        infoFactory.setConstructor(new String[] { "kernel",
-            GBEAN_ATTR_DEFAULT_STORE_NAME_QUERY,
-            "Stores",
-            "AttributeStore",
-            "PersistentConfigurationList",
-            "ArtifactManager",
-            "ArtifactResolver",
-            "Repositories",
-            "Watchers",
-            "classLoader" });
-
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/GBeanState.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/GBeanState.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/GBeanState.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/GBeanState.java Sat Aug 29 00:51:12 2009
@@ -22,12 +22,13 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
  */
 public interface GBeanState {
-    List<GBeanData> getGBeans(ClassLoader classLoader) throws InvalidConfigException;
+    List<GBeanData> getGBeans(Bundle bundle) throws InvalidConfigException;
 
     void addGBean(GBeanData gbeanData);
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/IOUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/IOUtil.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/IOUtil.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/IOUtil.java Sat Aug 29 00:51:12 2009
@@ -291,7 +291,7 @@
             JarFile jarFile = null;
             try {
                 jarFile = new JarFile(root);
-                URL baseURL = new URL("jar:" + root.toURL().toString() + "!/");
+                URL baseURL = new URL("jar:" + root.toURI().toURL().toString() + "!/");
                 if (pattern == null || pattern.length() == 0) {
                     return Collections.singleton(baseURL);
                 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/JarFileClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/JarFileClassLoaderFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/JarFileClassLoaderFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/JarFileClassLoaderFactory.java Sat Aug 29 00:51:12 2009
@@ -104,7 +104,7 @@
         } else {
             parentClassLoaders = new ArrayList<ClassLoader>(classParents.size());
             for (Configuration parent : classParents) {
-                parentClassLoaders.add(parent.getClassLoaderHolder().getExternalClassLoader());
+//                parentClassLoaders.add(parent.getClassLoaderHolder().getExternalClassLoader());
             }
         }
 
@@ -182,7 +182,7 @@
         LinkedHashMap<Artifact, URL[]> artifactToURL = new LinkedHashMap<Artifact, URL[]>();
         for (Artifact artifact : dependencies) {
             File file = configurationResolver.resolve(artifact);
-            artifactToURL.put(artifact, new URL[]{file.toURL()});
+            artifactToURL.put(artifact, new URL[]{file.toURI().toURL()});
         }
         return artifactToURL;
     }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Sat Aug 29 00:51:12 2009
@@ -17,7 +17,6 @@
 
 package org.apache.geronimo.kernel.config;
 
-import java.net.MalformedURLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -33,6 +32,10 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.InternalKernelException;
@@ -42,7 +45,11 @@
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,40 +60,40 @@
  *
  * @version $Rev:386276 $ $Date$
  */
+
+@GBean(j2eeType = "ConfigurationManager")
 public class KernelConfigurationManager extends SimpleConfigurationManager implements GBeanLifecycle {
 
     protected final Kernel kernel;
     protected final ManageableAttributeStore attributeStore;
     protected final PersistentConfigurationList configurationList;
     private final ArtifactManager artifactManager;
-    protected final ClassLoader classLoader;
     private final ShutdownHook shutdownHook;
     private boolean online = true;
 
-    public KernelConfigurationManager(Kernel kernel,
-                                      Collection stores,
-                                      ManageableAttributeStore attributeStore,
-                                      PersistentConfigurationList configurationList,
-                                      ArtifactManager artifactManager,
-                                      ArtifactResolver artifactResolver,
-                                      Collection repositories,
-                                      Collection watchers,
-                                      ClassLoader classLoader) {
+    public KernelConfigurationManager(@ParamSpecial(type= SpecialAttributeType.kernel)Kernel kernel,
+                                      @ParamReference(name = "ConfigurationStore")Collection<ConfigurationStore> stores,
+                                      @ParamReference(name = "AttributeStore")ManageableAttributeStore attributeStore,
+                                      @ParamReference(name = "PersistentConfigurationList")PersistentConfigurationList configurationList,
+                                      @ParamReference(name = "ArtifactManager")ArtifactManager artifactManager,
+                                      @ParamReference(name = "ArtifactResolver") ArtifactResolver artifactResolver,
+                                      @ParamReference(name = "Repositories")Collection<ListableRepository> repositories,
+                                      @ParamReference(name = "Watchers")Collection<DeploymentWatcher> watchers,
+                                      @ParamSpecial(type= SpecialAttributeType.bundleContext)BundleContext bundleContext) {
 
         super(stores,
                 createArtifactResolver(artifactResolver, artifactManager, repositories),
-                repositories, watchers);
+                repositories, watchers, bundleContext);
 
         this.kernel = kernel;
         this.attributeStore = attributeStore;
         this.configurationList = configurationList;
         this.artifactManager = artifactManager;
-        this.classLoader = classLoader;
 
         shutdownHook = new ShutdownHook(kernel, configurationModel);
     }
 
-    private static ArtifactResolver createArtifactResolver(ArtifactResolver artifactResolver, ArtifactManager artifactManager, Collection repositories) {
+    private static ArtifactResolver createArtifactResolver(ArtifactResolver artifactResolver, ArtifactManager artifactManager, Collection<ListableRepository> repositories) {
         if (artifactResolver != null) {
             return artifactResolver;
         }
@@ -144,17 +151,17 @@
         gbeanData.setAttribute("configurationResolver", configurationResolver);
         try {
             dependencyNode = buildDependencyNode(configurationData);
-            ClassLoaderHolder classLoaderHolder = buildClassLoaders(configurationData, loadedConfigurations, dependencyNode, configurationResolver);
+//            ClassLoaderHolder classLoaderHolder = buildClassLoaders(configurationData, loadedConfigurations, dependencyNode, configurationResolver);
 
             gbeanData.setAttribute("dependencyNode", dependencyNode);
-            gbeanData.setAttribute("classLoaderHolder", classLoaderHolder);
+//            gbeanData.setAttribute("classLoaderHolder", classLoaderHolder);
             gbeanData.setAttribute("allServiceParents", buildAllServiceParents(loadedConfigurations, dependencyNode));
         } catch (MissingDependencyException e) {
             throw new InvalidConfigException(e);
-        } catch (MalformedURLException e) {
-            throw new InvalidConfigException(e);
-        } catch (NoSuchConfigException e) {
-            throw new InvalidConfigException(e);
+//        } catch (MalformedURLException e) {
+//            throw new InvalidConfigException(e);
+//        } catch (NoSuchConfigException e) {
+//            throw new InvalidConfigException(e);
         }
         //TODO is this dangerous?  should really add dependency on attribute store name
         gbeanData.setAttribute("attributeStore", attributeStore);
@@ -169,7 +176,8 @@
 
         // load the configuration
         try {
-            kernel.loadGBean(gbeanData, classLoader);
+            //TODO OSGI more likely use the configuration bundle??
+            kernel.loadGBean(gbeanData, bundleContext);
         } catch (GBeanAlreadyExistsException e) {
             throw new InvalidConfigException("Unable to load configuration gbean " + configurationId, e);
         }
@@ -376,21 +384,4 @@
         }
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(KernelConfigurationManager.class, SimpleConfigurationManager.GBEAN_INFO, "ConfigurationManager");
-        infoFactory.addAttribute("kernel", Kernel.class, false);
-        infoFactory.addReference("AttributeStore", ManageableAttributeStore.class, ManageableAttributeStore.ATTRIBUTE_STORE);
-        infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST);
-        infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
-        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
-        infoFactory.addInterface(ConfigurationManager.class);
-        infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "Repositories", "Watchers", "classLoader"});
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java Sat Aug 29 00:51:12 2009
@@ -22,6 +22,7 @@
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.osgi.framework.Bundle;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -45,11 +46,11 @@
      * @param configurationName The configuration in question
      * @param datas             The initial GBeanData's for all the GBeans in
      *                          the configuration
-     * @param classLoader
+     * @param bundle
      * @return                  The modified GBeanData's
      * @throws InvalidConfigException If something bad happens
      */
-    public Collection applyOverrides(Artifact configurationName, Collection<GBeanData> datas, ClassLoader classLoader) throws InvalidConfigException;
+    public Collection<GBeanData> applyOverrides(Artifact configurationName, Collection<GBeanData> datas, Bundle bundle) throws InvalidConfigException;
 
     /**
      * Sets the stored value for a particular attribute.  The attribute is
@@ -63,12 +64,12 @@
      *
      * @param configurationName The name of the configuration holding the GBean
      *                          in question
-     * @param gbean The ObjectName of the GBean in question
+     * @param gbeanName
      * @param attribute The attribute in question
      * @param value The value to save, or null if no value should be saved
-     * @param classLoader The configuration's classLoader
+     * @param bundle
      */
-    public void setValue(Artifact configurationName, AbstractName gbean, GAttributeInfo attribute, Object value, ClassLoader classLoader);
+    public void setValue(Artifact configurationName, AbstractName gbeanName, GAttributeInfo attribute, Object value, Bundle bundle);
 
     /**
      * Sets the pattern for a GBean reference. The reference is
@@ -101,9 +102,9 @@
      * Adds a GBean to the configuration.
      * @param configurationName the configuration that the GBean belongs to
      * @param gbeanData the GBean to add
-     * @param classLoader The configuration classLoader
+     * @param bundle
      */
-    public void addGBean(Artifact configurationName, GBeanData gbeanData, ClassLoader classLoader);
+    public void addGBean(Artifact configurationName, GBeanData gbeanData, Bundle bundle);
 
     /**
      * Saves the current values to persistent storage.  This should be called

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java Sat Aug 29 00:51:12 2009
@@ -271,7 +271,11 @@
                 name.equals("boolean") ||
                 name.equals("int") ||
                 name.equals("double") ||
-                name.equals("long")) {
+                name.equals("long") ||
+                name.equals("short") ||
+                name.equals("float") ||
+                name.equals("byte") ||
+                name.equals("char")) {
             Class clazz = ClassLoader.getSystemClassLoader().loadClass(name);
             return resolveClass(clazz, resolve);
         }
@@ -350,7 +354,11 @@
                 name.equals("boolean") ||
                 name.equals("int") ||
                 name.equals("double") ||
-                name.equals("long")) {
+                name.equals("long") ||
+                name.equals("short") ||
+                name.equals("float") ||
+                name.equals("byte") ||
+                name.equals("char")) {
             try {
                 return resolveClass(findSystemClass(name), resolve);
             } catch (ClassNotFoundException cnfe) {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SerializedGBeanState.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SerializedGBeanState.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SerializedGBeanState.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SerializedGBeanState.java Sat Aug 29 00:51:12 2009
@@ -34,6 +34,7 @@
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.ObjectInputStreamExt;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -57,11 +58,11 @@
         }
     }
 
-    public List<GBeanData> getGBeans(ClassLoader classLoader) throws InvalidConfigException {
+    public List<GBeanData> getGBeans(Bundle bundle) throws InvalidConfigException {
         if (gbeanState == null) {
             return Collections.unmodifiableList(gbeans);
         }
-        gbeans.addAll(loadGBeans(gbeanState, classLoader));
+        gbeans.addAll(loadGBeans(gbeanState, bundle));
         return Collections.unmodifiableList(gbeans);
     }
 
@@ -109,15 +110,15 @@
         stream.defaultWriteObject();
     }
 
-    private static List<GBeanData> loadGBeans(byte[] gbeanState, ClassLoader classLoader) throws InvalidConfigException {
+    private static List<GBeanData> loadGBeans(byte[] gbeanState, Bundle bundle) throws InvalidConfigException {
         List<GBeanData> gbeans = new ArrayList<GBeanData>();
         if (gbeanState != null && gbeanState.length > 0) {
             // Set the thread context classloader so deserializing classes can grab the cl from the thread
             ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
             try {
-                Thread.currentThread().setContextClassLoader(classLoader);
+//                Thread.currentThread().setContextClassLoader(classLoader);
 
-                ObjectInputStream ois = new ObjectInputStreamExt(new ByteArrayInputStream(gbeanState), classLoader);
+                ObjectInputStream ois = new ObjectInputStreamExt(new ByteArrayInputStream(gbeanState), bundle);
                 try {
                     while (true) {
                         GBeanData gbeanData = new GBeanData();
@@ -130,11 +131,11 @@
                     ois.close();
                 }
             } catch (ClassNotFoundException e) {
-                throw new InvalidConfigException("Class not loadable in classloader: " + classLoader, e);
+                throw new InvalidConfigException("Class not loadable in classloader: " + bundle, e);
             } catch (NoClassDefFoundError e) {
-                throw new InvalidConfigException("Class not loadable in classloader: " + classLoader, e);
+                throw new InvalidConfigException("Class not loadable in classloader: " + bundle, e);
             } catch (Exception e) {
-                throw new InvalidConfigException("Unable to deserialize GBeanState in classloader: " + classLoader, e);
+                throw new InvalidConfigException("Unable to deserialize GBeanState in classloader: " + bundle, e);
             } finally {
                 Thread.currentThread().setContextClassLoader(oldCl);
             }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Sat Aug 29 00:51:12 2009
@@ -27,37 +27,46 @@
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
-import java.net.MalformedURLException;
 
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.Version;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
 
 /**
  * @version $Rev$ $Date$
  */
+@GBean(j2eeType = "ConfigurationManager")
 public class SimpleConfigurationManager implements ConfigurationManager {
-    protected final Logger log = LoggerFactory.getLogger(getClass());
+    protected static final Logger log = LoggerFactory.getLogger(SimpleConfigurationManager.class);
     protected final Collection<ConfigurationStore> stores;
     private final ArtifactResolver artifactResolver;
     protected final Map<Artifact, Configuration> configurations = new LinkedHashMap<Artifact, Configuration>();
     protected final ConfigurationModel configurationModel = new ConfigurationModel();
     protected final Collection<? extends Repository> repositories;
     protected final Collection<DeploymentWatcher> watchers;
+    protected final BundleContext bundleContext;
 
-    private final JarFileClassLoaderFactory classLoaderFactory = new JarFileClassLoaderFactory();
+    //TODO need thread local of loaded configurations OSGI GROSS!!
+    private final ThreadLocal<Map<Artifact, Configuration>> loadedConfigurations = new ThreadLocal<Map<Artifact, Configuration>>() {
+    };
 
     /**
      * When this is not null, it points to the "new" configuration that is
@@ -68,14 +77,15 @@
     private Configuration reloadingConfiguration;
 
 
-    public SimpleConfigurationManager(Collection<ConfigurationStore> stores, ArtifactResolver artifactResolver, Collection<? extends Repository> repositories) {
-        this(stores, artifactResolver, repositories, Collections.<DeploymentWatcher>emptySet());
+    public SimpleConfigurationManager(Collection<ConfigurationStore> stores, ArtifactResolver artifactResolver, Collection<? extends Repository> repositories, BundleContext bundleContext) {
+        this(stores, artifactResolver, repositories, Collections.<DeploymentWatcher>emptySet(), bundleContext);
     }
 
-    public SimpleConfigurationManager(Collection<ConfigurationStore> stores,
-                                      ArtifactResolver artifactResolver,
-                                      Collection<? extends Repository> repositories,
-                                      Collection<DeploymentWatcher> watchers) {
+    public SimpleConfigurationManager(@ParamReference(name = "ConfigurationStore")Collection<ConfigurationStore> stores,
+                                      @ParamReference(name = "ArtifactResolver") ArtifactResolver artifactResolver,
+                                      @ParamReference(name = "Repositories")Collection<? extends Repository> repositories,
+                                      @ParamReference(name = "Watchers")Collection<DeploymentWatcher> watchers,
+                                      @ParamSpecial(type= SpecialAttributeType.bundleContext)BundleContext bundleContext) {
         if (stores == null) stores = Collections.emptySet();
         if (repositories == null) repositories = Collections.emptySet();
         for (Repository repo: repositories) {
@@ -90,6 +100,7 @@
         this.artifactResolver = artifactResolver;
         this.repositories = repositories;
         this.watchers = watchers;
+        this.bundleContext = bundleContext;
     }
 
     public synchronized boolean isInstalled(Artifact configId) {
@@ -267,17 +278,20 @@
             return new LifecycleResults();
         }
 
+
+
         // load the ConfigurationData for the new configuration
-        ConfigurationData configurationData;
         try {
-            configurationData = loadConfigurationData(configurationId, monitor);
+            String location = locateBundle(configurationId, monitor);
+            bundleContext.installBundle(location);
         } catch (Exception e) {
             monitor.finished();
             throw new LifecycleException("load", configurationId, e);
         }
 
         // load the configuration
-        LifecycleResults results = loadConfiguration(configurationData, monitor);
+//        LifecycleResults results = loadConfiguration(configurationData, monitor);
+        LifecycleResults results = new LifecycleResults();
 
         return results;
     }
@@ -291,43 +305,59 @@
         LifecycleResults results = new LifecycleResults();
         if (!isLoaded(id)) {
             // recursively load configurations from the new child to the parents
-            LinkedHashMap<Artifact, UnloadedConfiguration> configurationsToLoad = new LinkedHashMap<Artifact, UnloadedConfiguration>();
+//            LinkedHashMap<Artifact, UnloadedConfiguration> configurationsToLoad = new LinkedHashMap<Artifact, UnloadedConfiguration>();
+            LinkedHashSet<Artifact> resolvedParents;
             try {
-                loadDepthFirst(configurationData, configurationsToLoad, monitor);
+                resolvedParents = resolveParentIds(configurationData);
+//                loadDepthFirst(configurationData, configurationsToLoad, monitor);
             } catch (Exception e) {
                 monitor.finished();
                 throw new LifecycleException("load", id, e);
             }
 
             // load and start the unloaded the gbean for each configuration (depth first)
-            Map<Artifact, Configuration> actuallyLoaded = new LinkedHashMap<Artifact, Configuration>(configurationsToLoad.size());
-            Artifact configurationId = null;
+            Map<Artifact, Configuration> actuallyLoaded = loadedConfigurations.get();
+            boolean newLoad = actuallyLoaded == null;
+            if (actuallyLoaded == null) {
+                actuallyLoaded = new LinkedHashMap<Artifact, Configuration>(resolvedParents.size());
+            }
+//            Artifact configurationId = null;
             try {
-                for (Map.Entry<Artifact, UnloadedConfiguration> entry : configurationsToLoad.entrySet()) {
-                    configurationId = entry.getKey();
-                    UnloadedConfiguration unloadedConfiguration = entry.getValue();
+                for (Artifact configurationId : resolvedParents) {
 
                     monitor.loading(configurationId);
-                    Configuration configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), actuallyLoaded);
+                    String bundleId = locateBundle(configurationId, monitor);
+                    Bundle parent = bundleContext.installBundle(bundleId);
+//                    Configuration configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), actuallyLoaded);
                     monitor.succeeded(configurationId);
 
-                    actuallyLoaded.put(configurationId, configuration);
                 }
+                // update the status of the loaded configurations
+                Configuration configuration = load(configurationData, resolvedParents, actuallyLoaded);
+                actuallyLoaded.put(configurationData.getId(), configuration);
+                addNewConfigurationToModel(configuration);
+//            results.setLoaded(actuallyLoaded.keySet());
             } catch (Exception e) {
-                monitor.failed(configurationId, e);
+//                monitor.failed(configurationId, e);
 
                 // there was a problem, so we need to unload all configurations that were actually loaded
-                for (Configuration configuration : actuallyLoaded.values()) {
-                    unload(configuration);
-                }
+//                for (Bundle bundle : actuallyLoaded.values()) {
+//                    try {
+//                        //TODO OSGI REALLY?
+//                        bundle.stop();
+//                    } catch (BundleException e1) {
+//                        //?? TODO OSGI WHAT??
+//                    }
+//                }
 
                 monitor.finished();
                 throw new LifecycleException("load", id, e);
+            } finally {
+                if (newLoad) {
+                    loadedConfigurations.remove();
+                }
             }
 
-            // update the status of the loaded configurations
-            addNewConfigurationsToModel(actuallyLoaded);
-            results.setLoaded(actuallyLoaded.keySet());
         }
         load(id);
         monitor.finished();
@@ -351,11 +381,11 @@
     protected Configuration doLoad(ConfigurationData configurationData, LinkedHashSet<Artifact> resolvedParentIds, Map<Artifact, Configuration> loadedConfigurations, ConfigurationResolver configurationResolver) throws Exception {
         DependencyNode dependencyNode = buildDependencyNode(configurationData);
 
-        ClassLoaderHolder classLoaderHolder = buildClassLoaders(configurationData, loadedConfigurations, dependencyNode, configurationResolver);
+//        ClassLoaderHolder classLoaderHolder = buildClassLoaders(configurationData, loadedConfigurations, dependencyNode, configurationResolver);
 
-        List<Configuration> allServiceParents = buildAllServiceParents(loadedConfigurations, dependencyNode);
+        List<Configuration> allServiceParents = buildAllServiceParents(null, dependencyNode);
 
-        Configuration configuration = new Configuration(classLoaderHolder, configurationData, dependencyNode, allServiceParents, null, configurationResolver);
+        Configuration configuration = new Configuration(configurationData, dependencyNode, allServiceParents, null, configurationResolver);
         configuration.doStart();
         //TODO why???
         resolvedParentIds.add(configuration.getId());
@@ -378,12 +408,12 @@
         return allServiceParents;
     }
 
-    protected ClassLoaderHolder buildClassLoaders(ConfigurationData configurationData, Map<Artifact, Configuration> loadedConfigurations, DependencyNode dependencyNode, ConfigurationResolver configurationResolver) throws InvalidConfigException, MissingDependencyException, MalformedURLException, NoSuchConfigException {
-        Collection<Configuration> parents = findParentConfigurations(dependencyNode.getClassParents(), loadedConfigurations);
-        LinkedHashSet<String> classPath = new LinkedHashSet<String>(configurationData.getClassPath());
-        ClassLoaderHolder classLoaderHolder = classLoaderFactory.buildClassLoaders(parents, configurationData.getEnvironment(), classPath, configurationResolver);
-        return classLoaderHolder;
-    }
+//    protected ClassLoaderHolder buildClassLoaders(ConfigurationData configurationData, Map<Artifact, Configuration> loadedConfigurations, DependencyNode dependencyNode, ConfigurationResolver configurationResolver) throws InvalidConfigException, MissingDependencyException, MalformedURLException, NoSuchConfigException {
+//        Collection<Configuration> parents = findParentConfigurations(dependencyNode.getClassParents(), loadedConfigurations);
+//        LinkedHashSet<String> classPath = new LinkedHashSet<String>(configurationData.getClassPath());
+//        ClassLoaderHolder classLoaderHolder = classLoaderFactory.buildClassLoaders(parents, configurationData.getEnvironment(), classPath, configurationResolver);
+//        return classLoaderHolder;
+//    }
 
     protected DependencyNode buildDependencyNode(ConfigurationData configurationData) throws MissingDependencyException {
         DependencyNode dependencyNode = DependencyNodeUtil.toDependencyNode(configurationData.getEnvironment(), artifactResolver, this);
@@ -401,22 +431,25 @@
         }
     }
 
-    private Collection<Configuration> findParentConfigurations(LinkedHashSet<Artifact> resolvedParentIds, Map<Artifact, Configuration> loadedConfigurations) throws InvalidConfigException {
-        LinkedHashMap<Artifact, Configuration> parents = new LinkedHashMap<Artifact, Configuration>();
-        for (Artifact resolvedArtifact : resolvedParentIds) {
-
-            Configuration parent = getConfiguration(resolvedArtifact, loadedConfigurations);
-
-            parents.put(resolvedArtifact, parent);
-        }
-        return parents.values();
-    }
+//    private Collection<Configuration> findParentConfigurations(LinkedHashSet<Artifact> resolvedParentIds, Map<Artifact, Configuration> loadedConfigurations) throws InvalidConfigException {
+//        LinkedHashMap<Artifact, Configuration> parents = new LinkedHashMap<Artifact, Configuration>();
+//        for (Artifact resolvedArtifact : resolvedParentIds) {
+//
+//            Configuration parent = getConfiguration(resolvedArtifact, loadedConfigurations);
+//
+//            parents.put(resolvedArtifact, parent);
+//        }
+//        return parents.values();
+//    }
 
     private Configuration getConfiguration(Artifact resolvedArtifact, Map<Artifact, Configuration> loadedConfigurations) throws InvalidConfigException {
         Configuration parent;
-        if (loadedConfigurations.containsKey(resolvedArtifact)) {
-            parent = loadedConfigurations.get(resolvedArtifact);
-        } else if (isLoaded(resolvedArtifact)) {
+
+        //TODO OSGI track loaded configurations in thread local ???
+//        if (loadedConfigurations.containsKey(resolvedArtifact)) {
+//            parent = loadedConfigurations.get(resolvedArtifact);
+//        } else
+        if (isLoaded(resolvedArtifact)) {
             parent = getConfiguration(resolvedArtifact);
         } else {
             throw new InvalidConfigException("Cound not find parent configuration: " + resolvedArtifact);
@@ -424,14 +457,14 @@
         return parent;
     }
 
-    private void addNewConfigurationsToModel(Map<Artifact, Configuration> loadedConfigurations) throws NoSuchConfigException {
-        for (Configuration configuration : loadedConfigurations.values()) {
-            addNewConfigurationToModel(configuration);
-        }
-    }
+//    private void addNewConfigurationsToModel(Map<Artifact, Bundle> loadedConfigurations) throws NoSuchConfigException {
+//        for (Bundle configuration : loadedConfigurations.values()) {
+//            addNewConfigurationToModel(configuration);
+//        }
+//    }
 
     protected void addNewConfigurationToModel(Configuration configuration) throws NoSuchConfigException {
-        configurationModel.addConfiguation(configuration.getId(),
+        configurationModel.addConfiguration(configuration.getId(),
                 getConfigurationIds(getLoadParents(configuration)),
                 getConfigurationIds(getStartParents(configuration)));
         configurations.put(configuration.getId(), configuration);
@@ -561,6 +594,18 @@
         monitor.failed(configurationId, exception);
         throw exception;
     }
+    private String locateBundle(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, IOException, InvalidConfigException {
+        monitor.addConfiguration(configurationId);
+        monitor.reading(configurationId);
+        for (Repository repo : repositories) {
+            if (repo.contains(configurationId)) {
+                return repo.getLocation(configurationId).getAbsolutePath();
+            }
+        }
+        NoSuchConfigException exception = new NoSuchConfigException(configurationId);
+        monitor.failed(configurationId, exception);
+        throw exception;
+    }
 
     private LinkedHashSet<Artifact> resolveParentIds(ConfigurationData configurationData) throws MissingDependencyException, InvalidConfigException {
         Environment environment = configurationData.getEnvironment();
@@ -570,16 +615,16 @@
         for (ListIterator<Dependency> iterator = dependencies.listIterator(); iterator.hasNext();) {
             Dependency dependency = iterator.next();
             Artifact resolvedArtifact = artifactResolver.resolveInClassLoader(dependency.getArtifact());
-            if (isConfiguration(resolvedArtifact)) {
+//            if (isConfiguration(resolvedArtifact)) {
                 parentIds.add(resolvedArtifact);
 
                 // update the dependency list to contain the resolved artifact
                 dependency = new Dependency(resolvedArtifact, dependency.getImportType());
                 iterator.set(dependency);
-            } else if (dependency.getImportType() == ImportType.SERVICES) {
-                // Service depdendencies require that the depdencency be a configuration
-                throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
-            }
+//            } else if (dependency.getImportType() == ImportType.SERVICES) {
+//                 Service depdendencies require that the depdencency be a configuration
+//                throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
+//            }
         }
 
         for (ConfigurationData childConfigurationData : configurationData.getChildConfigurations().values()) {
@@ -1107,7 +1152,8 @@
                 //
 
                 // add all of the new configurations the model
-                addNewConfigurationsToModel(loadedParents);
+                //TODO OSGI TOTALLY BROKEN
+//                addNewConfigurationsToModel(loadedParents);
 
                 // now ugrade the existing node in the model
                 if (configurationModel.containsConfiguration(existingConfigurationId)) {
@@ -1116,7 +1162,7 @@
                             getConfigurationIds(getLoadParents(newConfiguration)),
                             getConfigurationIds(getStartParents(newConfiguration)));
                 } else {
-                    configurationModel.addConfiguation(newConfigurationId,
+                    configurationModel.addConfiguration(newConfigurationId,
                             getConfigurationIds(getLoadParents(newConfiguration)),
                             getConfigurationIds(getStartParents(newConfiguration)));
                     load(newConfigurationId);
@@ -1392,29 +1438,12 @@
      * @throws InvalidConfigException on error
      */
     private void applyOverrides(Configuration configuration) throws InvalidConfigException {
-        ClassLoader configurationClassLoader = configuration.getConfigurationClassLoader();
-        Collection<GBeanData> gbeans = configuration.getConfigurationData().getGBeans(configurationClassLoader);
+        Bundle bundle = configuration.getBundle();
+        Collection<GBeanData> gbeans = configuration.getConfigurationData().getGBeans(bundle);
         if (configuration.getManageableAttributeStore() != null) {
             configuration.getManageableAttributeStore().applyOverrides(configuration.getId(), gbeans,
-                    configurationClassLoader);
+                    bundle);
         }
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(SimpleConfigurationManager.class, "ConfigurationManager");
-        infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore");
-        infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
-        infoFactory.addReference("Repositories", Repository.class, "Repository");
-        infoFactory.addReference("Watchers", DeploymentWatcher.class);
-        infoFactory.addInterface(ConfigurationManager.class);
-        infoFactory.setConstructor(new String[]{"Stores", "ArtifactResolver", "Repositories", "Watchers"});
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/classloading/OneClassLoaderPerJarClassLoaderBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/classloading/OneClassLoaderPerJarClassLoaderBuilder.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/classloading/OneClassLoaderPerJarClassLoaderBuilder.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/classloading/OneClassLoaderPerJarClassLoaderBuilder.java Sat Aug 29 00:51:12 2009
@@ -71,7 +71,7 @@
         Set<ConfigurationClassLoaderExtension> classloaders = new HashSet<ConfigurationClassLoaderExtension>();
         URL artifactURL;
         try {
-            artifactURL = configurationResolver.resolve(configId).toURL();
+            artifactURL = configurationResolver.resolve(configId).toURI().toURL();
             new MavenDependencyResolver().resolve(artifactURL, GLOBAL_CL_REGISTER, configId);
         } catch (MissingDependencyException e) {
             //bootstrap configuration
@@ -105,7 +105,7 @@
             for (Artifact parent : parents) {
                 ConfigurationClassLoaderExtension cl = GLOBAL_CL_REGISTER.retrieve(parent);
                 if (cl == null) {
-                    URL url = configurationResolver.resolve(parent).toURL();
+                    URL url = configurationResolver.resolve(parent).toURI().toURL();
                     cl = newGlobalClassLoader(parent, new URL[]{url}, configurationResolver);
                 }
                 classLoaders[i++] = cl;

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/GBeanDataConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/GBeanDataConverter.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/GBeanDataConverter.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/GBeanDataConverter.java Sat Aug 29 00:51:12 2009
@@ -16,17 +16,16 @@
  */
 package org.apache.geronimo.kernel.config.xstream;
 
-import java.util.Iterator;
+import java.net.URI;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.LinkedHashMap;
-import java.net.URI;
 
+import com.thoughtworks.xstream.converters.ConversionException;
 import com.thoughtworks.xstream.converters.Converter;
 import com.thoughtworks.xstream.converters.MarshallingContext;
 import com.thoughtworks.xstream.converters.UnmarshallingContext;
-import com.thoughtworks.xstream.converters.ConversionException;
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
 import com.thoughtworks.xstream.mapper.Mapper;
@@ -36,6 +35,8 @@
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.MultiGBeanInfoFactory;
 import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.annotation.EncryptionSetting;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -44,12 +45,19 @@
     private final Mapper mapper;
     private final GBeanInfoFactory infoFactory;
 
+    private final ThreadLocal<Bundle> currentBundle = new ThreadLocal<Bundle>();
+
     public GBeanDataConverter(Mapper mapper) {
         this.mapper = mapper;
         
         infoFactory = newGBeanInfoFactory();
     }
 
+    //TODO OSGI call me or better remove.
+    public void setBundle(Bundle bundle) {
+        currentBundle.set(bundle);
+    }
+
     protected GBeanInfoFactory newGBeanInfoFactory() {
         return new MultiGBeanInfoFactory();
     }
@@ -79,20 +87,19 @@
         }
 
         // dependencies Set<ReferencePatterns>
-        Set dependencies = gbeanData.getDependencies();
-        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
-            ReferencePatterns referencePatterns = (ReferencePatterns) iterator.next();
+        Set<ReferencePatterns> dependencies = gbeanData.getDependencies();
+        for (ReferencePatterns referencePatterns : dependencies) {
             writer.startNode("dependency");
             marshallingContext.convertAnother(referencePatterns);
             writer.endNode();
         }
 
         // attributes Map<String, Object>
-        Map attributes = gbeanData.getAttributes();
-        for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String attributeName = (String) entry.getKey();
-            Object attributeValue = entry.getValue();
+        Map<String, Object> attributes = gbeanData.getAttributes();
+        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+            String attributeName = entry.getKey();
+            EncryptionSetting encryptionSetting = gbeanInfo.getAttribute(attributeName).getEncryptedSetting();
+            Object attributeValue = encryptionSetting.encrypt(entry.getValue());
             if (attributeValue != null) {
                 writer.startNode("attribute");
                 writer.addAttribute("name", attributeName);
@@ -105,11 +112,10 @@
             }
         }
         // references Map<String, ReferencePatterns>
-        Map references = gbeanData.getReferences();
-        for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String referenceName = (String) entry.getKey();
-            ReferencePatterns referencePatterns = (ReferencePatterns) entry.getValue();
+        Map<String, ReferencePatterns> references = gbeanData.getReferences();
+        for (Map.Entry<String, ReferencePatterns> entry : references.entrySet()) {
+            String referenceName = entry.getKey();
+            ReferencePatterns referencePatterns = entry.getValue();
             writer.startNode("reference");
             writer.addAttribute("name", referenceName);
             marshallingContext.convertAnother(referencePatterns);
@@ -118,10 +124,6 @@
     }
 
     public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext unmarshallingContext) {
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        if (classLoader == null) {
-            classLoader = this.getClass().getClassLoader();
-        }
 
         // name
         String gbeanName = reader.getAttribute("name");
@@ -134,12 +136,12 @@
         GBeanInfo gbeanInfo = null;
         String sourceClass = reader.getAttribute("sourceClass");
         if (sourceClass != null) {
-            gbeanInfo = infoFactory.getGBeanInfo(sourceClass, classLoader);
+            gbeanInfo = infoFactory.getGBeanInfo(sourceClass, currentBundle.get());
         }
 
-        Set dependencies = new LinkedHashSet();
-        Map attributes = new LinkedHashMap();
-        Map references = new LinkedHashMap();
+        Set<ReferencePatterns> dependencies = new LinkedHashSet<ReferencePatterns>();
+        Map<String, Object> attributes = new LinkedHashMap<String, Object>();
+        Map<String, ReferencePatterns> references = new LinkedHashMap<String, ReferencePatterns>();
         while (reader.hasMoreChildren()) {
             reader.moveDown();
 
@@ -184,16 +186,14 @@
 
         GBeanData gbeanData = new GBeanData(abstractName, gbeanInfo);
         gbeanData.setDependencies(dependencies);
-        for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String attributeName = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+            String attributeName = entry.getKey();
             Object attributeValue = entry.getValue();
             gbeanData.setAttribute(attributeName, attributeValue);
         }
-        for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String referenceName = (String) entry.getKey();
-            ReferencePatterns referencePatterns = (ReferencePatterns) entry.getValue();
+        for (Map.Entry <String, ReferencePatterns> entry : references.entrySet()) {
+            String referenceName = entry.getKey();
+            ReferencePatterns referencePatterns = entry.getValue();
             gbeanData.setReferencePatterns(referenceName, referencePatterns);
         }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java Sat Aug 29 00:51:12 2009
@@ -39,6 +39,7 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -72,11 +73,11 @@
         return gbeanState;
     }
 
-    public List<GBeanData> getGBeans(ClassLoader classLoader) throws InvalidConfigException {
+    public List<GBeanData> getGBeans(Bundle bundle) throws InvalidConfigException {
         if (gbeanState == null) {
             return Collections.unmodifiableList(gbeans);
         }
-        gbeans.addAll(XStreamGBeanState.loadGBeans(gbeanState, classLoader));
+        gbeans.addAll(XStreamGBeanState.loadGBeans(gbeanState, bundle));
         return Collections.unmodifiableList(gbeans);
     }
 
@@ -115,16 +116,17 @@
         return gBeanData;
     }
 
-    private static List<GBeanData> loadGBeans(Element element, ClassLoader classLoader) throws InvalidConfigException {
+    private static List<GBeanData> loadGBeans(Element element, Bundle bundle) throws InvalidConfigException {
         if (element != null) {
             // Set the thread context classloader so deserializing classes can grab the cl from the thread
             ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
             try {
-                Thread.currentThread().setContextClassLoader(classLoader);
+//                Thread.currentThread().setContextClassLoader(bundle);
 
                 DomReader reader = new DomReader(element);
                 XStream xstream = XStreamUtil.createXStream();
-                xstream.setClassLoader(classLoader);
+                //TODO Obviously, totally broken
+//                xstream.setClassLoader(bundle);
                 Object o = xstream.unmarshal(reader);
                 GBeanData[] gbeanDatas = (GBeanData[]) o;
                 return Arrays.asList(gbeanDatas);

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/lifecycle/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/management/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java?rev=809078&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java Sat Aug 29 00:51:12 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.geronimo.kernel.osgi;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BundleClassLoader extends ClassLoader {
+
+    private final Bundle bundle;
+
+    public BundleClassLoader(Bundle bundle) {
+        this.bundle = bundle;
+    }
+
+
+    @Override
+    public Class<?> loadClass(String s) throws ClassNotFoundException {
+        return bundle.loadClass(s);
+    }
+    
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleClassLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java?rev=809078&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java Sat Aug 29 00:51:12 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.kernel.osgi;
+
+import java.net.URL;
+import java.io.InputStream;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationActivator implements BundleActivator {
+    
+    private Artifact id;
+
+
+    public void start(BundleContext bundleContext) throws Exception {
+        ServiceReference kernelReference = bundleContext.getServiceReference(Kernel.class.getName());
+        Kernel kernel = (Kernel) bundleContext.getService(kernelReference);
+        ConfigurationManager manager = ConfigurationUtil.getConfigurationManager(kernel);
+        Bundle bundle = bundleContext.getBundle();
+        URL plan = bundle.getEntry("META-INF/config.ser");
+        InputStream in = plan.openStream();
+        try {
+            //TODO there are additional consistency checks in RepositoryConfigurationStore that we should use.
+            ConfigurationData data = ConfigurationUtil.readConfigurationData(in);
+            data.setBundleContext(bundleContext);
+            manager.loadConfiguration(data);
+            id = data.getId();
+//            manager.startConfiguration(id);
+        } finally {
+            in.close();
+        }
+    }
+
+    public void stop(BundleContext bundleContext) throws Exception {
+        ServiceReference kernelReference = bundleContext.getServiceReference(Kernel.class.getName());
+        Kernel kernel = (Kernel) bundleContext.getService(kernelReference);
+        ConfigurationManager manager = ConfigurationUtil.getConfigurationManager(kernel);
+        manager.unloadConfiguration(id);
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ConfigurationActivator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java?rev=809078&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java Sat Aug 29 00:51:12 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.geronimo.kernel.osgi;
+
+import java.util.Dictionary;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class KernelActivator implements BundleActivator {
+
+    private ServiceRegistration kernelRegistration;
+
+    public void start(BundleContext bundleContext) throws Exception {
+        Kernel kernel = KernelFactory.newInstance(bundleContext).createKernel("geronimo");
+        kernel.boot();
+        Dictionary dictionary = null;//new Hashtable();
+        kernelRegistration = bundleContext.registerService(Kernel.class.getName(), kernel, dictionary);
+    }
+
+    public void stop(BundleContext bundleContext) throws Exception {
+        kernelRegistration.unregister();
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/proxy/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/registry/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -0,0 +1,9 @@
+.*
+*.iws
+*.ipr
+*.iml
+*.log
+junit*.properties
+maven-eclipse.xml
+target
+bin



Mime
View raw message