geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r395155 [2/2] - in /geronimo/branches/1.1: applications/console-core/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/java/org/apache/geronimo/console/internaldb/ applications/console-standard/src/java/org/apache...
Date Wed, 19 Apr 2006 06:44:28 GMT
Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java?rev=395155&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java Tue Apr 18 23:44:24 2006
@@ -0,0 +1,1003 @@
+/**
+ *
+ * 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.system.jmx;
+
+import java.util.Date;
+import java.util.Set;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.JMRuntimeException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class KernelDelegate implements Kernel {
+    private final MBeanServerConnection mbeanServer;
+    private final ProxyManager proxyManager;
+
+    public KernelDelegate(MBeanServerConnection mbeanServer) {
+        this.mbeanServer = mbeanServer;
+        proxyManager = new JMXProxyManager(this);
+    }
+
+    public Date getBootTime() {
+        return (Date) getKernelAttribute("bootTime");
+    }
+
+    public String getKernelName() {
+        return (String) getKernelAttribute("kernelName");
+    }
+
+    public Naming getNaming() {
+        return (Naming) getKernelAttribute("naming");
+    }
+
+    public Object getGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            return invokeKernel("getGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            return invokeKernel("getGBean", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            return invokeKernel("getGBean", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            return invokeKernel("getGBean", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            return invokeKernel("getGBean", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException {
+        try {
+            invokeKernel("loadGBean", new Object[] {gbeanData, classLoader}, new String[] {GBeanData.class.getName(), ClassLoader.class.getName()});
+        } catch (GBeanAlreadyExistsException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startGBean", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startGBean", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startGBean", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startGBean", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startRecursiveGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startRecursiveGBean", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startRecursiveGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startRecursiveGBean", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startRecursiveGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startRecursiveGBean", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void startRecursiveGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("startRecursiveGBean", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isRunning(AbstractName name) {
+        try {
+            return ((Boolean) invokeKernel("isRunning", new Object[]{name}, new String[]{AbstractName.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+     }
+
+    public boolean isRunning(String shortName) {
+        try {
+            return ((Boolean) invokeKernel("isRunning", new Object[]{shortName}, new String[]{String.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isRunning(Class type) {
+        try {
+            return ((Boolean) invokeKernel("isRunning", new Object[]{type}, new String[]{Class.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isRunning(String shortName, Class type) {
+        try {
+            return ((Boolean) invokeKernel("isRunning", new Object[]{shortName, type}, new String[]{String.class.getName(), Class.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+
+    public void stopGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("stopGBean", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void stopGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("stopGBean", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void stopGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("stopGBean", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void stopGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("stopGBean", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unloadGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("unloadGBean", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unloadGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("unloadGBean", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unloadGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("unloadGBean", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unloadGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        try {
+            invokeKernel("unloadGBean", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return ((Integer) invokeKernel("getGBeanState", new Object[]{name}, new String[]{ObjectName.class.getName()})).intValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getGBeanState(AbstractName name) throws GBeanNotFoundException {
+        try {
+            return ((Integer) invokeKernel("getGBeanState", new Object[]{name}, new String[]{AbstractName.class.getName()})).intValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getGBeanState(String shortName) throws GBeanNotFoundException {
+        try {
+            return ((Integer) invokeKernel("getGBeanState", new Object[]{shortName}, new String[]{String.class.getName()})).intValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getGBeanState(Class type) throws GBeanNotFoundException {
+        try {
+            return ((Integer) invokeKernel("getGBeanState", new Object[]{type}, new String[]{Class.class.getName()})).intValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public int getGBeanState(String shortName, Class type) throws GBeanNotFoundException {
+        try {
+            return ((Integer) invokeKernel("getGBeanState", new Object[]{shortName, type}, new String[]{String.class.getName(), Class.class.getName()})).intValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public long getGBeanStartTime(AbstractName name) throws GBeanNotFoundException {
+        try {
+            return ((Long) invokeKernel("getGBeanStartTime", new Object[]{name}, new String[]{AbstractName.class.getName()})).longValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public long getGBeanStartTime(String shortName) throws GBeanNotFoundException {
+        try {
+            return ((Long) invokeKernel("getGBeanStartTime", new Object[]{shortName}, new String[]{String.class.getName()})).longValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public long getGBeanStartTime(Class type) throws GBeanNotFoundException {
+        try {
+            return ((Long) invokeKernel("getGBeanStartTime", new Object[]{type}, new String[]{Class.class.getName()})).longValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public long getGBeanStartTime(String shortName, Class type) throws GBeanNotFoundException {
+        try {
+            return ((Long) invokeKernel("getGBeanStartTime", new Object[]{shortName, type}, new String[]{String.class.getName(), Class.class.getName()})).longValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return ((Boolean) invokeKernel("isGBeanEnabled", new Object[] {name}, new String[] {ObjectName.class.getName()})).booleanValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isGBeanEnabled(AbstractName name) throws GBeanNotFoundException {
+        try {
+            return ((Boolean) invokeKernel("isGBeanEnabled", new Object[] {name}, new String[] {AbstractName.class.getName()})).booleanValue();
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException {
+        try {
+            invokeKernel("setGBeanEnabled", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void setGBeanEnabled(AbstractName name, boolean enabled) throws GBeanNotFoundException {
+        try {
+            invokeKernel("setGBeanEnabled", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
+        return invokeKernel("getAttribute", new Object[]{objectName, attributeName}, new String[]{ObjectName.class.getName(), String.class.getName()});
+    }
+
+    public Object getAttribute(AbstractName abstractName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return invokeKernel("getAttribute", new Object[]{abstractName, attributeName}, new String[]{AbstractName.class.getName(), String.class.getName()});
+    }
+
+    public Object getAttribute(String shortName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return invokeKernel("getAttribute", new Object[]{shortName, attributeName}, new String[]{String.class.getName(), String.class.getName()});
+    }
+
+    public Object getAttribute(Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return invokeKernel("getAttribute", new Object[]{type, attributeName}, new String[]{Class.class.getName(), String.class.getName()});
+    }
+
+    public Object getAttribute(String shortName, Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return invokeKernel("getAttribute", new Object[]{shortName, type, attributeName}, new String[]{String.class.getName(), Class.class.getName(), String.class.getName()});
+    }
+
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws Exception {
+        invokeKernel("setAttribute", new Object[]{objectName, attributeName, attributeValue}, new String[]{ObjectName.class.getName(), String.class.getName(), Object.class.getName()});
+    }
+
+    public void setAttribute(AbstractName abstractName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        invokeKernel("setAttribute", new Object[]{abstractName, attributeName, attributeValue}, new String[]{AbstractName.class.getName(), String.class.getName(), Object.class.getName()});
+    }
+
+    public void setAttribute(String shortName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        invokeKernel("setAttribute", new Object[]{shortName, attributeName, attributeValue}, new String[]{String.class.getName(), String.class.getName(), Object.class.getName()});
+    }
+
+    public void setAttribute(Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        invokeKernel("setAttribute", new Object[]{type, attributeName, attributeValue}, new String[]{Class.class.getName(), String.class.getName(), Object.class.getName()});
+    }
+
+    public void setAttribute(String shortName, Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        invokeKernel("setAttribute", new Object[]{shortName, type, attributeName, attributeValue}, new String[]{String.class.getName(), Class.class.getName(), String.class.getName(), Object.class.getName()});
+    }
+
+    public Object invoke(ObjectName objectName, String methodName) throws Exception {
+        return invokeKernel("invoke", new Object[]{objectName, methodName}, new String[]{ObjectName.class.getName(), String.class.getName()});
+    }
+
+    public Object invoke(AbstractName abstractName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{abstractName, methodName}, new String[]{AbstractName.class.getName(), String.class.getName()});
+    }
+
+    public Object invoke(String shortName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{shortName, methodName}, new String[]{String.class.getName(), String.class.getName()});
+    }
+
+    public Object invoke(Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{type, methodName}, new String[]{Class.class.getName(), String.class.getName()});
+    }
+
+    public Object invoke(String shortName, Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{shortName, type, methodName}, new String[]{String.class.getName(), Class.class.getName(), String.class.getName()});
+    }
+
+    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws Exception {
+        return invokeKernel("invoke", new Object[]{objectName, methodName, args, types}, new String[]{ObjectName.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+    }
+
+    public Object invoke(AbstractName abstractName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{abstractName, methodName, args, types}, new String[]{AbstractName.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+    }
+
+    public Object invoke(String shortName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{shortName, methodName, args, types}, new String[]{String.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+    }
+
+    public Object invoke(Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{type, methodName, args, types}, new String[]{Class.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+    }
+
+    public Object invoke(String shortName, Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invokeKernel("invoke", new Object[]{shortName, type, methodName, args, types}, new String[]{String.class.getName(), Class.class.getName(), String.class.getName(), Object[].class.getName(), String[].class.getName()});
+    }
+
+    public boolean isLoaded(ObjectName name) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{name}, new String[]{ObjectName.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isLoaded(AbstractName name) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{name}, new String[]{AbstractName.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+     }
+
+    public boolean isLoaded(String shortName) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{shortName}, new String[]{String.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isLoaded(Class type) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{type}, new String[]{Class.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public boolean isLoaded(String shortName, Class type) {
+        try {
+            return ((Boolean) invokeKernel("isLoaded", new Object[]{shortName, type}, new String[]{String.class.getName(), Class.class.getName()})).booleanValue();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(AbstractName name) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(String shortName) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(Class type) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanInfo getGBeanInfo(String shortName, Class type) throws GBeanNotFoundException {
+        try {
+            return (GBeanInfo) invokeKernel("getGBeanInfo", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Set listGBeans(ObjectName pattern) {
+        try {
+            return (Set) invokeKernel("listGBeans", new Object[] {pattern}, new String[] {ObjectName.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public Set listGBeans(Set patterns) {
+        try {
+            return (Set) invokeKernel("listGBeans", new Object[] {patterns}, new String[] {Set.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void registerShutdownHook(Runnable hook) {
+        try {
+            invokeKernel("registerShutdownHook", new Object[] {hook}, new String[] {Runnable.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void unregisterShutdownHook(Runnable hook) {
+        try {
+            invokeKernel("unregisterShutdownHook", new Object[] {hook}, new String[] {Runnable.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public void shutdown() {
+        try {
+            invokeKernel("shutdown", new Object[] {}, new String[] {});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
+        try {
+            return (ClassLoader) invokeKernel("getClassLoaderFor", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {name}, new String[] {ObjectName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(AbstractName name) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {name}, new String[] {AbstractName.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(String shortName) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {shortName}, new String[] {String.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(Class type) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {type}, new String[] {Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public GBeanData getGBeanData(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException {
+        try {
+            return (GBeanData) invokeKernel("getGBeanData", new Object[] {shortName, type}, new String[] {String.class.getName(), Class.class.getName()});
+        } catch (GBeanNotFoundException e) {
+            throw e;
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public AbstractName getAbstractNameFor(Object service) {
+        AbstractName name = proxyManager.getProxyTarget(service);
+        if (name != null) {
+            return name;
+        }
+        try {
+            return (AbstractName) invokeKernel("getAbstractNameFor", new Object[] {service}, new String[] {Object.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    public String getShortNameFor(Object service) {
+        AbstractName name = getAbstractNameFor(service);
+        return (String) name.getName().get("name");
+    }
+
+    public boolean isRunning() {
+        return ((Boolean) getKernelAttribute("running")).booleanValue();
+    }
+
+    public Set listGBeans(AbstractNameQuery query) {
+        try {
+            return (Set) invokeKernel("listGBeans", new Object[] {query}, new String[] {AbstractNameQuery.class.getName()});
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InternalKernelException(e);
+        }
+    }
+
+    /**
+     * Throws UnsupportedOperationException.  The dependency manager is not accesable over a remote connection.
+     */
+    public DependencyManager getDependencyManager() {
+        throw new UnsupportedOperationException("Dependency manager is not accessable by way of a remote connection");
+    }
+
+    /**
+     * Throws UnsupportedOperationException.  The lifecycle monitor is not accesable over a remote connection.
+     */
+    public LifecycleMonitor getLifecycleMonitor() {
+        throw new UnsupportedOperationException("Lifecycle monitor is not accessable by way of a remote connection");
+    }
+
+    public ProxyManager getProxyManager() {
+        return proxyManager;
+    }
+
+    /**
+     * Throws UnsupportedOperationException.  A remote kernel will alreayd be booted.
+     */
+    public void boot() throws Exception {
+        throw new UnsupportedOperationException("A remote kernel can not be booted");
+    }
+
+    private Object getKernelAttribute(String attributeName) {
+        try {
+            return mbeanServer.getAttribute(Kernel.KERNEL, attributeName);
+        } catch (Exception e) {
+            Throwable cause = unwrapJMException(e);
+            if (cause instanceof InstanceNotFoundException) {
+                throw new InternalKernelException("Kernel is not loaded");
+            } else if (cause instanceof AttributeNotFoundException) {
+                throw new InternalKernelException("KernelDelegate is out of synch with Kernel");
+            } else {
+                throw new InternalKernelException(cause);
+            }
+        }
+    }
+
+    private Object invokeKernel(String methodName, Object[] args, String[] types) throws Exception {
+        if(args != null && types != null && args.length != types.length) {
+            throw new IllegalArgumentException("Call to "+methodName+" has "+args.length+" arguments but "+types.length+" argument classes!");
+        }
+        try {
+            return mbeanServer.invoke(Kernel.KERNEL, methodName, args, types);
+        } catch (Exception e) {
+            Throwable cause = unwrapJMException(e);
+            if (cause instanceof InstanceNotFoundException) {
+                throw new InternalKernelException("Kernel is not loaded");
+            } else if (cause instanceof NoSuchMethodException) {
+                StringBuffer buf = new StringBuffer("KernelDelegate is out of synch with Kernel on ");
+                buf.append(methodName).append("(");
+                if(types != null) {
+                    for (int i = 0; i < types.length; i++) {
+                        String type = types[i];
+                        if(i>0) buf.append(",");
+                        buf.append(type);
+                    }
+                }
+                buf.append(")");
+                throw new InternalKernelException(buf.toString());
+            } else if (cause instanceof JMException) {
+                throw new InternalKernelException(cause);
+            } else if (cause instanceof JMRuntimeException) {
+                throw new InternalKernelException(cause);
+            } else if (cause instanceof Error) {
+                throw (Error) cause;
+            } else if (cause instanceof Exception) {
+                throw (Exception) cause;
+            } else {
+                throw new InternalKernelException("Unknown throwable", cause);
+            }
+        }
+    }
+
+    private Throwable unwrapJMException(Throwable cause) {
+        while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
+            cause = cause.getCause();
+        }
+        return cause;
+    }
+}

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java?rev=395155&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java Tue Apr 18 23:44:24 2006
@@ -0,0 +1,351 @@
+/**
+ *
+ * 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.system.jmx;
+
+import java.io.ObjectInputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.OperationsException;
+import javax.management.QueryExp;
+import javax.management.ReflectionException;
+import javax.management.loading.ClassLoaderRepository;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.Kernel;
+ 
+/**
+ * A fake MBeanServer that delegates to a Kernel.
+ * @version $Rev$ $Date$
+ */
+public class KernelMBeanServer implements MBeanServer {
+    private final Kernel kernel;
+
+    public KernelMBeanServer(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
+        try {
+            return kernel.getAttribute(name, attribute);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attribute);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.getCanonicalName());
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
+        AttributeList attributeList = new AttributeList(attributes.length);
+        for (int i = 0; i < attributes.length; i++) {
+            String attribute = attributes[i];
+            try {
+                Object value = kernel.getAttribute(name, attribute);
+                attributeList.add(i, new Attribute(attribute, value));
+            } catch (NoSuchAttributeException e) {
+                // ignored - caller will simply find no value
+            } catch (GBeanNotFoundException e) {
+                throw new InstanceNotFoundException(name.getCanonicalName());
+            } catch (InternalKernelException e) {
+                throw new ReflectionException(unwrapInternalKernelException(e));
+            } catch (Exception e) {
+                // ignored - caller will simply find no value
+            }
+        }
+        return attributeList;
+    }
+
+    public String getDefaultDomain() {
+        return kernel.getKernelName();
+    }
+
+    public Integer getMBeanCount() {
+        return new Integer(kernel.listGBeans((AbstractNameQuery)null).size());
+    }
+
+    public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, ReflectionException {
+        GBeanInfo gbeanInfo;
+        try {
+            gbeanInfo = kernel.getGBeanInfo(name);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.toString());
+        } catch (InternalKernelException e) {
+            throw new ReflectionException(unwrapInternalKernelException(e));
+        }
+        return JMXUtil.toMBeanInfo(gbeanInfo);
+    }
+
+    public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException {
+        try {
+            return kernel.invoke(name, operationName, params, signature);
+        } catch (NoSuchOperationException e) {
+            throw new ReflectionException(new NoSuchMethodException(e.getMessage()));
+        } catch (GBeanNotFoundException e) {
+            if(name.equals(e.getGBeanName())) {
+                throw new InstanceNotFoundException(name.getCanonicalName());
+            }
+            throw new MBeanException(e);
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public boolean isRegistered(ObjectName name) {
+        return kernel.isLoaded(name);
+    }
+
+    public Set queryNames(ObjectName pattern, QueryExp query) {
+        Set names = kernel.listGBeans(pattern);
+        if (query == null) {
+            return names;
+        }
+
+        Set filteredNames = new HashSet(names.size());
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            // this must be done for each objectName applied
+            query.setMBeanServer(this);
+
+            ObjectName name = (ObjectName) iterator.next();
+            try {
+                if (query.apply(name)) {
+                    filteredNames.add(name);
+                }
+            } catch (Exception e) {
+                // reject any name that threw an exception
+            }
+        }
+        return filteredNames;
+    }
+
+    public Set queryMBeans(ObjectName pattern, QueryExp query) {
+        Set names = queryNames(pattern, query);
+        Set objectInstances = new HashSet(names.size());
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            ObjectName name = (ObjectName) iterator.next();
+            try {
+                objectInstances.add(getObjectInstance(name));
+            } catch (InstanceNotFoundException e) {
+                // ignore
+            }
+        }
+        return objectInstances;
+    }
+
+    public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, MBeanException {
+        String attributeName = attribute.getName();
+        Object attributeValue = attribute.getValue();
+        try {
+            kernel.setAttribute(name, attributeName, attributeValue);
+        } catch (NoSuchAttributeException e) {
+            throw new AttributeNotFoundException(attributeName);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(name.getCanonicalName());
+        } catch (InternalKernelException e) {
+            throw new MBeanException(unwrapInternalKernelException(e));
+        } catch (Exception e) {
+            throw new MBeanException(e);
+        }
+    }
+
+    public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException {
+        AttributeList set = new AttributeList(attributes.size());
+        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+            Attribute attribute = (Attribute) iterator.next();
+            String attributeName = attribute.getName();
+            Object attributeValue = attribute.getValue();
+            try {
+                kernel.setAttribute(name, attributeName, attributeValue);
+                set.add(attribute);
+            } catch (NoSuchAttributeException e) {
+                // ignored - caller will see value was not set because this attribute will not be in the attribute list
+            } catch (GBeanNotFoundException e) {
+                throw new InstanceNotFoundException(name.getCanonicalName());
+            } catch (InternalKernelException e) {
+                throw new ReflectionException(unwrapInternalKernelException(e));
+            } catch (Exception e) {
+                // ignored - caller will see value was not set because this attribute will not be in the attribute list
+            }
+        }
+        return set;
+    }
+
+    public String[] getDomains() {
+        Set domains = new HashSet();
+        Set names = kernel.listGBeans((ObjectName)null);
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            ObjectName objectName = (ObjectName) iterator.next();
+            domains.add(objectName.getDomain());
+        }
+        return (String[]) domains.toArray(new String[domains.size()]);
+    }
+
+    public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException {
+        try {
+            GBeanInfo gbeanInfo = kernel.getGBeanInfo(objectName);
+            return new ObjectInstance(objectName, gbeanInfo.getClassName());
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(objectName.getCanonicalName());
+        }
+    }
+
+    public ClassLoader getClassLoaderFor(ObjectName objectName) throws InstanceNotFoundException {
+        try {
+            return kernel.getClassLoaderFor(objectName);
+        } catch (GBeanNotFoundException e) {
+            throw new InstanceNotFoundException(objectName.getCanonicalName());
+        }
+    }
+
+    private static Exception unwrapInternalKernelException(InternalKernelException e) {
+        if (e.getCause() instanceof Exception) {
+            return (Exception) e.getCause();
+        }
+        return e;
+    }
+
+    //////////////////////////////////////////////
+    //
+    // NOT ALLOWED
+    //
+    //////////////////////////////////////////////
+
+    public void addNotificationListener(ObjectName objectName, NotificationListener notificationListener, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void addNotificationListener(ObjectName objectName, ObjectName objectName1, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, ObjectName objectName1) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, ObjectName objectName1, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener, NotificationFilter notificationFilter, Object o) throws InstanceNotFoundException, ListenerNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public boolean isInstanceOf(ObjectName objectName, String s) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, ObjectName objectName1) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, Object[] objects, String[] strings) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance createMBean(String s, ObjectName objectName, ObjectName objectName1, Object[] objects, String[] strings) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s) throws ReflectionException, MBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, ObjectName objectName) throws ReflectionException, MBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, Object[] objects, String[] strings) throws ReflectionException, MBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public Object instantiate(String s, ObjectName objectName, Object[] objects, String[] strings) throws ReflectionException, MBeanException, InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInstance registerMBean(Object o, ObjectName objectName) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(String s, ObjectName objectName, byte[] bytes) throws InstanceNotFoundException, OperationsException, ReflectionException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(String s, byte[] bytes) throws OperationsException, ReflectionException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) throws InstanceNotFoundException, OperationsException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ClassLoader getClassLoader(ObjectName objectName) throws InstanceNotFoundException {
+        throw new SecurityException("Operation not allowed");
+    }
+
+    public ClassLoaderRepository getClassLoaderRepository() {
+        return new ClassLoaderRepository() {
+            public Class loadClass(String className) throws ClassNotFoundException {
+                throw new ClassNotFoundException(className);
+            }
+
+            public Class loadClassWithout(ClassLoader loader, String className) throws ClassNotFoundException {
+                throw new ClassNotFoundException(className);
+            }
+
+            public Class loadClassBefore(ClassLoader loader, String className) throws ClassNotFoundException {
+                throw new ClassNotFoundException(className);
+            }
+        };
+    }
+
+    public void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException, MBeanRegistrationException {
+        throw new SecurityException("Operation not allowed");
+    }
+}

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServerReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServerReference.java?rev=395155&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServerReference.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/KernelMBeanServerReference.java Tue Apr 18 23:44:24 2006
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.system.jmx;
+
+import javax.management.MBeanServer;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * Creates a fake mbean server which delegates all calls to the kernel
+ * @version $Rev$ $Date$
+ */
+public class KernelMBeanServerReference implements MBeanServerReference {
+    private MBeanServer mbeanServer;
+
+    public KernelMBeanServerReference(Kernel kernel) {
+        mbeanServer = new KernelMBeanServer(kernel);
+    }
+
+    public MBeanServer getMBeanServer() {
+        return mbeanServer;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(KernelMBeanServerReference.class);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.setConstructor(new String[]{"kernel"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return KernelMBeanServerReference.GBEAN_INFO;
+    }
+}

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerKernelBridge.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerKernelBridge.java?rev=395155&r1=395154&r2=395155&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerKernelBridge.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerKernelBridge.java Tue Apr 18 23:44:24 2006
@@ -16,7 +16,6 @@
  */
 package org.apache.geronimo.system.jmx;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -28,7 +27,6 @@
 import javax.management.JMRuntimeException;
 import javax.management.MBeanInfo;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 
 import org.apache.commons.logging.Log;
@@ -40,11 +38,10 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 384351 $ $Date$
  */
 public class MBeanServerKernelBridge implements GBeanLifecycle {
     private static final Log log = LogFactory.getLog(MBeanServerKernelBridge.class);
@@ -53,17 +50,14 @@
     private final MBeanServer mbeanServer;
     private static final AbstractNameQuery ALL = new AbstractNameQuery(null, Collections.EMPTY_MAP, Collections.EMPTY_SET);
 
-    public MBeanServerKernelBridge(Kernel kernel, String mbeanServerId) throws MBeanServerNotFound {
-        this.kernel = kernel;
-        ArrayList servers = MBeanServerFactory.findMBeanServer(mbeanServerId);
-        if (servers.size() == 0) {
-            mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
-        } else if (servers.size() > 1) {
-            throw new MBeanServerNotFound(servers.size() + " MBeanServers were found with the agent id " + mbeanServerId);
-        } else {
-            mbeanServer = (MBeanServer) servers.get(0);
-        }
+    // todo remove this as soon as Geronimo supports factory beans    
+    public MBeanServerKernelBridge(Kernel kernel, MBeanServerReference mbeanServerReference) {
+        this(kernel, mbeanServerReference.getMBeanServer());
+    }
 
+    public MBeanServerKernelBridge(Kernel kernel, MBeanServer mbeanServer) {
+        this.kernel = kernel;
+        this.mbeanServer = mbeanServer;
     }
 
     public void doStart() {
@@ -185,8 +179,8 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(MBeanServerKernelBridge.class);
         infoFactory.addAttribute("kernel", Kernel.class, false);
-        infoFactory.addAttribute("mbeanServerId", String.class, true);
-        infoFactory.setConstructor(new String[]{"kernel", "mbeanServerId"});
+        infoFactory.addReference("MBeanServerReference", MBeanServerReference.class);
+        infoFactory.setConstructor(new String[]{"kernel", "MBeanServerReference"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerReference.java?rev=395155&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerReference.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerReference.java Tue Apr 18 23:44:24 2006
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.system.jmx;
+
+import javax.management.MBeanServer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MBeanServerReference {
+    MBeanServer getMBeanServer();
+}

Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java?rev=395155&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java (added)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java Tue Apr 18 23:44:24 2006
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.system.jmx;
+
+import java.util.ArrayList;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+/**
+ * Creates a real mbean server of finds an existing one with the specified mbeanServerId
+ * @version $Rev$ $Date$
+ */
+public class RealMBeanServerReference implements MBeanServerReference {
+    private MBeanServer mbeanServer;
+
+    public RealMBeanServerReference(String mbeanServerId) throws MBeanServerNotFound {
+        ArrayList servers = MBeanServerFactory.findMBeanServer(mbeanServerId);
+        if (servers.size() == 0) {
+            mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
+        } else if (servers.size() > 1) {
+            throw new MBeanServerNotFound(servers.size() + " MBeanServers were found with the agent id " + mbeanServerId);
+        } else {
+            mbeanServer = (MBeanServer) servers.get(0);
+        }
+    }
+
+    public MBeanServer getMBeanServer() {
+        return mbeanServer;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(RealMBeanServerReference.class);
+        infoFactory.addAttribute("mbeanServerId", String.class, true);
+        infoFactory.setConstructor(new String[]{"mbeanServerId"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=395155&r1=395154&r2=395155&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java (original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java Tue Apr 18 23:44:24 2006
@@ -31,7 +31,7 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.ObjectNameUtil;
 import org.apache.geronimo.management.J2EEApplication;
 import org.apache.geronimo.management.J2EEServer;
 import org.apache.geronimo.management.geronimo.WebModule;
@@ -219,7 +219,7 @@
 
         this.kernel = kernel;
         if (objectName != null) {
-            ObjectName myObjectName = JMXUtil.getObjectName(objectName);
+            ObjectName myObjectName = ObjectNameUtil.getObjectName(objectName);
             verifyObjectName(myObjectName);
         }
 

Modified: geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java?rev=395155&r1=395154&r2=395155&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java (original)
+++ geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopRemoteServer.java Tue Apr 18 23:44:24 2006
@@ -1,7 +1,7 @@
 package org.apache.geronimo.deployment.mavenplugin;
 
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.KernelDelegate;
+import org.apache.geronimo.system.jmx.KernelDelegate;
 
 import javax.management.MBeanServerConnection;
 import javax.management.remote.JMXConnector;

Modified: geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java?rev=395155&r1=395154&r2=395155&view=diff
==============================================================================
--- geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java (original)
+++ geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/WaitForStarted.java Tue Apr 18 23:44:24 2006
@@ -27,7 +27,7 @@
 import org.apache.geronimo.kernel.InternalKernelException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.jmx.KernelDelegate;
+import org.apache.geronimo.system.jmx.KernelDelegate;
 import org.apache.geronimo.kernel.repository.Artifact;
 
 public class WaitForStarted extends AbstractModuleCommand {



Mime
View raw message