geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r809078 [6/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/gbean/BasicGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java Sat Aug 29 00:51:12 2009
@@ -21,6 +21,7 @@
 
 import java.lang.reflect.Method;
 
+import org.osgi.framework.Bundle;
 
 
 /**
@@ -29,14 +30,53 @@
  */
 public class BasicGBeanInfoFactory implements GBeanInfoFactory {
 
+    /**
+     * try not to use this one, it requires the *GBean class to be in the same classloader as the * class.
+     * @param clazz
+     * @return
+     * @throws GBeanInfoFactoryException
+     */
     public GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException {
-        return getGBeanInfo(clazz.getName(), clazz.getClassLoader());
+        Method method;
+        try {
+            method = clazz.getDeclaredMethod("getGBeanInfo", new Class[]{});
+        } catch (NoSuchMethodException e) {
+            try {
+                // try to get the info from ${className}GBean
+                clazz = clazz.getClassLoader().loadClass(clazz.getName() + "GBean");
+                method = clazz.getDeclaredMethod("getGBeanInfo", new Class[]{});
+            } catch (Exception ignored) {
+                throw new GBeanInfoFactoryException("Class does not have a getGBeanInfo() method: " + clazz.getName());
+            }
+        } catch (NoClassDefFoundError e) {
+            String message = e.getMessage();
+            StringBuffer buf = new StringBuffer("Could not load gbean class ").append(clazz.getName()).append(" due to NoClassDefFoundError\n");
+            if (message != null) {
+                message = message.replace('/', '.');
+                buf.append("    problematic class ").append(message);
+                try {
+                    Class hardToLoad = clazz.getClassLoader().loadClass(message);
+                    buf.append(" can be loaded in supplied classloader ").append(clazz.getClassLoader()).append("\n");
+                    buf.append("    and is found in ").append(hardToLoad.getClassLoader());
+                } catch (ClassNotFoundException e1) {
+                    buf.append(" cannot be loaded in supplied classloader ").append(clazz.getClassLoader()).append("\n");
+                }
+            }
+            throw new GBeanInfoFactoryException(buf.toString(), e);
+        }
+        try {
+            return (GBeanInfo) method.invoke(null, new Object[]{});
+        } catch (Exception e) {
+            throw new GBeanInfoFactoryException("Could not get GBeanInfo from class: " + clazz.getName(), e);
+        } catch (NoClassDefFoundError e) {
+            throw new GBeanInfoFactoryException("Could not get GBeanInfo from class: " + clazz.getName(), e);
+        }
     }
 
-    public GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException {
+    public GBeanInfo getGBeanInfo(String className, Bundle bundle) throws GBeanInfoFactoryException {
         Class clazz;
         try {
-            clazz = classLoader.loadClass(className);
+            clazz = bundle.loadClass(className);
         } catch (ClassNotFoundException e) {
             throw new GBeanInfoFactoryException("Could not load class " + className, e);
         } catch (NoClassDefFoundError e) {
@@ -48,7 +88,7 @@
         } catch (NoSuchMethodException e) {
             try {
                 // try to get the info from ${className}GBean
-                clazz = classLoader.loadClass(className + "GBean");
+                clazz = bundle.loadClass(className + "GBean");
                 method = clazz.getDeclaredMethod("getGBeanInfo", new Class[]{});
             } catch (Exception ignored) {
                 throw new GBeanInfoFactoryException("Class does not have a getGBeanInfo() method: " + className);
@@ -60,11 +100,11 @@
                 message = message.replace('/', '.');
                 buf.append("    problematic class ").append(message);
                 try {
-                    Class hardToLoad = classLoader.loadClass(message);
-                    buf.append(" can be loaded in supplied classloader ").append(classLoader).append("\n");
+                    Class hardToLoad = bundle.loadClass(message);
+                    buf.append(" can be loaded in supplied classloader ").append(bundle).append("\n");
                     buf.append("    and is found in ").append(hardToLoad.getClassLoader());
                 } catch (ClassNotFoundException e1) {
-                    buf.append(" cannot be loaded in supplied classloader ").append(classLoader).append("\n");
+                    buf.append(" cannot be loaded in supplied classloader ").append(bundle).append("\n");
                 }
             }
             throw new GBeanInfoFactoryException(buf.toString(), e);

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java Sat Aug 29 00:51:12 2009
@@ -17,12 +17,18 @@
 
 package org.apache.geronimo.gbean;
 
+import org.apache.geronimo.gbean.annotation.EncryptionSetting;
+
 /**
  * Describes an attibute of a GBean.
  * 
  * @version $Rev$ $Date$
  */
 public class DynamicGAttributeInfo extends GAttributeInfo {
+    public DynamicGAttributeInfo(String name, String type, boolean persistent, boolean manageable, EncryptionSetting encrypted, boolean readable, boolean writable) {
+        super(name, type, persistent, manageable, encrypted, readable, writable, null, null);
+    }
+    
     public DynamicGAttributeInfo(String name, String type, boolean persistent, boolean manageable, boolean readable, boolean writable) {
         super(name, type, persistent, manageable, readable, writable, null, null);
     }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java Sat Aug 29 00:51:12 2009
@@ -17,11 +17,11 @@
 
 package org.apache.geronimo.gbean;
 
-import java.io.Serializable;
-import java.util.Arrays;
-
+import org.apache.geronimo.gbean.annotation.EncryptionSetting;
 import org.apache.geronimo.kernel.KernelRegistry;
 
+import java.io.Serializable;
+
 /**
  * Describes an attibute of a GBean.
  *
@@ -51,6 +51,11 @@
     private final boolean manageable;
 
     /**
+     * Does this attribute need to be encrypted when persisted?
+     */
+    private final EncryptionSetting encrypted;
+
+    /**
      * Is this attribute readable?
      */
     private final boolean readable;
@@ -77,11 +82,34 @@
     }
 
     public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, boolean readable, boolean writable, String getterName, String setterName) {
+        this(name, type, persistent, manageable, EncryptionSetting.defaultEncryption(name, type), readable, writable, getterName,
+                setterName);
+    }
+
+    public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, boolean encrypted, String getterName, String setterName) {
+        this(name, type, persistent, manageable, encrypted ? EncryptionSetting.ENCRYPTED : EncryptionSetting.PLAINTEXT, getterName != null, setterName != null, getterName,
+                setterName);
+    }
+
+    public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, EncryptionSetting encrypted, String getterName, String setterName) {
+        this(name, type, persistent, manageable, encrypted, getterName != null, setterName != null, getterName,
+                setterName);
+    }
+
+    public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, EncryptionSetting encrypted, boolean readable, boolean writable, String getterName, String setterName) {
+        if (encrypted == null) throw new NullPointerException("enctryption must be specified");
+        if (encrypted == EncryptionSetting.ENCRYPTED && !"java.lang.String".equals(type)) {
+            throw new IllegalArgumentException("Only attributes of String type can be encrypted.");
+        }
+        if (encrypted == EncryptionSetting.DEFAULT) {
+            encrypted = EncryptionSetting.defaultEncryption(name, type);
+        }
         this.name = name;
         this.type = type;
         this.persistent = persistent;
         //non persistent attributes cannot be manageable
         this.manageable = manageable & persistent;
+        this.encrypted = encrypted;
         this.readable = readable;
         this.writable = writable;
         this.getterName = getterName;
@@ -104,6 +132,14 @@
         return manageable;
     }
 
+    public boolean isEncrypted() {
+        return encrypted == EncryptionSetting.ENCRYPTED;
+    }
+
+    public EncryptionSetting getEncryptedSetting() {
+        return encrypted;
+    }
+
     public boolean isReadable() {
         return readable;
     }
@@ -122,44 +158,48 @@
 
     public String toString() {
         return "[GAttributeInfo: name=" + name +
-                 " type=" + type +
-                 " persistent=" + persistent +
-                 " manageable=" + manageable +
-                 " readable=" + readable +
-                 " writable=" + writable +
-                 " getterName=" + getterName +
-                 " setterName=" + setterName +
-                 "]";
+                " type=" + type +
+                " persistent=" + persistent +
+                " manageable=" + manageable +
+                " encrypted=" + encrypted +
+                " readable=" + readable +
+                " writable=" + writable +
+                " getterName=" + getterName +
+                " setterName=" + setterName +
+                "]";
     }
 
     public String toXML(AbstractName abstractName) {
         StringBuilder xml = new StringBuilder();
 
         xml.append("<gAttributeInfo ");
-        xml.append("name='" + name + "' ");
-        xml.append("type='" + type + "' ");
-        xml.append("persistent='" + persistent + "' ");
-        xml.append("manageable='" + manageable + "' ");
-        xml.append("readable='" + readable + "' ");
-        xml.append("writable='" + writable + "' ");
+        xml.append("name='").append(name).append("' ");
+        xml.append("type='").append(type).append("' ");
+        xml.append("persistent='").append(persistent).append("' ");
+        xml.append("manageable='").append(manageable).append("' ");
+        xml.append("encrypted='").append(encrypted).append("' ");
+        xml.append("readable='").append(readable).append("' ");
+        xml.append("writable='").append(writable).append("' ");
         xml.append(">");
 
-        xml.append("<getterName>" + getterName + "</getterName>");
-        xml.append("<setterName>" + setterName + "</setterName>");
+        xml.append("<getterName>").append(getterName).append("</getterName>");
+        xml.append("<setterName>").append(setterName).append("</setterName>");
 
         if (readable) {
             try {
                 Object value = KernelRegistry.getSingleKernel().getAttribute(abstractName, name);
                 if (value != null) {
                     if (value instanceof String[]) {
-                        for (String valueString : Arrays.asList((String[]) value))
-                            xml.append("<value>" + valueString + "</value>");
+                        for (String valueString : (String[])value) {
+                            xml.append("<value>").append(valueString).append("</value>");
+                        }
                     } else {
-                        xml.append("<value>" + value + "</value>");
+                        value = encrypted.encrypt((String) value);
+                        xml.append("<value>").append(value).append("</value>");
                     }
                 }
             } catch (Exception e) {
-
+                xml.append("<value>[could not be determined:").append(e.getMessage()).append("]</value>");
             }
         }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java Sat Aug 29 00:51:12 2009
@@ -27,6 +27,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.geronimo.gbean.annotation.EncryptionSetting;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -131,8 +133,19 @@
     public Object getAttribute(String name) {
         return attributes.get(name);
     }
+    
+    private EncryptionSetting isEncrypted(String attrName) {
+        if (gbeanInfo != null) {
+            GAttributeInfo attr = gbeanInfo.getAttribute(attrName);
+            if (attr != null) {
+                return attr.getEncryptedSetting();
+            }
+        }
+        return EncryptionSetting.PLAINTEXT;
+    }
 
     public void setAttribute(String name, Object value) {
+        value = isEncrypted(name). decrypt(value);
         attributes.put(name, value);
     }
 
@@ -228,6 +241,7 @@
         for (Map.Entry<String, Object> entry : attributes.entrySet()) {
             String name = entry.getKey();
             Object value = entry.getValue();
+            value = isEncrypted(name).encrypt(value);
             try {
                 out.writeObject(name);
                 out.writeObject(value);
@@ -377,3 +391,4 @@
 
 }
 
+

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java Sat Aug 29 00:51:12 2009
@@ -32,6 +32,7 @@
 import java.util.Set;
 
 import org.apache.geronimo.kernel.management.NotificationType;
+import org.osgi.framework.Bundle;
 
 /**
  * Describes a GBean.  This class should never be constructed directly.  Insted use GBeanInfoBuilder.
@@ -50,15 +51,15 @@
      * Static helper to try to get the GBeanInfo from the class supplied.
      *
      * @param className   name of the class to get the GBeanInfo from
-     * @param classLoader the class loader use to load the specifiec class
+     * @param bundle the bundle used to load the specifiec class
      * @return GBeanInfo generated by supplied class
      * @throws InvalidConfigurationException
      *          if there is a problem getting the GBeanInfo from the class
      */
-    public static GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws InvalidConfigurationException {
+    public static GBeanInfo getGBeanInfo(String className, Bundle bundle) throws InvalidConfigurationException {
         GBeanInfoFactory infoFactory = new MultiGBeanInfoFactory();
         try {
-            return infoFactory.getGBeanInfo(className, classLoader);
+            return infoFactory.getGBeanInfo(className, bundle);
         } catch (GBeanInfoFactoryException e) {
             throw new InvalidConfigurationException("See nested", e);
         }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java Sat Aug 29 00:51:12 2009
@@ -30,6 +30,8 @@
 
 import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.kernel.Kernel;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
@@ -120,11 +122,11 @@
 
     private final Class gbeanType;
 
-    private final Map attributes = new HashMap();
+    private final Map<String, GAttributeInfo> attributes = new HashMap<String, GAttributeInfo>();
 
     private GConstructorInfo constructor = new GConstructorInfo();
 
-    private final Map operations = new HashMap();
+    private final Map<GOperationSignature, GOperationInfo> operations = new HashMap<GOperationSignature, GOperationInfo>();
 
     private final Map references = new HashMap();
 
@@ -156,14 +158,6 @@
         this(checkNotNull(gbeanType).getName(), gbeanType, source, j2eeType);
     }
 
-    //TODO remove this
-    /**
-     * @deprecated This will be removed in a future release
-     */
-    public GBeanInfoBuilder(String name, ClassLoader classLoader) {
-        this(checkNotNull(name), loadClass(classLoader, name), GBeanInfo.getGBeanInfo(name, classLoader));
-    }
-
     public GBeanInfoBuilder(String name, Class gbeanType, GBeanInfo source) {
         this(name, gbeanType, source, null);
     }
@@ -233,11 +227,12 @@
                     // magic attributes can't be persistent
                     continue;
                 }
-                attributes.put(attributeName,
+                attributes.put(attributeName,   
                         new GAttributeInfo(attributeName,
-                                attribute.getType(),
+                                attribute.getType(), 
                                 true,
                                 attribute.isManageable(),
+                                attribute.getEncryptedSetting(),
                                 attribute.getGetterName(),
                                 attribute.getSetterName()));
             } else {
@@ -245,6 +240,10 @@
                     addAttribute("kernel", Kernel.class, false);
                 } else if (attributeName.equals("classLoader")) {
                     addAttribute("classLoader", ClassLoader.class, false);
+                } else if (attributeName.equals("bundle")) {
+                    addAttribute("bundle", Bundle.class, false);
+                } else if (attributeName.equals("bundleContext")) {
+                    addAttribute("bundleContext", BundleContext.class, false);
                 } else if (attributeName.equals("abstractName")) {
                     addAttribute("abstractName", AbstractName.class, false);
                 } else if (attributeName.equals("objectName")) {
@@ -264,6 +263,7 @@
                                 attribute.getType(),
                                 attribute.isPersistent(),
                                 true,
+                                attribute.getEncryptedSetting(),
                                 attribute.getGetterName(),
                                 attribute.getSetterName()));
             }
@@ -275,6 +275,8 @@
         String type = attributeInfo.getType();
         return ("kernel".equals(name) && Kernel.class.getName().equals(type)) ||
                 ("classLoader".equals(name) && ClassLoader.class.getName().equals(type)) ||
+                ("bundle".equals(name) && Bundle.class.getName().equals(type)) ||
+                ("bundleContext".equals(name) && BundleContext.class.getName().equals(type)) ||
                 ("abstractName".equals(name) && AbstractName.class.getName().equals(type)) ||
                 ("objectName".equals(name) && String.class.getName().equals(type));
     }
