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/07/27 08:41:15 UTC
svn commit: r225470 - in /geronimo/trunk/modules/kernel/src:
java/org/apache/geronimo/gbean/ java/org/apache/geronimo/gbean/runtime/
test/org/apache/geronimo/kernel/
Author: dain
Date: Tue Jul 26 23:41:11 2005
New Revision: 225470
URL: http://svn.apache.org/viewcvs?rev=225470&view=rev
Log:
GERONIMO-791 Removed J2EEManagedObject methods from GBeanInstance
Removed:
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanLifecycleController.java
Modified:
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java
geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java
geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=225470&r1=225469&r2=225470&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Tue Jul 26 23:41:11 2005
@@ -35,7 +35,6 @@
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.GBeanLifecycleController;
import org.apache.geronimo.gbean.GConstructorInfo;
import org.apache.geronimo.gbean.GOperationInfo;
import org.apache.geronimo.gbean.GOperationSignature;
@@ -99,11 +98,6 @@
private final LifecycleBroadcaster lifecycleBroadcaster;
/**
- * The lifecycle controller given to the instance
- */
- private final GBeanLifecycleController gbeanLifecycleController;
-
- /**
* Interfaces for this GBean
*/
private final Class[] interfaces;
@@ -204,7 +198,6 @@
this.lifecycleBroadcaster = lifecycleBroadcaster;
this.gbeanInstanceState = new GBeanInstanceState(objectName, kernel, dependencyManager, this, lifecycleBroadcaster);
this.classLoader = classLoader;
- gbeanLifecycleController = new GBeanInstanceLifecycleController(this);
GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
try {
@@ -251,7 +244,6 @@
// operations
Map operationsMap = new HashMap();
- addManagedObjectOperations(operationsMap);
for (Iterator iterator = gbeanInfo.getOperations().iterator(); iterator.hasNext();) {
GOperationInfo operationInfo = (GOperationInfo) iterator.next();
GOperationSignature signature = new GOperationSignature(operationInfo.getName(), operationInfo.getParameterList());
@@ -306,7 +298,11 @@
Map.Entry entry = (Map.Entry) iterator.next();
String attributeName = (String) entry.getKey();
Object attributeValue = entry.getValue();
- setAttribute(attributeName, attributeValue);
+ if ("gbeanEnabled".equals(attributeName)) {
+ enabled = ((Boolean)attributeValue).booleanValue();
+ } else {
+ setAttribute(attributeName, attributeValue);
+ }
}
// add the references
@@ -1040,13 +1036,6 @@
String.class,
getObjectName()));
- attributesMap.put("gbeanInfo",
- GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("gbeanInfo"),
- this,
- "gbeanInfo",
- GBeanInfo.class,
- gbeanInfo));
-
attributesMap.put("classLoader",
GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("classLoader"),
this,
@@ -1054,13 +1043,6 @@
ClassLoader.class,
classLoader));
- attributesMap.put("gbeanLifecycleController",
- GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("gbeanLifecycleController"),
- this,
- "gbeanLifecycleController",
- GBeanLifecycleController.class,
- gbeanLifecycleController));
-
attributesMap.put("kernel",
GBeanAttribute.createSpecialAttribute((GBeanAttribute) attributesMap.get("kernel"),
this,
@@ -1068,123 +1050,6 @@
Kernel.class,
kernel));
- //
- // Framework attributes
- //
- attributesMap.put("state",
- GBeanAttribute.createFrameworkAttribute(this,
- "state",
- Integer.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Integer(getState());
- }
- }));
-
- attributesMap.put("startTime",
- GBeanAttribute.createFrameworkAttribute(this,
- "startTime",
- Long.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Long(getStartTime());
- }
- }));
-
- attributesMap.put("stateManageable",
- GBeanAttribute.createFrameworkAttribute(this,
- "stateManageable",
- Boolean.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Boolean(isStateManageable());
- }
- }));
-
- attributesMap.put("statisticsProvider",
- GBeanAttribute.createFrameworkAttribute(this,
- "statisticsProvider",
- Boolean.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Boolean(isStatisticsProvider());
- }
- }));
-
-
- attributesMap.put("eventProvider",
- GBeanAttribute.createFrameworkAttribute(this,
- "eventProvider",
- Boolean.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Boolean(isEventProvider());
- }
- }));
-
- attributesMap.put("eventTypes",
- GBeanAttribute.createFrameworkAttribute(this,
- "eventTypes",
- Boolean.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return getEventTypes();
- }
- }));
-
- attributesMap.put("gbeanEnabled",
- GBeanAttribute.createFrameworkAttribute(this,
- "gbeanEnabled",
- Boolean.TYPE,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- return new Boolean(isEnabled());
- }
- },
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- Boolean enabled = (Boolean) arguments[0];
- setEnabled(enabled.booleanValue());
- return null;
- }
- },
- true,
- Boolean.TRUE));
- }
-
- private void addManagedObjectOperations(Map operationsMap) {
- operationsMap.put(new GOperationSignature("start", Collections.EMPTY_LIST),
- GBeanOperation.createFrameworkOperation(this,
- "start",
- Collections.EMPTY_LIST,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- start();
- return null;
- }
- }));
-
- operationsMap.put(new GOperationSignature("startRecursive", Collections.EMPTY_LIST),
- GBeanOperation.createFrameworkOperation(this,
- "startRecursive",
- Collections.EMPTY_LIST,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- startRecursive();
- return null;
- }
- }));
-
- operationsMap.put(new GOperationSignature("stop", Collections.EMPTY_LIST),
- GBeanOperation.createFrameworkOperation(this,
- "stop",
- Collections.EMPTY_LIST,
- new MethodInvoker() {
- public Object invoke(Object target, Object[] arguments) throws Exception {
- stop();
- return null;
- }
- }));
}
private GBeanInfo rebuildGBeanInfo(GConstructorInfo constructor, String j2eeType) {
@@ -1216,56 +1081,6 @@
operationInfos,
referenceInfos,
interfaceInfos);
- }
-
- public static final class GBeanInstanceLifecycleController implements GBeanLifecycleController {
- /**
- * The GeronimoInstance which owns the target.
- */
- private final GBeanInstance gbeanInstance;
-
- /**
- * Creates a new context for a target.
- *
- * @param gbeanInstance the GeronimoInstance
- */
- public GBeanInstanceLifecycleController(GBeanInstance gbeanInstance) {
- this.gbeanInstance = gbeanInstance;
- }
-
- /**
- * Gets the state of this component as an int.
- * The int return is required by the JSR77 specification.
- *
- * @return the current state of this component
- */
- public int getState() {
- return gbeanInstance.getState();
- }
-
- /**
- * Attempt to bring the component into the fully stopped state. If an exception occurs while
- * stopping the component, tthe component is automaticaly failed.
- * <p/>
- * There is no guarantee that the Geronimo MBean will be stopped when the method returns.
- *
- * @throws Exception if a problem occurs while stopping the component
- */
- public void stop() throws Exception {
- synchronized(gbeanInstance) {
- if (gbeanInstance.instanceState == CREATING) {
- throw new IllegalStateException("Stop can not be called until instance is fully started");
- } else if (gbeanInstance.instanceState == DESTROYING) {
- log.debug("Stop ignored. GBean is already being stopped");
- return;
- } else if (gbeanInstance.instanceState == DESTROYED) {
- log.debug("Stop ignored. GBean is already stopped");
- return;
- }
- }
- gbeanInstance.stop();
- }
-
}
public boolean equals(Object obj) {
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java?rev=225470&r1=225469&r2=225470&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java Tue Jul 26 23:41:11 2005
@@ -24,7 +24,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.kernel.DependencyManager;
import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.NoSuchAttributeException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
@@ -137,11 +136,9 @@
for (Iterator iterator = dependents.iterator(); iterator.hasNext();) {
ObjectName dependent = (ObjectName) iterator.next();
try {
- if (((Boolean) kernel.getAttribute(dependent, "gbeanEnabled")).booleanValue()) {
+ if (kernel.isGBeanEnabled(dependent)) {
kernel.startRecursiveGBean(dependent);
}
- } catch (NoSuchAttributeException e) {
- // this is ok didn't have the attribute....
} catch (GBeanNotFoundException e) {
// this is ok the gbean died before we could start it
continue;
@@ -377,14 +374,11 @@
if (kernel.isLoaded(child)) {
try {
log.trace("Checking if child is stopped: child=" + child);
- int state = ((Integer) kernel.getAttribute(child, "State")).intValue();
+ int state = kernel.getGBeanState(child);
if (state == State.RUNNING_INDEX) {
log.trace("Cannot stop because child is still running: child=" + child);
return;
}
- } catch (NoSuchAttributeException e) {
- // ok -- dependect bean is not state manageable
- log.trace("Child does not have a State attibute");
} catch (GBeanNotFoundException e) {
// depended on instance was removed between the register check and the invoke
} catch (Exception e) {
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=225470&r1=225469&r2=225470&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 Tue Jul 26 23:41:11 2005
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanLifecycleController;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.proxy.ProxyManager;
@@ -56,10 +55,6 @@
// the MockGBean implemmentation of getConfigurationClassLoader will throw an exception, but since the GBean architecture
// handles this directly the implementation method will never be called
kernel.getAttribute(name, "classLoader");
-
- GBeanLifecycleController gbeanLifecycleController = (GBeanLifecycleController) kernel.getAttribute(name, "gbeanLifecycleController");
- assertNotNull(gbeanLifecycleController);
- assertEquals(State.RUNNING_INDEX, gbeanLifecycleController.getState());
assertSame(kernel, kernel.getAttribute(name, "kernel"));
assertSame(kernel, kernel.getAttribute(name, "actualKernel"));
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=225470&r1=225469&r2=225470&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 Tue Jul 26 23:41:11 2005
@@ -17,8 +17,6 @@
package org.apache.geronimo.kernel;
-import org.apache.geronimo.gbean.GBeanLifecycleController;
-
/**
* @version $Rev$ $Date$
*/
@@ -35,6 +33,4 @@
void doNothing();
String echo(String message);
-
- 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=225470&r1=225469&r2=225470&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 Tue Jul 26 23:41:11 2005
@@ -24,7 +24,6 @@
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycleController;
/**
* @version $Rev$ $Date$
@@ -52,7 +51,6 @@
private MockEndpoint endpoint;
private Collection endpointCollection = Collections.EMPTY_SET;
- private GBeanLifecycleController gbeanLifecycleController;
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
@@ -63,7 +61,6 @@
infoFactory.addAttribute("name", String.class, true);
infoFactory.addAttribute("actualObjectName", String.class, false);
infoFactory.addAttribute("objectName", String.class, false);
- infoFactory.addAttribute("gbeanLifecycleController", GBeanLifecycleController.class, false);
infoFactory.addAttribute("actualClassLoader", ClassLoader.class, false);
infoFactory.addAttribute("classLoader", ClassLoader.class, false);
infoFactory.addAttribute("actualKernel", Kernel.class, false);
@@ -88,7 +85,7 @@
infoFactory.addReference("MockEndpoint", MockEndpoint.class, null);
infoFactory.addReference("EndpointCollection", MockEndpoint.class, null);
- infoFactory.setConstructor(new String[]{"name", "finalInt", "objectName", "classLoader", "gbeanLifecycleController", "kernel"});
+ infoFactory.setConstructor(new String[]{"name", "finalInt", "objectName", "classLoader", "kernel"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
@@ -98,12 +95,11 @@
this.finalInt = finalInt;
}
- public MockGBean(String name, int finalInt, String objectName, ClassLoader classLoader, GBeanLifecycleController gbeanLifecycleController, Kernel kernel) {
+ public MockGBean(String name, int finalInt, String objectName, ClassLoader classLoader, Kernel kernel) {
this.name = name;
this.finalInt = finalInt;
this.objectName = objectName;
this.classLoader = classLoader;
- this.gbeanLifecycleController = gbeanLifecycleController;
this.kernel = kernel;
}
@@ -121,10 +117,6 @@
public ClassLoader getClassLoader() {
return classLoader;
- }
-
- public GBeanLifecycleController getGbeanLifecycleController() {
- return gbeanLifecycleController;
}
public Kernel getActualKernel() {