[jboss-cvs] JBossAS SVN: r83499 - in trunk/system/src: main/org/jboss/system/server/profileservice/repository and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 27 09:35:57 EST 2009
Author: emuckenhuber
Date: 2009-01-27 09:35:57 -0500 (Tue, 27 Jan 2009)
New Revision: 83499
Added:
trunk/system/src/resources/parsing-tests/common/profiles/jboss-web.profile
trunk/system/src/resources/parsing-tests/common/profiles/metadata-deployers.profile
Removed:
trunk/system/src/resources/parsing-tests/common/profiles/common.profile
trunk/system/src/resources/parsing-tests/common/profiles/web.profile
Modified:
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
Log:
update xml profile resolution
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -31,9 +31,9 @@
import org.jboss.xb.annotations.JBossXmlSchema;
/**
- * A filtered profile source meta data. This is a workaround, that the
- * we can create a filtered deploymentRepository based on the source
- * meta data only.
+ * A filtered profile source meta data.
+ * This is a workaround that we can a filtered deploymentRepository
+ * on this metadata only, based on the deployments list.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -21,11 +21,6 @@
*/
package org.jboss.system.server.profile.repository.metadata;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.jboss.xb.annotations.JBossXmlSchema;
-
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -71,7 +71,7 @@
* @param key the root profile key.
* @throws Exception
*/
- protected abstract void createProfileMetaData(ProfileKey key, URL url) throws Exception;
+ protected abstract void createProfileMetaData(ProfileKey key, URL url) throws Exception;
/**
* Create the profiles required for this profile.
@@ -201,7 +201,7 @@
}
/**
- * Add a profile.
+ * Add profile meta data.
*
* @param key the profile key.
* @param metaData the profile meta data.
@@ -219,7 +219,8 @@
}
/**
- * Add a list of profile meta data which make up a profiles reference.
+ * Add the profiles meta data, which is basically is a reference to
+ * a list of profile meta data.
*
* @param key the profile key.
* @param metaData a list of profile meta data.
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -143,12 +143,20 @@
public void addDeployment(String vfsPath, VFSDeployment d) throws Exception
{
+ if(vfsPath == null)
+ throw new IllegalArgumentException("Null vfsPath");
+ if(d == null)
+ throw new IllegalArgumentException("Null deployment");
+
this.applicationCtxs.put(vfsPath, d);
updateLastModfied();
}
public VFSDeployment removeDeployment(String vfsPath) throws Exception
{
+ if(vfsPath == null)
+ throw new IllegalArgumentException("Null vfsPath");
+
VFSDeployment deployment = this.applicationCtxs.remove(vfsPath);
if(deployment != null)
updateLastModfied();
@@ -219,6 +227,9 @@
public VFSDeployment getDeployment(String vfsPath) throws NoSuchDeploymentException
{
+ if(vfsPath == null)
+ throw new IllegalArgumentException("Null vfsPath");
+
boolean trace = log.isTraceEnabled();
VFSDeployment ctx = this.applicationCtxs.get(vfsPath);
// TODO should a lookup of the simple name really be done here ?
@@ -265,6 +276,8 @@
public VirtualFile getDeploymentContent(String name) throws IOException, URISyntaxException
{
+ if(name == null)
+ throw new IllegalArgumentException("Null name");
for(URI uri : this.uris)
{
VirtualFile root = getCachedVirtualFile(uri);
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -139,11 +139,7 @@
public Collection<ProfileKey> getProfileKeys()
{
- // Make it serializable
- List<ProfileKey> copy = new ArrayList<ProfileKey>();
- for(ProfileKey key : this.registeredProfiles.keySet())
- copy.add(key);
- return copy;
+ return new ArrayList<ProfileKey>(this.registeredProfiles.keySet());
}
/**
@@ -179,6 +175,9 @@
*/
public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
{
+ if(key == null)
+ throw new IllegalArgumentException("Null profile key.");
+
ProfileContext profile = null;
if(this.activeProfiles.contains(key))
{
@@ -208,6 +207,16 @@
}
/**
+ * Destroy the profileService.
+ *
+ */
+ public void destroy()
+ {
+ //
+ this.profileActions.clear();
+ }
+
+ /**
* Register a Profile.
*
* @param profile the profile.
@@ -220,7 +229,7 @@
ProfileKey key = profile.getKey();
if(key == null)
- throw new IllegalStateException("Null profile key.");
+ throw new IllegalArgumentException("Null profile key.");
if(registeredProfiles.get(profile.getKey()) != null)
return;
@@ -298,9 +307,7 @@
// TODO
AbstractProfileLifeCycleAction action = this.profileActions.get(toState);
if(action != null)
- {
action.install((ProfileContext) context);
- }
}
public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
@@ -310,9 +317,7 @@
// TODO
AbstractProfileLifeCycleAction action = this.profileActions.get(fromState);
if(action != null)
- {
action.uninstall((ProfileContext) context);
- }
}
/**
@@ -337,7 +342,7 @@
throw new IllegalStateException("Profile not installed: "+ key);
try
{
- log.debug("releasing profile: " + key);
+ log.debug("deactivating profile: " + key);
controller.change(context, ControllerState.NOT_INSTALLED);
// TODO release other not needed contexts ?
@@ -357,7 +362,7 @@
public void unregisterProfile(ProfileKey key) throws NoSuchProfileException
{
if(key == null)
- throw new IllegalStateException("Null profile key.");
+ throw new IllegalArgumentException("Null profile key.");
if(this.activeProfiles.contains(key))
throw new IllegalStateException("Cannot unregister active profile: "+ key);
@@ -516,13 +521,11 @@
{
// activate profile
activeProfiles.add(0, profile.getKey());
- log.debug("profile activated: " + profile);
}
public void uninstall(Profile profile)
{
// release profile
activeProfiles.remove(profile.getKey());
- log.debug("releasing profile: " + profile);
}
}
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -230,7 +230,6 @@
ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
modified.add(info);
}
- // TODO: this could check metadata files modifications as well
}
// Now check for additions
for (URI applicationDir : getRepositoryURIs())
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java 2009-01-27 14:35:57 UTC (rev 83499)
@@ -22,6 +22,7 @@
package org.jboss.system.server.profileservice.repository;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
@@ -31,12 +32,12 @@
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
import org.jboss.xb.binding.JBossXBException;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
@@ -53,22 +54,22 @@
{
/** The profiles directory name. */
public final static String PROFILES_SUFFIX = ".profile";
-
+
+ /** The attachment store uri. */
+ private File attachmentStoreRoot;
+
+ /** Profile directories */
+ private Collection<VirtualFile> profileDirectories;
+
/** The unmarshaller. */
private Unmarshaller unmarshaller;
- /** Profile directories */
- private Collection<VirtualFile> profileDirectories;
+ /** The parsed file list */
+ private Collection<ProfileKey> processedProfileKeys = new ArrayList<ProfileKey>();
- /** The schema resolver. */
+ /** The default schema resolver. */
private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
- /** A xml include filter. */
- private final static VirtualFileFilter fileIncludeFilter = new FileIncludeFilter();
-
- /** The attachment store uri. */
- private File attachmentStoreRoot;
-
static
{
// Add schema bindings
@@ -114,9 +115,10 @@
}
/**
- * Create the profile meta data based on the .xml files found in the folders.
+ * Create the profile meta data.
*
- * @param server The Server.
+ * @param rootKey the key of the profile/
+ * @param the url pointing to the profile file.
* @throws Exception
*/
@Override
@@ -124,55 +126,158 @@
{
// Create the unmarshaller
this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ // Get the root profile virtual file
+ VirtualFile vf = getProfileFile(rootKey, url);
+ // Parse
+ ProfilesMetaData rootProfiles = parse(vf);
+ // Process
+ processProfilesMetaData(rootProfiles);
+ }
+
+ /**
+ * process the profile meta data.
+ *
+ * @param metaData the profile meta data.
+ * @throws Exception
+ */
+ protected void processProfileMetaData(ProfileMetaData metaData) throws Exception
+ {
+ // Create profileKey
+ ProfileKey key = createProfileKey(metaData);
+ processProfileMetaData(key, metaData);
+ }
+
+ /**
+ * process the profile meta data
+ *
+ * @param key the profile key.
+ * @param metaData the meta data.
+ *
+ * @throws Exception
+ */
+ protected void processProfileMetaData(ProfileKey key, ProfileMetaData metaData) throws Exception
+ {
+ // Don't process the same key twice
+ if(this.processedProfileKeys.contains(key))
+ return;
+
+ // Add profile meta data
+ addProfile(key, metaData);
- for(VirtualFile vf : getProfileDirectories())
- parseProfiles(vf);
+ // Process sub profiles
+ processSubProfiles(key, metaData);
}
-
+
/**
- * Parse all .xml files in a directory.
+ * process the sub profiles.
*
- * @param profileDirectory the directory
- * @throws IOException
- * @throws JBossXBException
+ * @param key the profile key.
+ * @param metaData the profile meta data
+ * @throws Exception
*/
- protected void parseProfiles(VirtualFile profileDirectory) throws IOException, JBossXBException
+ protected void processSubProfiles(ProfileKey key, ProfileMetaData metaData) throws Exception
{
- List<VirtualFile> fileList = profileDirectory.getChildren(fileIncludeFilter);
- if(fileList != null && fileList.isEmpty() == false)
+ if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
{
- for(VirtualFile vf : fileList)
+ for(SubProfileMetaData subProfile : metaData.getSubprofiles())
{
- ProfilesMetaData profilesMetaData = parse(vf);
- if(profilesMetaData == null)
- throw new IllegalStateException("Parsing returned null for file: "+ vf.getPathName());
-
- processProfilesMetaData(profilesMetaData);
+ ProfileKey subProfileKey = createProfileKey(subProfile);
+ processSubProfileMetaData(subProfileKey, subProfile);
}
}
}
/**
+ * process the sub profile.
+ *
+ * @param key the sub profile key.
+ * @param metaData the sub profile meta data.
+ * @throws Exception
+ */
+ protected void processSubProfileMetaData(ProfileKey key, SubProfileMetaData metaData) throws Exception
+ {
+ // get file
+ VirtualFile vf = getProfileFile(key, null);
+ // parse
+ ProfilesMetaData profiles = parse(vf);
+ // Override the profiles key (as it should be the same - filename and profiles name
+ processProfilesMetaData(key, profiles);
+ }
+
+ /**
+ * process the profiles meta data.
+ *
+ * @param key the profiles key.
+ * @param metaData the profiles meta data.
+ * @throws Exception
+ */
+ protected void processProfilesMetaData(ProfileKey key, ProfilesMetaData metaData) throws Exception
+ {
+ if(metaData.getProfiles() != null && metaData.getProfiles().isEmpty() == false)
+ {
+ for(ProfileMetaData profile : metaData.getProfiles())
+ {
+ processProfileMetaData(profile);
+ }
+ }
+ // Add the profiles for later resolution
+ addProfiles(key, metaData.getProfiles());
+ }
+
+ /**
* Process the <profiles> meta data.
* This will add dependencies based on the ordering of the xml.
*
* @param profilesMetaData the profiles meta data
*/
- protected void processProfilesMetaData(ProfilesMetaData profilesMetaData)
+ protected void processProfilesMetaData(ProfilesMetaData profilesMetaData) throws Exception
{
// The <profiles> key
ProfileKey profilesKey = createProfileKey(profilesMetaData);
- if(profilesMetaData.getProfiles() != null && profilesMetaData.getProfiles().isEmpty() == false)
+ processProfilesMetaData(profilesKey, profilesMetaData);
+ }
+
+ /**
+ * get the virtual file of the profile.
+ *
+ * @param key the profile key.
+ * @param url the url pointing to the file
+ * @return a resolved name if the url is null.
+ *
+ * @throws Exception
+ */
+ protected VirtualFile getProfileFile(ProfileKey key, URL url) throws Exception
+ {
+ if(url != null)
+ return VFS.getRoot(url);
+ else
+ return resolveFile(key.getName());
+ }
+
+ /**
+ * Try to resolve the profile name.
+ *
+ * @param name the profile name.
+ * @return the virtual file
+ * @throws Exception
+ */
+ protected VirtualFile resolveFile(String name) throws Exception
+ {
+ // ProfileKey.getName() + .profile
+ if(name.endsWith(PROFILES_SUFFIX) == false)
+ name = name + PROFILES_SUFFIX;
+
+ VirtualFile vf = null;
+ for(VirtualFile dir : profileDirectories)
{
- for(ProfileMetaData profile : profilesMetaData.getProfiles())
- {
- // The <profile> key
- ProfileKey profileKey = createProfileKey(profile);
- addProfile(profileKey, profile);
- }
+ vf = dir.getChild(name);
+ if(vf != null)
+ break;
}
- // Add the profiles for later resolution
- addProfiles(profilesKey, profilesMetaData.getProfiles());
+ if(vf == null)
+ throw new FileNotFoundException("Could not find profile configuration file for: " + name);
+ return vf;
}
/**
@@ -190,12 +295,22 @@
return (ProfilesMetaData) unmarshaller.unmarshal(vf.openStream(), resolver);
}
- private static final class FileIncludeFilter implements VirtualFileFilter
+ @Override
+ protected void addProfile(ProfileKey key, ProfileMetaData metaData)
{
- public boolean accepts(VirtualFile file)
- {
- return file.getName().endsWith(PROFILES_SUFFIX);
- }
+ // Add to processed keys
+ processedProfileKeys.add(key);
+ // Add to parent
+ super.addProfile(key, metaData);
}
+
+ @Override
+ protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
+ {
+ // Add to processed keys
+ processedProfileKeys.add(key);
+ // Add to pared
+ super.addProfiles(key, metaData);
+ }
}
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/common.profile
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/common.profile 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/resources/parsing-tests/common/profiles/common.profile 2009-01-27 14:35:57 UTC (rev 83499)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
-
- <profile name="metadata-deployers">
- <profile-source>
- <source>${jboss.server.base.url}deployers</source>
- </profile-source>
- <deployment>metadata-deployer-jboss-beans.xml</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/common/profiles/jboss-web.profile (from rev 83459, trunk/system/src/resources/parsing-tests/common/profiles/web.profile)
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/jboss-web.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/jboss-web.profile 2009-01-27 14:35:57 UTC (rev 83499)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="jboss-web">
+
+ <profile name="jboss-web-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <sub-profile>metadata-deployers</sub-profile>
+ <deployment>jbossweb.deployer</deployment>
+ </profile>
+
+ <profile name="jboss-web-runtime">
+ <profile-source>
+ <source>${jboss.server.base.url}deploy</source>
+ </profile-source>
+ <deployment>jbossweb.sar</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Added: trunk/system/src/resources/parsing-tests/common/profiles/metadata-deployers.profile
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/metadata-deployers.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/metadata-deployers.profile 2009-01-27 14:35:57 UTC (rev 83499)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+ <profile name="metadata-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <deployment>metadata-deployer-jboss-beans.xml</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/web.profile
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/web.profile 2009-01-27 14:28:14 UTC (rev 83498)
+++ trunk/system/src/resources/parsing-tests/common/profiles/web.profile 2009-01-27 14:35:57 UTC (rev 83499)
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<profiles
- xmlns="urn:jboss:profileservice:profiles:1.0"
- name="jboss-web">
-
- <profile name="jboss-web-deployers">
- <profile-source>
- <source>${jboss.server.base.url}deployers</source>
- </profile-source>
- <sub-profile>metadata-deployers</sub-profile>
- <deployment>jbossweb.deployer</deployment>
- </profile>
-
- <profile name="jboss-web-runtime">
- <profile-source>
- <source>${jboss.server.base.url}deploy</source>
- </profile-source>
- <deployment>jbossweb.sar</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list