@@ -322,6 +324,7 @@
                                     attributeType,
                                     attribute.isPersistent() || persistentNames.contains(attributeName),
                                     attribute.isManageable() || manageableNames.contains(attributeName),
+                                    attribute.getEncryptedSetting(),
                                     method.getName(),
                                     attribute.getSetterName()));
                 }
@@ -346,6 +349,7 @@
                                     attributeType,
                                     attribute.isPersistent() || persistentNames.contains(attributeName),
                                     attribute.isManageable() || manageableNames.contains(attributeName),
+                                    attribute.getEncryptedSetting(),
                                     attribute.getGetterName(),
                                     method.getName()));
                 }
@@ -367,7 +371,6 @@
             addInterface(set, cls[i]);
         }
     }
-
     public void addAttribute(String name, Class type, boolean persistent) {
         addAttribute(name, type.getName(), persistent, true);
     }
@@ -386,6 +389,16 @@
         addAttribute(new GAttributeInfo(name, type, persistent, manageable, getter, setter));
     }
 
+    public void addAttribute(String name, Class type, boolean persistent, boolean manageable, boolean encrypted) {
+        addAttribute(name, type.getName(), persistent, manageable, encrypted);
+    }
+
+    public void addAttribute(String name, String type, boolean persistent, boolean manageable, boolean encrypted) {
+        String getter = searchForGetter(name, type, gbeanType);
+        String setter = searchForSetter(name, type, gbeanType);
+        addAttribute(new GAttributeInfo(name, type, persistent, manageable, encrypted, getter, setter));
+    }
+
     public void addAttribute(GAttributeInfo info) {
         attributes.put(info.getName(), info);
     }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java Sat Aug 29 00:51:12 2009
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gbean;
 
