geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r169154 [4/6] - in /geronimo/trunk: applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/ applications/jmxdebug/src/webapp/WEB-INF/ assemblies/j2ee-server/ etc/ modules/assembly/ modules/assembly/src/plan/ modules/axis-builder/ modules/axis/ modules/classloader-server/ modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/ modules/client-builder/ modules/client-builder/src/java/org/apache/geronimo/client/builder/ modules/client-builder/src/test/org/apache/geronimo/client/builder/ modules/client/ modules/connector-builder/ modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ modules/connector/ modules/connector/src/java/org/apache/geronimo/connector/ modules/connector/src/java/org/apache/geronimo/connector/outbound/ modules/connector/src/test/org/apache/geronimo/connector/ modules/connector/src/test/org/apache/geronimo/connector/outbound/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/jmx/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/plugin/local/ modules/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/util/ modules/interop/ modules/interop/src/test/org/apache/geronimo/interop/ modules/j2ee-builder/ modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/ modules/j2ee/ modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/ modules/j2ee/src/test/org/apache/geronimo/j2ee/management/ modules/jetty-builder/ modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/ modules/jetty/ modules/jetty/src/test/org/apache/geronimo/jetty/ modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/ modules/kernel/ modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ modules/kernel/src/java/org/apache/geronimo/kernel/ modules/kernel/src/java/org/apache/geronimo/kernel/basic/ modules/kernel/src/java/org/apache/geronimo/kernel/config/ modules/kernel/src/java/org/apache/geronimo/kernel/jmx/ modules/kernel/src/java/org/apache/geronimo/kernel/lifecycle/ modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ modules/kernel/src/java/org/apache/geronimo/kernel/registry/ modules/kernel/src/test/org/apache/geronimo/gbean/ modules/kernel/src/test/org/apache/geronimo/gbean/runtime/ modules/kernel/src/test/org/apache/geronimo/kernel/ modules/mail/ modules/mail/src/java/org/apache/geronimo/mail/ modules/mail/src/test/org/apache/geronimo/mail/ modules/naming/src/java/org/apache/geronimo/naming/reference/ modules/naming/src/test/org/apache/geronimo/naming/java/ modules/security/ modules/security/src/java/org/apache/geronimo/security/jaas/ modules/security/src/java/org/apache/geronimo/security/realm/ modules/security/src/java/org/apache/geronimo/security/realm/providers/ modules/security/src/test/org/apache/geronimo/security/ modules/security/src/test/org/apache/geronimo/security/jaas/ modules/security/src/test/org/apache/geronimo/security/remoting/jmx/ modules/service-builder/ modules/service-builder/src/java/org/apache/geronimo/deployment/service/ modules/spring-builder/ modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/ modules/spring/ modules/spring/src/java/org/apache/geronimo/spring/ modules/system/ modules/system/src/java/org/apache/geronimo/system/configuration/ modules/system/src/java/org/apache/geronimo/system/jmx/ modules/system/src/java/org/apache/geronimo/system/main/ modules/system/src/test/org/apache/geronimo/system/configuration/ modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/ modules/tomcat-builder/ modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/ modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/ modules/tomcat/ modules/tomcat/src/plan/ modules/tomcat/src/test/org/apache/geronimo/tomcat/ modules/webservices/ plugins/geronimo-packaging-plugin/ plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ plugins/maven-geronimo-plugin/ plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/
Date Sun, 08 May 2005 19:35:28 GMT
Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicLifecycleMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicLifecycleMonitor.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicLifecycleMonitor.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicLifecycleMonitor.java Sun May  8 12:35:23 2005
@@ -0,0 +1,251 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+import org.apache.geronimo.gbean.runtime.LifecycleBroadcaster;
+
+/**
+ * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
+ */
+public class BasicLifecycleMonitor implements LifecycleMonitor {
+    private static final Log log = LogFactory.getLog(BasicLifecycleMonitor.class);
+
+    private final Kernel kernel;
+
+    // todo we should only hold weak references to the listeners
+    private final Map boundListeners = new HashMap();
+    private final Map listenerPatterns = new HashMap();
+
+    public BasicLifecycleMonitor(Kernel kernel) {
+        this.kernel = kernel;
+
+        // register for state change notifications with all mbeans that match the target patterns
+        Set names = this.kernel.listGBeans((ObjectName)null);
+        for (Iterator objectNameIterator = names.iterator(); objectNameIterator.hasNext();) {
+            addSource((ObjectName) objectNameIterator.next());
+        }
+    }
+
+    public synchronized void destroy() {
+        boundListeners.clear();
+        listenerPatterns.clear();
+    }
+
+    private synchronized void addSource(ObjectName source) {
+        if (boundListeners.containsKey(source)) {
+            // alreayd registered
+            return;
+        }
+
+        // find all listeners interested in events from this source
+        HashSet listeners = new HashSet();
+        for (Iterator listenerIterator = listenerPatterns.entrySet().iterator(); listenerIterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) listenerIterator.next();
+            Set patterns = (Set) entry.getValue();
+            for (Iterator patternIterator = patterns.iterator(); patternIterator.hasNext();) {
+                ObjectName pattern = (ObjectName) patternIterator.next();
+                if (pattern.apply(source)) {
+                    LifecycleListener listener = (LifecycleListener) entry.getKey();
+                    listeners.add(listener);
+                }
+            }
+        }
+
+        boundListeners.put(source, listeners);
+    }
+
+    private synchronized void removeSource(ObjectName source) {
+        boundListeners.remove(source);
+    }
+
+    public synchronized void addLifecycleListener(LifecycleListener listener, ObjectName pattern) {
+        addLifecycleListener(listener, Collections.singleton(pattern));
+    }
+
+    public synchronized void addLifecycleListener(LifecycleListener listener, Set patterns) {
+        for (Iterator patternIterator = patterns.iterator(); patternIterator.hasNext();) {
+            ObjectName pattern = (ObjectName) patternIterator.next();
+            for (Iterator iterator = boundListeners.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                ObjectName source = (ObjectName) entry.getKey();
+                if (pattern.apply(source)) {
+                    Set listeners = (Set) entry.getValue();
+                    listeners.add(listener);
+                }
+            }
+        }
+        listenerPatterns.put(listener, patterns);
+    }
+
+    public synchronized void removeLifecycleListener(LifecycleListener listener) {
+        for (Iterator iterator = boundListeners.values().iterator(); iterator.hasNext();) {
+            Set set = (Set) iterator.next();
+            set.remove(listener);
+        }
+        listenerPatterns.remove(listener);
+    }
+
+    private synchronized Set getTargets(ObjectName source) {
+        Set targets = (Set) boundListeners.get(source);
+        if (targets == null) {
+            // no one is interested in this event
+            return Collections.EMPTY_SET;
+        } else {
+            return new HashSet(targets);
+        }
+    }
+
+    private void fireLoadedEvent(ObjectName objectName) {
+        Set targets = getTargets(objectName);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.loaded(objectName);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStartingEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.starting(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireRunningEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.running(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStoppingEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.stopping(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireStoppedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.stopped(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireFailedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.failed(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    private void fireUnloadedEvent(ObjectName source) {
+        Set targets = getTargets(source);
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            LifecycleListener listener = (LifecycleListener) iterator.next();
+            try {
+                listener.unloaded(source);
+            } catch (Throwable e) {
+                log.warn("Exception occured while notifying listener", e);
+            }
+        }
+    }
+
+    public LifecycleBroadcaster createLifecycleBroadcaster(ObjectName objectName) {
+        return new RawLifecycleBroadcaster(objectName);
+    }
+
+    private class RawLifecycleBroadcaster implements LifecycleBroadcaster {
+        private final ObjectName objectName;
+
+        public RawLifecycleBroadcaster(ObjectName objectName) {
+            this.objectName = objectName;
+        }
+
+        public void fireLoadedEvent() {
+            addSource(objectName);
+            BasicLifecycleMonitor.this.fireLoadedEvent(objectName);
+        }
+
+        public void fireStartingEvent() {
+            BasicLifecycleMonitor.this.fireStartingEvent(objectName);
+        }
+
+        public void fireRunningEvent() {
+            BasicLifecycleMonitor.this.fireRunningEvent(objectName);
+        }
+
+        public void fireStoppingEvent() {
+            BasicLifecycleMonitor.this.fireStoppingEvent(objectName);
+        }
+
+        public void fireStoppedEvent() {
+            BasicLifecycleMonitor.this.fireStoppedEvent(objectName);
+        }
+
+        public void fireFailedEvent() {
+            BasicLifecycleMonitor.this.fireFailedEvent(objectName);
+        }
+
+        public void fireUnloadedEvent() {
+            BasicLifecycleMonitor.this.fireUnloadedEvent(objectName);
+            removeSource(objectName);
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java Sun May  8 12:35:23 2005
@@ -0,0 +1,102 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import java.util.IdentityHashMap;
+import javax.management.ObjectName;
+
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.proxy.ProxyFactory;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicProxyManager implements ProxyManager {
+    private final Kernel kernel;
+
+    // todo use weak keys for this
+    private final IdentityHashMap interceptors = new IdentityHashMap();
+
+    public BasicProxyManager(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public synchronized ProxyFactory createProxyFactory(Class type) {
+        assert type != null: "type is null";
+        return new ManagedProxyFactory(type);
+    }
+
+    public synchronized Object createProxy(ObjectName target, Class type) {
+        assert type != null: "type is null";
+        assert target != null: "target is null";
+
+        return createProxyFactory(type).createProxy(target);
+    }
+
+    public synchronized void destroyProxy(Object proxy) {
+        if (proxy == null) {
+            return;
+        }
+
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor != null) {
+            methodInterceptor.destroy();
+        }
+    }
+
+    public boolean isProxy(Object proxy) {
+        return interceptors.containsKey(proxy);
+    }
+
+    public synchronized ObjectName getProxyTarget(Object proxy) {
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor == null) {
+            return null;
+        }
+        return methodInterceptor.getObjectName();
+    }
+
+    private class ManagedProxyFactory implements ProxyFactory {
+        private final Class type;
+        private final Enhancer enhancer;
+
+        public ManagedProxyFactory(Class type) {
+            enhancer = new Enhancer();
+            enhancer.setSuperclass(type);
+            enhancer.setCallbackType(MethodInterceptor.class);
+            enhancer.setUseFactory(false);
+            this.type = enhancer.createClass();
+        }
+
+        public synchronized Object createProxy(ObjectName target) {
+            assert target != null: "target is null";
+
+            ProxyMethodInterceptor interceptor = new ProxyMethodInterceptor(type, kernel, target);
+
+            // @todo trap CodeGenerationException indicating missing no-arg ctr
+            enhancer.setCallbacks(new Callback[]{interceptor});
+            Object proxy = enhancer.create();
+
+            interceptors.put(proxy, interceptor);
+            return proxy;
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java Sun May  8 12:35:23 2005
@@ -0,0 +1,140 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.gbean.GBeanName;
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicRegistry {
+    private final Map registry = new HashMap();
+    private String kernelName = "";
+
+    /**
+     * Start the registry and associate it with a kernel.
+     *
+     * @param kernel the kernel to associate with
+     */
+    public void start(Kernel kernel) {
+        kernelName = kernel.getKernelName();
+    }
+
+    /**
+     * Shut down the registry and unregister any GBeans
+     */
+    public synchronized void stop() {
+        registry.clear();
+        kernelName = "";
+    }
+
+    /**
+     * See if there is a GBean registered with a specific name.
+     *
+     * @param name the name of the GBean to check for
+     * @return true if there is a GBean registered with that name
+     */
+    public synchronized boolean isRegistered(GBeanName name) {
+        return registry.containsKey(name);
+    }
+
+    /**
+     * Register a GBean instance.
+     *
+     * @param gbeanInstance the GBean to register
+     * @throws GBeanAlreadyExistsException if there is already a GBean registered with the instance's name
+     */
+    public synchronized void register(GBeanInstance gbeanInstance) throws GBeanAlreadyExistsException {
+        GBeanName name = createGBeanName(gbeanInstance.getObjectNameObject());
+        if (registry.containsKey(name)) {
+            throw new GBeanAlreadyExistsException("GBean already registered: " + name);
+        }
+        registry.put(name, gbeanInstance);
+    }
+
+    /**
+     * Unregister a GBean instance.
+     *
+     * @param name the name of the GBean to unregister
+     * @throws GBeanNotFoundException if there is no GBean registered with the supplied name
+     */
+    public synchronized void unregister(GBeanName name) throws GBeanNotFoundException, InternalKernelException {
+        if (registry.remove(name) == null) {
+            throw new GBeanNotFoundException("No GBean registered: " + name);
+        }
+    }
+
+    /**
+     * Return the GBeanInstance registered with the supplied name.
+     *
+     * @param name the name of the instance to return
+     * @return the GBeanInstance
+     * @throws GBeanNotFoundException if there is no GBean registered with the supplied name
+     */
+    public synchronized GBeanInstance getGBeanInstance(GBeanName name) throws GBeanNotFoundException {
+        GBeanInstance instance = (GBeanInstance) registry.get(name);
+        if (instance == null) {
+            throw new GBeanNotFoundException("No GBean registered: " + name);
+        }
+        return instance;
+    }
+
+
+    /**
+     * Search the registry for GBeans matching a name pattern.
+     *
+     * @param domain the domain to query in; null indicates all
+     * @param properties the properties the GBeans must have
+     * @return an unordered Set<GBeanInstance> of GBeans that matched the pattern
+     */
+    public Set listGBeans(String domain, Map properties) {
+        // fairly dumb implementation that iterates the list of all registered GBeans
+        Map clone;
+        synchronized(this) {
+            clone = new HashMap(registry);
+        }
+        Set result = new HashSet(clone.size());
+        for (Iterator i = clone.entrySet().iterator(); i.hasNext();) {
+            Map.Entry entry = (Map.Entry) i.next();
+            GBeanName name = (GBeanName) entry.getKey();
+            if (name.matches(domain, properties)) {
+                result.add(entry.getValue());
+            }
+        }
+        return result;
+    }
+
+    private GBeanName createGBeanName(ObjectName objectName) {
+        if (objectName.getDomain().length() == 0) {
+            return new GBeanName(kernelName, objectName.getKeyPropertyList());
+        }
+        return new GBeanName(objectName);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelGetAttributeInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelGetAttributeInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelGetAttributeInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelGetAttributeInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelGetAttributeInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+
+    public KernelGetAttributeInvoker(Kernel kernel, String name) {
+        this.kernel = kernel;
+        this.name = name;
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        return kernel.getAttribute(objectName, name);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelOperationInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelOperationInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelOperationInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelOperationInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import java.lang.reflect.Method;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelOperationInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+    private final String[] argumentTypes;
+
+    public KernelOperationInvoker(Kernel kernel, Method method) {
+        this.kernel = kernel;
+        name = method.getName();
+
+        // convert the parameters to a MBeanServer friendly string array
+        Class[] parameters = method.getParameterTypes();
+        argumentTypes = new String[parameters.length];
+        for (int i = 0; i < parameters.length; i++) {
+            argumentTypes[i] = parameters[i].getName();
+        }
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        return kernel.invoke(objectName, name, arguments, argumentTypes);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelSetAttributeInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelSetAttributeInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelSetAttributeInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/KernelSetAttributeInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelSetAttributeInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+
+    public KernelSetAttributeInvoker(Kernel kernel, String name) {
+        this.kernel = kernel;
+        this.name = name;
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        kernel.setAttribute(objectName, name, arguments[0]);
+        return null;
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java Sun May  8 12:35:23 2005
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LifecycleMonitorFlyweight implements LifecycleMonitor {
+    private final LifecycleMonitor lifecycleMonitor;
+
+    public LifecycleMonitorFlyweight(LifecycleMonitor lifecycleMonitor) {
+        this.lifecycleMonitor = lifecycleMonitor;
+    }
+
+    public void addLifecycleListener(LifecycleListener listener, ObjectName pattern) {
+        lifecycleMonitor.addLifecycleListener(listener, pattern);
+    }
+
+    public void addLifecycleListener(LifecycleListener listener, Set patterns) {
+        lifecycleMonitor.addLifecycleListener(listener, patterns);
+    }
+
+    public void removeLifecycleListener(LifecycleListener listener) {
+        lifecycleMonitor.removeLifecycleListener(listener);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public interface ProxyInvoker {
+    Object invoke(ObjectName objectName, Object[] arguments) throws Throwable;
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/ProxyMethodInterceptor.java Sun May  8 12:35:23 2005
@@ -0,0 +1,308 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.beans.Introspector;
+import javax.management.ObjectName;
+
+import net.sf.cglib.asm.Type;
+import net.sf.cglib.core.Signature;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+import net.sf.cglib.reflect.FastClass;
+import org.apache.geronimo.gbean.GOperationSignature;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GOperationInfo;
+import org.apache.geronimo.gbean.runtime.GBeanInstance;
+import org.apache.geronimo.gbean.runtime.RawInvoker;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.proxy.DeadProxyException;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+
+/**
+ * @version $Rev: 106345 $ $Date: 2004-11-23 12:37:03 -0800 (Tue, 23 Nov 2004) $
+ */
+public class ProxyMethodInterceptor implements MethodInterceptor {
+    /**
+     * Type of the proxy interface
+     */
+    private final Class proxyType;
+
+    /**
+     * The object name to which we are connected.
+     */
+    private final ObjectName objectName;
+
+    /**
+     * GBeanInvokers keyed on the proxy interface method index
+     */
+    private ProxyInvoker[] gbeanInvokers;
+
+    public ProxyMethodInterceptor(Class proxyType, Kernel kernel, ObjectName objectName) {
+        assert proxyType != null;
+        assert kernel != null;
+        assert objectName != null;
+
+        this.proxyType = proxyType;
+        this.objectName = objectName;
+        gbeanInvokers = createGBeanInvokers(kernel, objectName);
+    }
+
+    public synchronized void destroy() {
+        gbeanInvokers = null;
+    }
+
+    public ObjectName getObjectName() {
+        return objectName;
+    }
+
+    public final Object intercept(final Object object, final Method method, final Object[] args, final MethodProxy proxy) throws Throwable {
+        ProxyInvoker gbeanInvoker;
+
+        int interfaceIndex = proxy.getSuperIndex();
+        synchronized (this) {
+            if (gbeanInvokers == null) {
+                throw new DeadProxyException("Proxy is no longer valid");
+            }
+            gbeanInvoker = gbeanInvokers[interfaceIndex];
+        }
+
+        if (gbeanInvoker == null) {
+            throw new UnsupportedOperationException("No implementation method: objectName=" + objectName + ", method=" + method);
+        }
+
+        return gbeanInvoker.invoke(objectName, args);
+    }
+
+    private ProxyInvoker[] createGBeanInvokers(Kernel kernel, ObjectName objectName) {
+        ProxyInvoker[] invokers;
+        try {
+            RawInvoker rawInvoker = (RawInvoker) kernel.getAttribute(objectName, GBeanInstance.RAW_INVOKER);
+            invokers = createRawGBeanInvokers(rawInvoker, proxyType);
+        } catch (Exception e) {
+            invokers = createKernelGBeanInvokers(kernel, objectName, proxyType);
+        }
+
+        // handle equals, hashCode and toString directly here
+        try {
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("equals", new Class[]{Object.class}))] = new EqualsInvoke(kernel.getProxyManager());
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("hashCode", null))] = new HashCodeInvoke();
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("toString", null))] = new ToStringInvoke(proxyType.getName());
+        } catch (Exception e) {
+            // this can not happen... all classes must implement equals, hashCode and toString
+            throw new AssertionError(e);
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker[] createRawGBeanInvokers(RawInvoker rawInvoker, Class proxyType) {
+        Map operations = rawInvoker.getOperationIndex();
+        Map attributes = rawInvoker.getAttributeIndex();
+
+        // build the method lookup table
+        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];
+            int interfaceIndex = getSuperIndex(proxyType, method);
+            if (interfaceIndex >= 0) {
+                invokers[interfaceIndex] = createRawGBeanInvoker(rawInvoker, method, operations, attributes);
+            }
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker createRawGBeanInvoker(RawInvoker rawInvoker, Method method, Map operations, Map attributes) {
+        if (operations.containsKey(new GOperationSignature(method))) {
+            int methodIndex = ((Integer) operations.get(new GOperationSignature(method))).intValue();
+            return new RawOperationInvoker(rawInvoker, methodIndex);
+        }
+
+        if (method.getName().startsWith("get")) {
+            String attributeName = method.getName().substring(3);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+
+        if (method.getName().startsWith("is")) {
+            String attributeName = method.getName().substring(2);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+
+        if (method.getName().startsWith("set")) {
+            String attributeName = method.getName().substring(3);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawSetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawSetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+        return null;
+    }
+
+    private ProxyInvoker[] createKernelGBeanInvokers(Kernel kernel, ObjectName objectName, Class proxyType) {
+        GBeanInfo info;
+        try {
+            info = kernel.getGBeanInfo(objectName);
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Could not get GBeanInfo for target object: " + objectName);
+        }
+
+        // build attributeName->attributeInfo map
+        Set attributeInfos = info.getAttributes();
+        Set attributeNames = new HashSet(attributeInfos.size());
+        for (Iterator iterator = attributeInfos.iterator(); iterator.hasNext();) {
+            GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next();
+            attributeNames.add(attributeInfo.getName());
+        }
+
+        // build operationSignature->operationInfo map
+        Set operationInfos = info.getOperations();
+        Set operationSignatures = new HashSet(operationInfos.size());
+        for (Iterator iterator = operationInfos.iterator(); iterator.hasNext();) {
+            GOperationInfo operationInfo = (GOperationInfo) iterator.next();
+            operationSignatures.add(new GOperationSignature(operationInfo.getName(), operationInfo.getParameterList()));
+        }
+
+        // build the method lookup table
+        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];
+            int interfaceIndex = getSuperIndex(proxyType, method);
+            if (interfaceIndex >= 0) {
+                invokers[interfaceIndex] = createJMXGBeanInvoker(kernel, method, operationSignatures, attributeNames);
+            }
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker createJMXGBeanInvoker(Kernel kernel, Method method, Set operationSignatures, Set attributeNames) {
+        if (operationSignatures.contains(new GOperationSignature(method))) {
+            return new KernelOperationInvoker(kernel, method);
+        }
+
+        String name = method.getName();
+        if (name.startsWith("get")) {
+            String attributeName = method.getName().substring(3);
+            if (attributeNames.contains(attributeName)) {
+                return new KernelGetAttributeInvoker(kernel, attributeName);
+            }
+            attributeName = Introspector.decapitalize(attributeName);
+            if (attributeNames.contains(attributeName)) {
+                return new KernelGetAttributeInvoker(kernel, attributeName);
+            }
+        } else if (name.startsWith("is")) {
+            String attrName = method.getName().substring(2);
+            if (attributeNames.contains(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributeNames.contains(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+        } else if (name.startsWith("set")) {
+            String attrName = method.getName().substring(3);
+            if (attributeNames.contains(attrName)) {
+                return new KernelSetAttributeInvoker(kernel, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributeNames.contains(attrName)) {
+                return new KernelSetAttributeInvoker(kernel, attrName);
+            }
+        }
+        return null;
+    }
+
+    private static int getSuperIndex(Class proxyType, Method method) {
+        Signature signature = new Signature(method.getName(), Type.getReturnType(method), Type.getArgumentTypes(method));
+        MethodProxy methodProxy = MethodProxy.find(proxyType, signature);
+        if (methodProxy != null) {
+            return methodProxy.getSuperIndex();
+        }
+        return -1;
+    }
+
+    private static Integer getMethodIndex(Map attributes, String attributeName) {
+        Iterator iter = attributes.keySet().iterator();
+        while (iter.hasNext()) {
+            String key = (String) iter.next();
+            if (key.equalsIgnoreCase(attributeName)) {
+                return (Integer) attributes.get(key);
+            }
+        }
+        return null;
+    }
+
+    static final class HashCodeInvoke implements ProxyInvoker {
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return new Integer(objectName.hashCode());
+        }
+    }
+
+    static final class EqualsInvoke implements ProxyInvoker {
+        private final ProxyManager proxyManager;
+
+        public EqualsInvoke(ProxyManager proxyManager) {
+            this.proxyManager = proxyManager;
+        }
+
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            ObjectName proxyTarget = proxyManager.getProxyTarget(arguments[0]);
+            return Boolean.valueOf(objectName.equals(proxyTarget));
+        }
+    }
+
+    static final class ToStringInvoke implements ProxyInvoker {
+        private final String interfaceName;
+
+        public ToStringInvoke(String interfaceName) {
+            this.interfaceName = "[" + interfaceName + ": ";
+        }
+
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return interfaceName + objectName + "]";
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawGetAttributeInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawGetAttributeInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawGetAttributeInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawGetAttributeInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawGetAttributeInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawGetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        return rawInvoker.getAttribute(methodIndex);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawOperationInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawOperationInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawOperationInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawOperationInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawOperationInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawOperationInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        return rawInvoker.invoke(methodIndex, arguments);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawSetAttributeInvoker.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawSetAttributeInvoker.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawSetAttributeInvoker.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/basic/RawSetAttributeInvoker.java Sun May  8 12:35:23 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.basic;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.runtime.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawSetAttributeInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawSetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        rawInvoker.setAttribute(methodIndex, arguments[0]);
+        return null;
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Sun May  8 12:35:23 2005
@@ -46,8 +46,8 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.ObjectInputStreamExt;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -61,8 +61,8 @@
  * <p/>
  * The persistent attributes of the Configuration are:
  * <ul>
- * <li>its unique configID used to identify this specific config</li>
- * <li>the configID of a parent Configuration on which this one is dependent</li>
+ * <li>its unique configId used to identify this specific config</li>
+ * <li>the configId of a parent Configuration on which this one is dependent</li>
  * <li>a List<URI> of code locations (which may be absolute or relative to a baseURL)</li>
  * <li>a byte[] holding the state of the GBeans instances in Serialized form</li>
  * </ul>
@@ -84,8 +84,8 @@
 public class Configuration implements GBeanLifecycle {
     private static final Log log = LogFactory.getLog(Configuration.class);
 
-    public static ObjectName getConfigurationObjectName(URI configID) throws MalformedObjectNameException {
-        return new ObjectName("geronimo.config:name=" + ObjectName.quote(configID.toString()));
+    public static ObjectName getConfigurationObjectName(URI configId) throws MalformedObjectNameException {
+        return new ObjectName("geronimo.config:name=" + ObjectName.quote(configId.toString()));
     }
 
     /**
@@ -112,7 +112,7 @@
     /**
      * The uri of the parent of this configuration.  May be null.
      */
-    private final URI parentID;
+    private final URI parentId;
 
     /**
      * The configuration store from which this configuration was loaded.  May be null if this configuration
@@ -121,6 +121,8 @@
      */
     private final ConfigurationStore configurationStore;
 
+    private final List dependencies;
+    private final List classPath;
     private final String domain;
     private final String server;
 
@@ -150,19 +152,21 @@
         objectName = null;
         id = null;
         moduleType = null;
-        parentID = null;
+        parentId = null;
         configurationStore = null;
         domain = null;
         server = null;
         objectNames = null;
         configurationClassLoader = null;
+        dependencies = null;
+        classPath = null;
     }
 
     /**
      * Constructor that can be used to create an offline Configuration, typically
      * only used publically during the deployment process for initial configuration.
      *
-     * @param id           the unique ID of this Configuration
+     * @param id           the unique id of this Configuration
      * @param moduleType   the module type identifier
      * @param parent       the parent Configuration; may be null
      * @param classPath    a List<URI> of locations that define the codebase for this Configuration
@@ -175,7 +179,7 @@
             URI id,
             ConfigurationModuleType moduleType,
             URL baseURL,
-            URI parentID,
+            URI parentId,
             ConfigurationParent parent,
             String domain,
             String server,
@@ -190,8 +194,18 @@
         this.objectName = JMXUtil.getObjectName(objectName);
         this.id = id;
         this.moduleType = moduleType;
-        this.parentID = parentID;
+        this.parentId = parentId;
         this.gbeanState = gbeanState;
+        if (classPath != null) {
+            this.classPath = classPath;
+        } else {
+            this.classPath = Collections.EMPTY_LIST;
+        }
+        if (dependencies != null) {
+            this.dependencies = dependencies;
+        } else {
+            this.dependencies = Collections.EMPTY_LIST;
+        }
 
         this.configurationStore = configurationStore;
 
@@ -341,7 +355,16 @@
         }
 
         if (configurationStore != null) {
-            configurationStore.updateConfiguration(this);
+            ConfigurationData configurationData = new ConfigurationData();
+            configurationData.setId(id);
+            configurationData.setModuleType(moduleType);
+            configurationData.setDomain(domain);
+            configurationData.setServer(server);
+            configurationData.setParentId(parentId);
+            configurationData.setGBeans(Arrays.asList(gbeans));
+            configurationData.setDependencies(dependencies);
+            configurationData.setClassPath(classPath);
+            configurationStore.updateConfiguration(configurationData);
         }
     }
 
@@ -349,20 +372,20 @@
     }
 
     /**
-     * Return the unique ID of this Configuration's parent
+     * Return the unique id of this Configuration's parent
      *
-     * @return the unique ID of the parent, or null if it does not have one
+     * @return the unique id of the parent, or null if it does not have one
      */
-    public URI getParentID() {
-        return parentID;
+    public URI getParentId() {
+        return parentId;
     }
 
     /**
-     * Return the unique ID
+     * Return the unique Id
      *
-     * @return the unique ID
+     * @return the unique Id
      */
-    public URI getID() {
+    public URI getId() {
         return id;
     }
 
@@ -422,6 +445,10 @@
      * @throws org.apache.geronimo.kernel.config.InvalidConfigException if there is a problem serializing the state
      */
     public static byte[] storeGBeans(GBeanData[] gbeans) throws InvalidConfigException {
+        return storeGBeans(Arrays.asList(gbeans));
+    }
+
+    public static byte[] storeGBeans(List gbeans) throws InvalidConfigException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos;
         try {
@@ -429,8 +456,8 @@
         } catch (IOException e) {
             throw (AssertionError) new AssertionError("Unable to initialize ObjectOutputStream").initCause(e);
         }
-        for (int i = 0; i < gbeans.length; i++) {
-            GBeanData gbeanData = gbeans[i];
+        for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+            GBeanData gbeanData = (GBeanData) iterator.next();
             try {
                 gbeanData.writeExternal(oos);
             } catch (Exception e) {
@@ -451,9 +478,9 @@
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(Configuration.class);//does not use jsr-77 naming
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addAttribute("objectName", String.class, false);
-        infoFactory.addAttribute("ID", URI.class, true);
+        infoFactory.addAttribute("id", URI.class, true);
         infoFactory.addAttribute("type", ConfigurationModuleType.class, true);
-        infoFactory.addAttribute("parentID", URI.class, true);
+        infoFactory.addAttribute("parentId", URI.class, true);
         infoFactory.addAttribute("domain", String.class, true);
         infoFactory.addAttribute("server", String.class, true);
         infoFactory.addAttribute("classPath", List.class, true);
@@ -469,10 +496,10 @@
         infoFactory.setConstructor(new String[]{
             "kernel",
             "objectName",
-            "ID",
+            "id",
             "type",
             "baseURL",
-            "parentID",
+            "parentId",
             "Parent",
             "domain",
             "server",

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java Sun May  8 12:35:23 2005
@@ -0,0 +1,199 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.config;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedHashSet;
+
+import org.apache.geronimo.gbean.GBeanData;
+
+/**
+ * @version $Rev: 158589 $ $Date: 2005-03-22 02:03:00 -0800 (Tue, 22 Mar 2005) $
+ */
+public class ConfigurationData {
+    /**
+     * URI used to referr to this configuration in the configuration manager
+     */
+    private URI id;
+
+    /**
+     * Identifies the type of configuration (WAR, RAR et cetera)
+     */
+    private ConfigurationModuleType moduleType;
+
+    /**
+     * The uri of the parent of this configuration.  May be null.
+     */
+    private URI parentId;
+
+    /**
+     * The domain name of the configurations.  This is used to autogenerate names for sub components.
+     */
+    private String domain;
+
+    /**
+     * The server name of the configurations.  This is used to autogenerate names for sub components.
+     */
+    private String server;
+
+    /**
+     * List of URIs of jar files on which this configuration is dependent on.
+     */
+    private final LinkedHashSet dependencies = new LinkedHashSet();
+
+    /**
+     * List of URIs in this configuration's classpath.
+     */
+    private final LinkedHashSet classPath = new LinkedHashSet();
+
+    /**
+     * GBeans contained in this configuration.
+     */
+    private final List gbeans = new ArrayList();
+
+    /**
+     * Child configurations of this configuration
+     */
+    private final List childConfigurations = new ArrayList();
+
+    public ConfigurationData() {
+    }
+
+    public ConfigurationData(ConfigurationData configurationData) {
+        id = configurationData.id;
+        moduleType = configurationData.moduleType;
+        parentId = configurationData.getParentId();
+        domain = configurationData.domain;
+        server = configurationData.server;
+        setDependencies(new ArrayList(configurationData.dependencies));
+        setClassPath(new ArrayList(configurationData.classPath));
+        setGBeans(configurationData.gbeans);
+        setChildConfigurations(configurationData.childConfigurations);
+    }
+
+    public URI getId() {
+        return id;
+    }
+
+    public void setId(URI id) {
+        this.id = id;
+    }
+
+    public ConfigurationModuleType getModuleType() {
+        return moduleType;
+    }
+
+    public void setModuleType(ConfigurationModuleType moduleType) {
+        this.moduleType = moduleType;
+    }
+
+    public URI getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(URI parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+    public String getServer() {
+        return server;
+    }
+
+    public void setServer(String server) {
+        this.server = server;
+    }
+
+    public List getDependencies() {
+        return Collections.unmodifiableList(new ArrayList(dependencies));
+    }
+
+    public void setDependencies(List dependencies) {
+        this.dependencies.clear();
+        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+            URI dependency = (URI) iterator.next();
+            addDependency(dependency);
+        }
+    }
+
+    public void addDependency(URI dependency) {
+        assert dependency != null;
+        this.dependencies.add(dependency);
+    }
+
+    public List getClassPath() {
+        return Collections.unmodifiableList(new ArrayList(classPath));
+    }
+
+    public void setClassPath(List classPath) {
+        this.classPath.clear();
+        for (Iterator iterator = classPath.iterator(); iterator.hasNext();) {
+            URI location = (URI) iterator.next();
+            addClassPathLocation(location);
+        }
+    }
+
+    public void addClassPathLocation(URI location) {
+        assert location != null;
+        this.classPath.add(location);
+    }
+
+    public List getGBeans() {
+        return Collections.unmodifiableList(gbeans);
+    }
+
+    public void setGBeans(List gbeans) {
+        this.gbeans.clear();
+        for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+            GBeanData gbeanData = (GBeanData) iterator.next();
+            addGBean(gbeanData);
+        }
+    }
+
+    public void addGBean(GBeanData gbeanData) {
+        assert gbeanData != null;
+        gbeans.add(gbeanData);
+    }
+
+    public List getChildConfigurations() {
+        return Collections.unmodifiableList(childConfigurations);
+    }
+
+    public void setChildConfigurations(List childConfigurations) {
+        this.childConfigurations.clear();
+        for (Iterator iterator = childConfigurations.iterator(); iterator.hasNext();) {
+            ConfigurationData configurationData = (ConfigurationData) iterator.next();
+            addChildConfiguration(configurationData);
+        }
+    }
+    public void addChildConfiguration(ConfigurationData configurationData) {
+        assert configurationData != null;
+        childConfigurations.add(configurationData);
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java Sun May  8 12:35:23 2005
@@ -18,18 +18,18 @@
 
 import java.io.IOException;
 import java.net.URI;
-import java.net.URL;
 import java.util.List;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.gbean.GBeanData;
-
 /**
- * 
- * 
  * @version $Rev$ $Date$
  */
 public interface ConfigurationManager {
+    /**
+     * Is the specified configuration loaded into the kernel?
+     * @param configID the name of the configuration
+     * @return true if the configuration has been loaded; false otherwise
+     */
     boolean isLoaded(URI configID);
 
     /**
@@ -46,23 +46,30 @@
      */
     List listConfigurations(ObjectName store) throws NoSuchStoreException;
 
+    /**
+     * Load the specified configuration into the kernel.
+     * @param configID the id of the configuration
+     * @return the name of the new configuration object mounted into the kernel
+     * @throws NoSuchConfigException if no configuration with the given id exists in the configuration stores
+     * @throws IOException if there is a problem loading te configuration from the store
+     * @throws InvalidConfigException if the configuration is corrupt
+     */
     ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException;
 
     /**
-     * Load the supplied Configuration into the Kernel and override the default JMX name.
-     * This method should be used with discretion as it is possible to create
-     * Configurations that cannot be located by management or monitoring tools.
-     *
-     * @param config the GBeanData representing the Configuration
-     * @param rootURL the URL to be used to resolve relative paths in the configuration
-     * @throws org.apache.geronimo.kernel.config.InvalidConfigException if the Configuration is not valid
+     * Load the specified configuration and all parent configurations into the kernel.
+     * @param configID the id of the configuration
+     * @return a list of names of configurations loaded into the kernel
+     * @throws NoSuchConfigException if no configuration with the given id exists in the configuration stores
+     * @throws IOException if there is a problem loading te configuration from the store
+     * @throws InvalidConfigException if the configuration is corrupt
      */
-    ObjectName load(GBeanData config, URL rootURL, ClassLoader classLoader) throws InvalidConfigException;
-
     List loadRecursive(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException;
 
+    /**
+     * Unloads the specified configuration from the kernel
+     * @param configID the name fo the configuration to remove
+     * @throws NoSuchConfigException if the configuration is now loaded into the kernel
+     */
     void unload(URI configID) throws NoSuchConfigException;
-
-    void unload(ObjectName configName) throws NoSuchConfigException;
-
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java Sun May  8 12:35:23 2005
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.net.URI;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -31,7 +30,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -39,7 +37,6 @@
 import org.apache.geronimo.kernel.InternalKernelException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.management.State;
 
 /**
  * @version $Rev$ $Date$
@@ -48,10 +45,12 @@
     private static final Log log = LogFactory.getLog(ConfigurationManagerImpl.class);
     private final Kernel kernel;
     private final Collection stores;
+    private final ShutdownHook shutdownHook;
 
     public ConfigurationManagerImpl(Kernel kernel, Collection stores) {
         this.kernel = kernel;
         this.stores = stores;
+        shutdownHook = new ShutdownHook(kernel);
     }
 
     public List listStores() {
@@ -69,38 +68,7 @@
         for (int i = 0; i < storeSnapshot.size(); i++) {
             ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
             if (storeName.equals(JMXUtil.getObjectName(store.getObjectName()))) {
-                List ids = store.listConfiguations();
-                List result = new ArrayList(ids.size());
-                for (int j = 0; j < ids.size(); j++) {
-                    URI configID = (URI) ids.get(j);
-                    ObjectName configName;
-                    try {
-                        configName = Configuration.getConfigurationObjectName(configID);
-                    } catch (MalformedObjectNameException e) {
-                        throw new AssertionError("Store returned invalid configID: " + configID);
-                    }
-                    State state;
-                    if (kernel.isLoaded(configName)) {
-                        try {
-                            state = State.fromInteger((Integer) kernel.getAttribute(configName, "state"));
-                        } catch (Exception e) {
-                            state = null;
-                        }
-                    } else {
-                        // If the configuration is not loaded by the kernel
-                        // and defined by the store, then it is stopped.
-                        state = State.STOPPED;
-                    }
-                    ConfigurationModuleType type = null;
-                    try {
-                        GBeanData bean = store.getConfiguration(configID);
-                        type = (ConfigurationModuleType) bean.getAttribute("type");
-                    } catch (Exception e) {
-                        log.error(store + " defines configID " + configID + " which can not be loaded.");
-                    }
-                    result.add(new ConfigurationInfo(storeName, configID, state, type));
-                }
-                return result;
+                return store.listConfiguations();
             }
         }
         throw new NoSuchStoreException("No such store: " + storeName);
@@ -121,52 +89,19 @@
         for (int i = 0; i < storeSnapshot.size(); i++) {
             ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
             if (store.containsConfiguration(configID)) {
-                GBeanData config = store.getConfiguration(configID);
-                URL baseURL = store.getBaseURL(configID);
-                return load(config, baseURL, Configuration.class.getClassLoader());
+                return store.loadConfiguration(configID);
             }
         }
         throw new NoSuchConfigException("No configuration with id: " + configID);
     }
 
-    public ObjectName load(GBeanData config, URL rootURL, ClassLoader classLoader) throws InvalidConfigException {
-        ObjectName name;
-        try {
-            URI configID = (URI) config.getAttribute("ID");
-            name = Configuration.getConfigurationObjectName(configID);
-        } catch (MalformedObjectNameException e) {
-            throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e);
-        }
-        config.setName(name);
-
-        try {
-            kernel.loadGBean(config, classLoader);
-        } catch (Exception e) {
-            throw new InvalidConfigException("Unable to register configuration", e);
-        }
-
-        try {
-            kernel.setAttribute(name, "baseURL", rootURL);
-        } catch (Exception e) {
-            try {
-                kernel.unloadGBean(name);
-            } catch (Exception ignored) {
-                // ignore
-            }
-            throw new InvalidConfigException("Cannot set baseURL", e);
-        }
-        log.info("Loaded Configuration " + name);
-
-        return name;
-    }
-
     public List loadRecursive(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
         try {
             LinkedList ancestors = new LinkedList();
             while (configID != null && !isLoaded(configID)) {
                 ObjectName name = load(configID);
                 ancestors.addFirst(name);
-                configID = (URI) kernel.getAttribute(name, "parentID");
+                configID = (URI) kernel.getAttribute(name, "parentId");
             }
             return ancestors;
         } catch (NoSuchConfigException e) {
@@ -187,10 +122,6 @@
         } catch (MalformedObjectNameException e) {
             throw new NoSuchConfigException("Cannot convert ID to ObjectName: ", e);
         }
-        unload(configName);
-    }
-
-    public void unload(ObjectName configName) throws NoSuchConfigException {
         try {
             kernel.unloadGBean(configName);
         } catch (GBeanNotFoundException e) {
@@ -204,45 +135,25 @@
     }
 
     public void doStart() {
+        kernel.registerShutdownHook(shutdownHook);
     }
 
     private static final ObjectName CONFIG_QUERY = JMXUtil.getObjectName("geronimo.config:*");
 
     public void doStop() {
-        while (true) {
-            Set configs = kernel.listGBeans(CONFIG_QUERY);
-            if (configs.isEmpty()) {
-                return;
-            }
-            for (Iterator i = configs.iterator(); i.hasNext();) {
-                ObjectName configName = (ObjectName) i.next();
-                if (kernel.isLoaded(configName)) {
-                    try {
-                        kernel.stopGBean(configName);
-                    } catch (GBeanNotFoundException e) {
-                        // ignore
-                    } catch (InternalKernelException e) {
-                        log.warn("Could not stop configuration: " + configName, e);
-                    }
-                    try {
-                        kernel.unloadGBean(configName);
-                    } catch (GBeanNotFoundException e) {
-                        // ignore
-                    }
-                }
-            }
-        }
+        kernel.unregisterShutdownHook(shutdownHook);
     }
 
     public void doFail() {
+        log.error("Cofiguration manager failed");
     }
 
     public static final GBeanInfo GBEAN_INFO;
 
     static {
-        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(ConfigurationManagerImpl.class);  //name assigned by boot process
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(ConfigurationManagerImpl.class, "ConfigurationManager");
         infoFactory.addAttribute("kernel", Kernel.class, false);
-        infoFactory.addReference("Stores", ConfigurationStore.class);
+        infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore");
         infoFactory.addInterface(ConfigurationManager.class);
         infoFactory.setConstructor(new String[]{"kernel", "Stores"});
         GBEAN_INFO = infoFactory.getBeanInfo();
@@ -250,5 +161,39 @@
 
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
+    }
+
+    private static class ShutdownHook implements Runnable {
+        private final Kernel kernel;
+
+        public ShutdownHook(Kernel kernel) {
+            this.kernel = kernel;
+        }
+
+        public void run() {
+            while (true) {
+                Set configs = kernel.listGBeans(CONFIG_QUERY);
+                if (configs.isEmpty()) {
+                    return;
+                }
+                for (Iterator i = configs.iterator(); i.hasNext();) {
+                    ObjectName configName = (ObjectName) i.next();
+                    if (kernel.isLoaded(configName)) {
+                        try {
+                            kernel.stopGBean(configName);
+                        } catch (GBeanNotFoundException e) {
+                            // ignore
+                        } catch (InternalKernelException e) {
+                            log.warn("Could not stop configuration: " + configName, e);
+                        }
+                        try {
+                            kernel.unloadGBean(configName);
+                        } catch (GBeanNotFoundException e) {
+                            // ignore
+                        }
+                    }
+                }
+            }
+        }
     }
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java Sun May  8 12:35:23 2005
@@ -23,7 +23,7 @@
 import java.net.URL;
 import java.util.List;
 
-import org.apache.geronimo.gbean.GBeanData;
+import javax.management.ObjectName;
 
 /**
  * Interface to a store for Configurations.
@@ -43,15 +43,32 @@
     /**
      * Move the unpacked configuration directory into this store
      *
+     * @param configurationData the configuration data
      * @param source the directory which contains a contiguration
      * @throws IOException if the direcotyr could not be moved into the store
      * @throws InvalidConfigException if there is a configuration problem within the source direcotry
      */
-    URI install(File source) throws IOException, InvalidConfigException;
+    void install(ConfigurationData configurationData, File source) throws IOException, InvalidConfigException;
 
+    /**
+     * Removes a configuration from the store
+     * @param configID the id of the configuration to remove
+     * @throws NoSuchConfigException if the configuration is not contained in the store
+     * @throws IOException if a problem occurs during the removal
+     */
     void uninstall(URI configID) throws NoSuchConfigException, IOException;
 
     /**
+     * Loads the specified configuration into the kernel
+     * @param configId the id of the configuration to load
+     * @return the object name of the configuration in the kernel
+     * @throws NoSuchConfigException if the configuration is not contained in the kernel
+     * @throws IOException if a problem occurs loading the configuration from the store
+     * @throws InvalidConfigException if the configuration is corrupt
+     */
+    ObjectName loadConfiguration(URI configId) throws NoSuchConfigException, IOException, InvalidConfigException;
+
+    /**
      * Determines if the store contains a configuration with the spedified ID.
      *
      * @param configID the unique ID of the configuration
@@ -60,31 +77,11 @@
     boolean containsConfiguration(URI configID);
 
     /**
-     * Return the Configuration GBean for the specified ID
-     *
-     * @param id the unique ID of a Configuration
-     * @return the GBeanData for that configuration
-     * @throws NoSuchConfigException if the store does not contain a Configuration with that id
-     * @throws IOException if there was a problem loading the Configuration from the store
-     * @throws InvalidConfigException if the Configuration is invalid
-     */
-    GBeanData getConfiguration(URI id) throws NoSuchConfigException, IOException, InvalidConfigException;
-
-    /**
      * Updates the saved state of the configuration.
      *
-     * @param configuration the configuration to update
+     * @param configurationData the configuration to update
      */
-    void updateConfiguration(Configuration configuration) throws NoSuchConfigException, Exception;
-
-    /**
-     * Return the base URL for the specified ID
-     *
-     * @param id the unique ID for a Configuration
-     * @return the URL of the base location for the Configuration that should be used for resolution
-     * @throws NoSuchConfigException if the store does not contain a Configuration with that id
-     */
-    URL getBaseURL(URI id) throws NoSuchConfigException;
+    void updateConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, Exception;
 
     /**
      * Return the object name for the store.
@@ -96,9 +93,10 @@
     /**
      * Return the configurations in the store
      *
-     * @return a List<URI> of configurations in the store
+     * @return a List ConfigurationInfo objects
      */
     List listConfiguations();
 
     File createNewConfigurationDir();
+
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Sun May  8 12:35:23 2005
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.config;
+
+import java.util.Set;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class ConfigurationUtil {
+    private static final ObjectName CONFIGURATION_MANAGER_QUERY = JMXUtil.getObjectName("*:j2eeType=ConfigurationManager,*");
+
+    private ConfigurationUtil() {
+    }
+
+    public static ConfigurationManager getConfigurationManager(Kernel kernel) {
+        // todo cache this
+        Set names = kernel.listGBeans(CONFIGURATION_MANAGER_QUERY);
+        if (names.isEmpty()) {
+            throw new IllegalStateException("Configuration mananger could not be found in kernel: " + CONFIGURATION_MANAGER_QUERY);
+        }
+        if (names.size() > 1) {
+            throw new IllegalStateException("More then one configuration mananger was found in kernel: " + CONFIGURATION_MANAGER_QUERY);
+        }
+        ObjectName configurationManagerName = (ObjectName) names.iterator().next();
+        return (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyManager.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyManager.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyManager.java Sun May  8 12:35:23 2005
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.jmx;
+
+import java.util.IdentityHashMap;
+import javax.management.ObjectName;
+
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.basic.ProxyMethodInterceptor;
+import org.apache.geronimo.kernel.proxy.ProxyFactory;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMXProxyManager implements ProxyManager {
+    private final Kernel kernel;
+    private final IdentityHashMap interceptors = new IdentityHashMap();
+
+    public JMXProxyManager(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public synchronized ProxyFactory createProxyFactory(Class type) {
+        assert type != null: "type is null";
+        return new ManagedProxyFactory(type);
+    }
+
+    public synchronized Object createProxy(ObjectName target, Class type) {
+        assert type != null: "type is null";
+        assert target != null: "target is null";
+
+        return createProxyFactory(type).createProxy(target);
+    }
+
+    public synchronized void destroyProxy(Object proxy) {
+        if (proxy == null) {
+            return;
+        }
+
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor != null) {
+            methodInterceptor.destroy();
+        }
+    }
+
+    public boolean isProxy(Object proxy) {
+        return interceptors.containsKey(proxy);
+    }
+
+    public synchronized ObjectName getProxyTarget(Object proxy) {
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor == null) {
+            return null;
+        }
+        return methodInterceptor.getObjectName();
+    }
+
+    private class ManagedProxyFactory implements ProxyFactory {
+        private final Class type;
+        private final Enhancer enhancer;
+
+        public ManagedProxyFactory(Class type) {
+            enhancer = new Enhancer();
+            enhancer.setSuperclass(type);
+            enhancer.setCallbackType(MethodInterceptor.class);
+            enhancer.setUseFactory(false);
+            this.type = enhancer.createClass();
+        }
+
+        public synchronized Object createProxy(ObjectName target) {
+            assert target != null: "target is null";
+
+            JMXProxyMethodInterceptor interceptor = new JMXProxyMethodInterceptor(type, kernel, target);
+
+            // @todo trap CodeGenerationException indicating missing no-arg ctr
+            enhancer.setCallbacks(new Callback[]{interceptor});
+            Object proxy = enhancer.create();
+
+            interceptors.put(proxy, interceptor);
+            return proxy;
+        }
+    }
+}



Mime
View raw message