[jboss-cvs] JBossAS SVN: r59988 - in trunk/profileservice/src: main/org/jboss/profileservice/management/templates and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 25 03:22:07 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-25 03:22:07 -0500 (Thu, 25 Jan 2007)
New Revision: 59988
Added:
trunk/profileservice/src/main/org/jboss/profileservice/management/BaseManagedObject.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedDeploymentImpl.java
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/FakeDsXmlDataSourceTemplate.java
trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/DataSourceDeployment.java
trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/FakeDataSourceDeployer.java
trunk/profileservice/src/resources/profileservice-beans.xml
Log:
Update the profile service for the ManagedDeployment/ManagedComponent changes
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/BaseManagedObject.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/BaseManagedObject.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/BaseManagedObject.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -0,0 +1,70 @@
+package org.jboss.profileservice.management;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.ManagedProperty;
+
+public class BaseManagedObject
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+ private String name;
+ private Map<String, ManagedProperty> properties;
+
+ public BaseManagedObject(String name, Map<String, ManagedProperty> properties)
+ {
+ this.name = name;
+ this.properties = properties;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the managed property names
+ *
+ * @return the property names
+ */
+ public Set<String> getPropertyNames()
+ {
+ return properties.keySet();
+ }
+
+ /**
+ * Get a property
+ *
+ * @param name the name
+ * @return the property
+ */
+ public ManagedProperty getProperty(String name)
+ {
+ ManagedProperty prop = properties.get(name);
+ return prop;
+ }
+
+ /**
+ * Get the properties
+ *
+ * @return the properties
+ */
+ public Map<String, ManagedProperty> getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Append the name and props
+ * @param sb the buffer to append the name and props to
+ */
+ protected void toString(StringBuilder sb)
+ {
+ sb.append("name=");
+ sb.append(name);
+ sb.append(", properties=");
+ sb.append(properties);
+ }
+}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/BaseManagedObject.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentImpl.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentImpl.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -0,0 +1,74 @@
+/*
+ * 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.io.Serializable;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.ComponentType;
+import org.jboss.deployers.spi.management.ManagedComponent;
+import org.jboss.deployers.spi.management.ManagedDeployment;
+import org.jboss.managed.api.ManagedProperty;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ManagedComponentImpl extends BaseManagedObject
+ implements ManagedComponent, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ private ManagedDeployment owner;
+ private ComponentType type;
+
+ ManagedComponentImpl(String name, ComponentType type, Map<String, ManagedProperty> properties, ManagedDeployment owner)
+ {
+ super(name, properties);
+ this.type = type;
+ this.owner = owner;
+ }
+
+ public ManagedDeployment getDeployment()
+ {
+ return owner;
+ }
+
+ public ComponentType getType()
+ {
+ return type;
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder(super.toString());
+ tmp.append('{');
+ super.toString(tmp);
+ tmp.append(", type=");
+ tmp.append(type);
+ tmp.append(", owner=ManagedDeployment@");
+ tmp.append(System.identityHashCode(owner));
+ tmp.append('}');
+ return tmp.toString();
+ }
+}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedDeploymentImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedDeploymentImpl.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedDeploymentImpl.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -0,0 +1,149 @@
+/*
+ * 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.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.spi.management.ManagedComponent;
+import org.jboss.deployers.spi.management.ManagedDeployment;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.Profile.DeploymentPhase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ManagedDeploymentImpl extends BaseManagedObject
+ implements ManagedDeployment, Serializable
+{
+ private static final long serialVersionUID = 1;
+ private Set<String> types;
+ private DeploymentPhase phase;
+ private ManagedDeployment parent;
+ private ArrayList<ManagedComponent> components = new ArrayList<ManagedComponent>();
+ private ArrayList<ManagedDeployment> children = new ArrayList<ManagedDeployment>();
+
+ ManagedDeploymentImpl(ManagementViewImpl mgtView, DeploymentContext ctx,
+ Map<String, ManagedProperty> properties)
+ {
+ this(mgtView, ctx, properties, null);
+ }
+ ManagedDeploymentImpl(ManagementViewImpl mgtView, DeploymentContext ctx,
+ Map<String, ManagedProperty> properties, ManagedDeployment parent)
+ {
+ super(ctx.getSimpleName(), properties);
+ this.types = ctx.getTypes();
+ this.phase = ctx.getTransientManagedObjects().getAttachment(DeploymentPhase.class);
+ this.parent = parent;
+ }
+
+ public Set<String> getTypes()
+ {
+ return types;
+ }
+
+ public DeploymentPhase getDeploymentPhase()
+ {
+ return phase;
+ }
+ public ManagedDeployment getParent()
+ {
+ return parent;
+ }
+
+ public Set<String> getComponentTemplateNames()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public DeploymentTemplateInfo getTemplate(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public ManagedComponent addComponent(DeploymentTemplateInfo info)
+ {
+
+ return null;
+ }
+
+ public List<ManagedComponent> getComponents()
+ {
+ return components;
+ }
+
+ public void removeComponent(ManagedComponent mc)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Set<String> getDeploymentTemplateNames()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public List<ManagedDeployment> getChildren()
+ {
+ return children;
+ }
+
+ public ManagedDeployment addModule(String deplymentBaseName, DeploymentTemplateInfo info)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder(super.toString());
+ tmp.append('{');
+ super.toString(tmp);
+ tmp.append(", types=");
+ tmp.append(types);
+ tmp.append(", phase=");
+ tmp.append(phase);
+ tmp.append(", parent=");
+ if( parent != null )
+ {
+ tmp.append("ManagedDeployment@");
+ tmp.append(System.identityHashCode(parent));
+ }
+ else
+ {
+ tmp.append("null");
+ }
+ tmp.append(", components=");
+ tmp.append(components);
+ tmp.append(", children=");
+ tmp.append(children);
+ tmp.append('}');
+ return tmp.toString();
+ }
+
+}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedDeploymentImpl.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-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -1,33 +1,32 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.
- */
-
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.io.IOException;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
@@ -40,10 +39,12 @@
import org.jboss.deployers.spi.IncompleteDeploymentException;
import org.jboss.deployers.spi.IncompleteDeployments;
import org.jboss.deployers.spi.IncompleteDeploymentsBuilder;
-import org.jboss.deployers.spi.deployer.Deployer;
import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.management.ComponentType;
import org.jboss.deployers.spi.management.DeploymentTemplate;
import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.spi.management.ManagedComponent;
+import org.jboss.deployers.spi.management.ManagedDeployment;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.logging.Logger;
@@ -55,7 +56,6 @@
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.profileservice.spi.Profile.DeploymentPhase;
-import org.jboss.util.graph.Graph;
import org.jboss.virtual.VirtualFile;
/**
@@ -70,6 +70,8 @@
/** */
private ProfileService ps;
+ /** The currently loaded profile */
+ private Profile activeProfile;
/** */
private MainDeployer mainDeployer;
/** */
@@ -80,6 +82,9 @@
private Locale currentLocale;
/** */
private MessageFormat formatter = new MessageFormat("");
+ /** An index of ManagedComponent by ComponentType */
+ private HashMap<ComponentType, Set<ManagedComponent>> ctxsByCompType =
+ new HashMap<ComponentType, Set<ManagedComponent>>();
public ManagementViewImpl()
{
@@ -88,6 +93,26 @@
i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
}
+ /**
+ * Load and associate the given profile with the ManagementView
+ * for future operations.
+ *
+ * @param key - the profile to load
+ * @throws NoSuchProfileException
+ */
+ public void loadProfile(ProfileKey key)
+ throws NoSuchProfileException
+ {
+ activeProfile = ps.getProfile(key);
+ if( activeProfile == null )
+ {
+ formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
+ Object[] args = {key};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+ }
+
public ProfileService getProfileService()
{
return ps;
@@ -112,18 +137,9 @@
* Get the names of the deployment in the profile.
* @param key - the profile containing the deployment
*/
- public Set<String> getDeploymentNames(ProfileKey key)
- throws NoSuchProfileException
+ public Set<String> getDeploymentNames()
{
- Profile profile = ps.getProfile(key);
- if( profile == null )
- {
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
- Set<String> names = profile.getDeploymentNames();
+ Set<String> names = activeProfile.getDeploymentNames();
return names;
}
@@ -133,25 +149,16 @@
* @param key - the profile containing the deployment
* @param type - the deployment type
*/
- public Set<String> getDeploymentNamesForType(ProfileKey key, String type)
- throws NoSuchProfileException
+ public Set<String> getDeploymentNamesForType(String type)
{
- Profile profile = ps.getProfile(key);
- if( profile == null )
- {
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
- Set<String> names = profile.getDeploymentNamesForType(type);
+ Set<String> names = activeProfile.getDeploymentNamesForType(type);
return names;
}
- public Set<String> getMatchingDeploymentName(ProfileKey key, String regex)
- throws NoSuchProfileException, NoSuchDeploymentException
+ public Set<String> getMatchingDeploymentName(String regex)
+ throws NoSuchDeploymentException
{
- Set<String> names = getDeploymentNames(key);
+ Set<String> names = getDeploymentNames();
HashSet<String> matches = new HashSet<String>();
Pattern p = Pattern.compile(regex);
for(String name : names)
@@ -186,27 +193,60 @@
log.debug("removeTemplate: "+template);
}
- public Graph<Map<String, ManagedObject>> getView(ProfileKey key, String deploymentName, DeploymentPhase phase)
- throws NoSuchProfileException, NoSuchDeploymentException, Exception
+ /**
+ *
+ * @param key
+ * @param name
+ * @return
+ */
+ public ManagedDeployment getDeployment(String name, DeploymentPhase phase)
+ throws NoSuchDeploymentException, Exception
{
- Profile profile = ps.getProfile(key);
- if( profile == null )
+ DeploymentContext ctx = activeProfile.getDeployment(name, phase);
+ ManagedDeployment md = getManagedDeployment(ctx);
+ log.debug("getDeployment, name="+name+", md="+md);
+ return md;
+ }
+
+ /**
+ *
+ * @param key
+ * @param type
+ * @return
+ * @throws NoSuchProfileException
+ */
+ public Set<ManagedDeployment> getDeploymentsForType(String type)
+ throws Exception
+ {
+ Set<String> names = getDeploymentNamesForType(type);
+ HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
+ for(String name : names)
{
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
+ DeploymentContext ctx = activeProfile.getDeployment(name, null);
+ ManagedDeployment md = getManagedDeployment(ctx);
+ mds.add(md);
}
- DeploymentContext d = profile.getDeployment(deploymentName, phase);
- Graph<Map<String, ManagedObject>> view = mainDeployer.getManagedObjects(deploymentName);
- if( log.isTraceEnabled() )
- log.trace("getView, key="+key+", deploymentName="+deploymentName+", phase="+phase+", :"+view);
- return view;
+ return mds;
}
- public void setView(ProfileKey key, String deploymentName, HashMap<String, ManagedProperty> view)
- throws NoSuchProfileException, IOException
+ /**
+ *
+ * @param key
+ * @param type
+ * @return
+ * @throws NoSuchProfileException
+ */
+ public Set<ManagedComponent> getComponentsForType(ComponentType type)
+ throws Exception
{
+ if( ctxsByCompType.size() == 0 )
+ {
+ // index the component types
+ indexComponents();
+ }
+
+ Set<ManagedComponent> mcs = ctxsByCompType.get(type);
+ return mcs;
}
public DeploymentTemplateInfo getTemplate(String name)
@@ -226,7 +266,7 @@
return info;
}
- public void applyTemplate(ProfileKey key, DeploymentPhase phase,
+ public void applyTemplate(DeploymentPhase phase,
String deploymentBaseName, DeploymentTemplateInfo info)
throws Exception
{
@@ -239,35 +279,19 @@
throw new IllegalStateException(msg);
}
- Profile profile = ps.getProfile(key);
- if( profile == null )
- {
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
-
// Create a deployment base from the template
- VirtualFile root = profile.getRootFile(phase);
+ VirtualFile root = activeProfile.getRootFile(phase);
if( log.isTraceEnabled() )
- log.trace("applyTemplate, key="+key+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", info="+info);
- VirtualFile deployment = template.applyTemplate(root, deploymentBaseName, info);
- AbstractDeploymentContext ctx = new AbstractDeploymentContext(deployment);
- profile.addDeployment(ctx, phase);
-
- // Process the base deployment
+ log.trace("applyTemplate, profile="+activeProfile+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", info="+info);
+ VirtualFile vf = template.applyTemplate(root, deploymentBaseName, info);
+ AbstractDeploymentContext ctx = new AbstractDeploymentContext(vf);
+ activeProfile.addDeployment(ctx, phase);
mainDeployer.addDeploymentContext(ctx);
- Collection<DeploymentContext> ctxs = mainDeployer.process(-1, Deployer.CLASSLOADER_DEPLOYER);
- checkIncomplete();
- for (DeploymentContext d : ctxs)
- {
- profile.updateDeployment(d, phase);
- }
+ template.updateTemplateDeployment(ctx, info);
// Apply the managed properties
Map<String, ManagedObject> mos = mainDeployer.getManagedObjects(ctx);
- log.debug("applyTemplate, key="+key+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", :"+mos);
+ log.debug("applyTemplate, profile="+activeProfile+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", :"+mos);
for(ManagedProperty prop : info.getProperties().values())
{
// Skip null values
@@ -301,25 +325,12 @@
ctxProp.setValue((Serializable)prop.getValue());
}
log.info("Updated mo: "+mos);
-
- // Process the updated deployment
- // TODO this is a complete reparse because of deployments like datasource that update a parser input
- mainDeployer.process(Deployer.CLASSLOADER_DEPLOYER, Integer.MAX_VALUE);
- checkIncomplete();
}
- public void removeDeployment(ProfileKey key, String deploymentName, DeploymentPhase phase)
+ public void removeDeployment(String deploymentName, DeploymentPhase phase)
throws NoSuchProfileException, NoSuchDeploymentException, Exception
{
- Profile profile = ps.getProfile(key);
- if( profile == null )
- {
- formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
- Object[] args = {key};
- String msg = formatter.format(args);
- throw new NoSuchProfileException(msg);
- }
- DeploymentContext ctx = profile.removeDeployment(deploymentName, phase);
+ DeploymentContext ctx = activeProfile.removeDeployment(deploymentName, phase);
if( ctx == null )
{
formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
@@ -328,12 +339,95 @@
throw new NoSuchDeploymentException(msg);
}
mainDeployer.removeDeploymentContext(deploymentName);
+ }
+
+ /**
+ * Process the changes made to the profile.
+ *
+ * @throws Exception
+ */
+ public void process() throws Exception
+ {
mainDeployer.process();
- checkIncomplete();
+ checkIncomplete();
}
/**
- * Check whether we are incomplete
+ * Go through the profile deployments and build ManagedDeployments
+ * @throws Exception
+ */
+ private void indexComponents()
+ throws Exception
+ {
+ Collection<DeploymentContext> ctxs = activeProfile.getDeployments();
+ for(DeploymentContext ctx : ctxs)
+ {
+ ManagedDeployment md = getManagedDeployment(ctx);
+ indexComponents(md);
+ }
+ }
+
+ private void indexComponents(ManagedDeployment md)
+ {
+ List<ManagedComponent> mcs = md.getComponents();
+ for(ManagedComponent mc : mcs)
+ {
+ ComponentType type = mc.getType();
+ Set<ManagedComponent> mcsForType = ctxsByCompType.get(type);
+ if( mcsForType == null )
+ {
+ mcsForType = new HashSet<ManagedComponent>();
+ ctxsByCompType.put(type, mcsForType);
+ }
+ mcsForType.add(mc);
+ }
+ //
+ List<ManagedDeployment> children = md.getChildren();
+ for(ManagedDeployment child : children)
+ {
+ indexComponents(child);
+ }
+ }
+
+ private ManagedDeployment getManagedDeployment(DeploymentContext ctx)
+ throws Exception
+ {
+ Map<String, ManagedObject> mdMOs = mainDeployer.getManagedObjects(ctx);
+ Map<String, ManagedProperty> mdProps = getProperties(mdMOs);
+ ManagedDeploymentImpl md = new ManagedDeploymentImpl(this, ctx, mdProps);
+ Set<DeploymentContext> children = ctx.getChildren();
+ for(DeploymentContext child : children)
+ {
+ Map<String, ManagedObject> childMOs = mainDeployer.getManagedObjects(ctx);
+ Map<String, ManagedProperty> childProps = getProperties(childMOs);
+ ManagedDeploymentImpl childMD = new ManagedDeploymentImpl(this, child, childProps, md);
+ md.getChildren().add(childMD);
+ }
+ 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;
+ }
+
+ private Map<String, ManagedProperty> getProperties(Map<String, ManagedObject> mos)
+ {
+ HashMap<String, ManagedProperty> props = new HashMap<String, ManagedProperty>();
+ for(ManagedObject mo : mos.values())
+ {
+ Set<ManagedProperty> moProps = mo.getProperties();
+ for(ManagedProperty prop : moProps)
+ props.put(prop.getName(), prop);
+ }
+ return props;
+ }
+
+ /**
+ * Check whether the deployment processing was complete
*
* @throws DeploymentException the deployment exception
*/
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java 2007-01-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -27,6 +27,7 @@
import org.jboss.deployers.spi.management.DeploymentTemplate;
import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.virtual.VirtualFile;
/**
@@ -54,6 +55,12 @@
VirtualFile dsXmlVF = root.findChild(dsName);
return dsXmlVF;
}
+ public void updateTemplateDeployment(DeploymentContext ctx,
+ DeploymentTemplateInfo values)
+ throws Exception
+ {
+
+ }
public DeploymentTemplateInfo getInfo()
{
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/FakeDsXmlDataSourceTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/FakeDsXmlDataSourceTemplate.java 2007-01-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/FakeDsXmlDataSourceTemplate.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -24,9 +24,17 @@
import java.io.File;
import java.io.FileWriter;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.spi.management.DeploymentTemplate;
import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.profileservice.mock.ds.DataSourceDeployment;
+import org.jboss.profileservice.mock.ds.FakeDataSourceDeployer;
+import org.jboss.system.metadata.ServiceDeployment;
+import org.jboss.system.metadata.ServiceMetaData;
import org.jboss.virtual.VirtualFile;
/**
@@ -39,7 +47,18 @@
implements DeploymentTemplate
{
private DeploymentTemplateInfo info;
+ private FakeDataSourceDeployer deployer;
+
+ public FakeDataSourceDeployer getDeployer()
+ {
+ return deployer;
+ }
+ public void setDeployer(FakeDataSourceDeployer deployer)
+ {
+ this.deployer = deployer;
+ }
+
/**
* Creates a root/{deploymentBaseName}-dsf.xml base descriptor.
*/
@@ -54,6 +73,19 @@
VirtualFile dsXmlVF = root.findChild(dsName);
return dsXmlVF;
}
+ public void updateTemplateDeployment(DeploymentContext ctx,
+ DeploymentTemplateInfo values)
+ throws Exception
+ {
+ // Add the -dsf.xml metadata
+ ServiceDeployment service = new ServiceDeployment();
+ ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+ DataSourceDeployment ds = new DataSourceDeployment();
+ ServiceMetaData dsMetaData = deployer.createDsServiceMetaData(ds);
+ services.add(dsMetaData);
+ service.setServices(services);
+ ctx.getTransientAttachments().addAttachment(ServiceDeployment.class, service);
+ }
public DeploymentTemplateInfo getInfo()
{
Modified: trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/DataSourceDeployment.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/DataSourceDeployment.java 2007-01-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/DataSourceDeployment.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -1,5 +1,6 @@
package org.jboss.profileservice.mock.ds;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -14,7 +15,10 @@
import org.w3c.dom.NodeList;
public class DataSourceDeployment
+ implements Serializable
{
+ private static final long serialVersionUID = 1;
+
private static Logger log = Logger.getLogger(DataSourceDeployment.class);
private boolean replace = true;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/FakeDataSourceDeployer.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/FakeDataSourceDeployer.java 2007-01-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/main/org/jboss/profileservice/mock/ds/FakeDataSourceDeployer.java 2007-01-25 08:22:07 UTC (rev 59988)
@@ -24,12 +24,18 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.jboss.deployers.plugins.deployers.helpers.JAXPDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.managed.ManagedObjectBuilder;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.plugins.advice.WrapperAdvice;
+import org.jboss.profileservice.management.builders.ServiceManagedObject;
import org.jboss.system.metadata.ServiceAttributeMetaData;
import org.jboss.system.metadata.ServiceConstructorMetaData;
import org.jboss.system.metadata.ServiceDependencyMetaData;
@@ -48,6 +54,7 @@
* @version $Revision:$
*/
public class FakeDataSourceDeployer extends JAXPDeployer<ServiceDeployment>
+ implements ManagedObjectBuilder
{
public FakeDataSourceDeployer()
@@ -55,6 +62,41 @@
super(ServiceDeployment.class);
}
+ private Map<String, String> propertyNameMappings;
+
+ public Map<String, String> getPropertyNameMappings()
+ {
+ return propertyNameMappings;
+ }
+
+ public void setPropertyNameMappings(Map<String, String> propertyNameMappings)
+ {
+ this.propertyNameMappings = propertyNameMappings;
+ }
+
+ public void build(DeploymentUnit unit, Map<String, ManagedObject> map)
+ throws DeploymentException
+ {
+ String name = unit.getSimpleName();
+ if(name.endsWith("-dsf.xml"))
+ {
+ Map<String, Object> attachments = unit.getAttachments();
+ log.info(name+" attachments: "+attachments);
+ ServiceDeployment service = unit.getAttachment(ServiceDeployment.class);
+ if( service == null )
+ throw new DeploymentException("Failed to find ServiceDeployment in "+unit.getName());
+ List<ServiceMetaData> services = service.getServices();
+ // TODO, can have multiple datasources in a deployment
+ if( services.size() != 1 )
+ throw new DeploymentException("Expected only 1 ServiceMetaData but saw "+services.size()+" in "+unit.getName());
+ ServiceMetaData dsMetaData = services.get(0);
+ String attachName = ServiceMetaData.class.getName();
+ ManagedObject mo = new ServiceManagedObject(attachName, dsMetaData);
+ ManagedObject wrapMO = WrapperAdvice.wrapManagedObject(mo);
+ map.put(attachName, wrapMO);
+ }
+ }
+
@Override
public void deploy(DeploymentUnit unit) throws DeploymentException
{
@@ -65,12 +107,31 @@
protected ServiceDeployment parse(DeploymentUnit unit, VirtualFile file, Document document) throws Exception
{
ServiceDeployment deployment = new ServiceDeployment();
- ServiceMetaData dsMbean = new ServiceMetaData();
DataSourceDeployment ds = new DataSourceDeployment();
ds.parse(document);
+
+ ServiceMetaData dsMbean = createDsServiceMetaData(ds);
+ ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+ services.add(dsMbean);
+ deployment.setServices(services);
+
+ return deployment;
+ }
+
+ @Override
+ protected boolean allowsReparse()
+ {
+ return true;
+ }
+
+ public ServiceMetaData createDsServiceMetaData(DataSourceDeployment ds)
+ throws Exception
+ {
+ ServiceMetaData dsMbean = new ServiceMetaData();
log.info("DataSource settings: "+ds);
- ObjectName objectName = new ObjectName("jboss.jca:type=FakeDataSourceConn,jndiName="+ds.getJndiName());
+ String jndiName = ds.getJndiName() == null ? "DefaultFakeDS" : ds.getJndiName();
+ ObjectName objectName = new ObjectName("jboss.jca:type=FakeDataSourceConn,jndiName="+jndiName);
dsMbean.setObjectName(objectName);
dsMbean.setCode(FakeDataSourceConn.class.getName());
// FakeDataSourceConn(DataSourceDeployment)
@@ -83,70 +144,53 @@
List<ServiceAttributeMetaData> attributes = new ArrayList<ServiceAttributeMetaData>();
ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
// jndiName
- if( ds.getJndiName() != null )
- {
- attribute.setName("JndiName");
- attribute.setReplace(true);
- attribute.setTrim(true);
- attribute.setValue(new ServiceTextValueMetaData(ds.getJndiName()));
- attributes.add(attribute);
- }
+ attribute.setName("JndiName");
+ attribute.setReplace(true);
+ attribute.setTrim(true);
+ attribute.setValue(new ServiceTextValueMetaData(jndiName));
+ attributes.add(attribute);
// jdbcURL
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("JdbcURL");
if( ds.getJdbcURL() != null )
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("JdbcURL");
attribute.setValue(new ServiceTextValueMetaData(ds.getJdbcURL()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// driverClass
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("DriverClass");
if(ds.getDriverClass() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("DriverClass");
attribute.setValue(new ServiceTextValueMetaData(ds.getDriverClass()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// username
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("Username");
if(ds.getUsername() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("Username");
attribute.setValue(new ServiceTextValueMetaData(ds.getUsername()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// password
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("Password");
if(ds.getPassword() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("Password");
attribute.setValue(new ServiceTextValueMetaData(ds.getPassword()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// securityDomain
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("SecurityDomain");
if(ds.getSecurityDomain() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("SecurityDomain");
attribute.setValue(new ServiceTextValueMetaData(ds.getSecurityDomain()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// minPoolSize
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("MinPoolSize");
if(ds.getMinPoolSize() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("MinPoolSize");
attribute.setValue(new ServiceTextValueMetaData(ds.getMinPoolSize()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
// maxPoolSize
+ attribute = new ServiceAttributeMetaData();
+ attribute.setName("MaxPoolSize");
if(ds.getMaxPoolSize() != null)
- {
- attribute = new ServiceAttributeMetaData();
- attribute.setName("MaxPoolSize");
attribute.setValue(new ServiceTextValueMetaData(ds.getMaxPoolSize()));
- attributes.add(attribute);
- }
+ attributes.add(attribute);
dsMbean.setAttributes(attributes);
@@ -159,17 +203,6 @@
sdmd.setIDependOn(iDependOn);
}
dsMbean.setDependencies(dependencies);
- ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
- services.add(dsMbean);
- deployment.setServices(services);
-
- return deployment;
+ return dsMbean;
}
-
- @Override
- protected boolean allowsReparse()
- {
- return true;
- }
-
}
Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml 2007-01-25 08:20:15 UTC (rev 59987)
+++ trunk/profileservice/src/resources/profileservice-beans.xml 2007-01-25 08:22:07 UTC (rev 59988)
@@ -74,6 +74,7 @@
</parameter>
</uninstall>
<property name="info"><inject bean="DsXmlDataSourceTemplateInfo"/></property>
+ <property name="deployer"><inject bean="FakeDataSourceDeployer" /></property>
</bean>
<bean name="DsXmlDataSourceTemplateInfo"
class="org.jboss.profileservice.management.templates.DsXmlDataSourceTemplateInfo">
@@ -116,24 +117,6 @@
</parameter>
</install>
</bean>
- <!-- Override the FakeDataSourceDeployer ManagedObjectBuilder -->
- <bean name="FakeConnectionFactoryDeployerManagedObjectBuilder"
- class="org.jboss.profileservice.management.builders.FakeConnectionFactoryDeployerManagedObjectBuilder">
- <install bean="MainDeployer" method="setDeployerManagedObjectBuilder">
- <parameter>
- <inject bean="FakeDataSourceDeployer" />
- </parameter>
- <parameter>
- <this/>
- </parameter>
- </install>
- <!-- Specify a mapping from service attribute names used by the datasource
- deployment ServiceMetaData to ManagedProperty names.
- -->
- <property name="propertyNameMappings">
- <inject bean="DsPropertyMappings" />
- </property>
- </bean>
<bean name="ProfileServiceProxyFactory" class="org.jboss.profileservice.remoting.ProxyFactory">
<property name="dispatchName">ProfileService</property>
More information about the jboss-cvs-commits
mailing list