You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2005/05/08 21:35:28 UTC
svn commit: r169154 [5/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/
Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyMethodInterceptor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyMethodInterceptor.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyMethodInterceptor.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXProxyMethodInterceptor.java Sun May 8 12:35:23 2005
@@ -0,0 +1,193 @@
+/**
+ *
+ * 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.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+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.kernel.Kernel;
+import org.apache.geronimo.kernel.basic.KernelGetAttributeInvoker;
+import org.apache.geronimo.kernel.basic.KernelOperationInvoker;
+import org.apache.geronimo.kernel.basic.KernelSetAttributeInvoker;
+import org.apache.geronimo.kernel.basic.ProxyInvoker;
+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 JMXProxyMethodInterceptor 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 JMXProxyMethodInterceptor(Class proxyType, Kernel kernel, ObjectName objectName) {
+ assert proxyType != null;
+ assert kernel != null;
+ assert objectName != null;
+
+ this.proxyType = proxyType;
+ this.objectName = objectName;
+ gbeanInvokers = createGBeanInvokers(kernel);
+ }
+
+ 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) {
+ // 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] = createProxyInvoker(kernel, method);
+ }
+ }
+
+ // 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 createProxyInvoker(Kernel kernel, Method method) {
+ String methodName = method.getName();
+ if (!Modifier.isPublic(method.getModifiers()) || Modifier.isStatic(method.getModifiers())) {
+ return null;
+ }
+
+ // is this a getter is "is" method
+ if (method.getParameterTypes().length == 0 && method.getReturnType() != Void.TYPE) {
+ if (methodName.length() > 3 && methodName.startsWith("get") && !methodName.equals("getClass")) {
+ String propertyName = decapitalizePropertyName(methodName.substring(3));
+ return new KernelGetAttributeInvoker(kernel, propertyName);
+ } else if (methodName.length() > 2 && methodName.startsWith("is")) {
+ String propertyName = decapitalizePropertyName(methodName.substring(2));
+ return new KernelGetAttributeInvoker(kernel, propertyName);
+ }
+ }
+
+ // is this a setter method
+ if (method.getParameterTypes().length == 1 &&
+ method.getReturnType() == Void.TYPE &&
+ methodName.length() > 3 &&
+ methodName.startsWith("set")) {
+ String propertyName = decapitalizePropertyName(methodName.substring(3));
+ return new KernelSetAttributeInvoker(kernel, propertyName);
+ }
+
+ // it is just a plain old opertaion
+ return new KernelOperationInvoker(kernel, method);
+ }
+
+ 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 String decapitalizePropertyName(String propertyName) {
+ if (Character.isUpperCase(propertyName.charAt(0))) {
+ return Character.toLowerCase(propertyName.charAt(0)) + propertyName.substring(1);
+ }
+ return propertyName;
+ }
+
+ 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 + "]";
+ }
+ }
+}
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java Sun May 8 12:35:23 2005
@@ -16,10 +16,7 @@
*/
package org.apache.geronimo.kernel.jmx;
-import java.io.IOException;
-import java.net.URI;
import java.util.Date;
-import java.util.List;
import java.util.Set;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
@@ -30,25 +27,24 @@
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.jmx.*;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
+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.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
/**
* @version $Rev$ $Date$
*/
-public class KernelDelegate implements KernelMBean {
+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() {
@@ -71,10 +67,6 @@
}
}
- public void loadGBean(ObjectName name, GBeanMBean gbean) throws GBeanAlreadyExistsException, InternalKernelException {
- throw new UnsupportedOperationException("Use loadGBean(GBeanData, ClassLoader)");
- }
-
public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
try {
invokeKernel("startGBean", new Object[] {name}, new String[] {ObjectName.class.getName()});
@@ -123,28 +115,10 @@
}
}
- public boolean isRunning() {
- return ((Boolean) getKernelAttribute("running")).booleanValue();
- }
-
- public ConfigurationManager getConfigurationManager() {
- return (ConfigurationManager) getKernelAttribute("configurationManager");
- }
-
- public List listConfigurationStores() {
- try {
- return (List) invokeKernel("listConfigurationStores", new Object[] {}, new String[] {});
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new InternalKernelException(e);
- }
- }
-
- public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
+ public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
try {
- return (List) invokeKernel("listConfigurations", new Object[] {storeName}, new String[] {ObjectName.class.getName()});
- } catch (NoSuchStoreException e) {
+ return ((Integer) invokeKernel("getGBeanState", new Object[]{name}, new String[]{ObjectName.class.getName()})).intValue();
+ } catch (GBeanNotFoundException e) {
throw e;
} catch (RuntimeException e) {
throw e;
@@ -153,14 +127,10 @@
}
}
- public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
+ public long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException {
try {
- return (ObjectName) invokeKernel("startConfiguration", new Object[]{configID}, new String[]{URI.class.getName()});
- } catch (NoSuchConfigException e) {
- throw e;
- } catch (IOException e) {
- throw e;
- } catch (InvalidConfigException e) {
+ return ((Long) invokeKernel("getGBeanStartTime", new Object[]{name}, new String[]{ObjectName.class.getName()})).longValue();
+ } catch (GBeanNotFoundException e) {
throw e;
} catch (RuntimeException e) {
throw e;
@@ -169,10 +139,10 @@
}
}
- public void stopConfiguration(URI configID) throws NoSuchConfigException {
+ public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
try {
- invokeKernel("stopConfiguration", new Object[]{configID}, new String[]{URI.class.getName()});
- } catch (NoSuchConfigException e) {
+ return ((Boolean) invokeKernel("isGBeanEnabled", new Object[] {name}, new String[] {ObjectName.class.getName()})).booleanValue();
+ } catch (GBeanNotFoundException e) {
throw e;
} catch (RuntimeException e) {
throw e;
@@ -181,10 +151,10 @@
}
}
- public int getConfigurationState(URI configID) throws NoSuchConfigException {
+ public void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException {
try {
- return ((Integer) invokeKernel("getConfigurationState", new Object[]{configID}, new String[]{URI.class.getName()})).intValue();
- } catch (NoSuchConfigException e) {
+ invokeKernel("setGBeanEnabled", new Object[] {name}, new String[] {ObjectName.class.getName()});
+ } catch (GBeanNotFoundException e) {
throw e;
} catch (RuntimeException e) {
throw e;
@@ -367,12 +337,30 @@
}
}
+ public boolean isRunning() {
+ return ((Boolean) getKernelAttribute("running")).booleanValue();
+ }
+
+ public DependencyManager getDependencyManager() {
+ throw new UnsupportedOperationException("Dependency manager is not accessable by way of 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;
+ }
+
+ public void boot() throws Exception {
+ throw new UnsupportedOperationException("A remote kernel can not be booted");
+ }
+
private Throwable unwrapJMException(Throwable cause) {
while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
cause = cause.getCause();
}
return cause;
}
-
-
}
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanServerDelegate.java Sun May 8 12:35:23 2005
@@ -43,9 +43,9 @@
import org.apache.geronimo.gbean.GBeanInfo;
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.Kernel;
/**
* A MBeanServerImplementation that delegates to a Kernel.
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java Sun May 8 12:35:23 2005
@@ -24,5 +24,10 @@
* @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
*/
public interface ProxyFactory {
+ /**
+ * Creates a proxy to the specified target
+ * @param target the name of the target
+ * @return the proxy
+ */
Object createProxy(ObjectName target);
}
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java Sun May 8 12:35:23 2005
@@ -16,85 +16,45 @@
*/
package org.apache.geronimo.kernel.proxy;
-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;
-
/**
+ * Manages kernel proxies
* @version $Rev$ $Date$
*/
-public class ProxyManager {
- private final Kernel kernel;
-
- // todo use weak keys for this
- private final IdentityHashMap interceptors = new IdentityHashMap();
-
- public ProxyManager(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;
- }
- }
+public interface ProxyManager {
+ /**
+ * Create a proxy factory which will generate proxies of the specified type
+ * @param type the type of the proxies to create
+ * @return the proxy factory
+ */
+ public ProxyFactory createProxyFactory(Class type);
+
+ /**
+ * Create a proxy implementing the class to the specified target.
+ * @param target the target object name
+ * @param type the type of the proxy to create
+ * @return the proxy
+ */
+ public Object createProxy(ObjectName target, Class type);
+
+ /**
+ * Cleans up and resources associated with the proxy
+ * @param proxy the proxy to destroy
+ */
+ public void destroyProxy(Object proxy);
+
+ /**
+ * Is the specified object a proxy
+ * @param object the object to determin if it is a proxy
+ * @return true if the object is a proxy
+ */
+ public boolean isProxy(Object object);
+
+ /**
+ * Get the object name of the specified proxy
+ * @param proxy the proxy to get the target object name from
+ * @return the object name of the target
+ */
+ public ObjectName getProxyTarget(Object proxy);
}
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java Sun May 8 12:35:23 2005
@@ -23,8 +23,9 @@
import javax.management.ObjectName;
import net.sf.cglib.reflect.FastClass;
-import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.MockGBean;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.gbean.runtime.RawInvoker;
/**
@@ -94,7 +95,7 @@
printResults("FastClass", end, start, iterations);
// start a kernel
- Kernel kernel = new Kernel("speed");
+ Kernel kernel = KernelFactory.newInstance().createKernel("speed");
kernel.boot();
ObjectName objectName = new ObjectName("speed:type=MockGBean");
GBeanData mockGBean = new GBeanData(objectName, MockGBean.getGBeanInfo());
@@ -224,7 +225,7 @@
printResults("FastClass", end, start, iterations);
// start a kernel
- Kernel kernel = new Kernel("speed");
+ Kernel kernel = KernelFactory.newInstance().createKernel("speed");
kernel.boot();
ObjectName objectName = new ObjectName("speed:type=MockGBean");
GBeanData mockGBean = new GBeanData(objectName, MockGBean.getGBeanInfo());
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java Sun May 8 12:35:23 2005
@@ -22,9 +22,10 @@
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.MockDynamicGBean;
import org.apache.geronimo.kernel.MockGBean;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.Kernel;
/**
* @version $Rev$ $Date$
@@ -345,7 +346,7 @@
}
protected void setUp() throws Exception {
- kernel = new Kernel("test");
+ kernel = KernelFactory.newInstance().createKernel("test");
kernel.boot();
gbeanInstance = new GBeanInstance(new GBeanData(new ObjectName("test:MockGBean=normal"), MockGBean.getGBeanInfo()),
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/BootstrapTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/BootstrapTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/BootstrapTest.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/BootstrapTest.java Sun May 8 12:35:23 2005
@@ -20,6 +20,7 @@
import java.io.File;
import junit.framework.TestCase;
+import org.apache.geronimo.kernel.Kernel;
/**
*
@@ -31,12 +32,12 @@
private File kernelState;
public void testCreate() throws Exception {
- Kernel kernel = new Kernel("test.kernel");
- assertEquals("No kernel should be registered", null, Kernel.getKernel("test.kernel"));
+ Kernel kernel = KernelFactory.newInstance().createKernel("test.kernel");
+ assertEquals("No kernel should be registered", null, KernelRegistry.getKernel("test.kernel"));
kernel.boot();
- assertEquals("test.kernel kernel should be registered", kernel, Kernel.getKernel("test.kernel"));
+ assertEquals("test.kernel kernel should be registered", kernel, KernelRegistry.getKernel("test.kernel"));
kernel.shutdown();
- assertEquals("No kernel should be registered", null, Kernel.getKernel("test.kernel"));
+ assertEquals("No kernel should be registered", null, KernelRegistry.getKernel("test.kernel"));
}
protected void setUp() throws Exception {
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java Sun May 8 12:35:23 2005
@@ -23,8 +23,8 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.management.State;
/**
@@ -38,22 +38,27 @@
public void testOnlineConfig() throws Exception {
URI id = new URI("test");
+ ObjectName configName = Configuration.getConfigurationObjectName(id);
+
+ // create the config gbean data
GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
- config.setAttribute("ID", id);
+ config.setAttribute("id", id);
config.setReferencePatterns("Parent", null);
config.setAttribute("classPath", Collections.EMPTY_LIST);
config.setAttribute("gBeanState", state);
config.setAttribute("dependencies", Collections.EMPTY_LIST);
- ConfigurationManager configurationManager = kernel.getConfigurationManager();
- ObjectName configName = configurationManager.load(config, null, getClass().getClassLoader());
- kernel.invoke(configName, "startRecursive", null, null);
+ config.setName(configName);
+
+ // load and start the config
+ kernel.loadGBean(config, this.getClass().getClassLoader());
+ kernel.startRecursiveGBean(configName);
- assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(configName, "state"));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configName));
assertNotNull(kernel.getAttribute(configName, "configurationClassLoader"));
- assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(gbeanName1, "state"));
- Object state = kernel.getAttribute(gbeanName2, "state");
- assertEquals(new Integer(State.RUNNING_INDEX), state);
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
+ int state = kernel.getGBeanState(gbeanName2);
+ assertEquals(State.RUNNING_INDEX, state);
assertEquals(new Integer(1), kernel.getAttribute(gbeanName1, "finalInt"));
assertEquals("1234", kernel.getAttribute(gbeanName1, "value"));
assertEquals(new Integer(3), kernel.getAttribute(gbeanName2, "finalInt"));
@@ -74,21 +79,26 @@
assertEquals(new Integer(99), kernel.getAttribute(gbeanName2, "endpointMutableInt"));
assertEquals(new Integer(99), kernel.getAttribute(gbeanName1, "mutableInt"));
- kernel.invoke(configName, "stop", null, null);
+ kernel.stopGBean(configName);
try {
kernel.getAttribute(gbeanName1, "value");
fail();
} catch (GBeanNotFoundException e) {
// ok
}
- assertEquals(new Integer(State.STOPPED.toInt()), kernel.getAttribute(configName, "state"));
- configurationManager.unload(configName);
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(configName));
+ kernel.unloadGBean(configName);
assertFalse(kernel.isLoaded(configName));
}
protected void setUp() throws Exception {
- kernel = new Kernel("test");
+ kernel = KernelFactory.newInstance().createKernel("test");
kernel.boot();
+
+ ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
+ GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
+ kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
+ kernel.startGBean(configurationManagerName);
gbeanName1 = new ObjectName("geronimo.test:name=MyMockGMBean1");
GBeanData mockBean1 = new GBeanData(gbeanName1, MockGBean.getGBeanInfo());
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java Sun May 8 12:35:23 2005
@@ -44,7 +44,7 @@
gbean.setAttribute("finalInt", new Integer(123));
kernel.loadGBean(gbean, myCl);
kernel.startGBean(name);
- assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(name, "state"));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(name));
assertEquals("Hello", kernel.invoke(name, "doSomething", new Object[]{"Hello"}, new String[]{String.class.getName()}));
assertEquals(name.getCanonicalName(), kernel.getAttribute(name, "objectName"));
@@ -86,7 +86,7 @@
protected void setUp() throws Exception {
name = new ObjectName("test:name=MyMockGBean");
name2 = new ObjectName("test:name=MyMockGBean2");
- kernel = new Kernel("test");
+ kernel = KernelFactory.newInstance().createKernel("test");
kernel.boot();
}
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java Sun May 8 12:35:23 2005
@@ -36,5 +36,5 @@
String echo(String message);
- GBeanLifecycleController getGBeanLifecycleController();
+ GBeanLifecycleController getGbeanLifecycleController();
}
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java Sun May 8 12:35:23 2005
@@ -108,7 +108,7 @@
}
public String getObjectName() {
- throw new RuntimeException("this should never be called");
+ return objectName;
}
public ClassLoader getActualClassLoader() {
@@ -116,10 +116,10 @@
}
public ClassLoader getClassLoader() {
- throw new RuntimeException("this should never be called");
+ return classLoader;
}
- public GBeanLifecycleController getGBeanLifecycleController() {
+ public GBeanLifecycleController getGbeanLifecycleController() {
return gbeanLifecycleController;
}
@@ -128,7 +128,7 @@
}
public Kernel getKernel() {
- throw new RuntimeException("this should never be called");
+ return kernel;
}
public void setKernel(Kernel kernel) {
@@ -148,13 +148,6 @@
public int getFinalInt() {
return finalInt;
- }
-
- /**
- * Note the wrong return type, instead of int type.
- */
- public String getAnotherFinalInt() {
- return null;
}
/**
Modified: geronimo/trunk/modules/mail/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/mail/project.xml (original)
+++ geronimo/trunk/modules/mail/project.xml Sun May 8 12:35:23 2005
@@ -71,7 +71,7 @@
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
Modified: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java (original)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java Sun May 8 12:35:23 2005
@@ -280,7 +280,7 @@
/**
* Returns the debug setting for Sessions created from this GBean.
*/
- public Boolean isDebug() {
+ public Boolean getDebug() {
return debug;
}
Modified: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java (original)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/SMTPTransportGBean.java Sun May 8 12:35:23 2005
@@ -730,7 +730,7 @@
public static final GBeanInfo GBEAN_INFO;
static {
- GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(SMTPTransportGBean.class, ProtocolGBean.GBEAN_INFO);
+ GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(SMTPTransportGBean.class);
infoFactory.addAttribute("port", Integer.class, true);
infoFactory.addAttribute("connectionTimeout", Integer.class, true);
@@ -753,6 +753,13 @@
infoFactory.addAttribute("socketFactoryFallback", Boolean.class, true);
infoFactory.addAttribute("socketFactoryPort", Integer.class, true);
infoFactory.addAttribute("mailExtension", String.class, true);
+
+ infoFactory.addAttribute("objectName", String.class, false);
+ infoFactory.addAttribute("protocol", String.class, false);
+ infoFactory.addAttribute("properties", Properties.class, true);
+ infoFactory.addAttribute("host", String.class, true);
+ infoFactory.addAttribute("user", String.class, true);
+ infoFactory.addOperation("addOverrides", new Class[]{Properties.class});
infoFactory.setConstructor(new String[]{"objectName", "properties", "host", "user",
"port",
Modified: geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java (original)
+++ geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java Sun May 8 12:35:23 2005
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
@@ -218,7 +219,7 @@
}
protected void setUp() throws Exception {
- kernel = new Kernel(KERNEL_NAME);
+ kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
kernel.boot();
}
Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/KernelReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/KernelReference.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/KernelReference.java (original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/KernelReference.java Sun May 8 12:35:23 2005
@@ -16,10 +16,7 @@
*/
package org.apache.geronimo.naming.reference;
-import javax.management.ObjectName;
-
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.proxy.ProxyManager;
/**
* @version $Rev$ $Date$
Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/SimpleAwareReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/SimpleAwareReference.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/SimpleAwareReference.java (original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/SimpleAwareReference.java Sun May 8 12:35:23 2005
@@ -16,8 +16,6 @@
*/
package org.apache.geronimo.naming.reference;
-import javax.naming.RefAddr;
-
import org.apache.geronimo.kernel.Kernel;
/**
Modified: geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java (original)
+++ geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java Sun May 8 12:35:23 2005
@@ -32,6 +32,8 @@
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
/**
@@ -86,10 +88,10 @@
// builder.addResourceEnvRef("resourceenvref", List.class, localRef);
SimpleReadOnlyContext context = new SimpleReadOnlyContext(builder.getContext());
- Kernel kernel = new Kernel("test.kernel");
+ Kernel kernel = KernelFactory.newInstance().createKernel("test.kernel");
kernel.boot();
try {
- assertEquals(kernel, Kernel.getKernel("test.kernel"));
+ assertEquals(kernel, KernelRegistry.getKernel("test.kernel"));
ObjectName proxyFactoryName = null;//referenceFactory.createAdminObjectObjectName("testAdminObject");
GBeanData gbean = new GBeanData(proxyFactoryName, getGbeanInfo());
gbean.setAttribute("Content", proxy);
Modified: geronimo/trunk/modules/security/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/project.xml (original)
+++ geronimo/trunk/modules/security/project.xml Sun May 8 12:35:23 2005
@@ -94,7 +94,7 @@
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java (original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java Sun May 8 12:35:23 2005
@@ -30,6 +30,7 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
+import org.apache.geronimo.kernel.KernelRegistry;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingClient;
@@ -137,7 +138,7 @@
}
private void clear() {
- Kernel kernel = Kernel.getKernel(kernelName);
+ Kernel kernel = KernelRegistry.getKernel(kernelName);
if (kernel != null) {
kernel.getProxyManager().destroyProxy(service);
}
@@ -158,7 +159,7 @@
if(serverHost != null && serverPort > 0) {
return JaasLoginServiceRemotingClient.create(serverHost, serverPort);
} else {
- Kernel kernel = Kernel.getKernel(kernelName);
+ Kernel kernel = KernelRegistry.getKernel(kernelName);
return (JaasLoginServiceMBean) kernel.getProxyManager().createProxy(JaasLoginService.OBJECT_NAME, JaasLoginServiceMBean.class);
}
}
Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java (original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java Sun May 8 12:35:23 2005
@@ -17,29 +17,23 @@
package org.apache.geronimo.security.realm;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.proxy.ProxyManager;
import org.apache.geronimo.security.deploy.Principal;
import org.apache.geronimo.security.jaas.ConfigurationEntryFactory;
import org.apache.geronimo.security.jaas.JaasLoginCoordinator;
import org.apache.geronimo.security.jaas.JaasLoginModuleConfiguration;
-import org.apache.geronimo.security.jaas.LoginModuleControlFlag;
-import org.apache.geronimo.security.jaas.LoginModuleControlFlagEditor;
-import org.apache.geronimo.security.jaas.LoginModuleGBean;
import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
+import org.apache.geronimo.security.jaas.LoginModuleControlFlag;
import org.apache.geronimo.system.serverinfo.ServerInfo;
Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java (original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java Sun May 8 12:35:23 2005
@@ -39,6 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.common.GeronimoSecurityException;
+import org.apache.geronimo.kernel.KernelRegistry;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -67,7 +68,7 @@
this.subject = subject;
this.handler = callbackHandler;
try {
- Kernel kernel = Kernel.getKernel((String)options.get(JaasLoginModuleUse.KERNEL_LM_OPTION));
+ Kernel kernel = KernelRegistry.getKernel((String)options.get(JaasLoginModuleUse.KERNEL_LM_OPTION));
ServerInfo serverInfo = (ServerInfo) options.get(JaasLoginModuleUse.SERVERINFO_LM_OPTION);
URI usersURI = new URI((String)options.get(USERS_URI));
URI groupsURI = new URI((String)options.get(GROUPS_URI));
Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java (original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/AbstractTest.java Sun May 8 12:35:23 2005
@@ -31,6 +31,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.bridge.TestLoginModule;
import org.apache.geronimo.security.jaas.JaasLoginService;
@@ -51,7 +52,7 @@
protected ObjectName serverStub;
protected void setUp() throws Exception {
- kernel = new Kernel("test.kernel");
+ kernel = KernelFactory.newInstance().createKernel("test.kernel");
kernel.boot();
GBeanData gbean;
Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java (original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/ConfigurationEntryTest.java Sun May 8 12:35:23 2005
@@ -30,6 +30,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.AbstractTest;
import org.apache.geronimo.security.ContextManager;
@@ -125,7 +126,7 @@
}
protected void setUp() throws Exception {
- kernel = new Kernel("test.kernel");
+ kernel = KernelFactory.newInstance().createKernel("test.kernel");
kernel.boot();
GBeanData gbean;
Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java (original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/jaas/TimeoutTest.java Sun May 8 12:35:23 2005
@@ -28,7 +28,7 @@
import javax.security.auth.login.LoginContext;
import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.security.AbstractTest;
import org.apache.geronimo.security.ContextManager;
import org.apache.geronimo.security.IdentificationPrincipal;
@@ -51,7 +51,7 @@
protected ObjectName clientCE;
public void setUp() throws Exception {
- kernel = new Kernel("test.kernel");
+ kernel = KernelFactory.newInstance().createKernel("test.kernel");
kernel.boot();
GBeanData gbean;
Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java (original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java Sun May 8 12:35:23 2005
@@ -34,6 +34,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.IdentificationPrincipal;
import org.apache.geronimo.security.RealmPrincipal;
@@ -85,7 +86,7 @@
}
public void setUp() throws Exception {
- kernel = new Kernel("test.kernel");
+ kernel = KernelFactory.newInstance().createKernel("test.kernel");
kernel.boot();
GBeanData gbean;
Modified: geronimo/trunk/modules/service-builder/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/project.xml (original)
+++ geronimo/trunk/modules/service-builder/project.xml Sun May 8 12:35:23 2005
@@ -99,7 +99,7 @@
<!--
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Sun May 8 12:35:23 2005
@@ -26,10 +26,8 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.ArrayList;
@@ -59,6 +57,7 @@
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.repository.MissingDependencyException;
import org.apache.geronimo.kernel.repository.Repository;
import org.apache.xmlbeans.XmlCursor;
@@ -147,17 +146,15 @@
}
}
- public List buildConfiguration(Object plan, JarFile unused, File outfile) throws IOException, DeploymentException {
+ public ConfigurationData buildConfiguration(Object plan, JarFile unused, File outfile) throws IOException, DeploymentException {
ConfigurationType configType = (ConfigurationType) plan;
String domain = null;
String server = null;
- buildConfiguration(configType, domain, server, outfile);
-
- return Collections.EMPTY_LIST;
+ return buildConfiguration(configType, domain, server, outfile);
}
- public void buildConfiguration(ConfigurationType configType, String domain, String server, File outfile) throws DeploymentException, IOException {
+ public ConfigurationData buildConfiguration(ConfigurationType configType, String domain, String server, File outfile) throws DeploymentException, IOException {
URI parentID = null;
if (configType.isSetParentId()) {
try {
@@ -206,6 +203,7 @@
GbeanType[] gbeans = configType.getGbeanArray();
addGBeans(gbeans, cl, j2eeContext, context);
context.close();
+ return context.getConfigurationData();
}
public static void addIncludes(DeploymentContext context, DependencyType[] includes, Repository repository) throws DeploymentException {
Modified: geronimo/trunk/modules/spring-builder/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring-builder/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/spring-builder/project.xml (original)
+++ geronimo/trunk/modules/spring-builder/project.xml Sun May 8 12:35:23 2005
@@ -201,7 +201,7 @@
<dependency>
<groupId>springframework</groupId>
- <artifactId>${spring_artifact}</artifactId>
+ <artifactId>spring</artifactId>
<version>${spring_version}</version>
<url>http://www.springframework.org</url>
</dependency>
@@ -272,7 +272,7 @@
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
Modified: geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java (original)
+++ geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java Sun May 8 12:35:23 2005
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
@@ -38,6 +37,7 @@
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.repository.Repository;
import org.apache.geronimo.spring.SpringApplicationImpl;
import org.apache.geronimo.spring.SpringGBean;
@@ -100,7 +100,7 @@
return this; // token passed to buildConfiguration()...
}
- public List
+ public ConfigurationData
buildConfiguration(Object plan, JarFile sprFile, File outfile)
throws IOException, DeploymentException
{
@@ -168,6 +168,6 @@
if (ctx!=null) ctx.close();
}
- return Collections.singletonList(uid);
+ return ctx.getConfigurationData();
}
}
Modified: geronimo/trunk/modules/spring/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/spring/project.xml (original)
+++ geronimo/trunk/modules/spring/project.xml Sun May 8 12:35:23 2005
@@ -70,14 +70,14 @@
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
<dependency>
<id>springframework</id>
- <artifactId>${spring_artifact}</artifactId>
+ <artifactId>spring</artifactId>
<version>${spring_version}</version>
<url>http://www.springframework.org</url>
</dependency>
Modified: geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/POJOGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/POJOGBean.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/POJOGBean.java (original)
+++ geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/POJOGBean.java Sun May 8 12:35:23 2005
@@ -17,28 +17,12 @@
package org.apache.geronimo.spring;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Hashtable;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.kernel.Kernel;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.beans.factory.support.BeanDefinitionValidationException;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
/**
* A peer GBean for mediating between Geronimo Kernel and Spring managed POJO...
Modified: geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/SpringApplicationImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/SpringApplicationImpl.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/SpringApplicationImpl.java (original)
+++ geronimo/trunk/modules/spring/src/java/org/apache/geronimo/spring/SpringApplicationImpl.java Sun May 8 12:35:23 2005
@@ -21,7 +21,6 @@
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.kernel.Kernel;
/**
* @version $Rev: 126313 $ $Date: 2005-01-24 21:03:52 +0000 (Mon, 24 Jan 2005) $
Modified: geronimo/trunk/modules/system/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/project.xml?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/system/project.xml (original)
+++ geronimo/trunk/modules/system/project.xml Sun May 8 12:35:23 2005
@@ -49,7 +49,7 @@
<dependency>
<groupId>cglib</groupId>
- <artifactId>cglib-full</artifactId>
+ <artifactId>cglib-nodep</artifactId>
<version>${cglib_version}</version>
<url>http://cglib.sf.net/</url>
</dependency>
Added: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=169154&view=auto
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java (added)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java Sun May 8 12:35:23 2005
@@ -0,0 +1,209 @@
+/**
+ *
+ * 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.configuration;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class ExecutableConfigurationUtil {
+ private ExecutableConfigurationUtil() {
+ }
+
+ public static void createExecutableConfiguration(ConfigurationData configurationData, Manifest manifest, File configurationDir, File destinationFile) throws IOException, InvalidConfigException {
+ JarOutputStream out = null;
+ try {
+ out = new JarOutputStream(new FileOutputStream(destinationFile), manifest);
+ byte[] buffer = new byte[4096];
+
+ // add the startup file which allows us to locate the startup directory
+ out.putNextEntry(new ZipEntry("META-INF/startup-jar"));
+ out.closeEntry();
+
+ // write the configurationData
+ ExecutableConfigurationUtil.writeConfiguration(configurationData, out);
+
+ URI baseURI = configurationDir.getAbsoluteFile().toURI();
+ Collection files = listRecursiveFiles(configurationDir);
+ for (Iterator iterator = files.iterator(); iterator.hasNext();) {
+ File file = (File) iterator.next();
+ String relativePath = baseURI.relativize(file.toURI()).getPath();
+ InputStream in = new FileInputStream(file);
+ try {
+ out.putNextEntry(new ZipEntry(relativePath));
+ try {
+ int count;
+ while ((count = in.read(buffer)) > 0) {
+ out.write(buffer, 0, count);
+ }
+ } finally {
+ out.closeEntry();
+ }
+ } finally {
+ close(in);
+ }
+ }
+ } finally {
+ close(out);
+ }
+ }
+
+ public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream out) throws IOException, InvalidConfigException {
+
+ // convert the configuration data to a gbeandata object
+ GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
+
+ // save the persisted form in the source directory
+ out.putNextEntry(new ZipEntry("META-INF/config.ser"));
+ ObjectOutputStream objectOutputStream = null;
+ try {
+ objectOutputStream = new ObjectOutputStream(out);
+ configurationGBeanData.writeExternal(objectOutputStream);
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvalidConfigException("Unable to save configuration state", e);
+ } finally {
+ if (objectOutputStream != null) {
+ try {
+ objectOutputStream.flush();
+ } catch (IOException ignored) {
+ }
+ }
+ out.closeEntry();
+ }
+ }
+
+ public static void writeConfiguration(ConfigurationData configurationData, File source) throws InvalidConfigException, IOException {
+ // convert the configuration data to a gbeandata object
+ GBeanData configurationGBeanData = getConfigurationGBeanData(configurationData);
+
+ // save the persisted form in the source directory
+ File metaInf = new File(source, "META-INF");
+ metaInf.mkdirs();
+ File configSer = new File(metaInf, "config.ser");
+ ObjectOutputStream out = null;
+ try {
+ out = new ObjectOutputStream(new FileOutputStream(configSer));
+ try {
+ configurationGBeanData.writeExternal(out);
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvalidConfigException("Unable to save configuration state", e);
+ }
+ } finally {
+ if (out != null) {
+ try {
+ out.flush();
+ } catch(Exception ignored) {
+ }
+ try {
+ out.close();
+ } catch(Exception ignored) {
+ }
+ }
+ }
+ }
+
+ public static GBeanData getConfigurationGBeanData(ConfigurationData configurationData) throws InvalidConfigException {
+ try {
+ URI id = configurationData.getId();
+ GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
+ config.setAttribute("id", id);
+ config.setAttribute("type", configurationData.getModuleType());
+ config.setAttribute("domain", configurationData.getDomain());
+ config.setAttribute("server", configurationData.getServer());
+
+ URI parentId = configurationData.getParentId();
+ if (parentId != null) {
+ config.setAttribute("parentId", parentId);
+ ObjectName parentName = Configuration.getConfigurationObjectName(parentId);
+ config.setReferencePattern("Parent", parentName);
+ }
+
+ config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
+ config.setReferencePatterns("Repositories", Collections.singleton(new ObjectName("*:name=Repository,*")));
+ config.setAttribute("dependencies", configurationData.getDependencies());
+ config.setAttribute("classPath", configurationData.getClassPath());
+
+ return config;
+ } catch (MalformedObjectNameException e) {
+ throw new InvalidConfigException(e);
+ }
+ }
+
+ private static Collection listRecursiveFiles(File file) {
+ LinkedList list = new LinkedList();
+ listRecursiveFiles(file, list);
+ return Collections.unmodifiableCollection(list);
+ }
+
+ private static void listRecursiveFiles(File file, Collection collection) {
+ File[] files = file.listFiles();
+ if (null == files) {
+ return;
+ }
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ listRecursiveFiles(files[i], collection);
+ } else {
+ collection.add(files[i]);
+ }
+ }
+ }
+
+ private static void close(InputStream thing) {
+ if (thing != null) {
+ try {
+ thing.close();
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ private static void close(OutputStream thing) {
+ if (thing != null) {
+ try {
+ thing.close();
+ } catch (Exception ignored) {
+ }
+ }
+ }
+}
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java Sun May 8 12:35:23 2005
@@ -40,6 +40,8 @@
import org.apache.geronimo.kernel.config.ConfigurationInfo;
import org.apache.geronimo.kernel.config.NoSuchStoreException;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -58,6 +60,11 @@
private final Kernel kernel;
/**
+ * The ConfigurationManager for the kernel
+ */
+ private final ConfigurationManager configurationManager;
+
+ /**
* Used to resolve the location of the configuration file.
*/
private final ServerInfo serverInfo;
@@ -87,6 +94,7 @@
public FileConfigurationList(Kernel kernel, ServerInfo serverInfo, String configDir) {
this.kernel = kernel;
+ configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
this.serverInfo = serverInfo;
this.configFile = configDir;
}
@@ -137,10 +145,10 @@
BufferedWriter writer = new BufferedWriter(new FileWriter(configList));
try {
- List stores = kernel.listConfigurationStores();
+ List stores = configurationManager.listStores();
for (Iterator i = stores.iterator(); i.hasNext();) {
ObjectName storeName = (ObjectName) i.next();
- List configList = kernel.listConfigurations(storeName);
+ List configList = configurationManager.listConfigurations(storeName);
for (Iterator j = configList.iterator(); j.hasNext();) {
ConfigurationInfo info = (ConfigurationInfo) j.next();
if (info.getState() == State.RUNNING) {
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=169154&r1=169153&r2=169154&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Sun May 8 12:35:23 2005
@@ -28,7 +28,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
@@ -47,11 +46,14 @@
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
@@ -95,7 +97,7 @@
return objectName.toString();
}
- public void doStart() throws FileNotFoundException, IOException {
+ public synchronized void doStart() throws FileNotFoundException, IOException {
// resolve the root dir if not alredy resolved
if (rootDir == null) {
if (serverInfo == null) {
@@ -185,7 +187,7 @@
URI configId;
try {
GBeanData config = loadConfig(configurationDir);
- configId = (URI) config.getAttribute("ID");
+ configId = (URI) config.getAttribute("id");
index.setProperty(configId.toString(), configurationDir.getName());
} catch (Exception e) {
delete(configurationDir);
@@ -200,7 +202,7 @@
return configId;
}
- public URI install(File source) throws IOException, InvalidConfigException {
+ public void install(ConfigurationData configurationData, File source) throws IOException, InvalidConfigException {
if (!source.isDirectory()) {
throw new InvalidConfigException("Source must be a directory: source=" + source);
}
@@ -208,21 +210,15 @@
throw new InvalidConfigException("Source must be within the config store: source=" + source + ", configStoreDir=" + rootDir);
}
- URI configId;
- try {
- GBeanData config = loadConfig(source);
- configId = (URI) config.getAttribute("ID");
- index.setProperty(configId.toString(), source.getName());
- } catch (Exception e) {
- throw new InvalidConfigException("Unable to get ID from downloaded configuration", e);
- }
+ ExecutableConfigurationUtil.writeConfiguration(configurationData, source);
+ // update the index
synchronized (this) {
+ index.setProperty(configurationData.getId().toString(), source.getName());
saveIndex();
}
- log.info("Installed configuration " + configId + " in location " + source.getName());
- return configId;
+ log.info("Installed configuration " + configurationData.getId() + " in location " + source.getName());
}
public void uninstall(URI configID) throws NoSuchConfigException, IOException {
@@ -245,20 +241,48 @@
delete(configDir);
}
- public synchronized GBeanData getConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
- return loadConfig(getRoot(configID));
+ public synchronized ObjectName loadConfiguration(URI configId) throws NoSuchConfigException, IOException, InvalidConfigException {
+ GBeanData config = loadConfig(getRoot(configId));
+
+ ObjectName name;
+ try {
+ name = Configuration.getConfigurationObjectName(configId);
+ } catch (MalformedObjectNameException e) {
+ throw new InvalidConfigException("Cannot convert id to ObjectName: ", e);
+ }
+ config.setName(name);
+
+ try {
+ kernel.loadGBean(config, Configuration.class.getClassLoader());
+ } catch (Exception e) {
+ throw new InvalidConfigException("Unable to register configuration", e);
+ }
+
+ try {
+ kernel.setAttribute(name, "baseURL", getRoot(configId).toURL());
+ } 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 synchronized void updateConfiguration(Configuration configuration) throws NoSuchConfigException, Exception {
- File root = getRoot(configuration.getID());
+ public synchronized void updateConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, Exception {
+ File root = getRoot(configurationData.getId());
File stateFile = new File(root, "META-INF/state.ser");
try {
FileOutputStream fos = new FileOutputStream(stateFile);
ObjectOutputStream oos;
try {
oos = new ObjectOutputStream(fos);
- GBeanData gbeanData = kernel.getGBeanData(JMXUtil.getObjectName(configuration.getObjectName()));
- gbeanData.writeExternal(oos);
+ GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
+ configurationGBeanData.writeExternal(oos);
oos.flush();
} finally {
fos.close();
@@ -275,20 +299,33 @@
synchronized (this) {
configs = new ArrayList(index.size());
for (Iterator i = index.keySet().iterator(); i.hasNext();) {
- String id = (String) i.next();
- configs.add(URI.create(id));
+ URI configId = URI.create((String) i.next());
+ try {
+ ObjectName configName = Configuration.getConfigurationObjectName(configId);
+ State state;
+ if (kernel.isLoaded(configName)) {
+ try {
+ state = State.fromInt(kernel.getGBeanState(configName));
+ } 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;
+ }
+
+ GBeanData bean = loadConfig(getRoot(configId));
+ ConfigurationModuleType type = (ConfigurationModuleType) bean.getAttribute("type");
+
+ configs.add(new ConfigurationInfo(objectName, configId, state, type));
+ } catch (Exception e) {
+ // bad configuration in store - ignored for this purpose
+ log.info("Unable get configuration info for configuration " + configId, e);
+ }
}
}
return configs;
- }
-
- public URL getBaseURL(URI configID) throws NoSuchConfigException {
- File root = getRoot(configID);
- try {
- return root.toURL();
- } catch (MalformedURLException e) {
- throw new IllegalStateException("Unable to turn config root into URL: " + root);
- }
}
public synchronized boolean containsConfiguration(URI configID) {