[jboss-cvs] JBossAS SVN: r81251 - in trunk: profileservice/src/resources and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 18 15:28:46 EST 2008
Author: scott.stark at jboss.org
Date: 2008-11-18 15:28:46 -0500 (Tue, 18 Nov 2008)
New Revision: 81251
Added:
trunk/system/src/main/org/jboss/deployers/plugins/managed/ControllerStateMetaType.java
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
trunk/profileservice/src/resources/profileservice-jboss-beans.xml
trunk/server/src/etc/conf/default/profile-repository.xml
trunk/server/src/etc/conf/default/profile.xml
trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
Log:
JBAS-5286, JBAS-5523, open console support
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -23,7 +23,14 @@
import java.lang.reflect.UndeclaredThrowableException;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.plugins.managed.ControllerStateMetaType;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.registry.KernelBus;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
@@ -31,10 +38,13 @@
* Microcontainer KernelBus runtime component dispatcher.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision$
*/
public class KernelBusRuntimeComponentDispatcher extends AbstractRuntimeComponentDispatcher
{
private KernelBus bus;
+ private Kernel kernel;
+ private String statePropertyName = "state";
public KernelBusRuntimeComponentDispatcher(KernelBus bus)
{
@@ -49,10 +59,52 @@
this.bus = bus;
}
+ /**
+ * Get the kernel.
+ *
+ * @return the kernel.
+ */
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+ /**
+ * Set the kernel.
+ *
+ * @param kernel the kernel.
+ */
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+
+ public KernelBus getBus()
+ {
+ return bus;
+ }
+
+ public void setBus(KernelBus bus)
+ {
+ this.bus = bus;
+ }
+
+ public String getStatePropertyName()
+ {
+ return statePropertyName;
+ }
+
+ public void setStatePropertyName(String statePropertyName)
+ {
+ this.statePropertyName = statePropertyName;
+ }
+
public MetaValue get(Object componentName, String propertyName)
{
try
{
+ if(propertyName.equals(statePropertyName))
+ return getState(componentName);
return create(bus.get(componentName, propertyName));
}
catch (Throwable t)
@@ -84,4 +136,26 @@
throw new UndeclaredThrowableException(t);
}
}
+
+ /**
+ * Get the state of a bean
+ *
+ * @param <T> the expected type
+ * @param controller the controller
+ * @param name the bean name
+ * @param expectedType the expected type
+ * @return the bean
+ * @throws IllegalStateException if the bean is not installed or has the wrong type
+ */
+ protected EnumValue getState(Object name)
+ {
+ KernelController controller = kernel.getController();
+ ControllerContext context = controller.getContext(name, null);
+ if (context == null)
+ throw new IllegalStateException("Context not installed: " + name);
+ ControllerState state = context.getState();
+ EnumValueSupport stateValue = new EnumValueSupport(ControllerStateMetaType.TYPE, state.getStateString());
+ return stateValue;
+ }
+
}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: trunk/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-jboss-beans.xml 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/profileservice/src/resources/profileservice-jboss-beans.xml 2008-11-18 20:28:46 UTC (rev 81251)
@@ -52,6 +52,7 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=KernelBus"/></parameter>
</constructor>
+ <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
</bean>
<!-- The ManagementView plugin -->
Modified: trunk/server/src/etc/conf/default/profile-repository.xml
===================================================================
--- trunk/server/src/etc/conf/default/profile-repository.xml 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/server/src/etc/conf/default/profile-repository.xml 2008-11-18 20:28:46 UTC (rev 81251)
@@ -40,7 +40,6 @@
<!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
- <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
<property name="mainDeployer"><inject bean="MainDeployer"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
<property name="mof"><inject bean="ManagedObjectFactory"/></property>
Modified: trunk/server/src/etc/conf/default/profile.xml
===================================================================
--- trunk/server/src/etc/conf/default/profile.xml 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/server/src/etc/conf/default/profile.xml 2008-11-18 20:28:46 UTC (rev 81251)
@@ -25,7 +25,6 @@
</bean>
<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
- <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
<property name="mainDeployer"><inject bean="MainDeployer"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
<property name="mof"><inject bean="ManagedObjectFactory"/></property>
Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -148,10 +148,20 @@
Object bean = locateBean(attachment.getName());
Object value = null;
MetaValue mvalue = null;
+ if(propertyInfo.isReadable() == false)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Skipping get of non-readable property: "+propertyInfo);
+ return null;
+ }
try
{
- value = propertyInfo.get(bean);
+ String getterClassName = propertyInfo.getGetter().getDeclaringClass().getName();
+ if(getterClassName.equals(attachment.getClass().getName()))
+ value = propertyInfo.get(attachment);
+ else
+ value = propertyInfo.get(bean);
mvalue = metaValueFactory.create(value, propertyInfo.getType());
}
catch(Throwable e)
@@ -183,7 +193,12 @@
PropertyInfo propertyInfo = beanInfo.getProperty(name);
if(propertyInfo == null)
throw new IllegalArgumentException("No matching property found: " + name + "/" + beanName);
-
+ if(propertyInfo.isWritable() == false)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Skipping get of non-writable property: "+propertyInfo);
+ return;
+ }
Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
Object bean = locateBean(beanName);
propertyInfo.set(bean, plainValue);
Added: trunk/system/src/main/org/jboss/deployers/plugins/managed/ControllerStateMetaType.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/ControllerStateMetaType.java (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/ControllerStateMetaType.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployers.plugins.managed;
+
+import java.util.Arrays;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.metatype.api.types.EnumMetaType;
+
+/**
+ * An EnumMetaType for the kernel ControllerState values.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ControllerStateMetaType extends EnumMetaType
+{
+ private static final long serialVersionUID = 2;
+ private static final String[] VALID_VALUES = {
+ "**ERROR**",
+ "Not Installed",
+ "PreInstall",
+ "Described",
+ "Instantiated",
+ "Configured",
+ "Create",
+ "Start",
+ "Installed"
+ };
+ public static final EnumMetaType TYPE = new ControllerStateMetaType();
+
+ private ControllerStateMetaType()
+ {
+ super(ControllerState.class.getName(), Arrays.asList(VALID_VALUES));
+ }
+}
Property changes on: trunk/system/src/main/org/jboss/deployers/plugins/managed/ControllerStateMetaType.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -21,8 +21,6 @@
*/
package org.jboss.deployers.plugins.managed;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -35,33 +33,23 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.logging.Logger;
import org.jboss.managed.api.Fields;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.annotation.ManagementConstants;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ManagementRuntimeRef;
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.managed.plugins.DefaultFieldsImpl;
import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory;
import org.jboss.metadata.spi.MetaData;
-import org.jboss.metatype.api.types.ArrayMetaType;
import org.jboss.metatype.api.types.CollectionMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.GenericValueSupport;
-import org.jboss.reflect.spi.AnnotatedInfo;
-import org.jboss.reflect.spi.TypeInfo;
/**
* ManagedObjectCreator for KernelDeployment
@@ -102,8 +90,18 @@
ManagedObject deploymentMO = managedObjects.get(KernelDeployment.class.getName());
if(deploymentMO == null)
{
- // Should not happen?
- deploymentMO = mof.createManagedObject(deployment.getClass());
+ // Check for the KernelDeployment impl name
+ deploymentMO = managedObjects.get(AbstractKernelDeployment.class.getName());
+ if(deploymentMO == null)
+ {
+ // Should not happen?
+ deploymentMO = mof.createManagedObject(deployment.getClass());
+ }
+ else
+ {
+ // Put the MO under the attachment interface name
+ managedObjects.remove(AbstractKernelDeployment.class.getName());
+ }
managedObjects.put(KernelDeployment.class.getName(), deploymentMO);
}
@@ -121,6 +119,7 @@
ManagedObject bmdfMO = mof.initManagedObject(bmdf, metaData);
if(bmdfMO == null)
continue;
+
if((bmdfMO instanceof MutableManagedObject) == false)
{
// Just go with the default ManagedObject
@@ -128,26 +127,28 @@
tmpBFs.add(gv);
continue;
}
- else
- {
- GenericValueSupport gv = new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, bmdfMO);
- tmpBFs.add(gv);
- }
-/*
+
MutableManagedObject bmdfMMO = (MutableManagedObject) bmdfMO;
Map<String, ManagedProperty> oldProps = bmdfMMO.getProperties();
ManagedProperty beansMPCheck = oldProps.get("beans");
// If there already is a beans property assume its correct
if(beansMPCheck != null)
+ {
+ // Need to map
continue;
+ }
Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
// Create a beans ManagedProperty, a list of BeanMetaData ManagedObjects
- DefaultFieldsImpl fields = new DefaultFieldsImpl();
+ Fields fields = getFields("beans", beansType);
ManagedPropertyImpl beansMP = new ManagedPropertyImpl(bmdfMO, fields);
- beansMP.setMetaType(beansType);
newProps.put("beans", beansMP);
-
+
+ // Add a state property
+ Fields stateFields = getFields("state", ControllerStateMetaType.TYPE);
+ ManagedPropertyImpl stateMP = new ManagedPropertyImpl(bmdfMO, stateFields);
+ newProps.put("state", beansMP);
+
// Create a ManagedObject for each of the beans BeanMetaData
List<BeanMetaData> beans = bmdf.getBeans();
if(beans != null)
@@ -158,18 +159,26 @@
if(compUnit == null)
{
log.debug("Failed to find component for bean: "+bmd.getName());
+ continue;
}
MetaData compMetaData = compUnit.getMetaData();
GenericValue gv = getManagedObjectValue(bmd, compMetaData, bmdfMO);
if(gv != null)
+ {
+ // The component managed objects need to be in the root map
+ ManagedObject compMO = (ManagedObject) gv.getValue();
+ managedObjects.put(compUnit.getName(), compMO);
+ // Add the bean MO to the beans list
tmpBeans.add(gv);
+ }
}
}
GenericValue[] beanMOs = new GenericValue[tmpBeans.size()];
tmpBeans.toArray(beanMOs);
CollectionValueSupport values = new CollectionValueSupport(beansType, beanMOs);
beansMP.setValue(values);
- */
+ // Update the bean factory properties
+ bmdfMMO.setProperties(newProps);
}
}
GenericValue[] mos = new GenericValue[tmpBFs.size()];
@@ -179,6 +188,13 @@
beanFactoriesMP.getFields().setField(Fields.VALUE, values);
}
+ /**
+ *
+ * @param bmd
+ * @param metaData
+ * @param parentMO
+ * @return
+ */
protected GenericValue getManagedObjectValue(BeanMetaData bmd, MetaData metaData, ManagedObject parentMO)
{
String name = bmd.getName();
@@ -191,4 +207,19 @@
return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
}
+ /**
+ * Create a DefaultFieldsImpl for the given property name and type
+ * @param name - the property name
+ * @param type - the property type
+ * @return return the fields implementation
+ */
+ protected Fields getFields(String name, MetaType type)
+ {
+ DefaultFieldsImpl fields = new DefaultFieldsImpl();
+ fields.setMetaType(type);
+ fields.setName(name);
+ fields.setMandatory(false);
+
+ return fields;
+ }
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -34,7 +34,6 @@
import org.jboss.bootstrap.spi.Bootstrap;
import org.jboss.bootstrap.spi.Server;
import org.jboss.bootstrap.spi.microcontainer.MCServer;
-import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.client.spi.IncompleteDeploymentException;
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.deployers.plugins.main.MainDeployerImpl;
@@ -45,8 +44,6 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer.KernelDeploymentVisitor;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ComponentType;
@@ -56,7 +53,6 @@
import org.jboss.managed.api.MutableManagedObject;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.managed.plugins.DefaultFieldsImpl;
import org.jboss.managed.plugins.ManagedComponentImpl;
@@ -89,11 +85,11 @@
/** The server ProfileService */
protected ProfileService profileService;
- /** The kernel */
- protected Kernel kernel;
/** The ManagedDeploymentCreator plugin */
private ManagedDeploymentCreator mgtDeploymentCreator = null;
+ /** The ManagedObjectFactory for building the bootstrap deployment ManagedObjects */
private ManagedObjectFactory mof;
+ /** The ManagedDeployment map for the MCServer KernelDeployments */
private Map<String, ManagedDeployment> bootstrapMDs = new HashMap<String, ManagedDeployment>();
/** Whether we are shutdown */
@@ -134,27 +130,6 @@
this.profileService = profileService;
}
- /**
- * Get the kernel.
- *
- * @return the kernel.
- */
- public Kernel getKernel()
- {
- return kernel;
- }
-
- /**
- * Set the kernel.
- *
- * @param kernel the kernel.
- */
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
-
public String getProfileName()
{
return profileName;
@@ -209,7 +184,7 @@
// Validate that everything is ok
mainDeployer.checkComplete();
- // TODO: JBAS-5689 Expose the bootstrap ManagedDeployments...
+ // Expose the bootstrap ManagedDeployments
initBootstrapMDs(server);
// Load the profile beans
@@ -253,29 +228,6 @@
}
/**
- * Get a bean
- *
- * @param <T> the expected type
- * @param controller the controller
- * @param name the bean name
- * @param expectedType the expected type
- * @return the bean
- * @throws IllegalStateException if the bean is not installed or has the wrong type
- */
- protected <T> T getBean(KernelController controller, Object name, Class<T> expectedType)
- {
- ControllerContext context = controller.getInstalledContext(name);
- if (context == null)
- throw new IllegalStateException("Context not installed: " + name);
- Object result = context.getTarget();
- if (result == null)
- throw new IllegalStateException("No target for " + name);
- if (expectedType.isInstance(result) == false)
- throw new IllegalStateException(name + " expected " + expectedType.getName() + " was " + result.getClass().getName());
- return expectedType.cast(result);
- }
-
- /**
* Load the deployments associated with the named profile and deploy them
* using the MainDeployer.
*
@@ -300,7 +252,7 @@
// HACK
VFSDeployment first = null;
- // Deploy the bootstrap
+ // Deploy the profile bootstrap deployments
Collection<VFSDeployment> boostraps = profile.getDeployments(DeploymentPhase.BOOTSTRAP);
for (VFSDeployment d : boostraps)
{
@@ -455,6 +407,15 @@
deployer.process();
}
+ /**
+ * Create ManagedDeployments for the MCServer KernelDeployments. This allows
+ * the bootstrap deployments outside of the profile service to be visible in
+ * the ManagementView
+ * @see {@link ManagementView}
+ *
+ * @param server - the Bootstrap.start Server instance. This must be an
+ * MCServer in order for there to be KernelDeployments available.
+ */
protected void initBootstrapMDs(Server server)
{
if(mof == null || mgtDeploymentCreator == null)
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2008-11-18 18:47:03 UTC (rev 81250)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2008-11-18 20:28:46 UTC (rev 81251)
@@ -80,6 +80,9 @@
ManagedProperty availableProcessors = props.get("availableProcessors");
long availableProcessorsValue = getLong(availableProcessors);
assertTrue("availableProcessors > 0", availableProcessorsValue > 0);
+
+ ManagedProperty state = props.get("state");
+ getLog().info(state);
}
More information about the jboss-cvs-commits
mailing list