+import org.osgi.framework.Bundle;
+
 
 /**
  *
@@ -27,5 +29,5 @@
 public interface GBeanInfoFactory {
     GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException;
     
-    GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException;
+    GBeanInfo getGBeanInfo(String className, Bundle bundle) throws GBeanInfoFactoryException;
 }
\ No newline at end of file

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java Sat Aug 29 00:51:12 2009
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoFactory;
+import org.osgi.framework.Bundle;
 
 
 /**
@@ -58,11 +59,11 @@
         throw new GBeanInfoFactoryException("Cannot create a GBeanInfo for [" + clazz + "], errors: " + errors);
     }
 
-    public GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException {
+    public GBeanInfo getGBeanInfo(String className, Bundle bundle) throws GBeanInfoFactoryException {
         List<GBeanInfoFactoryException> errors = new ArrayList<GBeanInfoFactoryException>(2);
         for (GBeanInfoFactory factory : FACTORIES) {
             try {
-                return factory.getGBeanInfo(className, classLoader);
+                return factory.getGBeanInfo(className, bundle);
             } catch (GBeanInfoFactoryException e) {
                 errors.add(e);
             }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/
------------------------------------------------------------------------------
--- 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/gbean/annotation/AnnotationGBeanInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java Sat Aug 29 00:51:12 2009
@@ -118,7 +118,16 @@
                     String name = attribute.name();
                     boolean persistent = attribute.persistent();
                     boolean manageable = attribute.manageable();
-                    infoBuilder.addAttribute(name, parameterType, persistent, manageable);
+                    if (attribute.encrypted() == EncryptionSetting.ENCRYPTED) {
+                        infoBuilder.addAttribute(name, parameterType,
+                                persistent, manageable, true);
+                    } else if (attribute.encrypted() == EncryptionSetting.PLAINTEXT) {
+                        infoBuilder.addAttribute(name, parameterType,
+                                persistent, manageable, false);
+                    } else {
+                        infoBuilder.addAttribute(name, parameterType,
+                                persistent, manageable);
+                    }
                     cstrNames[index] = name;
                     annotationFound = true;
                     break;
@@ -172,7 +181,13 @@
             Class type = method.getParameterTypes()[0];
             String name = getName(method);
             name = Introspector.decapitalize(name);
-            infoBuilder.addAttribute(name, type, true, persistent.manageable());
+            if (persistent.encrypted() == EncryptionSetting.ENCRYPTED) {
+                infoBuilder.addAttribute(name, type, true, persistent.manageable(), true);
+            } else if (persistent.encrypted() == EncryptionSetting.PLAINTEXT) {
+                infoBuilder.addAttribute(name, type, true, persistent.manageable(), false);
+            } else {
+                infoBuilder.addAttribute(name, type, true, persistent.manageable());
+            }
         }
     }
     

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java Sat Aug 29 00:51:12 2009
@@ -23,8 +23,7 @@
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.GBeanInfoFactoryException;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-
-
+import org.osgi.framework.Bundle;
 
 
 /**
@@ -33,10 +32,10 @@
  */
 public class AnnotationGBeanInfoFactory implements GBeanInfoFactory {
 
-    public GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException {
+    public GBeanInfo getGBeanInfo(String className, Bundle bundle) throws GBeanInfoFactoryException {
         Class clazz;
         try {
-            clazz = classLoader.loadClass(className);
+            clazz = bundle.loadClass(className);
         } catch (ClassNotFoundException e) {
             throw new InvalidConfigurationException("Could not load class " + className, e);
         } catch (NoClassDefFoundError e) {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java Sat Aug 29 00:51:12 2009
@@ -39,4 +39,7 @@
     boolean persistent() default true;
     
     boolean manageable() default true;
+    
+    EncryptionSetting encrypted() default EncryptionSetting.DEFAULT;
+
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java Sat Aug 29 00:51:12 2009
@@ -35,4 +35,5 @@
 @Target(value = {METHOD})
 public @interface Persistent {
     boolean manageable() default true;
+    EncryptionSetting encrypted() default EncryptionSetting.DEFAULT;
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java Sat Aug 29 00:51:12 2009
@@ -27,5 +27,7 @@
     abstractName,
     objectName,
     classLoader,
+    bundle,
+    bundleContext,
     kernel
 }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/jmx/
------------------------------------------------------------------------------
--- 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/gbean/runtime/
------------------------------------------------------------------------------
--- 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/gbean/runtime/GBeanAttribute.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java Sat Aug 29 00:51:12 2009
@@ -17,14 +17,15 @@
 
 package org.apache.geronimo.gbean.runtime;
 
-import java.lang.reflect.Method;
-
 import org.apache.geronimo.gbean.DynamicGAttributeInfo;
 import org.apache.geronimo.gbean.DynamicGBean;
 import org.apache.geronimo.gbean.GAttributeInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.gbean.annotation.EncryptionSetting;
 import org.apache.geronimo.kernel.ClassLoading;
 
+import java.lang.reflect.Method;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -47,6 +48,8 @@
 
     private final boolean manageable;
 
+    private final EncryptionSetting encrypted;
+
     private Object persistentValue;
     /**
      * Is this a special attribute like objectName, classLoader or gbeanContext?
@@ -113,6 +116,9 @@
         // not manageable
         this.manageable = false;
 
+        // special attributes are not encrypted
+        this.encrypted = EncryptionSetting.PLAINTEXT;
+
         // create an attribute info for this gbean
         if (attribute != null) {
             GAttributeInfo attributeInfo = attribute.getAttributeInfo();
@@ -120,6 +126,7 @@
                     this.type.getName(),
                     this.persistent,
                     this.manageable,
+                    this.encrypted,
                     this.readable,
                     this.writable,
                     attributeInfo.getGetterName(),
@@ -129,6 +136,7 @@
                     this.type.getName(),
                     this.persistent,
                     this.manageable,
+                    this.encrypted,
                     this.readable,
                     this.writable,
                     null,
@@ -148,7 +156,6 @@
         this.special = false;
         this.framework = true;
         this.dynamic = false;
-        this.persistentValue = persistentValue;
 
         if (gbeanInstance == null || name == null || type == null) {
             throw new IllegalArgumentException("null param(s) supplied");
@@ -181,6 +188,9 @@
                 this.writable,
                 null,
                 null);
+
+        this.encrypted = attributeInfo.getEncryptedSetting();
+        this.persistentValue = encrypted.decrypt(persistentValue);
     }
 
     public GBeanAttribute(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo) throws InvalidConfigurationException {
@@ -194,12 +204,13 @@
         this.attributeInfo = attributeInfo;
         this.name = attributeInfo.getName();
         try {
-            this.type = ClassLoading.loadClass(attributeInfo.getType(), gbeanInstance.getClassLoader());
+            this.type = ClassLoading.loadClass(attributeInfo.getType(), gbeanInstance.getBundle());
         } catch (ClassNotFoundException e) {
             throw new InvalidConfigurationException("Could not load attribute class: " + attributeInfo.getType(), e);
         }
         this.persistent = attributeInfo.isPersistent();
         this.manageable = attributeInfo.isManageable();
+        this.encrypted = attributeInfo.getEncryptedSetting();
 
         readable = attributeInfo.isReadable();
         writable = attributeInfo.isWritable();
@@ -223,7 +234,7 @@
             if (attributeInfo.getGetterName() != null) {
                 try {
                     String getterName = attributeInfo.getGetterName();
-                    Method getterMethod = gbeanInstance.getType().getMethod(getterName, null);
+                    Method getterMethod = gbeanInstance.getType().getMethod(getterName, (Class[])null);
 
                     if (!getterMethod.getReturnType().equals(type)) {
                         if (getterMethod.getReturnType().getName().equals(type.getName())) {
@@ -248,7 +259,7 @@
             if (attributeInfo.getSetterName() != null) {
                 try {
                     String setterName = attributeInfo.getSetterName();
-                    Method setterMethod = gbeanInstance.getType().getMethod(setterName, new Class[]{type});
+                    Method setterMethod = gbeanInstance.getType().getMethod(setterName, type);
                     if (AbstractGBeanReference.NO_PROXY) {
                         setInvoker = new ReflectionMethodInvoker(setterMethod);
                     } else {
@@ -299,6 +310,14 @@
         return manageable;
     }
 
+    public boolean isEncrypted() {
+        return encrypted == EncryptionSetting.ENCRYPTED;
+    }
+
+    public EncryptionSetting getEncryptionSetting() {
+        return encrypted;
+    }
+
     public boolean isSpecial() {
         return special;
     }
@@ -320,7 +339,7 @@
         }
 
         // @todo actually check type
-        this.persistentValue = persistentValue;
+        this.persistentValue = encrypted.decrypt(persistentValue);
     }
 
     public Object getValue(Object target) throws Exception {
@@ -342,8 +361,7 @@
         }
 
         // call the getter
-        Object value = getInvoker.invoke(target, null);
-        return value;
+        return getInvoker.invoke(target, null);
     }
 
     public void setValue(Object target, Object value) throws Exception {
@@ -368,6 +386,7 @@
         }
 
         // call the setter
+        value = encrypted.decrypt(value);
         setInvoker.invoke(target, new Object[]{value});
     }
 
@@ -399,11 +418,11 @@
             return null;
         }
     }
-    
+
     public void inject(Object target) throws Exception {
         if ((persistent || special) && writable && null != persistentValue) {
             setValue(target, persistentValue);
         }
     }
-    
+
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Sat Aug 29 00:51:12 2009
@@ -50,13 +50,15 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.kernel.config.ManageableAttributeStore;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.management.StateManageable;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.xbean.recipe.ConstructionException;
 import org.apache.xbean.recipe.ObjectRecipe;
-import org.apache.xbean.recipe.Option;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * A GBeanInstance is a J2EE Management Managed Object, and is standard base for Geronimo services.
@@ -158,6 +160,8 @@
      */
     private final ClassLoader classLoader;
 
+    private final BundleContext bundleContext;
+
     /**
      * Metadata describing the attributes, operations and references of this GBean
      */
@@ -208,26 +212,27 @@
     private String stateReason;
 
     /**
-     * Construct a GBeanMBean using the supplied GBeanData and class loader
+     * Construct a GBeanMBean using the supplied GBeanData and bundle
      *
      * @param gbeanData   the data for the new GBean including GBeanInfo, intial attribute values, and reference patterns
-     * @param classLoader the class loader used to load the gbean instance and attribute/reference types
+     * @param bundleContext
      * @throws org.apache.geronimo.gbean.InvalidConfigurationException
      *          if the gbeanInfo is inconsistent with the actual java classes, such as
      *          mismatched attribute types or the intial data cannot be set
      */
-    public GBeanInstance(GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException {
+    public GBeanInstance(GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, BundleContext bundleContext) throws InvalidConfigurationException {
         this.abstractName = gbeanData.getAbstractName();
         this.kernel = kernel;
         this.lifecycleBroadcaster = lifecycleBroadcaster;
         this.gbeanInstanceState = new GBeanInstanceState(abstractName, kernel, dependencyManager, this, lifecycleBroadcaster);
-        this.classLoader = classLoader;
+        this.bundleContext = bundleContext;
+        this.classLoader = new BundleClassLoader(bundleContext.getBundle());
 
         GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
         try {
-            type = classLoader.loadClass(gbeanInfo.getClassName());
+            type = bundleContext.getBundle().loadClass(gbeanInfo.getClassName());
         } catch (ClassNotFoundException e) {
-            throw new InvalidConfigurationException("Could not load GBeanInfo class from classloader: " + classLoader +
+            throw new InvalidConfigurationException("Could not load GBeanInfo class from classloader: " + bundleContext +
                     " className=" + gbeanInfo.getClassName(), e);
         }
 
@@ -278,7 +283,7 @@
             operationIndex.put(entry.getKey(), new Integer(opCounter));
             opCounter++;
         }
-        
+
         // rebuild the gbean info based on the current attributes, operations, and references because
         // the above code add new attributes and operations
         this.gbeanInfo = rebuildGBeanInfo(gbeanInfo.getConstructor(), gbeanInfo.getJ2eeType());
@@ -409,13 +414,12 @@
     }
 
     /**
-     * The class loader used to build this gbean.  This class loader is set into the thread context
-     * class loader before callint the target instace.
+     * The bundle used to build this gbean.  
      *
-     * @return the class loader used to build this gbean
+     * @return the bundle used to build this gbean
      */
-    public ClassLoader getClassLoader() {
-        return classLoader;
+    public Bundle getBundle() {
+        return bundleContext.getBundle();
     }
 
     /**
@@ -760,7 +764,7 @@
         }
         Artifact configName = abstractName.getArtifact();
         if (configName != null) {
-            manageableStore.setValue(configName, abstractName, attribute.getAttributeInfo(), value, classLoader);
+            manageableStore.setValue(configName, abstractName, attribute.getAttributeInfo(), value, getBundle());
         } else {
             log.error("Unable to identify Configuration for GBean " + abstractName + ".  Manageable attribute " + attribute.getName() + " was not updated in persistent store.");
         }
@@ -903,11 +907,12 @@
         }
 
         ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(classLoader);
+//        Thread.currentThread().setContextClassLoader(classLoader);
         Object instance = null;
         try {
             try {
-                instance = objectRecipe.create(classLoader);
+                //TODO OSGI NO!
+                instance = objectRecipe.create(new BundleClassLoader(bundleContext.getBundle()));
             } catch (ConstructionException e) {
                 Throwable targetException = e.getCause();
                 if (targetException instanceof Exception) {
@@ -1103,7 +1108,7 @@
 
         // we notify the bean before removing our reference so the bean can be called back while stopping
         ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(classLoader);
+//        Thread.currentThread().setContextClassLoader(classLoader);
         try {
             if (instance instanceof GBeanLifecycle) {
                 if (stop) {
@@ -1153,28 +1158,41 @@
         //  Special attributes
         //
         attributesMap.put("abstractName",
-                GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("abstractName"),
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("abstractName"),
                         this,
                         "abstractName",
                         AbstractName.class,
                         getAbstractName()));
 
         attributesMap.put("objectName",
-                GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("objectName"),
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("objectName"),
                         this,
                         "objectName",
                         String.class,
                         getObjectName()));
 
         attributesMap.put("classLoader",
-                GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("classLoader"),
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("classLoader"),
                         this,
                         "classLoader",
                         ClassLoader.class,
                         classLoader));
 
+        attributesMap.put("bundle",
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("bundle"),
+                        this,
+                        "bundle",
+                        Bundle.class,
+                        bundleContext.getBundle()));
+        attributesMap.put("bundleContext",
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("bundleContext"),
+                        this,
+                        "bundleContext",
+                        BundleContext.class,
+                        bundleContext));
+
         attributesMap.put("kernel",
-                GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("kernel"),
+                GBeanAttribute.createSpecialAttribute(attributesMap.get("kernel"),
                         this,
                         "kernel",
                         Kernel.class,

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java Sat Aug 29 00:51:12 2009
@@ -28,6 +28,7 @@
 import org.apache.geronimo.gbean.GOperationInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.kernel.ClassLoading;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -63,11 +64,11 @@
         // get an array of the parameter classes
         this.parameterTypes = Collections.unmodifiableList(new ArrayList(operationInfo.getParameterList()));
         Class[] types = new Class[parameterTypes.size()];
-        ClassLoader classLoader = gbeanInstance.getClassLoader();
+        Bundle bundle = gbeanInstance.getBundle();
         for (int i = 0; i < types.length; i++) {
             String type = (String) parameterTypes.get(i);
             try {
-                types[i] = ClassLoading.loadClass((String) parameterTypes.get(i), classLoader);
+                types[i] = ClassLoading.loadClass((String) parameterTypes.get(i), bundle);
             } catch (ClassNotFoundException e) {
                 throw new InvalidConfigurationException("Could not load operation parameter class:" +
                         " name=" + operationInfo.getName() +

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/
------------------------------------------------------------------------------
--- 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/ClassLoading.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ClassLoading.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ClassLoading.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ClassLoading.java Sat Aug 29 00:51:12 2009
@@ -27,6 +27,7 @@
 import java.util.ArrayList;
 
 import org.apache.geronimo.kernel.config.MultiParentClassLoader;
+import org.osgi.framework.Bundle;
 
 /**
  * Utility class for loading classes by a variety of name variations.
@@ -214,6 +215,107 @@
         }
         throw new ClassNotFoundException("Could not load class " + className + " from unknown classloader; " + classLoader);
     }
+    public static Class loadClass(String className, Bundle bundle) throws ClassNotFoundException {
+
+        // the tests require IllegalArgumentExceptions for null values on either of these.
+        if (className == null) {
+            throw new IllegalArgumentException("className is null");
+        }
+
+        if (bundle == null) {
+            throw new IllegalArgumentException("bundle is null");
+        }
+
+        // The second easiest version to resolve is a direct map to a primitive type name
+        // or method signature.  Check our name-to-class map for one of those.
+        Class resolvedClass = (Class) PRIMITIVE_CLASS_MAP.get(className);
+        if (resolvedClass != null) {
+            return resolvedClass;
+        }
+
+        // The easiest case is a proper class name.  We just have the class loader resolve this.
+        // If the class loader throws a ClassNotFoundException, then we need to check each of the
+        // special name encodings we support.
+        try {
+            return bundle.loadClass(className);
+        } catch (ClassNotFoundException ignore) {
+            // if not found, continue on to the other name forms.
+        }
+
+        // Class names in method signature have the format "Lfully.resolved.name;",
+        // so if it ends in a semicolon and begins with an "L", this must be in
+        // this format.  Have the class loader try to load this.  There are no other
+        // options if this fails, so just allow the class loader to throw the
+        // ClassNotFoundException.
+        if (className.endsWith(";") && className.startsWith("L")) {
+            // pick out the name portion
+            String typeName = className.substring(1, className.length() - 1);
+            // and delegate the loading to the class loader.
+            return bundle.loadClass(typeName);
+        }
+
+        // All we have left now are the array types.  Method signature array types
+        // have a series of leading "[" characters to specify the number of dimensions.
+        // The other array type we handle uses trailing "[]" for the dimensions, just
+        // like the Java language syntax.
+
+        // first check for the signature form ([[[[type).
+        if (className.charAt(0) == '[') {
+            // we have at least one array marker, now count how many leading '['s we have
+            // to get the dimension count.
+            int count = 0;
+            int nameLen = className.length();
+
+            while (count < nameLen && className.charAt(count) == '[') {
+                count++;
+            }
+
+            // pull of the name subtype, which is everything after the last '['
+            String arrayTypeName = className.substring(count, className.length());
+            // resolve the type using a recursive call, which will load any of the primitive signature
+            // types as well as class names.
+            Class arrayType = loadClass(arrayTypeName, bundle);
+
+            // Resolving array types require a little more work.  The array classes are
+            // created dynamically when the first instance of a given dimension and type is
+            // created.  We need to create one using reflection to do this.
+            return getArrayClass(arrayType, count);
+        }
+
+
+        // ok, last chance.  Now check for an array specification in Java language
+        // syntax.  This will be a type name followed by pairs of "[]" to indicate
+        // the number of dimensions.
+        if (className.endsWith("[]")) {
+            // get the base component class name and the arrayDimensions
+            int count = 0;
+            int position = className.length();
+
+            while (position > 1 && className.substring(position - 2, position).equals("[]")) {
+                // count this dimension
+                count++;
+                // and step back the probe position.
+                position -= 2;
+            }
+
+            // position now points at the location of the last successful test.  This makes it
+            // easy to pick off the class name.
+
+            String typeName = className.substring(0, position);
+
+            // load the base type, again, doing this recursively
+            Class arrayType = loadClass(typeName, bundle);
+            // and turn this into the class object
+            return getArrayClass(arrayType, count);
+        }
+
+        // We're out of options, just toss an exception over the wall.
+//        if (classLoader instanceof MultiParentClassLoader) {
+//            MultiParentClassLoader cl = (MultiParentClassLoader) classLoader;
+//            throw new ClassNotFoundException("Could not load class " + className + " from classloader: " + cl.getId() + ", destroyed state: " + cl.isDestroyed());
+//        }
+        throw new ClassNotFoundException("Could not load class " + className + " from unknown classloader; " + bundle);
+    }
 
 
     /**

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/Kernel.java Sat Aug 29 00:51:12 2009
@@ -16,18 +16,20 @@
  */
 package org.apache.geronimo.kernel;
 
+import java.util.Collections;
 import java.util.Date;
 import java.util.Set;
-import java.util.Collections;
-import javax.management.ObjectName;
 
+import javax.management.ObjectName;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev:386515 $ $Date$
@@ -75,11 +77,11 @@
      * This is intended for applications that are embedding the kernel.
      *
      * @param gbeanData the GBean to load
-     * @param classLoader the class loader to use to load the gbean
+     * @param bundleContext
      * @throws org.apache.geronimo.kernel.GBeanAlreadyExistsException if the name is already used
      * @throws org.apache.geronimo.kernel.InternalKernelException if there is a problem during registration
      */
-    void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException;
+    void loadGBean(GBeanData gbeanData, BundleContext bundleContext) throws GBeanAlreadyExistsException, InternalKernelException;
 
     /**
      * Is there a GBean registered with the kernel under the specified name?
@@ -194,10 +196,10 @@
      * @return the class loader associated with the specified GBean
      * @throws GBeanNotFoundException if the specified GBean is not registered with the kernel
      */
-    ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException;
-    ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException;
-    ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException;
-    ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException;
+    Bundle getBundleFor(AbstractName name) throws GBeanNotFoundException;
+    Bundle getBundleFor(String shortName) throws GBeanNotFoundException;
+    Bundle getBundleFor(Class type) throws GBeanNotFoundException;
+    Bundle getBundleFor(String shortName, Class type) throws GBeanNotFoundException;
 
     /**
      * Return the GBeanInfo for a registered GBean instance.

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelFactory.java Sat Aug 29 00:51:12 2009
@@ -22,6 +22,7 @@
 import java.io.InputStreamReader;
 
 import org.apache.geronimo.kernel.basic.BasicKernelFactory;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
@@ -29,17 +30,14 @@
 public abstract class KernelFactory {
     public static final String KERNEL_FACTORY_KEY = KernelFactory.class.getName();
 
-    public static KernelFactory newInstance() {
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        if (classLoader == null) {
-            classLoader = KernelFactory.class.getClassLoader();
-        }
+    private BundleContext bundleContext;
 
+    public static KernelFactory newInstance(BundleContext bundleContext) {
         // System property
         try {
             String kernelFactoryName = System.getProperty(KERNEL_FACTORY_KEY);
             if (kernelFactoryName != null) {
-                return createKernelFactory(kernelFactoryName, classLoader);
+                return createKernelFactory(kernelFactoryName, bundleContext);
             }
         } catch (SecurityException se) {
         }
@@ -48,14 +46,14 @@
         String serviceId = "META-INF/services/" + KERNEL_FACTORY_KEY;
         InputStream inputStream = null;
         try {
-            inputStream = classLoader.getResourceAsStream(serviceId);
+            inputStream = bundleContext.getBundle().getResource(serviceId).openStream();
             if (inputStream != null) {
                 BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                 String kernelFactoryName = reader.readLine();
                 reader.close();
 
                 if (kernelFactoryName != null && kernelFactoryName.length() > 0) {
-                    return createKernelFactory(kernelFactoryName, classLoader);
+                    return createKernelFactory(kernelFactoryName, bundleContext);
                 }
             }
         } catch (Exception ignored) {
@@ -70,12 +68,16 @@
         }
 
         // Default is the basic kernel
-        return new BasicKernelFactory();
+        KernelFactory kernelFactory = new BasicKernelFactory();
+        kernelFactory.bundleContext = bundleContext;
+        return kernelFactory;
     }
 
-    private static KernelFactory createKernelFactory(String className, ClassLoader classLoader) {
+    private static KernelFactory createKernelFactory(String className, BundleContext bundleContext) {
         try {
-            return (KernelFactory) classLoader.loadClass(className).newInstance();
+            KernelFactory kernelFactory = (KernelFactory) bundleContext.getBundle().loadClass(className).newInstance();
+            kernelFactory.bundleContext = bundleContext;
+            return kernelFactory;
         } catch (ClassCastException e) {
             throw new KernelFactoryError("Kernel factory class does not implement KernelFactory: " + className, e);
         } catch (ClassNotFoundException e) {
@@ -86,4 +88,8 @@
     }
 
     public abstract Kernel createKernel(String kernelName);
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/KernelGBean.java Sat Aug 29 00:51:12 2009
@@ -27,6 +27,8 @@
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev:386515 $ $Date$
@@ -58,8 +60,8 @@
         return kernel.getProxyManager();
     }
 
-    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
-        kernel.loadGBean(gbeanData, classLoader);
+    public void loadGBean(GBeanData gbeanData, BundleContext bundleContext) throws GBeanAlreadyExistsException, InternalKernelException {
+        kernel.loadGBean(gbeanData, bundleContext);
     }
 
     public boolean isLoaded(AbstractName name) {
@@ -214,20 +216,20 @@
         return kernel.getGBeanStartTime(shortName, type);
     }
 
-    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
-        return kernel.getClassLoaderFor(name);
+    public Bundle getBundleFor(AbstractName name) throws GBeanNotFoundException {
+        return kernel.getBundleFor(name);
     }
 
-    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
-        return kernel.getClassLoaderFor(shortName);
+    public Bundle getBundleFor(String shortName) throws GBeanNotFoundException {
+        return kernel.getBundleFor(shortName);
     }
 
-    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
-        return kernel.getClassLoaderFor(type);
+    public Bundle getBundleFor(Class type) throws GBeanNotFoundException {
+        return kernel.getBundleFor(type);
     }
 
-    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
-        return kernel.getClassLoaderFor(shortName, type);
+    public Bundle getBundleFor(String shortName, Class type) throws GBeanNotFoundException {
+        return kernel.getBundleFor(shortName, type);
     }
 
     public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java Sat Aug 29 00:51:12 2009
@@ -22,36 +22,36 @@
 import java.io.ObjectStreamClass;
 import java.lang.reflect.Proxy;
 
+import org.osgi.framework.Bundle;
+
 /**
  * @version $Rev$ $Date$
  */
 public class ObjectInputStreamExt extends ObjectInputStream {
 
-    private ClassLoader classloader;
+    private Bundle bundle;
 
-    public ObjectInputStreamExt(InputStream in, ClassLoader loader) throws IOException {
+    public ObjectInputStreamExt(InputStream in, Bundle bundle) throws IOException {
         super(in);
-        this.classloader = loader;
+        this.bundle = bundle;
     }
 
     protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
-        return ClassLoading.loadClass(classDesc.getName(), classloader);
+        return ClassLoading.loadClass(classDesc.getName(), bundle);
     }
 
+//see http://www.osgi.org/blog/2008/08/classy-solutions-to-tricky-proxies.html
+    //currently broken
     protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
         Class[] cinterfaces = new Class[interfaces.length];
         for (int i = 0; i < interfaces.length; i++)
-            cinterfaces[i] = classloader.loadClass(interfaces[i]);
+            cinterfaces[i] = bundle.loadClass(interfaces[i]);
 
         try {
-            return Proxy.getProxyClass(classloader, cinterfaces);
+            return Proxy.getProxyClass(null, cinterfaces);
         } catch (IllegalArgumentException e) {
             throw new ClassNotFoundException(null, e);
         }
     }
 
-    ClassLoader getClassloader() {
-        return classloader;
-    }
-
 }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/
------------------------------------------------------------------------------
--- 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/basic/BasicKernel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernel.java Sat Aug 29 00:51:12 2009
@@ -19,7 +19,6 @@
 
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Set;
 import javax.management.ObjectName;
@@ -46,6 +45,8 @@
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 
 /**
@@ -84,6 +85,8 @@
      */
     private final String kernelName;
 
+    private BundleContext bundleContext;
+
     /**
      * Is this kernel running?
      */
@@ -126,12 +129,17 @@
      * Construct a Kernel with the specified name.
      *
      * @param kernelName the name of the kernel
+     * @param bundleContext
      */
-    public BasicKernel(String kernelName) {
+    public BasicKernel(String kernelName, BundleContext bundleContext) {
         if (kernelName.indexOf(':') >= 0 || kernelName.indexOf('*') >= 0 || kernelName.indexOf('?') >= 0) {
             throw new IllegalArgumentException("Kernel name may not contain a ':', '*' or '?' character");
         }
+        if (bundleContext == null) {
+            throw new NullPointerException("bundleContext required");
+        }
         this.kernelName = kernelName;
+        this.bundleContext = bundleContext;
         this.registry = new BasicRegistry();
     }
 
@@ -345,11 +353,11 @@
         return gbeanInstance.getGBeanData();
     }
 
-    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
+    public void loadGBean(GBeanData gbeanData, BundleContext bundleContext) throws GBeanAlreadyExistsException, InternalKernelException {
         AbstractName abstractName = gbeanData.getAbstractName();
         Set interfaces = gbeanData.getGBeanInfo().getInterfaces();
         LifecycleBroadcaster lifecycleBroadcaster = lifecycleMonitor.createLifecycleBroadcaster(abstractName, interfaces);
-        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleBroadcaster, classLoader);
+        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleBroadcaster, bundleContext);
         registry.register(gbeanInstance);
         lifecycleBroadcaster.fireLoadedEvent();        
     }
@@ -600,7 +608,7 @@
 
         // load and start the kernel gbean
         GBeanData kernelGBeanData = new GBeanData(KERNEL_NAME, KernelGBean.GBEAN_INFO);
-        loadGBean(kernelGBeanData, getClass().getClassLoader());
+        loadGBean(kernelGBeanData, bundleContext);
         startGBean(KERNEL_NAME);
 
         running = true;
@@ -669,22 +677,22 @@
         return running;
     }
 
-    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
+    public Bundle getBundleFor(AbstractName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(name);
-        return gbeanInstance.getClassLoader();
+        return gbeanInstance.getBundle();
     }
 
-    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
-        return getClassLoaderFor(shortName, null);
+    public Bundle getBundleFor(String shortName) throws GBeanNotFoundException {
+        return getBundleFor(shortName, null);
     }
 
-    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
-        return getClassLoaderFor(null, type);
+    public Bundle getBundleFor(Class type) throws GBeanNotFoundException {
+        return getBundleFor(null, type);
     }
 
-    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
+    public Bundle getBundleFor(String shortName, Class type) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
-        return gbeanInstance.getClassLoader();
+        return gbeanInstance.getBundle();
     }
 
     /**

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicKernelFactory.java Sat Aug 29 00:51:12 2009
@@ -24,6 +24,6 @@
  */
 public class BasicKernelFactory extends KernelFactory {
     public Kernel createKernel(String kernelName) {
-        return new BasicKernel(kernelName);
+        return new BasicKernel(kernelName, getBundleContext());
     }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java Sat Aug 29 00:51:12 2009
@@ -85,9 +85,10 @@
         try {
             // if the type is visible from the target's classloader use it
             // otherwise use the type's classloader
-            ClassLoader classLoader;
+            //TODO OSGI BUSTED
+            ClassLoader classLoader = null;
             try {
-                classLoader = kernel.getClassLoaderFor(target);
+//                classLoader = kernel.getBundlerFor(target);
                 if (!type.equals(ClassLoading.loadClass(type.getName(), classLoader))) {
                     classLoader = type.getClassLoader();
                 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java Sat Aug 29 00:51:12 2009
@@ -107,17 +107,17 @@
 
         // handle equals, hashCode and toString directly here
         try {
-            invokers[getSuperIndex(proxyType, proxyType.getMethod("equals", new Class[]{Object.class}))] = new EqualsInvoke(kernel);
-            invokers[getSuperIndex(proxyType, proxyType.getMethod("hashCode", null))] = new HashCodeInvoke();
-            invokers[getSuperIndex(proxyType, proxyType.getMethod("toString", null))] = new ToStringInvoke(proxyType.getName());
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("equals", Object.class))] = new EqualsInvoke(kernel);
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("hashCode", (Class[])null))] = new HashCodeInvoke();
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("toString", (Class[])null))] = new ToStringInvoke(proxyType.getName());
             if(GeronimoManagedBean.class.isAssignableFrom(proxyType)) {
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("getState", null))] = new GetStateInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("getStateInstance", null))] = new GetStateInstanceInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("start", null))] = new StartInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("startRecursive", null))] = new StartRecursiveInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("stop", null))] = new StopInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("getStartTime", null))] = new GetStartTimeInvoke(kernel);
-                invokers[getSuperIndex(proxyType, proxyType.getMethod("getObjectName", null))] = new GetObjectNameInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("getState", (Class[])null))] = new GetStateInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("getStateInstance",(Class[]) null))] = new GetStateInstanceInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("start", (Class[])null))] = new StartInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("startRecursive", (Class[])null))] = new StartRecursiveInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("stop", (Class[])null))] = new StopInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("getStartTime", (Class[])null))] = new GetStartTimeInvoke(kernel);
+                invokers[getSuperIndex(proxyType, proxyType.getMethod("getObjectName", (Class[])null))] = new GetObjectNameInvoke(kernel);
             }
         } catch (Exception e) {
             // this can not happen... all classes must implement equals, hashCode and toString

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/
------------------------------------------------------------------------------
--- 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/classloader/DirectoryResourceHandle.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceHandle.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceHandle.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceHandle.java Sat Aug 29 00:51:12 2009
@@ -39,9 +39,9 @@
     public DirectoryResourceHandle(String name, File file, File codeSource, Manifest manifest) throws MalformedURLException {
         this.name = name;
         this.file = file;
-        this.codeSource = codeSource.toURL();
+        this.codeSource = codeSource.toURI().toURL();
         this.manifest = manifest;
-        url = file.toURL();
+        url = file.toURI().toURL();
     }
 
     public String getName() {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceLocation.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceLocation.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceLocation.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/DirectoryResourceLocation.java Sat Aug 29 00:51:12 2009
@@ -31,7 +31,7 @@
     private Manifest manifest;
 
     public DirectoryResourceLocation(File baseDir) throws MalformedURLException {
-        super(baseDir.toURL());
+        super(baseDir.toURI().toURL());
         this.baseDir = baseDir;
     }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlConnection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlConnection.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlConnection.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlConnection.java Sat Aug 29 00:51:12 2009
@@ -63,7 +63,7 @@
         this.url = url;
         this.jarFile = jarFile;
         this.jarEntry = jarEntry;
-        jarFileUrl = new File(jarFile.getName()).toURL();
+        jarFileUrl = new File(jarFile.getName()).toURI().toURL();
     }
 
     public JarFile getJarFile() throws IOException {
@@ -122,7 +122,7 @@
     }
 
     public Permission getPermission() throws IOException {
-        URL jarFileUrl = new File(jarFile.getName()).toURL();
+        URL jarFileUrl = new File(jarFile.getName()).toURI().toURL();
         return jarFileUrl.openConnection().getPermission();
     }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlStreamHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlStreamHandler.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlStreamHandler.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/JarFileUrlStreamHandler.java Sat Aug 29 00:51:12 2009
@@ -31,7 +31,7 @@
  */
 public class JarFileUrlStreamHandler extends URLStreamHandler {
     public static URL createUrl(JarFile jarFile, JarEntry jarEntry) throws MalformedURLException {
-        return createUrl(jarFile, jarEntry, new File(jarFile.getName()).toURL());
+        return createUrl(jarFile, jarEntry, new File(jarFile.getName()).toURI().toURL());
     }
 
     public static URL createUrl(JarFile jarFile, JarEntry jarEntry, URL codeSource) throws MalformedURLException {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java Sat Aug 29 00:51:12 2009
@@ -101,7 +101,7 @@
 
        // Annotation classes must be loaded by the normal classloader
        if (isAnnotationClass(bytes)) {
-           return Class.forName(name, resolve, getClass().getClassLoader());
+           return super.loadClass(name, resolve);
        }
 
        // define the package

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/UrlResourceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/UrlResourceFinder.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/UrlResourceFinder.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/UrlResourceFinder.java Sat Aug 29 00:51:12 2009
@@ -203,7 +203,7 @@
                     } catch (UnsupportedOperationException ex) {
                         // the protocol for the JAR file's URL is not supported.  This can occur when
                         // the jar file is embedded in an EAR or CAR file.  Proceed but log the message.
-                        log.error("The protocol for the JAR file's URL is not supported", ex);
+                        log.debug("The protocol for the JAR file's URL is not supported", ex);
                         continue;
                     }
                 }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/
------------------------------------------------------------------------------
--- 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