[jboss-cvs] JBossAS SVN: r60097 - in trunk/profileservice/src: main/org/jboss/profileservice/remoting and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 29 00:30:13 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-29 00:30:13 -0500 (Mon, 29 Jan 2007)
New Revision: 60097
Added:
trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
trunk/profileservice/src/resources/profileservice-beans.xml
Log:
Updated the ComponentType mapping
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java 2007-01-29 05:30:13 UTC (rev 60097)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.profileservice.management;
+
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.management.ComponentType;
+import org.jboss.deployers.spi.management.ComponentTypeVisitor;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ComponentTypeOverridesVisitor
+ implements ComponentTypeVisitor
+{
+ private static Logger log = Logger.getLogger(ComponentTypeOverridesVisitor.class);
+
+ public ComponentType visit(DeploymentUnit unit)
+ {
+ ComponentType type = unit.getAttachment(ComponentType.class);
+ if( type == null )
+ {
+ type = determineComponentType(unit);
+ }
+ log.debug(unit+", type="+type);
+ return type;
+ }
+
+ protected ComponentType determineComponentType(DeploymentUnit ctx)
+ {
+ ComponentType type = checkDataSource(ctx);
+ if( type == null )
+ type = checkJmsDestination(ctx);
+ return type;
+ }
+
+ protected ComponentType checkDataSource(DeploymentUnit ctx)
+ {
+ ComponentType type = null;
+ ServiceMetaData smd = ctx.getAttachment(ServiceMetaData.class);
+ if( smd != null )
+ {
+ String code = smd.getCode();
+ if( code.indexOf("FakeDataSourceConn") > 0 )
+ type = new ComponentType("DataSource", "LocalTx");
+ }
+ return type;
+ }
+ protected ComponentType checkJmsDestination(DeploymentUnit ctx)
+ {
+ ComponentType type = null;
+ return type;
+ }
+}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2007-01-29 05:27:57 UTC (rev 60096)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2007-01-29 05:30:13 UTC (rev 60097)
@@ -39,8 +39,11 @@
import org.jboss.deployers.spi.IncompleteDeploymentException;
import org.jboss.deployers.spi.IncompleteDeployments;
import org.jboss.deployers.spi.IncompleteDeploymentsBuilder;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.deployers.spi.deployment.MainDeployer;
import org.jboss.deployers.spi.management.ComponentType;
+import org.jboss.deployers.spi.management.ComponentTypeListener;
+import org.jboss.deployers.spi.management.ComponentTypeVisitor;
import org.jboss.deployers.spi.management.DeploymentTemplate;
import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
import org.jboss.deployers.spi.management.ManagedComponent;
@@ -50,6 +53,7 @@
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.aop.DeployerAspects;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
@@ -63,7 +67,7 @@
* @version $Revision$
*/
public class ManagementViewImpl
- implements ManagementView
+ implements ManagementView, ComponentTypeListener
{
private static Logger log = Logger.getLogger(ManagementViewImpl.class);
private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
@@ -82,8 +86,11 @@
private Locale currentLocale;
/** */
private MessageFormat formatter = new MessageFormat("");
+ /** */
+ private HashMap<DeploymentContext, ComponentType> ctxToCompType =
+ new HashMap<DeploymentContext, ComponentType>();
/** An index of ManagedComponent by ComponentType */
- private HashMap<ComponentType, Set<ManagedComponent>> ctxsByCompType =
+ private HashMap<ComponentType, Set<ManagedComponent>> compByCompType =
new HashMap<ComponentType, Set<ManagedComponent>>();
public ManagementViewImpl()
@@ -133,6 +140,21 @@
log.debug("setMainDeployer: "+mainDeployer);
}
+ public ComponentTypeVisitor getCompVisitor()
+ {
+ return DeployerAspects.getCompVisitor();
+ }
+ public void setCompVisitor(ComponentTypeVisitor compVisitor)
+ {
+ DeployerAspects.setCompVisitor(compVisitor);
+ DeployerAspects.setCompListener(this);
+ }
+
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
/**
* Get the names of the deployment in the profile.
* @param key - the profile containing the deployment
@@ -239,13 +261,13 @@
public Set<ManagedComponent> getComponentsForType(ComponentType type)
throws Exception
{
- if( ctxsByCompType.size() == 0 )
+ if( compByCompType.size() == 0 )
{
// index the component types
indexComponents();
}
- Set<ManagedComponent> mcs = ctxsByCompType.get(type);
+ Set<ManagedComponent> mcs = compByCompType.get(type);
return mcs;
}
@@ -352,6 +374,12 @@
checkIncomplete();
}
+ public void updateComponentType(DeploymentUnit unit, ComponentType type)
+ {
+ DeploymentContext ctx = unit.getDeploymentContext();
+ ctxToCompType.put(ctx, type);
+ }
+
/**
* Go through the profile deployments and build ManagedDeployments
* @throws Exception
@@ -373,11 +401,11 @@
for(ManagedComponent mc : mcs)
{
ComponentType type = mc.getType();
- Set<ManagedComponent> mcsForType = ctxsByCompType.get(type);
+ Set<ManagedComponent> mcsForType = compByCompType.get(type);
if( mcsForType == null )
{
mcsForType = new HashSet<ManagedComponent>();
- ctxsByCompType.put(type, mcsForType);
+ compByCompType.put(type, mcsForType);
}
mcsForType.add(mc);
}
@@ -402,16 +430,24 @@
Map<String, ManagedProperty> childProps = getProperties(childMOs);
ManagedDeploymentImpl childMD = new ManagedDeploymentImpl(this, child, childProps, md);
md.getChildren().add(childMD);
+ getManagedComponents(child, childMD);
}
+ getManagedComponents(ctx, md);
+ return md;
+ }
+ private void getManagedComponents(DeploymentContext ctx, ManagedDeploymentImpl md)
+ throws Exception
+ {
+ // Build ManagedComponents for the md
Set<DeploymentContext> comps = ctx.getComponents();
for(DeploymentContext comp : comps)
{
Map<String, ManagedObject> compMOs = mainDeployer.getManagedObjects(comp);
- Map<String, ManagedProperty> childProps = getProperties(compMOs);
- ManagedDeploymentImpl childMD = new ManagedDeploymentImpl(this, comp, childProps, md);
- md.getChildren().add(childMD);
- }
- return md;
+ Map<String, ManagedProperty> compProps = getProperties(compMOs);
+ ComponentType type = ctxToCompType.get(comp);
+ ManagedComponentImpl mc = new ManagedComponentImpl(comp.getSimpleName(), type, compProps, md);
+ md.getComponents().add(mc);
+ }
}
private Map<String, ManagedProperty> getProperties(Map<String, ManagedObject> mos)
Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java 2007-01-29 05:27:57 UTC (rev 60096)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java 2007-01-29 05:30:13 UTC (rev 60097)
@@ -50,6 +50,7 @@
private String jndiName = "ProfileService";
private InvokerLocator locator;
private ProfileService ps;
+ private ManagementView mgtView;
private Proxy psProxy;
private Proxy mgtViewProxy;
@@ -97,6 +98,16 @@
{
return psProxy;
}
+
+ public ManagementView getViewManager()
+ {
+ return mgtView;
+ }
+ public void setViewManager(ManagementView mgtView)
+ {
+ this.mgtView = mgtView;
+ }
+
public Proxy getManagementViewProxy()
{
return mgtViewProxy;
@@ -122,10 +133,9 @@
Util.bind(ctx, jndiName, psProxy);
// Create the ManagementView proxy
- ManagementView mv = ps.getViewManager();
Class[] mvIfaces = {ManagementView.class};
String mvDispatchName = dispatchName+".ManagementView";
- Dispatcher.singleton.registerTarget(mvDispatchName, mv);
+ Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator,
interceptors, "ProfileService");
}
Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml 2007-01-29 05:27:57 UTC (rev 60096)
+++ trunk/profileservice/src/resources/profileservice-beans.xml 2007-01-29 05:30:13 UTC (rev 60097)
@@ -46,6 +46,7 @@
</uninstall>
<property name="mainDeployer"><inject bean="MainDeployer"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
+ <property name="compVisitor"><inject bean="ComponentTypeOverridesVisitor"/></property>
</bean>
<!-- ConnectionFactory Deployment -->
@@ -123,8 +124,22 @@
<property name="jndiName">ProfileService</property>
<property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
+ <property name="viewManager"><inject bean="ManagementView"/></property>
<depends>ConnectorMBean</depends>
- <depends>ManagementView</depends>
</bean>
+ <bean name="ComponentTypeOverridesVisitor"
+ class="org.jboss.profileservice.management.ComponentTypeOverridesVisitor">
+ </bean>
+ <!--
+ <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+ name="Deployers"
+ class="org.jboss.profileservice.aop.DeployerAspects"
+ classes="org.jboss.deployers.spi.deployer.Deployer"
+ manager-bean="AspectManager"
+ manager-property="aspectManager"
+ pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployer.Deployer}->prepareDeploy(..))">
+ <property name="compVisitor"><inject bean="ComponentTypeOverridesVisitor" /></property>
+ </aop:lifecycle-configure>
+ -->
</deployment>
More information about the jboss-cvs-commits
mailing list