[jboss-cvs] JBossAS SVN: r75053 - trunk/system/src/main/org/jboss/system/server/profileservice/repository.
Adrian Brock
abrock at redhat.com
Wed Jun 25 08:20:11 EDT 2008
That's not very threadsafe is it?
On Wed, 2008-06-25 at 08:13 -0400, jboss-cvs-commits at lists.jboss.org
wrote:
> Author: alesj
> Date: 2008-06-25 08:13:05 -0400 (Wed, 25 Jun 2008)
> New Revision: 75053
>
> Modified:
> trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
> Log:
> Cache virtual files for app dirs.
>
> 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 2008-06-25 10:57:11 UTC (rev 75052)
> +++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2008-06-25 12:13:05 UTC (rev 75053)
> @@ -38,7 +38,7 @@
> import java.util.List;
> import java.util.Map;
> import java.util.Set;
> -import java.util.concurrent.atomic.AtomicBoolean;
> +import java.util.HashMap;
> import java.util.concurrent.locks.ReentrantReadWriteLock;
> import java.util.zip.ZipInputStream;
>
> @@ -50,10 +50,10 @@
> import org.jboss.profileservice.spi.AttachmentsSerializer;
> import org.jboss.profileservice.spi.DeploymentRepository;
> import org.jboss.profileservice.spi.ModificationInfo;
> +import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
> import org.jboss.profileservice.spi.NoSuchDeploymentException;
> import org.jboss.profileservice.spi.NoSuchProfileException;
> import org.jboss.profileservice.spi.ProfileKey;
> -import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
> import org.jboss.util.file.Files;
> import org.jboss.virtual.VFS;
> import org.jboss.virtual.VirtualFile;
> @@ -86,6 +86,8 @@
> private File deployersDir;
> /** The application phase deployments dir */
> private File[] applicationDirs;
> + /** The application phase deployments dir */
> + private Map<String, VirtualFile> deployDirs;
> /** The deployment post edit root location */
> private File adminEditsRoot;
> /** The profile key this repository is associated with */
> @@ -468,7 +470,7 @@
> // Now check for additions
> for (File applicationDir : applicationDirs)
> {
> - VirtualFile deployDir = VFS.getRoot(applicationDir.toURI());
> + VirtualFile deployDir = getDeployDir(applicationDir);
> List<VirtualFile> children = deployDir.getChildren();
> for(VirtualFile vf : children)
> {
> @@ -616,6 +618,7 @@
> if( applicationDir.exists() == false )
> throw new FileNotFoundException("Profile contains no deploy dir: "+applicationDir);
> }
> + deployDirs = new HashMap<String, VirtualFile>(applicationDirs.length);
>
> adminEditsRoot = new File(profileRoot, "profile/edits");
>
> @@ -632,11 +635,29 @@
> VFS deployersVFS = VFS.getVFS(deployersDir.toURI());
> loadDeployers(deployersVFS.getRoot());
> for (File applicationDir : applicationDirs)
> + loadApplications(getDeployDir(applicationDir));
> +
> + this.lastModified = System.currentTimeMillis();
> + }
> +
> + /**
> + * Get virtual file for app dir.
> + *
> + * @param applicationDir the app dir
> + * @return virtual file representing app dir
> + * @throws IOException for any error
> + */
> + protected VirtualFile getDeployDir(File applicationDir) throws IOException
> + {
> + URI uri = applicationDir.toURI();
> + String uriString = uri.toString();
> + VirtualFile dir = deployDirs.get(uriString);
> + if (dir == null)
> {
> - VFS deployVFS = VFS.getVFS(applicationDir.toURI());
> - loadApplications(deployVFS.getRoot());
> + dir = VFS.getRoot(uri);
> + deployDirs.put(uriString, dir);
> }
> - this.lastModified = System.currentTimeMillis();
> + return dir;
> }
>
> /**
>
> _______________________________________________
> jboss-cvs-commits mailing list
> jboss-cvs-commits at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-cvs-commits
--
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Chief Scientist
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
More information about the jboss-cvs-commits
mailing list