[jboss-cvs] JBossAS SVN: r75101 - in trunk: system/src/main/org/jboss/system/server/profile/basic and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 26 04:45:45 EDT 2008
Author: alesj
Date: 2008-06-26 04:45:44 -0400 (Thu, 26 Jun 2008)
New Revision: 75101
Added:
trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
trunk/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java
Modified:
trunk/server/src/etc/conf/default/profile-service.xml
trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
Log:
[JBAS-4545]; adding metadata aware profile.
Modified: trunk/server/src/etc/conf/default/profile-service.xml
===================================================================
--- trunk/server/src/etc/conf/default/profile-service.xml 2008-06-26 08:34:36 UTC (rev 75100)
+++ trunk/server/src/etc/conf/default/profile-service.xml 2008-06-26 08:45:44 UTC (rev 75101)
@@ -13,11 +13,12 @@
to determine the profile deployments. This version does not
support the full ProfileService spi.
-->
- <bean name="ProfileService" class="org.jboss.system.server.profileservice.basic.ProfileServiceImpl">
+ <bean name="ProfileService" class="org.jboss.system.server.profileservice.basic.MetaDataAwareProfileService">
<constructor>
<parameter>${jboss.server.name}</parameter>
</constructor>
<property name="profileRoot">${jboss.server.home.dir}</property>
+ <property name="mainDeployer"><inject bean="MainDeployer"/></property>
</bean>
<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
Added: trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java 2008-06-26 08:45:44 UTC (rev 75101)
@@ -0,0 +1,146 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.system.server.profile.basic;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Profile monitoring metadata changes.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MetaDataAwareProfile extends ProfileImpl
+{
+ private MainDeployerStructure mainDeployer;
+
+ public MetaDataAwareProfile(String profileRoot, ProfileKey key)
+ {
+ super(profileRoot, key);
+ }
+
+ /**
+ * Set main deployer structure.
+ *
+ * @param mainDeployer the main deployer structure
+ */
+ public void setMainDeployer(MainDeployerStructure mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
+
+ protected boolean hasBeenModified(VirtualFile root) throws Exception
+ {
+ // get file:/ schema
+ URL url = VFSUtils.getCompatibleURL(root);
+ File file = new File(url.toURI());
+ // if root is file - usually archive - check its modification
+ if (file.isFile())
+ return root.hasBeenModified();
+
+ // else check metadata
+ String name = root.toURI().toString();
+ VFSDeploymentContext deploymentContext = getDeploymentContext(name);
+ if (deploymentContext != null)
+ {
+ return hasBeenModified(deploymentContext);
+ }
+ log.debug("Falling back to root name: " + root);
+ deploymentContext = getDeploymentContext(root.getName());
+ if (deploymentContext != null)
+ {
+ return hasBeenModified(deploymentContext);
+ }
+ return false;
+ }
+
+ /**
+ * Has vfs deployment context been modified.
+ *
+ * @param deploymentContext the vfs deployment context
+ * @return true if modified
+ * @throws IOException for any error
+ */
+ protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
+ {
+ List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
+ if (metadataLocations != null && metadataLocations.isEmpty() == false)
+ {
+ for(VirtualFile metadataLocation : metadataLocations)
+ {
+ if (metadataLocation.isLeaf() && metadataLocation.hasBeenModified())
+ return true;
+
+ List<VirtualFile> children = metadataLocation.getChildren();
+ if (children != null && children.isEmpty() == false)
+ {
+ for(VirtualFile child : children)
+ {
+ if (child.hasBeenModified())
+ return true;
+ }
+ }
+ }
+ }
+ List<DeploymentContext> childContexts = deploymentContext.getChildren();
+ if (childContexts != null && childContexts.isEmpty() == false)
+ {
+ for (DeploymentContext childContext : childContexts)
+ {
+ if (childContext instanceof VFSDeploymentContext)
+ {
+ if (hasBeenModified((VFSDeploymentContext)childContext))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get deployment context.
+ *
+ * @param name the deployment context name
+ * @return vfs deployment context or null if doesn't exist or not vfs based
+ */
+ @SuppressWarnings("deprecation")
+ protected VFSDeploymentContext getDeploymentContext(String name)
+ {
+ if (mainDeployer == null)
+ throw new IllegalArgumentException("Null main deployer");
+
+ DeploymentContext deploymentContext = mainDeployer.getDeploymentContext(name);
+ if (deploymentContext == null || deploymentContext instanceof VFSDeploymentContext == false)
+ return null;
+
+ return (VFSDeploymentContext)deploymentContext;
+ }
+}
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 2008-06-26 08:34:36 UTC (rev 75100)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java 2008-06-26 08:45:44 UTC (rev 75101)
@@ -313,7 +313,7 @@
log.trace(root.getPathName() + " was removed");
}
// Check for modification
- else if( root.hasBeenModified() )
+ else if(hasBeenModified(root))
{
long rootLastModified = root.getLastModified();
if( trace )
@@ -346,6 +346,18 @@
}
/**
+ * Has the root been modified.
+ *
+ * @param root the virtual file root
+ * @return true if modifed
+ * @throws Exception for any error
+ */
+ protected boolean hasBeenModified(VirtualFile root) throws Exception
+ {
+ return root.hasBeenModified();
+ }
+
+ /**
* Noop as basic profile does not support hot deployment currently
*/
public void enableModifiedDeploymentChecks(boolean flag)
Copied: trunk/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java (from rev 75099, trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java 2008-06-26 08:45:44 UTC (rev 75101)
@@ -0,0 +1,66 @@
+/*
+ * 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.system.server.profileservice.basic;
+
+import java.io.IOException;
+
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profile.basic.MetaDataAwareProfile;
+
+
+/**
+ * Profile service creating profiles that
+ * monitor metadata changes.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MetaDataAwareProfileService extends ProfileServiceImpl
+{
+ private MainDeployerStructure mainDeployer;
+
+ public MetaDataAwareProfileService(String name) throws IOException
+ {
+ super(name);
+ }
+
+ protected Profile createProfile(ProfileKey key)
+ {
+ if (mainDeployer == null)
+ throw new IllegalArgumentException("Null main deployer");
+
+ MetaDataAwareProfile profile = new MetaDataAwareProfile(getProfileRoot(), key);
+ profile.setMainDeployer(mainDeployer);
+ return profile;
+ }
+
+ /**
+ * Set main deployer structure.
+ *
+ * @param mainDeployer the main deployer structure
+ */
+ public void setMainDeployer(MainDeployerStructure mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
+}
\ No newline at end of file
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java 2008-06-26 08:34:36 UTC (rev 75100)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java 2008-06-26 08:45:44 UTC (rev 75101)
@@ -76,14 +76,24 @@
public void start()
{
ProfileKey key = new ProfileKey(name);
- defaultImpl = new ProfileImpl(profileRoot, key);
+ defaultImpl = createProfile(key);
}
+ /**
+ * Create default profile.
+ *
+ * @param key the profile key
+ * @return new profile instance
+ */
+ protected Profile createProfile(ProfileKey key)
+ {
+ return new ProfileImpl(profileRoot, key);
+ }
+
// ProfileService implementation --------------------
public String[] getDomains()
{
- String[] domains = {ProfileKey.DEFAULT};
- return domains;
+ return new String[]{ProfileKey.DEFAULT};
}
public Collection<ProfileKey> getProfileKeys()
@@ -110,8 +120,7 @@
public String[] getProfileDeploymentNames(ProfileKey key)
throws NoSuchProfileException
{
- String[] names = {"default"};
- return names;
+ return new String[]{"default"};
}
public ManagementView getViewManager()
More information about the jboss-cvs-commits
mailing list