[jboss-cvs] JBossAS SVN: r106985 - in branches/JBPAPP_5_0_1_JBPAPP-4655: profileservice/src/main/org/jboss/profileservice/management and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 21 12:10:59 EDT 2010
Author: jiwils
Date: 2010-07-21 12:10:57 -0400 (Wed, 21 Jul 2010)
New Revision: 106985
Modified:
branches/JBPAPP_5_0_1_JBPAPP-4655/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
branches/JBPAPP_5_0_1_JBPAPP-4655/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
Log:
Fix for JBPAPP-4655; Datasource deployments sometimes return UNKNOWN status.
Modified: branches/JBPAPP_5_0_1_JBPAPP-4655/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
===================================================================
--- branches/JBPAPP_5_0_1_JBPAPP-4655/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2010-07-21 15:57:08 UTC (rev 106984)
+++ branches/JBPAPP_5_0_1_JBPAPP-4655/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2010-07-21 16:10:57 UTC (rev 106985)
@@ -33,18 +33,9 @@
import javax.xml.transform.sax.SAXSource;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.MetaValue;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.repository.JCAMetaDataRepository;
import org.jboss.util.xml.JBossEntityResolver;
@@ -63,7 +54,6 @@
* TODO Note, this is currently a total hack until we can rework the JAXBDeployer
*/
public class ManagedConnectionFactoryParserDeployer extends AbstractVFSParsingDeployer<ManagedConnectionFactoryDeploymentGroup>
- implements ManagedObjectCreator
{
/** The context */
private JAXBContext context;
@@ -151,44 +141,4 @@
metaData.setUrl(file.toURL());
}
- /**
- * Build managed object.
- *
- * @param unit the deployment unit
- * @param managedObjects map of managed objects
- * @throws DeploymentException for any deployment exception
- */
- public void build(DeploymentUnit unit, Set<String> outputs,
- Map<String, ManagedObject> managedObjects) throws DeploymentException
- {
- if(isBuildManagedObject())
- {
- ManagedObject mcfdgMO = managedObjects.get(ManagedConnectionFactoryDeploymentGroup.class.getName());
- if(mcfdgMO != null)
- {
- ManagedProperty deployments = mcfdgMO.getProperty("deployments");
- MetaType propType = deployments.getMetaType();
- if (propType.isCollection())
- {
- CollectionMetaType amt = (CollectionMetaType) propType;
- MetaType etype = amt.getElementType();
- if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
- {
- CollectionValue avalue = (CollectionValue) deployments.getValue();
- if(avalue != null)
- {
- MetaValue[] elements = avalue.getElements();
- for(int n = 0; n < avalue.getSize(); n ++)
- {
- GenericValue gv = (GenericValue) elements[n];
- ManagedObject propMO = (ManagedObject) gv.getValue();
- managedObjects.put(propMO.getName(), propMO);
- }
- }
- }
- }
- }
-
- }
- }
}
Modified: branches/JBPAPP_5_0_1_JBPAPP-4655/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/JBPAPP_5_0_1_JBPAPP-4655/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2010-07-21 15:57:08 UTC (rev 106984)
+++ branches/JBPAPP_5_0_1_JBPAPP-4655/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2010-07-21 16:10:57 UTC (rev 106985)
@@ -620,6 +620,19 @@
if(state != null && md instanceof ManagedDeploymentImpl)
((ManagedDeploymentImpl)md).setDeploymentState(state);
+ // Map any existing ManagedComponent types
+ for(ManagedComponent comp : md.getComponents().values())
+ {
+ ComponentType type = comp.getType();
+ Set<ManagedComponent> typeComps = compByCompType.get(type);
+ if (typeComps == null)
+ {
+ typeComps = new HashSet<ManagedComponent>();
+ compByCompType.put(type, typeComps);
+ }
+ typeComps.add(comp);
+ }
+
for(ManagedObject mo : mos.values())
{
processManagedObject(mo, md);
@@ -662,12 +675,35 @@
// See if this is a runtime ManagedObject
Map<String, Annotation> moAnns = mo.getAnnotations();
+
+ // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
+ ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
+ if (mc != null && md.getComponent(mo.getName()) == null)
+ {
+ ComponentType type = new ComponentType(mc.type(), mc.subtype());
+ MutableManagedComponent comp = new ManagedComponentImpl(type, md, mo);
+
+ if(mo.getTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName()) == null)
+ comp = this.proxyFactory.createComponentProxy(comp);
+
+ md.addComponent(mo.getName(), comp);
+ log.debug("Processing ManagementComponent("+mo.getName()+"): "+comp);
+ Set<ManagedComponent> typeComps = compByCompType.get(type);
+ if (typeComps == null)
+ {
+ typeComps = new HashSet<ManagedComponent>();
+ compByCompType.put(type, typeComps);
+ }
+ typeComps.add(comp);
+ RunState state = updateRunState(mo, comp);
+ }
+
ManagementObject managementObject = (ManagementObject) moAnns.get(ManagementObject.class.getName());
if (managementObject != null && managementObject.isRuntime())
{
boolean merged = false;
- ManagementComponent mc = managementObject.componentType();
- boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
+ ManagementComponent component = managementObject.componentType();
+ boolean isMC = !(component.type().length() == 0 && component.subtype().length() == 0);
// Merge this with the ManagedObject
ManagedObject parentMO = moRegistry.get(key);
@@ -732,42 +768,6 @@
// Check for unresolved refs
checkForReferences(key, mo);
- // Map any existing ManagedComponent types
- for(ManagedComponent comp : md.getComponents().values())
- {
- log.debug("Updating ManagementComponent: "+comp);
- ComponentType type = comp.getType();
- Set<ManagedComponent> typeComps = compByCompType.get(type);
- if (typeComps == null)
- {
- typeComps = new HashSet<ManagedComponent>();
- compByCompType.put(type, typeComps);
- }
- typeComps.add(comp);
- }
-
- // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
- ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
- if (mc != null && md.getComponent(mo.getName()) == null)
- {
- ComponentType type = new ComponentType(mc.type(), mc.subtype());
- MutableManagedComponent comp = new ManagedComponentImpl(type, md, mo);
-
- if(mo.getTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName()) == null)
- comp = this.proxyFactory.createComponentProxy(comp);
-
- md.addComponent(mo.getName(), comp);
- log.debug("Processing ManagementComponent("+mo.getName()+"): "+comp);
- Set<ManagedComponent> typeComps = compByCompType.get(type);
- if (typeComps == null)
- {
- typeComps = new HashSet<ManagedComponent>();
- compByCompType.put(type, typeComps);
- }
- typeComps.add(comp);
- RunState state = updateRunState(mo, comp);
- }
-
// Scan for @ManagementObjectRef
for(ManagedProperty prop : mo.getProperties().values())
{
@@ -984,11 +984,6 @@
this.bootstrapManagedDeployments = bootstrapManagedDeployments;
}
- public Map<String, Set<ManagedProperty>> getUnresolvedRefs()
- {
- return unresolvedRefs;
- }
-
public ProfileService getProfileService()
{
return ps;
@@ -997,7 +992,8 @@
public void setProfileService(ProfileService ps)
{
this.ps = ps;
- log.debug("setProfileService: "+ps);
+ if(log.isTraceEnabled())
+ log.trace("setProfileService: "+ps);
}
public ManagedOperationProxyFactory getProxyFactory()
@@ -1028,7 +1024,8 @@
public void setMainDeployer(MainDeployer mainDeployer)
{
this.mainDeployer = mainDeployer;
- log.debug("setMainDeployer: "+mainDeployer);
+ if(log.isTraceEnabled())
+ log.trace("setMainDeployer: "+mainDeployer);
}
public MetaValueFactory getMetaValueFactory()
@@ -1119,12 +1116,16 @@
}
public Set<String> getMatchingDeploymentName(String regex)
- throws NoSuchDeploymentException
{
SecurityManager sm = System.getSecurityManager();
if(sm != null)
+ {
sm.checkPermission(MV_RUNTIME_PERMISSION);
-
+ }
+ if(regex == null)
+ {
+ throw new IllegalArgumentException("null regex");
+ }
Set<String> names = getDeploymentNames();
HashSet<String> matches = new HashSet<String>();
Pattern p = Pattern.compile(regex);
@@ -1132,26 +1133,36 @@
{
Matcher m = p.matcher(name);
if( m.matches() )
+ {
matches.add(name);
+ }
}
- if( matches.size() == 0 )
- {
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
- Object[] args = {regex};
- String msg = formatter.format(args);
- throw new NoSuchDeploymentException(msg);
- }
return matches;
}
+
public Set<ManagedDeployment> getMatchingDeployments(String name, NameMatcher<ManagedDeployment> matcher)
- throws NoSuchDeploymentException, Exception
{
SecurityManager sm = System.getSecurityManager();
if(sm != null)
+ {
sm.checkPermission(MV_RUNTIME_PERMISSION);
-
+ }
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null deployment name");
+ }
+ if(matcher == null)
+ {
+ throw new IllegalArgumentException("null deployment matcher");
+ }
Set<ManagedDeployment> matches = new HashSet<ManagedDeployment>();
- // TODO
+ for(ManagedDeployment deployment : this.managedDeployments.values())
+ {
+ if(matcher.matches(deployment, name))
+ {
+ matches.add(deployment);
+ }
+ }
return matches;
}
More information about the jboss-cvs-commits
mailing list