[jboss-cvs] JBossAS SVN: r87161 - in branches/Branch_5_x: system/src/main/org/jboss/system/server/profile/repository/metadata and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 11 07:03:55 EDT 2009
Author: emuckenhuber
Date: 2009-04-11 07:03:55 -0400 (Sat, 11 Apr 2009)
New Revision: 87161
Modified:
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
Log:
cleanup
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractTemplateCreator.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -72,6 +72,9 @@
throw new IllegalArgumentException("Null deployment template.");
if(deploymentBaseName == null)
throw new IllegalArgumentException("Null deployment name.");
+ deploymentBaseName = deploymentBaseName.trim();
+ if(deploymentBaseName.length() == 0)
+ throw new IllegalArgumentException("emtpy deployment base name");
if(info == null)
throw new IllegalArgumentException("Null deployment template info.");
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -1045,6 +1045,8 @@
public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info)
throws Exception
{
+ if(deploymentBaseName == null)
+ throw new IllegalArgumentException("Null deployment base name.");
if(info == null)
throw new IllegalArgumentException("Null template info.");
@@ -1080,6 +1082,8 @@
public void updateComponent(ManagedComponent comp)
throws Exception
{
+ if(comp == null)
+ throw new IllegalArgumentException("Null managed component.");
// Find the comp deployment
ManagedDeployment md = comp.getDeployment();
@@ -1206,6 +1210,8 @@
public void removeComponent(ManagedComponent comp) throws Exception
{
+ if(comp == null)
+ throw new IllegalArgumentException("null managed component.");
//
ManagedDeployment md = comp.getDeployment();
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -56,7 +56,7 @@
/** The server. */
private String server;
- /** The doamin. */
+ /** The domain. */
private String domain;
/** The profiles. */
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/BootstrapDeployment.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -21,6 +21,9 @@
*/
package org.jboss.system.server.profileservice;
+import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
import org.jboss.deployers.spi.DeploymentState;
import org.jboss.deployers.spi.management.KnownDeploymentTypes;
import org.jboss.deployers.spi.structure.ContextInfo;
@@ -29,11 +32,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
-import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
-import org.jboss.deployers.plugins.structure.ContextInfoImpl;
-import org.jboss.deployers.plugins.structure.StructureMetaDataImpl;
import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
/**
* @author Scott.Stark at jboss.org
@@ -57,7 +56,6 @@
predeterminedManagedObjects.addAttachment(KnownDeploymentTypes.class, KnownDeploymentTypes.MCBeans);
predeterminedManagedObjects.addAttachment(StructureMetaData.class, structure);
predeterminedManagedObjects.addAttachment(KernelDeployment.class, deployment);
- predeterminedManagedObjects.addAttachment(DeploymentPhase.class, DeploymentPhase.BOOTSTRAP);
DeploymentContext rootContext = getDeploymentContext();
rootContext.setState(DeploymentState.DEPLOYED);
predeterminedManagedObjects.addAttachment(DeploymentContext.class, rootContext);
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -23,7 +23,6 @@
package org.jboss.system.server.profileservice;
import java.net.URI;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -46,14 +45,6 @@
*/
public class StaticClusteredProfileFactory extends StaticProfileFactory
{
- /** The bootstrap profile name. */
- private static final String BOOTSTRAP_NAME = "bootstrap";
-
- /** The deployers profile name. */
- private static final String DEPLOYERS_NAME = "deployers";
-
- /** The deployers profile name. */
- private static final String APPLICATIONS_NAME = "applications";
/** The deploy-hasingleton profile name. */
private static final String HASINGLETON_NAME = "deploy-hasingleton";
@@ -112,56 +103,30 @@
// }
// }
// }
-
+
/**
- * Create the legacy profiles, based on the injected uris.
+ * Create the cluster profiles, including the application profile from the
+ * StaticProfileFactory.
*
- * @param rootKey the key for the root profile.
- * @throws Exception
*/
@Override
- protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
- {
- if(rootKey == null)
- throw new IllegalArgumentException("Null root profile key.");
+ protected String[] createApplicationProfiles(String[] applicationsSubProfiles)
+ {
+ // Create the application profile
+ String applicationProfileName = super.createApplicationProfile(applicationsSubProfiles);
- // Create bootstrap profile meta data
- ProfileKey bootstrapKey = new ProfileKey(BOOTSTRAP_NAME);
- ProfileMetaData bootstrap = createProfileMetaData(
- BOOTSTRAP_NAME, false, new URI[] { getBootstrapURI() }, new String[0]);
- addProfile(bootstrapKey, bootstrap);
-
- // Create deployers profile meta data
- ProfileKey deployersKey = new ProfileKey(DEPLOYERS_NAME);
- ProfileMetaData deployers = createProfileMetaData(
- DEPLOYERS_NAME, false, new URI[] { getDeployersURI() }, new String[] { BOOTSTRAP_NAME });
- addProfile(deployersKey, deployers);
-
- // Create applications profile;
- ProfileKey applicationsKey = new ProfileKey(APPLICATIONS_NAME);
- URI[] deployURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
- String[] applicationSubProfiles = new String[] { BOOTSTRAP_NAME, DEPLOYERS_NAME };
- ProfileMetaData applications = createProfileMetaData(
- APPLICATIONS_NAME, true, deployURIs, applicationSubProfiles);
- addProfile(applicationsKey, applications);
-
+ // Create the farm profile
ProfileMetaData farm = null;
if (getFarmURIs() != null)
{
ProfileKey farmKey = new ProfileKey(FARM_NAME);
URI[] farmURIs = getFarmURIs().toArray(new URI[getFarmURIs().size()]);
- String[] farmSubProfiles = new String[] { APPLICATIONS_NAME };
+ String[] farmSubProfiles = new String[] { applicationProfileName };
farm = createClusteredProfileMetaData(
FARM_NAME, true, farmURIs, farmSubProfiles);
addProfile(farmKey, farm);
}
-
- String[] rootSubProfiles = farm == null ? new String[]{APPLICATIONS_NAME}
- : new String[] { FARM_NAME };
- ProfileMetaData root = createProfileMetaData(
- rootKey.getName(), true, new URI[0], rootSubProfiles);
- addProfile(rootKey, root);
-
+ // Create the hasingleton profile
if (getHASingletonURIs() != null)
{
ProfileKey hasingletonKey = new ProfileKey(HASINGLETON_NAME);
@@ -173,6 +138,8 @@
HASINGLETON_NAME, true, hasingletonURIs, hasingletonSubProfiles);
addProfile(hasingletonKey, hasingletons);
}
+ // Return the dependencies for the root profile
+ return farm == null ? new String[] { applicationProfileName } : new String[] { FARM_NAME };
}
private ProfileMetaData createClusteredProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -30,7 +30,6 @@
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
import org.jboss.metadata.spi.MetaData;
import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
@@ -52,7 +51,7 @@
private ManagedGenericOverrideHandler overrideHandler = new ManagedGenericOverrideHandler();
/** The managed object factory. */
- private final ManagedObjectFactory factory = ManagedObjectFactoryBuilder.create();
+ private ManagedObjectFactory factory = ManagedObjectFactory.getInstance();
/** The Logger. */
private static final Logger log = Logger.getLogger(ProfileServicePersistenceDeployer.class);
@@ -64,6 +63,16 @@
setStage(DeploymentStages.PRE_REAL);
}
+ public ManagedObjectFactory getManagedObjectFactory()
+ {
+ return factory;
+ }
+
+ public void setManagedObjectFactory(ManagedObjectFactory factory)
+ {
+ this.factory = factory;
+ }
+
@Override
protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -23,6 +23,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.jboss.profileservice.spi.Profile;
@@ -72,15 +74,27 @@
{
return;
}
- boolean isAccessible = m.isAccessible();
- try
+ invoke(profile, m);
+ }
+
+ private static void invoke(Profile profile, final Method method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ method.setAccessible(true);
+ else
{
- m.setAccessible(true);
- m.invoke(profile, args);
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ method.setAccessible(true);
+ return null;
+ }
+ });
}
- finally
- {
- m.setAccessible(isAccessible);
- }
+ // invoke
+ method.invoke(profile, args);
}
+
}
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -35,6 +35,7 @@
import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -130,6 +131,13 @@
updateLastModfied();
}
+ /**
+ * Add a deployment to this profile source.
+ *
+ * @param vfsPath the deployment name
+ * @param d the deployment
+ * @throws Exception
+ */
public void addDeployment(String vfsPath, ProfileDeployment d) throws Exception
{
if(d == null)
@@ -142,6 +150,12 @@
updateLastModfied();
}
+ /**
+ * Get the deployment
+ *
+ * @param vfsPath the deployment
+ * @return the deployment or null if it does not exist
+ */
public ProfileDeployment getDeployment(String vfsPath) throws NoSuchDeploymentException
{
if(vfsPath == null)
@@ -150,6 +164,13 @@
return this.applicationCtxs.get(vfsPath);
}
+ /**
+ * Remove a deployment from this source.
+ *
+ * @param vfsPath the deployment name
+ * @return the deployment
+ * @throws NoSuchProfileException if the deployment does not exist
+ */
public ProfileDeployment removeDeployment(String vfsPath) throws Exception
{
if(vfsPath == null)
@@ -183,6 +204,14 @@
}
}
+ /**
+ * Scan the children of the root for deployments.
+ *
+ * @param list a list of virtual files, where new deployments are added to
+ * @param root the root to scan
+ * @throws IOException
+ * @throws URISyntaxException
+ */
protected void addedDeployments(List<VirtualFile> list, VirtualFile root) throws IOException, URISyntaxException
{
if(root.isLeaf())
@@ -199,16 +228,25 @@
}
}
+ /**
+ * Scan a given virtualFile for deployments.
+ *
+ * @param list a list of virtual files, where new deployments are added to
+ * @param component the root file
+ * @throws IOException
+ * @throws URISyntaxException
+ */
protected void addedDeployment(List<VirtualFile> list, VirtualFile component) throws IOException, URISyntaxException
{
// Excluding files from scanning
- if(deploymentFilter != null && ! this.deploymentFilter.accepts(component))
+ if(deploymentFilter != null && this.deploymentFilter.accepts(component) == false)
{
if(log.isTraceEnabled())
log.trace("ignoring "+ component);
return;
}
+ // Check if we accept this deployment
String key = component.toURI().toString();
if(acceptsDeployment(key) == false)
return;
@@ -233,11 +271,24 @@
}
}
+ /**
+ * Check if the deployment should be added.
+ *
+ * @param name the deployment name
+ * @return
+ */
protected boolean acceptsDeployment(String name)
{
return applicationCtxs.containsKey(name) == false;
}
+ /**
+ * Try to find a deployment, based on the cached
+ * virtual roots of deployments we have.
+ *
+ * @param name the deployment name
+ * @return a collection of matching names
+ */
protected List<String> findDeploymentContent(String name)
{
if(this.applicationVFCache.containsKey(name))
@@ -260,11 +311,14 @@
return contents;
}
- protected ProfileDeployment createDeployment(VirtualFile vf) throws Exception
- {
- return new AbstractProfileDeployment(vf);
- }
-
+ /**
+ * Add a virtualFile to the local virtualFileCache
+ *
+ * @param vf the virtual file
+ * @return the name
+ * @throws MalformedURLException
+ * @throws URISyntaxException
+ */
protected String addVirtualFileCache(VirtualFile vf) throws MalformedURLException, URISyntaxException
{
String uri = vf.toURI().toString();
@@ -272,11 +326,25 @@
return uri;
}
+ /**
+ * Get a cached virtual file.
+ *
+ * @param name the name
+ * @return the virtual file or null, if it does not exist
+ */
protected VirtualFile getCachedVirtualFile(String name)
{
return this.applicationVFCache.get(name);
}
+ /**
+ * Get a cached virtual file. This will add the uri to the
+ * virtualFile if it does not exist.
+ *
+ * @param uri the uri
+ * @return the virtual file
+ * @throws IOException
+ */
protected VirtualFile getCachedVirtualFile(URI uri) throws IOException
{
VirtualFile vf = getCachedVirtualFile(uri.toString());
@@ -288,6 +356,21 @@
return vf;
}
+ /**
+ * Create a ProfileDeployment, based on the virtual file.
+ *
+ * @param vf the deployment root
+ * @return the profile deployment
+ * @throws Exception
+ */
+ protected static ProfileDeployment createDeployment(VirtualFile vf) throws Exception
+ {
+ return new AbstractProfileDeployment(vf);
+ }
+
+ /**
+ * Internally update the lastModified timestamp.
+ */
protected void updateLastModfied()
{
this.lastModified = System.currentTimeMillis();
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/ProfileStartAction.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -22,7 +22,7 @@
package org.jboss.system.server.profileservice.repository;
/**
- * Basic start/stop action.
+ * Basic profile start/stop action.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -42,8 +42,8 @@
/**
* A profile factory based on a static configuration.
- * This creates the legacy configuration: bootstrap, deployers, and the
- * root profile.
+ * This creates the legacy configuration: bootstrap, deployers, applications
+ * and the root profile.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -181,16 +181,9 @@
addProfile(deployersKey, deployers);
// Create applications profile meta data
- ProfileKey applicationsKey = new ProfileKey(applicationsName);
- URI[] applicationURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
- String[] applicationsSubProfiles = new String[] { bootstrapName, deployersName };
- ProfileMetaData applications = createProfileMetaData(
- applicationsName, true, applicationURIs, applicationsSubProfiles);
- // Add to profile map
- addProfile(applicationsKey, applications);
+ String[] rootSubProfiles = createApplicationProfiles(new String[] { bootstrapName, deployersName });
// Create empty root profile;
- String[] rootSubProfiles = new String[] { applicationsName };
ProfileMetaData root = new EmptyProfileMetaData(
null, null, rootKey.getName(), createSubProfileMetaData(rootSubProfiles));
@@ -199,6 +192,34 @@
}
/**
+ * Create the application sub profiles.
+ *
+ * @param applicationsSubProfiles
+ * @return the dependencies for the root profile
+ */
+ protected String[] createApplicationProfiles(String[] applicationsSubProfiles)
+ {
+ return new String[] { createApplicationProfile(applicationsSubProfiles) };
+ }
+
+ /**
+ * Create the applications sub profile.
+ *
+ * @param applicationsSubProfiles the dependencies for the application profile
+ * @return the application profile name
+ */
+ protected String createApplicationProfile(String[] applicationsSubProfiles)
+ {
+ ProfileKey applicationsKey = new ProfileKey(applicationsName);
+ URI[] applicationURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
+ ProfileMetaData applications = createProfileMetaData(
+ applicationsName, true, applicationURIs, applicationsSubProfiles);
+ // Add to profile map
+ addProfile(applicationsKey, applications);
+ return applicationsName;
+ }
+
+ /**
* Create a basic profile meta data. This profile will have it's own
* DeploymentRepository and therefore exposed in the DeploymentManager
* for deploy actions.
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java 2009-04-11 11:03:03 UTC (rev 87160)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java 2009-04-11 11:03:55 UTC (rev 87161)
@@ -36,7 +36,7 @@
/**
* The profile repository.
*
- * This accepts any implementation of DeploymentRepositoryFactory and dispatches
+ * This accepts any implementation of DeploymentRepositoryFactory and delegates
* the creation of the repository to one of the installed factories, based on
* the exposed types.
*
More information about the jboss-cvs-commits
mailing list