geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r809078 [11/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/or...
Date Sat, 29 Aug 2009 00:51:37 GMT
Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeEditorTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeEditorTest.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeEditorTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeEditorTest.java Sat Aug 29 00:51:12 2009
@@ -19,11 +19,17 @@
 
 package org.apache.geronimo.deployment.service;
 
+import java.util.HashMap;
+
 import org.apache.geronimo.deployment.javabean.xbeans.BeanPropertyType;
 import org.apache.geronimo.deployment.javabean.xbeans.JavabeanType;
 import org.apache.geronimo.deployment.javabean.xbeans.PropertyType;
 import org.apache.geronimo.crypto.Encryption;
 import org.apache.geronimo.crypto.EncryptionManager;
+import org.apache.geronimo.kernel.osgi.MockBundleContext;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.osgi.framework.BundleContext;
 
 import com.agical.rmock.extension.junit.RMockTestCase;
 
@@ -33,11 +39,12 @@
  */
 public class JavaBeanXmlAttributeEditorTest extends RMockTestCase {
 
+    private BundleContext bundleContext = new MockBundleContext(getClass().getClassLoader(), "", new HashMap<Artifact, ConfigurationData>(), null);
     private JavaBeanXmlAttributeEditor editor;
 
     @Override
     protected void setUp() throws Exception {
-        editor = new JavaBeanXmlAttributeEditor(DummyJavaBean.class);
+        editor = new JavaBeanXmlAttributeEditor(DummyJavaBean.class, bundleContext.getBundle());
     }
     
     public void testPrimitives() throws Exception {
@@ -102,7 +109,7 @@
         String prefix = "{Mock}";
         EncryptionManager.setEncryptionPrefix(prefix, encryption);
         
-        JavaBeanXmlAttributeEditor editor = new JavaBeanXmlAttributeEditor(DummyJavaBean.class);
+        JavaBeanXmlAttributeEditor editor = new JavaBeanXmlAttributeEditor(DummyJavaBean.class, bundleContext.getBundle());
 
         DummyJavaBean bean = new DummyJavaBean();
         bean.setEncryptOnPersist("encryptOnPersist");

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/java/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java Sat Aug 29 00:51:12 2009
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Set;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.jar.JarFile;
@@ -41,9 +40,11 @@
 import org.apache.geronimo.gbean.ReferenceCollectionListener;
 import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.osgi.MockBundleContext;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.mock.MockRepository;
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
@@ -53,12 +54,16 @@
 import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ServiceConfigBuilderTest extends TestCase {
 
+    private Map<String, Artifact> locations = new HashMap<String, Artifact>();
+    private MockBundleContext bundleContext = new MockBundleContext(getClass().getClassLoader(), "", new HashMap<Artifact, ConfigurationData>(), locations);
+
     private Environment parentEnvironment = new Environment();
 
     public void testNonService() throws Exception {
@@ -66,7 +71,7 @@
         File file = new File(url.getPath());
         JarFile jar = new JarFile(file);
         assertTrue(file.exists());
-        ServiceConfigBuilder builder = new ServiceConfigBuilder(parentEnvironment, null, new Jsr77Naming());
+        ServiceConfigBuilder builder = new ServiceConfigBuilder(parentEnvironment, null, new Jsr77Naming(), bundleContext);
         assertNull(builder.getDeploymentPlan(null, jar, new ModuleIDBuilder()));
         jar.close();
     }
@@ -93,6 +98,7 @@
             Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment());
             Map<Artifact, File> repo = new HashMap<Artifact, File>();
             File file = new File(plan1.getFile());
+            locations.put(file.getAbsolutePath(), environment.getConfigId());
             repo.put(Artifact.create("geronimo/foo1/DEV/jar"), file);
             repo.put(Artifact.create("geronimo/foo2/DEV/jar"), file);
             repo.put(Artifact.create("geronimo/foo3/DEV/car"), file);
@@ -101,9 +107,10 @@
             ListableRepository mockRepository = new MockRepository(repo);
             ArtifactManager artifactManager = new DefaultArtifactManager();
             ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, mockRepository);
-            ConfigurationManager configurationManager = new SimpleConfigurationManager(Collections.EMPTY_SET, artifactResolver, Collections.EMPTY_SET);
+            ConfigurationManager configurationManager = new SimpleConfigurationManager(Collections.EMPTY_SET, artifactResolver, Collections.EMPTY_SET, bundleContext);
+            bundleContext.setConfigurationManager(configurationManager);
             AbstractName moduleName = naming.createRootName(environment.getConfigId(), "foo", "bar");
-            DeploymentContext context = new DeploymentContext(outFile, null, environment, moduleName, ConfigurationModuleType.CAR, naming, configurationManager, Collections.<Repository>singleton(mockRepository));
+            DeploymentContext context = new DeploymentContext(outFile, null, environment, moduleName, ConfigurationModuleType.CAR, naming, configurationManager, Collections.<Repository>singleton(mockRepository), bundleContext);
             context.initializeConfiguration();
             gbeanBuilder.build(plan, context, context);
             Set gbeanNames = context.getGBeanNames();

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-service-builder/src/test/resources/
------------------------------------------------------------------------------
--- 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-service-builder/src/test/resources/services/
------------------------------------------------------------------------------
--- 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-service-builder/src/test/resources/services/service3/
------------------------------------------------------------------------------
--- 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-service-builder/src/test/resources/services/service3/META-INF/
------------------------------------------------------------------------------
--- 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-service-builder/src/test/resources/services/service3/classes/
------------------------------------------------------------------------------
--- 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-system/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Aug 29 00:51:12 2009
@@ -1,10 +1,9 @@
+.*
 *.iws
 *.ipr
 *.iml
-.classpath
-.project
-.settings
 *.log
 junit*.properties
+maven-eclipse.xml
 target
 bin

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/pom.xml?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/pom.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/pom.xml Sat Aug 29 00:51:12 2009
@@ -25,10 +25,11 @@
     <parent>
         <groupId>org.apache.geronimo.framework</groupId>
         <artifactId>modules</artifactId>
-        <version>2.2-SNAPSHOT</version>
+        <version>3.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>geronimo-system</artifactId>
+    <packaging>bundle</packaging>
     <name>Geronimo Framework, Modules :: System</name>
 
     <dependencies>
@@ -83,8 +84,8 @@
 
         <!-- plugin management -->
         <dependency>
-            <groupId>javax.xml.bind</groupId>
-            <artifactId>jaxb-api</artifactId>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jaxb_2.1_spec</artifactId>
         </dependency>
 
         <dependency>
@@ -150,19 +151,17 @@
                         <configuration>
                             <tasks>
                                 <tstamp>
-                                    <format property="build.year" pattern="yyyy"/>
+                                    <format property="build.year" pattern="yyyy" />
                                 </tstamp>
 
-                                <mkdir dir="${project.build.outputDirectory}/org/apache/geronimo/system/serverinfo"/>
+                                <mkdir dir="${project.build.outputDirectory}/org/apache/geronimo/system/serverinfo" />
+
+                                <propertyfile file="${project.build.outputDirectory}/org/apache/geronimo/system/serverinfo/geronimo-version.properties" comment="Geronimo version information (generated, do not modify)">
 
-                                <propertyfile
-                                        file="${project.build.outputDirectory}/org/apache/geronimo/system/serverinfo/geronimo-version.properties"
-                                        comment="Geronimo version information (generated, do not modify)">
-
-                                    <entry key="version" value="${version}"/>
-                                    <entry key="build.date" type="date" value="now" pattern="yyyy.MM.dd"/>
-                                    <entry key="build.time" type="date" value="now" pattern="HH:mm:ss.SSSZ"/>
-                                    <entry key="copyright" value="Copyright (C) 2003-${build.year}, The Apache Software Foundation"/>
+                                    <entry key="version" value="${version}" />
+                                    <entry key="build.date" type="date" value="now" pattern="yyyy.MM.dd" />
+                                    <entry key="build.time" type="date" value="now" pattern="HH:mm:ss.SSSZ" />
+                                    <entry key="copyright" value="Copyright (C) 2003-${build.year}, The Apache Software Foundation" />
                                 </propertyfile>
                             </tasks>
                         </configuration>

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/
------------------------------------------------------------------------------
--- 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-system/src/main/
------------------------------------------------------------------------------
--- 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-system/src/main/java/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/configuration/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java Sat Aug 29 00:51:12 2009
@@ -32,12 +32,19 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GReferenceInfo;
 
 /**
  * @version $Rev$ $Date$
@@ -46,8 +53,11 @@
     private static final String META_INF = "META-INF";
     private static final String CONFIG_SER = "config.ser";
     private static final String CONFIG_INFO = "config.info";
+    //hopefully temporary hack
+    private static final String IMPORT_PACKAGES = "imports.txt";
     private static final String META_INF_STARTUP_JAR = META_INF + "/startup-jar";
     private static final String META_INF_CONFIG_SER = META_INF + "/" + CONFIG_SER;
+    private static final String META_INF_IMPORT_PACKAGES = META_INF + "/" + IMPORT_PACKAGES;
     private static final String META_INF_CONFIG_SER_SHA1 = META_INF_CONFIG_SER + ".sha1";
     private static final String META_INF_CONFIG_INFO = META_INF + "/" + CONFIG_INFO;
 
@@ -113,6 +123,18 @@
     }
 
     public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream out) throws IOException {
+        out.putNextEntry(new ZipEntry(META_INF_IMPORT_PACKAGES));
+        try {
+            OutputStreamWriter writer = new OutputStreamWriter(out);
+            List<GBeanData> gbeans = configurationData.getGbeanState().getGBeans(null);
+            String imports = getImportString(gbeans);
+            writer.append(imports);
+        } catch (InvalidConfigException e) {
+            throw (IOException)new IOException("Could not get gbean datas").initCause(e);
+        } finally {
+            out.closeEntry();
+        }
+
         // save the persisted form in the source directory
         out.putNextEntry(new ZipEntry(META_INF_CONFIG_SER));
         ConfigurationStoreUtil.ChecksumOutputStream sumOut = null;
@@ -148,6 +170,21 @@
         // save the persisted form in the source directory
         File metaInf = new File(source, META_INF);
         metaInf.mkdirs();
+
+        PrintWriter writer = null;
+
+        try {
+            writer = new PrintWriter(new FileWriter(new File(metaInf, IMPORT_PACKAGES)));
+            List<GBeanData> gbeans = configurationData.getGbeanState().getGBeans(null);
+            String imports = getImportString(gbeans);
+            writer.append(imports);
+        } catch (InvalidConfigException e) {
+            throw (IOException)new IOException("Could not get gbean datas").initCause(e);
+        } finally {
+            flush(writer);
+            close(writer);
+        }
+
         File configSer = new File(metaInf, CONFIG_SER);
 
         OutputStream out = new FileOutputStream(configSer);
@@ -162,7 +199,6 @@
         ConfigurationStoreUtil.writeChecksumFor(configSer);
 
         // write the info file
-        PrintWriter writer = null;
         try {
             writer = new PrintWriter(new FileWriter(new File(metaInf, CONFIG_INFO)));
             ConfigurationUtil.writeConfigInfo(writer, configurationData);
@@ -170,6 +206,49 @@
             flush(writer);
             close(writer);
         }
+
+    }
+
+    public static String getImportString(List<GBeanData> gbeans) {
+        LinkedHashSet<String> imports = getImports(gbeans);
+        StringBuilder builder = new StringBuilder();
+        for (String importPackage: imports) {
+            if (builder.length() > 0) {
+                builder.append(",");
+            }
+            builder.append(importPackage);
+        }
+        return builder.toString();
+    }
+
+    public static LinkedHashSet<String> getImports(List<GBeanData> gbeans) {
+        LinkedHashSet<String> imports = new LinkedHashSet<String>();
+        for (GBeanData data: gbeans) {
+            GBeanInfo info = data.getGBeanInfo();
+            addImport(imports, info.getClassName());
+            for (GAttributeInfo attInfo: info.getAttributes()) {
+                addImport(imports, attInfo.getType());
+            }
+            for (GReferenceInfo refInfo: info.getReferences()) {
+                addImport(imports, refInfo.getReferenceType());
+            }
+        }
+        return imports;
+    }
+
+    private static void addImport(LinkedHashSet<String> imports, String className) {
+        int pos = className.lastIndexOf('.');
+        if (pos < 0 ) return;
+        int count = 0;
+        while (className.charAt(count) == '[') {
+            count++;
+        }
+        if (className.charAt(count) == 'L') {
+            count++;
+        }
+        className = className.substring(count, pos);
+        if (className.startsWith("java.")) return;
+        imports.add(className);
     }
 
     private static Collection listRecursiveFiles(File file) {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java Sat Aug 29 00:51:12 2009
@@ -32,9 +32,6 @@
 
 import javax.xml.bind.JAXBException;
 import javax.xml.stream.XMLStreamException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
@@ -51,7 +48,9 @@
 import org.apache.geronimo.system.plugin.model.AttributeType;
 import org.apache.geronimo.system.plugin.model.GbeanType;
 import org.apache.geronimo.system.plugin.model.ReferenceType;
-import org.apache.geronimo.crypto.EncryptionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -64,6 +63,7 @@
     private final Object name;
     private String comment;
     private boolean load;
+    //Note that encrypted attributes are stored encrypted in this map.
     private final Map<String, String> attributes = new LinkedHashMap<String, String>();
     private final Map<String, String> propertyEditors = new HashMap<String, String>();
     private final Map<String, ReferencePatterns> references = new LinkedHashMap<String, ReferencePatterns>();
@@ -126,7 +126,7 @@
         return buf.toString();
     }
 
-    public GBeanOverride(GBeanData gbeanData, JexlExpressionParser expressionParser, ClassLoader classLoader) throws InvalidAttributeException {
+    public GBeanOverride(GBeanData gbeanData, JexlExpressionParser expressionParser, Bundle bundle) throws InvalidAttributeException {
         GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
         this.gbeanInfo = gbeanInfo.getSourceClass();
         if (this.gbeanInfo == null) {
@@ -136,15 +136,15 @@
         load = true;
 
         // set attributes
-        for (Object o : gbeanData.getAttributes().entrySet()) {
-            Map.Entry entry = (Map.Entry) o;
-            String attributeName = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : gbeanData.getAttributes().entrySet()) {
+            String attributeName = entry.getKey();
             GAttributeInfo attributeInfo = gbeanInfo.getAttribute(attributeName);
             if (attributeInfo == null) {
                 throw new InvalidAttributeException("No attribute: " + attributeName + " for gbean: " + gbeanData.getAbstractName());
             }
+            // TODO: shouldn't we only save manageable attributes here?
             Object attributeValue = entry.getValue();
-            setAttribute(attributeName, attributeValue, attributeInfo.getType(), classLoader);
+            setAttribute(attributeInfo, attributeValue, bundle);
         }
 
         // references can be coppied in blind
@@ -197,8 +197,7 @@
                     if (value == null || value.length() == 0) {
                         setClearAttribute(attr.getName());
                     } else {
-                        String truevalue = (String) EncryptionManager.decrypt(value);
-                        setAttribute(attr.getName(), truevalue);
+                        setAttribute(attr.getName(), value);
                     }
                 }
             } else if (o instanceof ReferenceType) {
@@ -312,12 +311,22 @@
         references.remove(referenceName);
     }
 
-    public void setAttribute(String attributeName, Object attributeValue, String attributeType, ClassLoader classLoader) throws InvalidAttributeException {
-        String stringValue = getAsText(attributeName, attributeValue, attributeType, classLoader);
-        setAttribute(attributeName, stringValue);
+    public void setAttribute(GAttributeInfo attrInfo, Object attributeValue,
+            Bundle bundle) throws InvalidAttributeException {
+        String stringValue = getAsText(attrInfo.getName(), attributeValue, attrInfo.getType(), bundle);
+        stringValue = (String) attrInfo.getEncryptedSetting().encrypt(stringValue);
+        setAttribute(attrInfo.getName(), stringValue);
     }
 
-    public void setAttribute(String attributeName, String attributeValue) {
+    /**
+     * This method should be discouraged for usage outside in future, as it does
+     * not pass in encryption meta-information about the attribute being set.
+     * 
+     * Use setAttribute(GAttributeInfo attrInfo, Object attributeValue,
+     * ClassLoader classLoader) instead.
+     * 
+     */
+    private void setAttribute(String attributeName, String attributeValue) {
         if (attributeValue == null || attributeValue.length() == 0) {
             setClearAttribute(attributeName);
         } else {
@@ -341,7 +350,7 @@
         clearReferences.remove(name);
     }
 
-    public boolean applyOverrides(GBeanData data, Artifact configName, AbstractName gbeanName, ClassLoader classLoader) throws InvalidConfigException {
+    public boolean applyOverrides(GBeanData data, Artifact configName, AbstractName gbeanName, Bundle bundle) throws InvalidConfigException {
         if (!isLoad()) {
             return false;
         }
@@ -356,8 +365,18 @@
                 throw new InvalidConfigException("No attribute: " + attributeName + " for gbean: " + data.getAbstractName());
             }
             String valueString = entry.getValue();
-            Object value = getValue(attributeInfo, valueString, configName, gbeanName, classLoader);
+            Object value = getValue(attributeInfo, valueString, configName, gbeanName, bundle);
             data.setAttribute(attributeName, value);
+
+            //encrypt any encryptable attributes set to plaintext by users
+            if (valueString != null) {
+                if (valueString.equals(attributeInfo.getEncryptedSetting().decrypt(valueString))) {
+                    String encrypted = (String) attributeInfo.getEncryptedSetting().encrypt(valueString);
+                    if (!encrypted.equals(valueString)) {
+                        entry.setValue(encrypted);
+                    }
+                }
+            }
         }
 
         //Clear attributes
@@ -391,23 +410,24 @@
         return true;
     }
 
-    private synchronized Object getValue(GAttributeInfo attribute, String value, Artifact configurationName, AbstractName gbeanName, ClassLoader classLoader) {
+    private synchronized Object getValue(GAttributeInfo attribute, String value, Artifact configurationName, AbstractName gbeanName, Bundle bundle) {
         if (value == null) {
             return null;
         }
+        value = (String) attribute.getEncryptedSetting().decrypt(value);
         value = substituteVariables(attribute.getName(), value);
-        PropertyEditor editor = loadPropertyEditor(attribute, classLoader);
+        PropertyEditor editor = loadPropertyEditor(attribute, bundle);
         editor.setAsText(value);
         log.debug("Setting value for " + configurationName + "/" + gbeanName + "/" + attribute.getName() + " to value " + value);
         return editor.getValue();
     }
 
-    protected PropertyEditor loadPropertyEditor(GAttributeInfo attribute, ClassLoader classLoader) {
+    protected PropertyEditor loadPropertyEditor(GAttributeInfo attribute, Bundle bundle) {
         String propertyEditor = propertyEditors.get(attribute.getName());
         if (null == propertyEditor) {
             PropertyEditor editor;
             try {
-                editor = PropertyEditors.findEditor(attribute.getType(), classLoader);
+                editor = PropertyEditors.findEditor(attribute.getType(), bundle);
             } catch (ClassNotFoundException e) {
                 throw new IllegalStateException("Unable to load property editor for attribute type: " + attribute.getType());
             }            
@@ -417,7 +437,7 @@
             return editor;
         } else {
             try {
-                Class propertyEditorClass = classLoader.loadClass(propertyEditor);
+                Class propertyEditorClass = bundle.loadClass(propertyEditor);
                 return (PropertyEditor) propertyEditorClass.newInstance();
             } catch (Exception ex) {
                 throw new IllegalStateException("Cannot load property editor [" + propertyEditor + "]", ex);
@@ -468,10 +488,6 @@
             } else {                
                 nullAttributes.remove(name);
                 clearAttributes.remove(name);
-
-                if (name.toLowerCase().indexOf("password") > -1) {
-                    value = EncryptionManager.encrypt(value);
-                }
 /**
  * if there was a value such as jdbc url with &amp; then when that value was oulled
  * from the config.xml the &amp; would have been replaced/converted to '&', we need to check
@@ -564,13 +580,13 @@
         return gbean;
     }
 
-    protected String getAsText(String attributeName, Object value, String type, ClassLoader classLoader) throws InvalidAttributeException {
+    protected String getAsText(String attributeName, Object value, String type, Bundle bundle) throws InvalidAttributeException {
         try {
             if (null == value || value instanceof String) {
                 return (String) value;
             }
             
-            Class typeClass = ClassLoading.loadClass(type, classLoader);
+            Class typeClass = ClassLoading.loadClass(type, bundle);
             PropertyEditor editor = PropertyEditors.findEditor(value.getClass());
             if (null == editor) {
                 editor = PropertyEditors.findEditor(typeClass);

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Sat Aug 29 00:51:12 2009
@@ -64,6 +64,7 @@
 import org.apache.geronimo.system.plugin.model.GbeanType;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.xml.sax.SAXException;
+import org.osgi.framework.Bundle;
 
 /**
  * Stores managed attributes in an XML file on the local filesystem.
@@ -148,7 +149,7 @@
         return prefix;
     }
 
-    public synchronized Collection applyOverrides(Artifact configName, Collection<GBeanData> untypedGbeanDatas, ClassLoader classLoader) throws InvalidConfigException {
+    public synchronized Collection<GBeanData> applyOverrides(Artifact configName, Collection<GBeanData> untypedGbeanDatas, Bundle bundle) throws InvalidConfigException {
         // clone the datas since we will be modifying this collection
         Collection<GBeanData> gbeanDatas = new ArrayList<GBeanData>(untypedGbeanDatas);
 
@@ -184,7 +185,7 @@
                     message.append(" gbeanName=").append(name);
                     throw new InvalidConfigException(message.toString());
                 }
-                GBeanInfo gbeanInfo = infoFactory.getGBeanInfo(gbean.getGBeanInfo(), classLoader);
+                GBeanInfo gbeanInfo = infoFactory.getGBeanInfo(gbean.getGBeanInfo(), bundle);
                 AbstractName abstractName = (AbstractName) name;
                 GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo);
                 gbeanDatas.add(gBeanData);
@@ -194,7 +195,7 @@
         // set the attributes
         for (Iterator iterator = gbeanDatas.iterator(); iterator.hasNext();) {
             GBeanData data = (GBeanData) iterator.next();
-            boolean load = setAttributes(data, configuration, configName, classLoader);
+            boolean load = setAttributes(data, configuration, configName, bundle);
             if (!load) {
                 iterator.remove();
             }
@@ -208,12 +209,12 @@
      * @param data          GBeanData we are going to override attributes on
      * @param configuration the module override the gbean relates to
      * @param configName    name of the module (why can't this be determined from the configuration?)
-     * @param classLoader   ClassLoader to use for property objects/PropertyEditors
+     * @param bundle
      * @return true if the gbean should be loaded, false otherwise.
      * @throws org.apache.geronimo.kernel.config.InvalidConfigException
      *          if we cannot update the gbeanData
      */
-    private synchronized boolean setAttributes(GBeanData data, ConfigurationOverride configuration, Artifact configName, ClassLoader classLoader) throws InvalidConfigException {
+    private synchronized boolean setAttributes(GBeanData data, ConfigurationOverride configuration, Artifact configName, Bundle bundle) throws InvalidConfigException {
         AbstractName gbeanName = data.getAbstractName();
         GBeanOverride gbean = configuration.getGBean(gbeanName);
         if (gbean == null) {
@@ -225,7 +226,7 @@
             return true;
         }
 
-        return gbean.applyOverrides(data, configName, gbeanName, classLoader);
+        return gbean.applyOverrides(data, configName, gbeanName, bundle);
     }
 
     public void setModuleGBeans(Artifact moduleName, List<GbeanType> gbeans, boolean load, String condition) throws InvalidGBeanException {
@@ -251,6 +252,10 @@
         return serverOverride.getConfiguration(artifact) != null;
     }
 
+    public String substitute(String in) {
+        return expressionParser.parse(in);
+    }
+
     public void addConfigSubstitutions(Properties properties) {
         localConfigSubstitutions.putAll(properties);
         Map<String, Object> configSubstutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix);
@@ -258,7 +263,7 @@
         expressionParser.setVariables(configSubstutions);
     }
 
-    public synchronized void setValue(Artifact configurationName, AbstractName gbeanName, GAttributeInfo attribute, Object value, ClassLoader classLoader) {
+    public synchronized void setValue(Artifact configurationName, AbstractName gbeanName, GAttributeInfo attribute, Object value, Bundle bundle) {
         if (readOnly) {
             return;
         }
@@ -273,7 +278,7 @@
         }
 
         try {
-            gbean.setAttribute(attribute.getName(), value, attribute.getType(), classLoader);
+            gbean.setAttribute(attribute, value, bundle);
             attributeChanged();
         } catch (InvalidAttributeException e) {
             // attribute can not be represented as a string
@@ -320,7 +325,7 @@
         attributeChanged();
     }
 
-    public void addGBean(Artifact configurationName, GBeanData gbeanData, ClassLoader classLoader) {
+    public void addGBean(Artifact configurationName, GBeanData gbeanData, Bundle bundle) {
         if (readOnly) {
             return;
         }
@@ -330,7 +335,7 @@
             return;
         }
         try {
-            GBeanOverride gbean = new GBeanOverride(gbeanData, expressionParser, classLoader);
+            GBeanOverride gbean = new GBeanOverride(gbeanData, expressionParser, bundle);
             configuration.addGBean(gbean);
             attributeChanged();
         } catch (InvalidAttributeException e) {
@@ -406,6 +411,13 @@
         }
     }
 
+    void write(Writer writer) throws XMLStreamException, JAXBException,
+            IOException {
+        AttributesType attributes = serverOverride.writeXml();
+        AttributesXmlUtil.writeAttributes(attributes, writer);
+        writer.flush();
+    }
+
     private static void saveXmlToFile(File file, ServerOverride serverOverride) {
         try {
             Writer fileOut = new FileWriter(file);

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java Sat Aug 29 00:51:12 2009
@@ -41,4 +41,6 @@
     void addConfigSubstitutions(Properties properties);
 
     boolean isModuleInstalled(Artifact artifact);
+
+    String substitute(final String in);
 }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/cli/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/configuration/condition/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JexlExpressionParser.java Sat Aug 29 00:51:12 2009
@@ -127,7 +127,7 @@
 
         log.trace("Parsing input: {}", input);
 
-        StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
 
         int cur = 0;
         int prefixLoc;

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

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/JMXProxyMethodInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/JMXProxyMethodInterceptor.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/JMXProxyMethodInterceptor.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/JMXProxyMethodInterceptor.java Sat Aug 29 00:51:12 2009
@@ -94,8 +94,7 @@
         FastClass fastClass = FastClass.create(proxyType);
         ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
         Method[] methods = proxyType.getMethods();
-        for (int i = 0; i < methods.length; i++) {
-            Method method = methods[i];
+        for (Method method : methods) {
             int interfaceIndex = getSuperIndex(proxyType, method);
             if (interfaceIndex >= 0) {
                 invokers[interfaceIndex] = createProxyInvoker(kernel, method);
@@ -104,17 +103,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();
+                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();
             }
         } catch (Exception e) {
             // this can not happen... all classes must implement equals, hashCode and toString
@@ -172,7 +171,7 @@
 
     static final class HashCodeInvoke implements ProxyInvoker {
         public Object invoke(AbstractName abstractName, Object[] arguments) throws Throwable {
-            return new Integer(abstractName.hashCode());
+            return abstractName.hashCode();
         }
     }
 
@@ -185,7 +184,7 @@
 
         public Object invoke(AbstractName abstractName, Object[] arguments) throws Throwable {
             AbstractName proxyTarget = kernel.getAbstractNameFor(arguments[0]);
-            return Boolean.valueOf(abstractName.equals(proxyTarget));
+            return abstractName.equals(proxyTarget);
         }
     }
 
@@ -209,7 +208,7 @@
         }
 
         public Object invoke(AbstractName abstractName, Object[] arguments) throws Throwable {
-            return new Integer(kernel.getGBeanState(abstractName));
+            return kernel.getGBeanState(abstractName);
         }
     }
 
@@ -259,7 +258,7 @@
         }
 
         public Object invoke(AbstractName abstractName, Object[] arguments) throws Throwable {
-            return new Long(kernel.getGBeanStartTime(abstractName));
+            return kernel.getGBeanStartTime(abstractName);
         }
     }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelDelegate.java Sat Aug 29 00:51:12 2009
@@ -39,6 +39,8 @@
 import org.apache.geronimo.kernel.Naming;
 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$ $Date$
@@ -120,9 +122,9 @@
         }
     }
 
-    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException {
+    public void loadGBean(GBeanData gbeanData, BundleContext bundleContext) throws GBeanAlreadyExistsException {
         try {
-            invokeKernel("loadGBean", new Object[] {gbeanData, classLoader}, new String[] {GBeanData.class.getName(), ClassLoader.class.getName()});
+            invokeKernel("loadGBean", new Object[] {gbeanData, bundleContext}, new String[] {GBeanData.class.getName(), ClassLoader.class.getName()});
         } catch (GBeanAlreadyExistsException e) {
             throw e;
         } catch (RuntimeException e) {
@@ -709,9 +711,9 @@
         }
     }
 
-    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
+    public Bundle getBundleFor(AbstractName name) throws GBeanNotFoundException {
         try {
-            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {name}, new String[] {AbstractName.class.getName()});
+            return (Bundle) invokeKernel("getBundleFor", new Object[] {name}, new String[] {AbstractName.class.getName()});
         } catch (GBeanNotFoundException e) {
             throw e;
         } catch (RuntimeException e) {
@@ -721,9 +723,9 @@
         }
     }
 
-    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
+    public Bundle getBundleFor(String shortName) throws GBeanNotFoundException {
         try {
-            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {shortName}, new String[] {String.class.getName()});
+            return (Bundle) invokeKernel("getBundleFor", new Object[] {shortName}, new String[] {String.class.getName()});
         } catch (GBeanNotFoundException e) {
             throw e;
         } catch (RuntimeException e) {
@@ -733,9 +735,9 @@
         }
     }
 
-    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
+    public Bundle getBundleFor(Class type) throws GBeanNotFoundException {
         try {
-            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {type}, new String[] {Class.class.getName()});
+            return (Bundle) invokeKernel("getBundleFor", new Object[] {type}, new String[] {Class.class.getName()});
         } catch (GBeanNotFoundException e) {
             throw e;
         } catch (RuntimeException e) {
@@ -745,9 +747,9 @@
         }
     }
 
-    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
+    public Bundle getBundleFor(String shortName, Class type) throws GBeanNotFoundException {
         try {
-            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+            return (Bundle) invokeKernel("getBundleFor", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
         } catch (GBeanNotFoundException e) {
             throw e;
         } catch (RuntimeException e) {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java Sat Aug 29 00:51:12 2009
@@ -52,6 +52,7 @@
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 
 /**
@@ -61,7 +62,7 @@
 public class KernelMBeanServer implements MBeanServer {
     private static final AbstractNameQuery ALL = new AbstractNameQuery(null, Collections.EMPTY_MAP, Collections.EMPTY_SET);
 
-    private final HashMap objetNameToAbstractName = new HashMap();
+    private final HashMap<ObjectName, AbstractName> objetNameToAbstractName = new HashMap<ObjectName, AbstractName>();
     private final Kernel kernel;
 
     public KernelMBeanServer(Kernel kernel) {
@@ -71,15 +72,14 @@
     public void doStart() {
         kernel.getLifecycleMonitor().addLifecycleListener(new GBeanRegistrationListener(), ALL);
 
-        Set allNames = kernel.listGBeans(ALL);
-        for (Iterator iterator = allNames.iterator(); iterator.hasNext();) {
-            AbstractName abstractName = (AbstractName) iterator.next();
+        Set<AbstractName> allNames = kernel.listGBeans(ALL);
+        for (AbstractName abstractName : allNames) {
             register(abstractName);
         }
     }
 
     public synchronized AbstractName getAbstractNameFor(ObjectName objectName) {
-        return (AbstractName) objetNameToAbstractName.get(objectName);
+        return objetNameToAbstractName.get(objectName);
     }
 
     private synchronized void register(AbstractName abstractName) {
@@ -125,7 +125,7 @@
         } catch (GBeanNotFoundException e) {
             throw (InstanceNotFoundException)new InstanceNotFoundException(name.getCanonicalName()).initCause(e);
         } catch (InternalKernelException e) {
-            throw (MBeanException)new MBeanException(unwrapInternalKernelException(e));
+            throw new MBeanException(unwrapInternalKernelException(e));
         } catch (Exception e) {
             throw new MBeanException(e);
         }
@@ -315,7 +315,7 @@
     public ClassLoader getClassLoaderFor(ObjectName objectName) throws InstanceNotFoundException {
         AbstractName abstractName = toAbstractName(objectName);
         try {
-            return kernel.getClassLoaderFor(abstractName);
+            return new BundleClassLoader(kernel.getBundleFor(abstractName));
         } catch (GBeanNotFoundException e) {
             throw (InstanceNotFoundException)new InstanceNotFoundException(objectName.getCanonicalName()).initCause(e);
         }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/logging/jul/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/logging/log4j/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/logging/log4j/ApplicationLog4jConfigurationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/ApplicationLog4jConfigurationGBean.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/ApplicationLog4jConfigurationGBean.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/ApplicationLog4jConfigurationGBean.java Sat Aug 29 00:51:12 2009
@@ -30,7 +30,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.log4j.PropertyConfigurator;
 
 /**
  * @version $Rev$ $Date$
@@ -62,20 +61,25 @@
         } finally {
             in.close();
         }
-        //remove any global log4j configuration
-        for (Iterator it = props.keySet().iterator(); it.hasNext(); ) {
-            String key = (String) it.next();
-            if (key.startsWith(CATEGORY_PREFIX)
-                    || key.startsWith(LOGGER_PREFIX)
-                    || key.startsWith(ADDITIVITY_PREFIX)
-                    || key.startsWith(APPENDER_PREFIX)
-                    || key.startsWith(RENDERER_PREFIX)) {
-                continue;
+        try {
+            Class log4jConfigClass = classloader.loadClass("org.apache.log4j.PropertyConfigurator");
+            if (log4jConfigClass.getClassLoader() == ClassLoader.getSystemClassLoader()) {
+                //remove any global log4j configuration
+                for (Iterator it = props.keySet().iterator(); it.hasNext();) {
+                    String key = (String) it.next();
+                    if (key.startsWith(CATEGORY_PREFIX)
+                            || key.startsWith(LOGGER_PREFIX)
+                            || key.startsWith(ADDITIVITY_PREFIX)
+                            || key.startsWith(APPENDER_PREFIX)
+                            || key.startsWith(RENDERER_PREFIX)) {
+                        continue;
+                    }
+                    it.remove();
+                }
             }
-            it.remove();
+            log4jConfigClass.getMethod("configure", Properties.class).invoke(null, props);
+        } catch (Exception e) {        
         }
-
-        PropertyConfigurator.configure(props);
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java Sat Aug 29 00:51:12 2009
@@ -519,7 +519,7 @@
         }
 
         try {
-            URLConfigurator.configure(file.toURL());
+            URLConfigurator.configure(file.toURI().toURL());
         } catch (MalformedURLException e) {
             e.printStackTrace();
         }
@@ -575,6 +575,11 @@
             timer.cancel();
             timer = null;
         }
+
+        log.info("Stopping Logging Service");
+        log.info("----------------------------------------------");
+
+        LogManager.shutdown();
     }
 
     public void doFail() {
@@ -664,10 +669,10 @@
 
         infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
 
-        infoFactory.addOperation("reconfigure");
-        infoFactory.addOperation("setLoggerLevel", new Class[]{String.class, String.class});
-        infoFactory.addOperation("getLoggerLevel", new Class[]{String.class});
-        infoFactory.addOperation("getLoggerEffectiveLevel", new Class[]{String.class});
+//        infoFactory.addOperation("reconfigure");
+//        infoFactory.addOperation("setLoggerLevel", new Class[]{String.class, String.class});
+//        infoFactory.addOperation("getLoggerLevel", new Class[]{String.class});
+//        infoFactory.addOperation("getLoggerEffectiveLevel", new Class[]{String.class});
         infoFactory.addInterface(SystemLog.class);
 
         infoFactory.setConstructor(new String[]{"configFileName", "refreshPeriodSeconds", "ServerInfo"});

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/appender/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/main/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/main/CommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/CommandLine.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/CommandLine.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/CommandLine.java Sat Aug 29 00:51:12 2009
@@ -42,6 +42,7 @@
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
@@ -124,11 +125,12 @@
     }
 
     protected void loadBootstrapConfiguration() throws Exception {
-        ClassLoader classLoader = CommandLine.class.getClassLoader();
-        InputStream in = classLoader.getResourceAsStream("META-INF/config.ser");
+//        ClassLoader classLoader = CommandLine.class.getClassLoader();
+        BundleContext bundleContext = null;
+        InputStream in = bundleContext.getBundle().getResource("META-INF/config.ser").openStream();
         try {
             // load the configuration
-            configurationName = ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader);
+            configurationName = ConfigurationUtil.loadBootstrapConfiguration(kernel, in, bundleContext);
         } finally {
             if (in != null) {
                 try {
@@ -141,22 +143,24 @@
     }
 
     protected Kernel getBootedKernel() throws Exception {
-        kernel = KernelFactory.newInstance().createKernel("geronimo");
+        BundleContext bundleContext = null;
+        kernel = KernelFactory.newInstance(bundleContext).createKernel("geronimo");
         kernel.boot();
         return kernel;
     }
 
     protected void startKernel(Artifact moduleId) throws Exception {
         getBootedKernel();
-        ClassLoader classLoader = CommandLine.class.getClassLoader();
-        for (Enumeration modules = classLoader.getResources("META-INF/config.ser"); modules.hasMoreElements(); ) {
+//        ClassLoader classLoader = CommandLine.class.getClassLoader();
+        BundleContext bundleContext = null;
+        for (Enumeration modules = bundleContext.getBundle().getResources("META-INF/config.ser"); modules.hasMoreElements(); ) {
             URL moduleDataURL = (URL) modules.nextElement();
             InputStream in = moduleDataURL.openStream();
             try {
                 ConfigurationData moduleData = ConfigurationUtil.readConfigurationData(in);
                 if (moduleId.matches(moduleData.getId())) {
                     // load the configuration
-                    configurationName = ConfigurationUtil.loadBootstrapConfiguration(kernel, moduleData, classLoader);
+                    configurationName = ConfigurationUtil.loadBootstrapConfiguration(kernel, moduleData, bundleContext);
                     return;
                 }
             } finally {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/Daemon.java Sat Aug 29 00:51:12 2009
@@ -24,6 +24,7 @@
 import org.apache.geronimo.cli.daemon.DaemonCLParser;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.osgi.framework.BundleContext;
 
 
 /**
@@ -32,12 +33,14 @@
 public class Daemon extends EmbeddedDaemon {
 
     private Daemon() {
-        super(KernelFactory.newInstance().createKernel("geronimo"));
+        //TODO osgi bundleContext == null
+        super(KernelFactory.newInstance(null).createKernel("geronimo"));
     }
 
     @Override
     protected int initializeKernel() throws Exception {
         ClassLoader classLoader = EmbeddedDaemon.class.getClassLoader();
+        BundleContext bundleContext = null;
 
         // boot the kernel
         try {
@@ -60,7 +63,7 @@
         // load this configuration
         InputStream in = classLoader.getResourceAsStream("META-INF/config.ser");
         try {
-            ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader);
+            ConfigurationUtil.loadBootstrapConfiguration(kernel, in, bundleContext);
         } finally {
             if (in != null) {
                 try {

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/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-system/src/main/java/org/apache/geronimo/system/resolver/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/serverinfo/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/sharedlib/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/sharedlib/SharedLib.java Sat Aug 29 00:51:12 2009
@@ -63,7 +63,7 @@
                 if (!dir.isDirectory()) {
                     throw new IllegalArgumentException("Shared classes dir is not a directory: " + dir);
                 }
-                URL location = dir.toURL();
+                URL location = dir.toURI().toURL();
                 if (!currentUrls.contains(location)) {
                     newUrls.add(location);
                 }
@@ -87,7 +87,7 @@
                 for (int j = 0; j < files.length; j++) {
                     File file = files[j];
                     if (file.canRead() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) {
-                        URL location = file.toURL();
+                        URL location = file.toURI().toURL();
                         if (!currentUrls.contains(location)) {
                             newUrls.add(location);
                         }

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/threads/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/url/
------------------------------------------------------------------------------
--- 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-system/src/main/java/org/apache/geronimo/system/util/
------------------------------------------------------------------------------
--- 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-system/src/main/xsd/
------------------------------------------------------------------------------
--- 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-system/src/test/
------------------------------------------------------------------------------
--- 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-system/src/test/java/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/apache/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/apache/geronimo/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/apache/geronimo/system/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/apache/geronimo/system/configuration/
------------------------------------------------------------------------------
--- 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-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java?rev=809078&r1=809077&r2=809078&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java Sat Aug 29 00:51:12 2009
@@ -19,18 +19,23 @@
 
 package org.apache.geronimo.system.configuration;
 
-import java.beans.PropertyEditorSupport;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Collections;
-
 import junit.framework.TestCase;
-
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoFactory;
+import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.system.configuration.condition.JexlExpressionParser;
 import org.apache.geronimo.system.plugin.model.AttributeType;
 import org.apache.geronimo.system.plugin.model.GbeanType;
+import org.apache.geronimo.kernel.osgi.MockBundle;
+import org.osgi.framework.Bundle;
+
+import java.beans.PropertyEditorSupport;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  *
@@ -40,13 +45,26 @@
 
     private GbeanType gbeanType;
     private String attributeName;
+    private GBeanInfo gbeanInfo;
+    private GAttributeInfo beanInfo;
+    private GAttributeInfo serviceInfo;
+    private GAttributeInfo intInfo;
+    private GAttributeInfo collectionInfo;
+    private GAttributeInfo fooInfo;
+    private Bundle bundle = new MockBundle(getClass().getClassLoader(), null, 0L);
 
     @Override
     protected void setUp() throws Exception {
         gbeanType = new GbeanType();
         gbeanType.setName("name");
         
-        attributeName = "attName";
+        attributeName = "bean";
+        gbeanInfo = new AnnotationGBeanInfoFactory().getGBeanInfo(TestGBean.class);
+        beanInfo = gbeanInfo.getAttribute(attributeName);
+        serviceInfo = gbeanInfo.getAttribute("service");
+        intInfo = gbeanInfo.getAttribute("intValue");
+        collectionInfo = gbeanInfo.getAttribute("collection");
+        fooInfo = gbeanInfo.getAttribute("foo");
     }
     
     public void testPropertyEditorIsCarriedByWriteXml() throws Exception {
@@ -65,7 +83,7 @@
     
     public void testPropertyEditorIsUsedToGetTextValue() throws Exception {
         GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
-        override.setAttribute(attributeName, new Bean(), Bean.class.getName(), getClass().getClassLoader());
+        override.setAttribute(beanInfo, new Bean(), bundle);
         
         assertEquals("bean", override.getAttribute(attributeName));
         
@@ -77,7 +95,7 @@
     
     public void testPropertyEditorIsDefinedWhenAttributeIsNotAPrimitiveAndItsTypeDoesNotEqualValueType() throws Exception {
         GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
-        override.setAttribute(attributeName, new Bean(), Service.class.getName(), getClass().getClassLoader());
+        override.setAttribute(serviceInfo, new Bean(), bundle);
         
         GbeanType copiedGBeanType = override.writeXml();
         assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
@@ -87,7 +105,7 @@
     
     public void testPropertyEditorIsNotDefinedWhenAttributeTypeEqualsValueType() throws Exception {
         GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
-        override.setAttribute(attributeName, new Bean(), Bean.class.getName(), getClass().getClassLoader());
+        override.setAttribute(beanInfo, new Bean(), bundle);
         
         GbeanType copiedGBeanType = override.writeXml();
         assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
@@ -97,7 +115,7 @@
     
     public void testPropertyEditorIsNotDefinedForPrimitives() throws Exception {
         GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
-        override.setAttribute(attributeName, new Integer(1), int.class.getName(), getClass().getClassLoader());
+        override.setAttribute(intInfo, 1, bundle);
         
         GbeanType copiedGBeanType = override.writeXml();
         assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
@@ -107,7 +125,7 @@
     
     public void testPropertyEditorIsNotDefinedForCollectionSubClasses() throws Exception {
         GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
-        override.setAttribute(attributeName, Collections.singleton("test"), Collection.class.getName(), getClass().getClassLoader());
+        override.setAttribute(collectionInfo, Collections.singleton("test"), bundle);
         
         GbeanType copiedGBeanType = override.writeXml();
         assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
@@ -145,7 +163,7 @@
         override = new GBeanOverride(gbeanType, new JexlExpressionParser()); 
         override.setNullAttribute("foo");
         override.setClearAttribute("foo");
-        override.setAttribute("foo", "bar");
+        override.setAttribute(fooInfo, "bar", bundle);
         override.writeXml();
         
         assertFalse(override.isNullAttribute("foo"));
@@ -156,7 +174,7 @@
         assertTrue(override.getAttributes().containsKey("foo"));
             
         override = new GBeanOverride(gbeanType, new JexlExpressionParser()); 
-        override.setAttribute("foo", "bar");
+        override.setAttribute(fooInfo, "bar", bundle);
         override.setNullAttribute("foo");
         override.setClearAttribute("foo");
         override.writeXml();
@@ -170,7 +188,7 @@
         
         override = new GBeanOverride(gbeanType, new JexlExpressionParser()); 
         override.setClearAttribute("foo");
-        override.setAttribute("foo", "bar");
+        override.setAttribute(fooInfo, "bar", bundle);
         override.setNullAttribute("foo");
         override.writeXml();
             
@@ -182,8 +200,8 @@
         assertTrue(override.getNullAttributes().contains("foo"));
         
         override = new GBeanOverride(gbeanType, new JexlExpressionParser()); 
-        override.setAttribute("bar1", "foo");
-        override.setAttribute("bar2", "foo");
+        override.setAttribute(gbeanInfo.getAttribute("bar1"), "foo", bundle);
+        override.setAttribute(gbeanInfo.getAttribute("bar2"), "foo", bundle);
         override.getAttributes().put("foo", null);
         GbeanType gbean = override.writeXml();
         assertEquals(3, gbean.getAttributeOrReference().size());
@@ -192,13 +210,80 @@
         assertTrue(attribute.isNull());
     }
     
-    public interface Service {
+    @GBean
+    public static class TestGBean {
+        private Bean bean;
+        private Service service;
+        private int intvalue;
+        private Collection collection;
+        private String foo;
+        private String bar1;
+        private String bar2;
+
+        public String getFoo() {
+            return foo;
+        }
+
+        public void setFoo(String foo) {
+            this.foo = foo;
+        }
+
+        public String getBar1() {
+            return bar1;
+        }
+
+        public void setBar1(String bar1) {
+            this.bar1 = bar1;
+        }
+
+        public String getBar2() {
+            return bar2;
+        }
+
+        public void setBar2(String bar2) {
+            this.bar2 = bar2;
+        }
+
+        public Collection getCollection() {
+            return collection;
+        }
+
+        public void setCollection(Collection collection) {
+            this.collection = collection;
+        }
+
+        public int getIntValue() {
+            return intvalue;
+        }
+
+        public void setIntValue(int intvalue) {
+            this.intvalue = intvalue;
+        }
+
+        public Service getService() {
+            return service;
+        }
+
+        public void setService(Service service) {
+            this.service = service;
+        }
+
+
+        public Bean getBean() {
+            return bean;
+        }
+
+        public void setBean(Bean bean) {
+            this.bean = bean;
+        }
     }
     
-    public static class Bean implements Service {
+    public interface Service {
+    }
 
+    public static class Bean implements Service {
     }
-    
+
     public static class BeanEditor extends PropertyEditorSupport {
         
         @Override
@@ -212,5 +297,18 @@
         }
         
     }
-    
+    public static class ServiceEditor extends PropertyEditorSupport {
+
+        @Override
+        public String getAsText() {
+            return "bean";
+        }
+
+        @Override
+        public void setAsText(String text) throws IllegalArgumentException {
+            assertEquals("bean", text);
+        }
+
+    }
+
 }



Mime
View raw message