[jboss-cvs] JBossAS SVN: r59986 - in trunk/system/src/main/org/jboss: profileservice/spi and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 25 03:19:37 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-25 03:19:37 -0500 (Thu, 25 Jan 2007)
New Revision: 59986
Added:
trunk/system/src/main/org/jboss/deployers/spi/management/ComponentType.java
trunk/system/src/main/org/jboss/deployers/spi/management/ManagedComponent.java
trunk/system/src/main/org/jboss/deployers/spi/management/ManagedDeployment.java
Modified:
trunk/system/src/main/org/jboss/deployers/spi/management/DeploymentTemplate.java
trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
Log:
Update the profile service for the ManagedDeployment/ManagedComponent changes
Added: trunk/system/src/main/org/jboss/deployers/spi/management/ComponentType.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ComponentType.java (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ComponentType.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -0,0 +1,117 @@
+/*
+ * 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.deployers.spi.management;
+
+import java.io.Serializable;
+
+/**
+ * A simple type/subtype key for a ManagedComponent. Example
+ * type/subtypes include: DataSource/{XA,LocalTx,NoTX},
+ * JMSDestination/{Queue,Topic},
+ * EJB/{StatelessSession,StatefulSession,Entity,MDB},
+ * MBean/{Standard,XMBean,Dynamic},
+ * ...
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ComponentType
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+ private String type;
+ private String subtype;
+
+ public String getType()
+ {
+ return type;
+ }
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String getSubtype()
+ {
+ return subtype;
+ }
+ public void setSubtype(String subtype)
+ {
+ this.subtype = subtype;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hashCode = 1;
+ if( type != null )
+ hashCode += type.hashCode();
+ if( subtype != null )
+ hashCode += subtype.hashCode();
+ return hashCode;
+ }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if( this == obj )
+ return true;
+ if( obj instanceof ComponentType )
+ return false;
+
+ boolean equals = false;
+ final ComponentType other = (ComponentType) obj;
+ // type
+ if( type != null )
+ {
+ equals = type.equals(other.getType());
+ }
+ else
+ {
+ equals = type == other.getType();
+ }
+ // subtype
+ if( equals )
+ {
+ if( subtype != null )
+ {
+ equals = subtype.equals(other.getSubtype());
+ }
+ else
+ {
+ equals = subtype == other.getSubtype();
+ }
+ }
+ return equals;
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder("ComponentType");
+ tmp.append('{');
+ tmp.append("type=");
+ tmp.append(type);
+ tmp.append(", subtype=");
+ tmp.append(subtype);
+ tmp.append('}');
+ return tmp.toString();
+ }
+}
Property changes on: trunk/system/src/main/org/jboss/deployers/spi/management/ComponentType.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/DeploymentTemplate.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/DeploymentTemplate.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/DeploymentTemplate.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -22,6 +22,7 @@
package org.jboss.deployers.spi.management;
+import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.virtual.VirtualFile;
/**
@@ -36,7 +37,35 @@
*/
public interface DeploymentTemplate
{
+ /**
+ * Get the exportable representation of the properties that the
+ * template supports.
+ * @return the external representation of the template properties.
+ */
public DeploymentTemplateInfo getInfo();
- VirtualFile applyTemplate(VirtualFile root, String deploymentBaseName, DeploymentTemplateInfo values)
+
+ /**
+ * Create a deployment virtual that can be added to a profile.
+ *
+ * @param root - the parent directory where the deployment can be created.
+ * @param deploymentBaseName - a base name (without any suffix) to use for
+ * any deployment files.
+ * @param values - the template ManagedProperty values.
+ * @return the virtual file for the template deployment.
+ * @throws Exception - thrown on any failure to create the deployment
+ */
+ public VirtualFile applyTemplate(VirtualFile root, String deploymentBaseName,
+ DeploymentTemplateInfo values)
throws Exception;
+
+ /**
+ * Update the DeploymentContext with any attachments needed by the
+ * ManagedProperty instance found in values.
+ * @param ctx - the DeploymentContext created from the applyTemplate result.
+ * @param values - the template ManagedProperty values.
+ * @throws Exception
+ */
+ public void updateTemplateDeployment(DeploymentContext ctx,
+ DeploymentTemplateInfo values)
+ throws Exception;
}
Added: trunk/system/src/main/org/jboss/deployers/spi/management/ManagedComponent.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ManagedComponent.java (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ManagedComponent.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -0,0 +1,73 @@
+/*
+ * 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.deployers.spi.management;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.ManagedProperty;
+
+/**
+ * A runtime component associated with a deployment.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ManagedComponent
+{
+ /**
+ * The component name, typically only unique within the ManagedDeployment
+ * @return omponent name
+ */
+ public String getName();
+ /**
+ * The component classification as a type/subtype.
+ * @return component type.
+ */
+ public ComponentType getType();
+ /**
+ * Get the managed property names
+ *
+ * @return the property names
+ */
+ public Set<String> getPropertyNames();
+ /**
+ * Get a property
+ *
+ * @param name the name
+ * @return the property
+ */
+ public ManagedProperty getProperty(String name);
+
+ /**
+ * Get the properties
+ *
+ * @return the properties
+ */
+ public Map<String, ManagedProperty> getProperties();
+
+ /**
+ * The deployment the component is associated with.
+ * @return component deployment.
+ */
+ public ManagedDeployment getDeployment();
+}
Property changes on: trunk/system/src/main/org/jboss/deployers/spi/management/ManagedComponent.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: trunk/system/src/main/org/jboss/deployers/spi/management/ManagedDeployment.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ManagedDeployment.java (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ManagedDeployment.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -0,0 +1,113 @@
+/*
+ * 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.deployers.spi.management;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.Profile.DeploymentPhase;
+
+/**
+ * A collection of ManagedComponent and structural information
+ * about a deployment.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ManagedDeployment
+{
+ public String getName();
+ public DeploymentPhase getDeploymentPhase();
+ /**
+ * Get the deployment/module types.
+ * @return deployment types
+ */
+ public Set<String> getTypes();
+ /**
+ * Get the managed property names
+ *
+ * @return the property names
+ */
+ public Set<String> getPropertyNames();
+ /**
+ * Get a property
+ *
+ * @param name the name
+ * @return the property
+ */
+ public ManagedProperty getProperty(String name);
+
+ /**
+ * Get the properties
+ *
+ * @return the properties
+ */
+ public Map<String, ManagedProperty> getProperties();
+
+ /**
+ *
+ * @return
+ */
+ public ManagedDeployment getParent();
+
+ /**
+ * Get the ManagedComponents for the deployment module.
+ * @return ManagedComponents for the deployment module.
+ */
+ public List<ManagedComponent> getComponents();
+ /**
+ * Get the nested deployment modules.
+ * @return nested deployment modules.
+ */
+ public List<ManagedDeployment> getChildren();
+
+ /**
+ * Get the DeploymentTemplate names for components
+ * that can be added to this deployment.
+ * @return
+ */
+ public Set<String> getComponentTemplateNames();
+ public DeploymentTemplateInfo getTemplate(String name);
+ /**
+ * Add a component to this deployment
+ * @param info
+ * @return
+ */
+ public ManagedComponent addComponent(DeploymentTemplateInfo info);
+ public void removeComponent(ManagedComponent mc);
+
+ /**
+ * Get the DeploymentTemplate names for deployments
+ * that can be added to this deployment.
+ * @return
+ */
+ public Set<String> getDeploymentTemplateNames();
+ /**
+ * Add a deployment
+ * @param deplymentBaseName
+ * @param info
+ * @return
+ */
+ public ManagedDeployment addModule(String deplymentBaseName, DeploymentTemplateInfo info);
+}
Property changes on: trunk/system/src/main/org/jboss/deployers/spi/management/ManagedDeployment.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -22,9 +22,6 @@
package org.jboss.deployers.spi.management;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import org.jboss.managed.api.ManagedObject;
@@ -45,11 +42,20 @@
public interface ManagementView
{
/**
+ * 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;
+
+ /**
* 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();
/**
* Get the names of the deployment in the profile that have the
@@ -57,8 +63,7 @@
* @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);
/**
* Search for a deployment matching the regex expression.
@@ -67,28 +72,37 @@
* @throws NoSuchProfileException if key is not valie
* @throws NoSuchDeploymentException if no matches are found
*/
- public Set<String> getMatchingDeploymentName(ProfileKey key, String regex)
- throws NoSuchProfileException, NoSuchDeploymentException;
+ public Set<String> getMatchingDeploymentName(String regex)
+ throws NoSuchDeploymentException;
/**
- * Obtain the top-level management view for a deployment. This is
- * done by identifying all DeploymentBeans annotated with
- * @link{org.jboss.annotation.management.ManagedObject}
*
- * @param key - the profile containing the deployment
- * @param deploymentName - the name of deployment
- * @param phase - the phase of the deployment as it relates to when the
- * deployment is loaded
- * @return the root management view
- * @throws NoSuchProfileException
- * @throws NoSuchDeploymentException
+ * @param key
+ * @param name
+ * @return
*/
- public Graph<Map<String, ManagedObject>> getView(ProfileKey key, String deploymentName, DeploymentPhase phase)
- throws NoSuchProfileException, NoSuchDeploymentException, Exception;
- public void setView(ProfileKey key, String deploymentName, HashMap<String, ManagedProperty> view)
- throws NoSuchProfileException, IOException;
+ public ManagedDeployment getDeployment(String name, DeploymentPhase phase)
+ throws NoSuchDeploymentException, Exception;
/**
+ * Get the deployments of a type.
+ * @param type - the deployment or module type.
+ * @return the possibly empty set of deployment with the given type.
+ * @throws Exception
+ */
+ public Set<ManagedDeployment> getDeploymentsForType(String type)
+ throws Exception;
+
+ /**
+ * Get the components of a type. The
+ * @param type - the component type.
+ * @return the possibly empty set of components with the given type.
+ * @throws Exception
+ */
+ public Set<ManagedComponent> getComponentsForType(ComponentType type)
+ throws Exception;
+
+ /**
* Get the registered DeploymentTemplate names.
*
* TODO: probably needs a Map<String, DeploymentType> notion
@@ -103,7 +117,8 @@
* @return the named DeploymentTemplate
* @throws NoSuchDeploymentException - if there is no such template
*/
- public DeploymentTemplateInfo getTemplate(String name) throws NoSuchDeploymentException;
+ public DeploymentTemplateInfo getTemplate(String name)
+ throws NoSuchDeploymentException;
/**
*
@@ -113,7 +128,7 @@
* @param info
* @throws Exception
*/
- public void applyTemplate(ProfileKey key, DeploymentPhase phase,
+ public void applyTemplate(DeploymentPhase phase,
String deploymentBaseName, DeploymentTemplateInfo info)
throws Exception;
@@ -124,6 +139,13 @@
* @throws NoSuchProfileException
* @throws NoSuchDeploymentException
*/
- public void removeDeployment(ProfileKey key, String deploymentName, DeploymentPhase phase)
- throws NoSuchProfileException, NoSuchDeploymentException, Exception;
+ public void removeDeployment(String deploymentName, DeploymentPhase phase)
+ throws NoSuchDeploymentException, Exception;
+
+ /**
+ * Process the changes made to the profile.
+ *
+ * @throws Exception
+ */
+ public void process() throws Exception;
}
Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -28,6 +28,7 @@
import java.util.zip.ZipInputStream;
import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.management.ComponentType;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.profileservice.spi.Profile.DeploymentPhase;
@@ -50,7 +51,6 @@
public Set<String> getDeploymentNames(DeploymentPhase phase);
public Set<String> getDeploymentNamesForType(String type);
-
// Upload a raw deployment
public void addDeploymentContent(String name, ZipInputStream contentIS, DeploymentPhase phase)
throws IOException;
Modified: trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/Profile.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/profileservice/spi/Profile.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -123,7 +123,7 @@
*
* @param name - the deployment name
* @param phase - the phase of the deployment as it relates to when the
- * deployment is loaded
+ * deployment is loaded. If null, then all phases are queried.
* @return the named bootstrap
* @throws NoSuchDeploymentException - if there is no such bootstrap
*/
Modified: trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -133,18 +133,33 @@
throws NoSuchDeploymentException
{
DeploymentContext ctx = null;
- switch( phase )
+ if( phase == null )
{
- case BOOTSTRAP:
- ctx = this.getBootstrap(name);
- break;
- case DEPLOYER:
+ // Try all phases
+ ctx = this.getBootstrap(name);
+ if( ctx == null )
ctx = this.getDeployer(name);
- break;
- case APPLICATION:
+ if( ctx == null )
ctx = this.getApplication(name);
- break;
}
+ else
+ {
+ switch( phase )
+ {
+ case BOOTSTRAP:
+ ctx = this.getBootstrap(name);
+ break;
+ case DEPLOYER:
+ ctx = this.getDeployer(name);
+ break;
+ case APPLICATION:
+ ctx = this.getApplication(name);
+ break;
+ }
+ }
+ // Make sure we don't return null
+ if( ctx == null )
+ throw new NoSuchDeploymentException("name="+name+", phase="+phase);
return ctx;
}
@@ -249,7 +264,7 @@
return bootstraps.remove(name);
}
- protected DeploymentContext getBootstrap(String name) throws NoSuchDeploymentException
+ protected DeploymentContext getBootstrap(String name)
{
DeploymentContext deployment = bootstraps.get(name);
return deployment;
@@ -270,7 +285,7 @@
return deployers.remove(name);
}
- protected DeploymentContext getDeployer(String name) throws NoSuchDeploymentException
+ protected DeploymentContext getDeployer(String name)
{
DeploymentContext deployment = deployers.get(name);
return deployment;
@@ -292,7 +307,6 @@
}
protected DeploymentContext getApplication(String name)
- throws NoSuchDeploymentException
{
DeploymentContext deployment = applications.get(name);
return deployment;
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -22,7 +22,6 @@
package org.jboss.system.server.profile.repository;
import java.net.URI;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -31,7 +30,6 @@
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.Profile.DeploymentPhase;
import org.jboss.util.JBossObject;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2007-01-25 06:29:11 UTC (rev 59985)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2007-01-25 08:19:37 UTC (rev 59986)
@@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -40,6 +41,7 @@
import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.management.ComponentType;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.AttachmentsSerializer;
@@ -201,18 +203,19 @@
throws Exception
{
switch( phase )
- {
- case BOOTSTRAP:
- this.addBootstrap(vfsPath, d);
- break;
- case DEPLOYER:
- this.addDeployer(vfsPath, d);
- break;
- case APPLICATION:
- this.addApplication(vfsPath, d);
- break;
- }
+ {
+ case BOOTSTRAP:
+ this.addBootstrap(vfsPath, d);
+ break;
+ case DEPLOYER:
+ this.addDeployer(vfsPath, d);
+ break;
+ case APPLICATION:
+ this.addApplication(vfsPath, d);
+ break;
+ }
}
+
public void updateDeployment(String vfsPath, DeploymentContext d, DeploymentPhase phase)
throws Exception
{
@@ -227,27 +230,61 @@
{
log.warn("Failed to save attachments for: "+d.getName()+", "+e);
}
+
}
public DeploymentContext getDeployment(String name, DeploymentPhase phase)
throws Exception, NoSuchDeploymentException
{
DeploymentContext ctx = null;
- switch( phase )
+ if( phase == null )
{
- case BOOTSTRAP:
+ // Try all phases
+ try
+ {
ctx = this.getBootstrap(name);
- break;
- case DEPLOYER:
- ctx = this.getDeployer(name);
- break;
- case APPLICATION:
- ctx = this.getApplication(name);
- break;
+ }
+ catch(NoSuchDeploymentException ignore)
+ {
+ }
+ try
+ {
+ if( ctx == null )
+ ctx = this.getDeployer(name);
+ }
+ catch(NoSuchDeploymentException ignore)
+ {
+ }
+ try
+ {
+ if( ctx == null )
+ ctx = this.getApplication(name);
+ }
+ catch(NoSuchDeploymentException ignore)
+ {
+ }
}
- if( ctx != null )
- loadAttachments(ctx);
+ else
+ {
+ switch( phase )
+ {
+ case BOOTSTRAP:
+ ctx = this.getBootstrap(name);
+ break;
+ case DEPLOYER:
+ ctx = this.getDeployer(name);
+ break;
+ case APPLICATION:
+ ctx = this.getApplication(name);
+ break;
+ }
+ }
+ // Make sure we don't return null
+ if( ctx == null )
+ throw new NoSuchDeploymentException("name="+name+", phase="+phase);
+ loadAttachments(ctx);
return ctx;
}
+
public Collection<DeploymentContext> getDeployments()
{
HashSet<DeploymentContext> deployments = new HashSet<DeploymentContext>();
@@ -274,6 +311,7 @@
}
return ctxs;
}
+
public DeploymentContext removeDeployment(String name, DeploymentPhase phase)
throws Exception
{
@@ -540,7 +578,7 @@
File deploymentFile = new File(applicationDir, vfsPath);
if( Files.delete(deploymentFile) == false )
throw new IOException("Failed to delete: "+deploymentFile);
- return this.removeApplication(vfsPath);
+ return this.applicationCtxs.remove(vfsPath);
}
protected void setBootstrapURI(URI uri)
{
@@ -565,16 +603,26 @@
private void loadAttachments(DeploymentContext ctx)
throws Exception
{
- Map<String, Object> map = serializer.loadAttachments(ctx);
- if( map != null )
+ ClassLoader prevTCL = Thread.currentThread().getContextClassLoader();
+ try
{
- for(String key : map.keySet())
+ ClassLoader loader = ctx.getClassLoader();
+ if( loader != null )
+ Thread.currentThread().setContextClassLoader(loader);
+ Map<String, Object> map = serializer.loadAttachments(ctx);
+ if( map != null )
{
- Object value = map.get(key);
- ctx.getTransientAttachments().addAttachment(key, value);
+ for(String key : map.keySet())
+ {
+ Object value = map.get(key);
+ ctx.getTransientAttachments().addAttachment(key, value);
+ }
}
}
-
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(prevTCL);
+ }
}
/**
More information about the jboss-cvs-commits
mailing list