[jboss-cvs] JBossAS SVN: r97546 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/repository/artifact/file and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 8 10:36:37 EST 2009
Author: emuckenhuber
Date: 2009-12-08 10:36:36 -0500 (Tue, 08 Dec 2009)
New Revision: 97546
Added:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/VirtualDeploymentRepository.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryFactory.java
Removed:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentRepository.java
Modified:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractRepositoryId.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualProfileFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentProfile.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualDeploymentAssembly.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestArtifactRepository.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java
projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryId.java
Log:
JBPROFILE-4
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -48,28 +48,34 @@
/** The repository root. */
private final VirtualFile repositoryRoot;
- public AbstractArtifactRepository(String type, URI root) throws IOException
+ public AbstractArtifactRepository(ArtifactRepositoryId identifier, URI root) throws IOException
{
+ if(identifier == null)
+ {
+ throw new IllegalArgumentException("null identifier");
+ }
if(root == null)
{
throw new IllegalArgumentException("null repository root.");
}
this.repositoryRoot = VFS.getRoot(root);
- BasicRepositoryConfiguration configuration = new BasicRepositoryConfiguration(type, root);
- this.configuration = configuration;
- this.identifier = configuration;
+ this.configuration = new BasicRepositoryConfiguration(root, false);;
+ this.identifier = identifier;
}
- public AbstractArtifactRepository(String type, VirtualFile root) throws IOException, URISyntaxException
+ public AbstractArtifactRepository(ArtifactRepositoryId identifier, VirtualFile root) throws IOException, URISyntaxException
{
+ if(identifier == null)
+ {
+ throw new IllegalArgumentException("null identifier");
+ }
if(root == null)
{
throw new IllegalArgumentException("null repository root.");
}
this.repositoryRoot = root;
- BasicRepositoryConfiguration configuration = new BasicRepositoryConfiguration(type, root.toURI());
- this.configuration = configuration;
- this.identifier = configuration;
+ this.configuration = new BasicRepositoryConfiguration(root.toURI(), false);
+ this.identifier = identifier;
}
@Override
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractRepositoryId.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractRepositoryId.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractRepositoryId.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -24,6 +24,8 @@
import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
/**
+ * The artifact repository identifier.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
@@ -39,6 +41,9 @@
/** The repository type. */
private final String type;
+ /** The hashCode. */
+ private final int hashCode;
+
public AbstractRepositoryId(String name, String type)
{
if(name == null)
@@ -51,9 +56,9 @@
}
this.name = name;
this.type = type;
+ this.hashCode = createHashCode();
}
-
@Override
public String getName()
{
@@ -65,6 +70,56 @@
{
return this.type;
}
+
+ @Override
+ public int hashCode()
+ {
+ return this.hashCode;
+ }
+
+ protected int createHashCode()
+ {
+ int result = 17;
+ result = 31 * name.hashCode();
+ result = 31 * type.hashCode();
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(obj == this)
+ {
+ return true;
+ }
+ if(obj == null || obj instanceof ArtifactRepositoryId == false)
+ {
+ return false;
+ }
+ ArtifactRepositoryId other = (ArtifactRepositoryId) obj;
+ if(name.equals(other.getName()) == false)
+ {
+ return false;
+ }
+ if(type.equals(other.getType()) == false)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(getClass().getSimpleName()).append('@');
+ buffer.append(Integer.toHexString(System.identityHashCode(this)));
+ buffer.append('{');
+ buffer.append("name=").append(name);
+ buffer.append(", type=").append(type);
+ buffer.append('}');
+ return buffer.toString();
+ }
+
}
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/ArtifactRepositoryManager.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.repository.artifact;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryFactory;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
+
+/**
+ * The artifact repository manager.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ArtifactRepositoryManager implements ArtifactRepositoryFactory<ArtifactId>
+{
+
+ /** The default name. */
+ private static final String DEFAULT_NAME = "###DEFAULT####";
+
+ /** The artifact repositories. */
+ private ConcurrentMap<ArtifactRepositoryId, ArtifactRepository<ArtifactId>> repositories = new ConcurrentHashMap<ArtifactRepositoryId, ArtifactRepository<ArtifactId>>();
+
+ /** The artifact repository factories. */
+ private Map<String, ArtifactRepositoryFactory<ArtifactId>> factories = new ConcurrentHashMap<String, ArtifactRepositoryFactory<ArtifactId>>();
+
+ /**
+ * Get a artifact repository based on a id.
+ *
+ * @param repositoryId the repository id
+ * @return the artifact repository
+ * @throws IllegalStateException if no repository is found
+ */
+ public ArtifactRepository<ArtifactId> getArtifactRepository(ArtifactRepositoryId repositoryId)
+ {
+ ArtifactRepository<ArtifactId> repository = repositories.get(repositoryId);
+ if(repository == null)
+ {
+ throw new IllegalStateException("failed to find artifact repository for id " + repositoryId);
+ }
+ return repository;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ArtifactRepository<ArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
+ ArtifactRepositoryConfiguration configuration) throws IOException
+ {
+ if(repositoryId == null)
+ {
+ throw new IllegalArgumentException("null repository id");
+ }
+ // Check if the repository is already created
+ ArtifactRepository<ArtifactId> repository = repositories.get(repositoryId);
+ if(repository == null)
+ {
+ // Resolve repository type
+ String repositoryType = repositoryId.getType();
+ if(repositoryType == null)
+ {
+ throw new IllegalArgumentException("null repository type");
+ }
+ // Get repository factory
+ ArtifactRepositoryFactory<ArtifactId> factory = factories.get(repositoryType);
+ if(factory == null)
+ {
+ throw new IllegalStateException("no registered factory for type " + repositoryType);
+ }
+ // Create repository
+ repository = factory.createArtifactRepository(repositoryId, configuration);
+ if(repository == null)
+ {
+ throw new IllegalArgumentException("created null artifact repository " + repositoryId);
+ }
+ // Add repository
+ addRepository(repository);
+ }
+ return repository;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getRepositoryType()
+ {
+ return DEFAULT_NAME;
+ }
+
+ public void addRepository(ArtifactRepository<ArtifactId> repository)
+ {
+ if(repository == null)
+ throw new IllegalArgumentException("null repository");
+ if(repository.getIdentifier() == null)
+ throw new IllegalArgumentException("null repository configuration");
+ // Don't override existing repositories
+ repositories.putIfAbsent(repository.getIdentifier(), repository);
+ }
+
+ public void removeRepository(ArtifactRepository<ArtifactId> repository)
+ {
+ if(repository == null)
+ throw new IllegalArgumentException("null repository");
+ if(repository.getIdentifier() == null)
+ throw new IllegalArgumentException("null repository configuration");
+ repositories.remove(repository.getIdentifier());
+ }
+
+ public void addRepositoryFactory(ArtifactRepositoryFactory<ArtifactId> factory)
+ {
+ if(factory == null)
+ throw new IllegalArgumentException("null factory");
+ if(factory.getRepositoryType() == null)
+ throw new IllegalArgumentException("null factory type");
+ factories.put(factory.getRepositoryType(), factory);
+ }
+
+ public void removeRepositoryFactory(ArtifactRepositoryFactory<ArtifactId> factory)
+ {
+ if(factory == null)
+ throw new IllegalArgumentException("null factory");
+ if(factory.getRepositoryType() == null)
+ throw new IllegalArgumentException("null factory type");
+ factories.remove(factory.getRepositoryType());
+ }
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/BasicRepositoryConfiguration.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -24,57 +24,30 @@
import java.net.URI;
import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
-import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class BasicRepositoryConfiguration implements ArtifactRepositoryConfiguration, ArtifactRepositoryId
+public class BasicRepositoryConfiguration implements ArtifactRepositoryConfiguration
{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -8415309101407938475L;
-
- /** The repository type. */
- private String type;
/** The repository location. */
private URI location;
/** IsMutable. */
private final boolean mutable;
-
- public BasicRepositoryConfiguration(String type, URI location)
- {
- this(type, location, false);
- }
- public BasicRepositoryConfiguration(String type, URI location, boolean mutable)
+ public BasicRepositoryConfiguration(URI location, boolean mutable)
{
- if(type == null)
- {
- throw new IllegalArgumentException("null repository type");
- }
if(location == null)
{
throw new IllegalArgumentException("null repository location");
}
- this.type = type;
this.location = location;
this.mutable = mutable;
}
- public String getName()
- {
- return null;
- }
-
- public String getType()
- {
- return type;
- }
-
public URI getLocation()
{
return location;
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.repository.artifact.file;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryFactory;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * The file artifact repository factory.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class FileArtifactRepositoryFactory implements ArtifactRepositoryFactory<FileArtifactId>
+{
+
+ /** The file repository root. */
+ private VirtualFile root;
+
+ public FileArtifactRepositoryFactory(URI rootURI) throws IOException
+ {
+ this.root = VFS.getRoot(rootURI);
+ }
+
+ @Override
+ public String getRepositoryType()
+ {
+ return FileArtifactId.TYPE;
+ }
+
+ @Override
+ public ArtifactRepository<FileArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
+ ArtifactRepositoryConfiguration configuration) throws IOException
+ {
+ if(repositoryId == null)
+ {
+ throw new IllegalArgumentException("null repository id");
+ }
+ String name = repositoryId.getName();
+ VirtualFile vf = root.getChild(name);
+ if(vf == null)
+ {
+ // FIXME ignore for testing
+ // throw new FileNotFoundException("child ("+ name +") not found in " + root);
+ vf = root;
+ }
+ try
+ {
+ return new LocalFileArtifactRepository(repositoryId, vf);
+ }
+ catch(URISyntaxException e)
+ {
+ throw new RuntimeException("failed to create file artifact repository ", e);
+ }
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -30,6 +30,7 @@
import org.jboss.profileservice.repository.artifact.AbstractArtifactRepository;
import org.jboss.profileservice.spi.repository.Artifact;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
import org.jboss.virtual.VirtualFile;
/**
@@ -38,21 +39,15 @@
*/
public class LocalFileArtifactRepository extends AbstractArtifactRepository<FileArtifactId>
{
-
- static VirtualFile hack(VirtualFile parent, String group) throws IOException
- {
- VirtualFile vf = parent.getChild(group);
- return vf != null ? vf : parent;
- }
- public LocalFileArtifactRepository(URI rootURI) throws IOException
+ public LocalFileArtifactRepository(ArtifactRepositoryId identifier, URI rootURI) throws IOException
{
- super(FileArtifactId.TYPE, rootURI);
+ super(identifier, rootURI);
}
- public LocalFileArtifactRepository(VirtualFile parent, String group) throws IOException, URISyntaxException
+ public LocalFileArtifactRepository(ArtifactRepositoryId identifier, VirtualFile root) throws IOException, URISyntaxException
{
- super(FileArtifactId.TYPE, hack(parent, group));
+ super(identifier, root);
}
@Override
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -26,6 +26,7 @@
import java.net.URI;
import org.jboss.profileservice.repository.artifact.AbstractArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
import org.jboss.virtual.VirtualFile;
/**
@@ -37,9 +38,9 @@
public abstract class AbstractMavenArtifactRepository extends AbstractArtifactRepository<MavenArtifactId>
{
- public AbstractMavenArtifactRepository(URI root) throws IOException
+ public AbstractMavenArtifactRepository(ArtifactRepositoryId identifier, URI root) throws IOException
{
- super(MavenArtifactId.TYPE, root);
+ super(identifier, root);
}
protected VirtualFile getGroupRoot(String groupId) throws IOException
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -28,7 +28,12 @@
import java.util.Collection;
import java.util.List;
+import org.jboss.profileservice.repository.artifact.AbstractRepositoryId;
import org.jboss.profileservice.spi.repository.Artifact;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryFactory;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
import org.jboss.virtual.VirtualFile;
/**
@@ -36,7 +41,11 @@
* @version $Revision$
*/
public class LocalMavenArtifactRepository extends AbstractMavenArtifactRepository
+ implements ArtifactRepositoryFactory<MavenArtifactId>
{
+
+ /** The artifact repository id. */
+ public static final ArtifactRepositoryId ID = new AbstractRepositoryId("###DEFAULT###", MavenArtifactId.TYPE);
/** The meta data. */
private final MavenArtifactRepositoryMetaData metaData;
@@ -46,19 +55,11 @@
public LocalMavenArtifactRepository(MavenArtifactRepositoryMetaData metaData, URI root) throws IOException
{
- super(root);
+ super(ID, root);
this.metaData = metaData;
initialize();
}
- protected void initialize()
- {
- for(MavenArtifactMetaData artifactId : metaData.getArtifacts())
- {
- artifacts.add(new MavenArtifact(artifactId, this));
- }
- }
-
@Override
public boolean containsArtifact(MavenArtifactId artifactId)
{
@@ -103,10 +104,35 @@
return null;
}
+ /**
+ * Override create artifact repository to only return
+ * this instance of a local maven repository.
+ */
+ @Override
+ public ArtifactRepository<MavenArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
+ ArtifactRepositoryConfiguration configuration) throws IOException
+ {
+ return this;
+ }
+
+ @Override
+ public String getRepositoryType()
+ {
+ return MavenArtifactId.TYPE;
+ }
+
protected void checkConsistent()
{
-
+ // TODO
}
+ protected void initialize()
+ {
+ for(MavenArtifactMetaData artifactId : metaData.getArtifacts())
+ {
+ artifacts.add(new MavenArtifact(artifactId, this));
+ }
+ }
+
}
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.repository.virtual;
+
+import java.io.IOException;
+
+import org.jboss.profileservice.repository.BasicProfileDeployment;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.virtual.VirtualDeployment;
+import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.profileservice.virtual.assembly.AbstractVirtualDeploymentAssembly;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractVirtualDeploymentRepository extends AbstractVirtualDeploymentAssembly
+{
+
+ /**
+ * Create a ProfileDeployment.
+ * TODO - ProfileDeployment should maybe be a virtual deployment?
+ *
+ * @param deployment the virtual deployment descriptor
+ * @return the profile deployment
+ * @throws Exception for any error
+ */
+ public ProfileDeployment createDeployment(VirtualDeployment deployment) throws IOException
+ {
+ if(deployment == null)
+ {
+ throw new IllegalArgumentException("null virtual deployment");
+ }
+ // Assemble the virtual deployment
+ VirtualDeploymentAssemblyContext ctx = assemble(deployment);
+ VirtualFile vf = ctx.getRoot();
+ if(vf == null)
+ {
+ throw new IllegalStateException("Assembled null virtual file");
+ }
+ return new BasicProfileDeployment(vf, ctx);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected VirtualFile getVirtualFile(ArtifactId artifact) throws IOException
+ {
+ return resolveRepository(artifact).getArtifactFile(artifact);
+ }
+
+ /**
+ * Resolve the artifact repository
+ *
+ * @param id the artifact id
+ * @return the artifact repository
+ * @throws IllegalStateException if the repository cannot be resolved
+ */
+ protected abstract ArtifactRepository<ArtifactId> resolveRepository(ArtifactId id);
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualProfileFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualProfileFactory.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualProfileFactory.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -26,63 +26,81 @@
import java.util.List;
import org.jboss.profileservice.profile.metadata.FileRepositorySourceMetaData;
+import org.jboss.profileservice.repository.artifact.AbstractRepositoryId;
+import org.jboss.profileservice.repository.artifact.ArtifactRepositoryManager;
import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
-import org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository;
+import org.jboss.profileservice.repository.artifact.maven.LocalMavenArtifactRepository;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
/**
+ * The abstract virtual profile factory.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public class AbstractVirtualProfileFactory
{
+
+ /** The artifact repository manager. */
+ private ArtifactRepositoryManager repositoryManager;
- /** The virtual deployment repository. */
- private VirtualDeploymentRepository repository;
-
- public void setRepository(VirtualDeploymentRepository repository)
+ /** The maven artifact repository id. */
+ protected static final ArtifactRepositoryId MVN_ID = LocalMavenArtifactRepository.ID;
+
+ /** A unconfigured virtual repository instance. */
+ protected final static VirtualDeploymentRepository UNCONFIGURED = new UnconfiguredVirtualDeploymentRepository();
+
+ public ArtifactRepositoryManager getRepositoryManager()
{
- this.repository = repository;
+ return repositoryManager;
}
- public VirtualDeploymentRepository getRepository()
+ public void setRepositoryManager(ArtifactRepositoryManager repositoryManager)
{
- return repository;
+ this.repositoryManager = repositoryManager;
}
public void start()
{
- if(getRepository() == null)
+ if(getRepositoryManager() == null)
{
- throw new IllegalStateException("virtual deployment repository not set");
+ throw new IllegalStateException("repository manager not injected");
}
}
-
+
protected VirtualDeploymentRepository createRepository(FileRepositorySourceMetaData source) throws Exception
{
- if(source != null && source.getGroup() != null)
+ if(source != null && source.getGroup()!= null)
{
- // FIXME
- ArtifactRepository<ArtifactId> repo = repository.getRepository(new FileArtifactId());
- VirtualFile vf = VFS.getRoot(repo.getConfiguration().getLocation());
- LocalFileArtifactRepository scoped = new LocalFileArtifactRepository(vf, source.getGroup());
- return new GroupedVirtualDeploymentRepository(scoped, repository);
+ // Create the file repository, based on the group
+ ArtifactRepository<ArtifactId> fileRepository = repositoryManager.
+ createArtifactRepository(createFileRepositoryId(source.getGroup()), null);
+ // Create the virtual deployment repository
+ return new DelegatingDeploymentRepository(getRepositoryManager(),
+ fileRepository.getIdentifier(), MVN_ID);
}
- return repository;
+ return UNCONFIGURED;
}
+
+ protected AbstractRepositoryId createFileRepositoryId(String group)
+ {
+ return new AbstractRepositoryId(group, FileArtifactId.TYPE);
+ }
- protected List<VirtualDeployment> getVirtualDeployments(ProfileMetaData metaData)
+ // FIXME
+ protected static List<VirtualDeployment> getVirtualDeployments(ProfileMetaData metaData)
{
List<? extends ProfileDeploymentMetaData> deployments = metaData.getDeployments();
List<VirtualDeployment> virtual = new ArrayList<VirtualDeployment>();
- // TODO ProfileDeployment extends VirtualDeployment ?
+ // TODO ProfileDeploymentMetaData extends VirtualDeployment ?
if(deployments != null && deployments.isEmpty() == false)
{
for(ProfileDeploymentMetaData deployment : deployments)
@@ -99,26 +117,14 @@
}
return virtual;
}
-
- static class GroupedVirtualDeploymentRepository extends VirtualDeploymentRepository
+
+ static class UnconfiguredVirtualDeploymentRepository implements VirtualDeploymentRepository
{
- private LocalFileArtifactRepository scoped;
- private VirtualDeploymentRepository parent;
-
- public GroupedVirtualDeploymentRepository(LocalFileArtifactRepository scoped, VirtualDeploymentRepository parent)
+ @Override
+ public ProfileDeployment createDeployment(VirtualDeployment virtual) throws IOException
{
- this.scoped = scoped;
- this.parent = parent;
+ throw new RuntimeException("repository not configured");
}
-
- public VirtualFile getVirtualFile(ArtifactId artifact) throws IOException
- {
- if(FileArtifactId.TYPE.equals(artifact.getType()))
- {
- return scoped.getArtifactFile((FileArtifactId) artifact);
- }
- return parent.getVirtualFile(artifact);
- }
}
}
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java (from rev 97457, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentRepository.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,102 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.repository.virtual;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.profileservice.repository.artifact.ArtifactRepositoryManager;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
+
+
+/**
+ * The virtual deployment repository.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DelegatingDeploymentRepository extends AbstractVirtualDeploymentRepository implements VirtualDeploymentRepository
+{
+
+ /** The repository ids. */
+ private Map<String, ArtifactRepositoryId> repos = new HashMap<String, ArtifactRepositoryId>();
+
+ /** The artifact repository manager. */
+ private final ArtifactRepositoryManager repositoryManager;
+
+ public DelegatingDeploymentRepository(ArtifactRepositoryManager repositoryManager, ArtifactRepositoryId... repositoryIds)
+ {
+ if(repositoryManager == null)
+ {
+ throw new IllegalArgumentException("null repository manager");
+ }
+ processMappings(repositoryIds);
+ this.repositoryManager = repositoryManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ArtifactRepository<ArtifactId> resolveRepository(ArtifactId artifactId)
+ {
+ ArtifactRepositoryId repositoryId = resolveRepositoryId(artifactId);
+ return resolveRepository(repositoryId);
+ }
+
+ protected ArtifactRepositoryId resolveRepositoryId(ArtifactId artifact)
+ {
+ ArtifactRepositoryId reference = this.repos.get(artifact.getType());
+ if(reference == null)
+ {
+ throw new IllegalArgumentException("failed to find artifact repository reference for " + artifact);
+ }
+ return reference;
+ }
+
+ protected ArtifactRepository<ArtifactId> resolveRepository(ArtifactRepositoryId repositoryId)
+ {
+ ArtifactRepository<ArtifactId> repository = this.repositoryManager.getArtifactRepository(repositoryId);
+ if(repository == null)
+ {
+ throw new IllegalStateException("failed to find repository for repository reference " + repositoryId);
+ }
+ return repository;
+ }
+
+ protected void processMappings(ArtifactRepositoryId... ids)
+ {
+ if(ids == null || ids.length == 0)
+ {
+ throw new IllegalArgumentException("no repository mappings");
+ }
+ for(ArtifactRepositoryId id : ids)
+ {
+ repos.put(id.getType(), id);
+ }
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentProfile.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentProfile.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -32,6 +32,7 @@
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
/**
@@ -94,7 +95,7 @@
{
try
{
- ProfileDeployment deployment = getRepository().createDeployment(virtual);
+ ProfileDeployment deployment = createDeployment(virtual);
this.deployments.put(deployment.getName(), deployment);
}
catch(Exception e)
@@ -170,6 +171,18 @@
}
/**
+ * Create the ProfileDeployment.
+ *
+ * @param virtual the virtual deployment meta data
+ * @return the profile deployment
+ * @throws Exception
+ */
+ protected ProfileDeployment createDeployment(VirtualDeployment virtual) throws Exception
+ {
+ return getRepository().createDeployment(virtual);
+ }
+
+ /**
* Get the virtual deployment repository.
*
* @return the virtual deployment repository
Deleted: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -1,128 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.profileservice.repository.virtual;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.profileservice.repository.BasicProfileDeployment;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.repository.ArtifactId;
-import org.jboss.profileservice.spi.repository.ArtifactRepository;
-import org.jboss.profileservice.spi.virtual.VirtualDeployment;
-import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
-import org.jboss.profileservice.virtual.assembly.AbstractVirtualDeploymentAssembly;
-import org.jboss.virtual.VirtualFile;
-
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class VirtualDeploymentRepository extends AbstractVirtualDeploymentAssembly
-{
-
- /** The repositories. */
- private Map<String, ArtifactRepository<ArtifactId>> repositories = new ConcurrentHashMap<String, ArtifactRepository<ArtifactId>>();
-
- /**
- * Create a ProfileDeployment.
- * TODO - ProfileDeployment should maybe be a virtual deployment?
- *
- * @param deployment the virtual deployment descriptor
- * @return the profile deployment
- * @throws Exception for any error
- */
- public ProfileDeployment createDeployment(VirtualDeployment deployment) throws Exception
- {
- if(deployment == null)
- {
- throw new IllegalArgumentException("null virtual deployment");
- }
- // Assemble the virtual deployment
- VirtualDeploymentAssemblyContext ctx = assemble(deployment);
- VirtualFile vf = ctx.getRoot();
- if(vf == null)
- {
- throw new IllegalStateException("Assembled null virtual file");
- }
- return new BasicProfileDeployment(vf, ctx);
- }
-
- @Override
- public VirtualFile getVirtualFile(ArtifactId artifact) throws IOException
- {
- return getRepository(artifact).getArtifactFile(artifact);
- }
-
- /**
- * Resolve the artifact repository
- *
- * @param artifact the artifact id
- * @return the artifact repository
- * @throws IllegalStateException if there is no associated artifact repository
- */
- public ArtifactRepository<ArtifactId> getRepository(ArtifactId artifact)
- {
- ArtifactRepository<ArtifactId> repository = this.repositories.get(artifact.getType());
- if(repository == null)
- {
- throw new IllegalStateException("failed to find repository for artifact " + artifact);
- }
- return repository;
- }
-
- public void addRepository(ArtifactRepository<ArtifactId> repository)
- {
- if(repository == null)
- throw new IllegalArgumentException("null repository");
- if(repository.getIdentifier() == null)
- throw new IllegalArgumentException("null repository configuration");
- if(repository.getIdentifier().getType() == null)
- throw new IllegalArgumentException("null repository configuration type");
- addRepository(repository.getIdentifier().getType(), repository);
- }
-
- public void addRepository(String type, ArtifactRepository<ArtifactId> repository)
- {
- this.repositories.put(type, repository);
- }
-
- public void removeRepository(ArtifactRepository<ArtifactId> repository)
- {
- if(repository == null)
- throw new IllegalArgumentException("null repository");
- if(repository.getIdentifier() == null)
- throw new IllegalArgumentException("null repository configuration");
- if(repository.getIdentifier().getType() == null)
- throw new IllegalArgumentException("null repository configuration type");
- removeRepository(repository.getIdentifier().getType(), repository);
- }
-
- public void removeRepository(String type, ArtifactRepository<ArtifactId> repository)
- {
- this.repositories.remove(type);
- }
-
-}
-
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualDeploymentAssembly.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualDeploymentAssembly.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualDeploymentAssembly.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -44,7 +44,7 @@
{
/** The assembled context factory. */
- private final AssembledContextFactory assemblyFactory = AssembledContextFactory.getInstance();
+ private static final AssembledContextFactory assemblyFactory = AssembledContextFactory.getInstance();
/**
* Get the virtual file for an artifact.
@@ -53,7 +53,7 @@
* @return the file
* @throws IOException
*/
- public abstract VirtualFile getVirtualFile(ArtifactId artifact) throws IOException;
+ protected abstract VirtualFile getVirtualFile(ArtifactId artifact) throws IOException;
/**
* Assemble a virtual deployment.
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -26,18 +26,19 @@
import org.jboss.profileservice.profile.metadata.ProfilesMetaData;
import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
-import org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository;
import org.jboss.profileservice.repository.artifact.maven.LocalMavenArtifactRepository;
import org.jboss.profileservice.repository.artifact.maven.MavenArtifactId;
import org.jboss.profileservice.repository.artifact.maven.MavenArtifactRepositoryMetaData;
-import org.jboss.profileservice.repository.virtual.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
import org.jboss.test.profileservice.ProfileServiceTestBase;
+import org.jboss.test.profileservice.virtual.support.TestArtifactRepository;
+import org.jboss.test.profileservice.virtual.support.TestVirtualDeploymentRepository;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -72,8 +73,8 @@
protected VirtualDeploymentRepository createRepository(MavenArtifactRepositoryMetaData metaData) throws Exception
{
- VirtualDeploymentRepository repository = new VirtualDeploymentRepository();
- repository.addRepository(FileArtifactId.TYPE, (ArtifactRepository) new LocalFileArtifactRepository(getResource("repository/static").toURI()));
+ TestVirtualDeploymentRepository repository = new TestVirtualDeploymentRepository();
+ repository.addRepository(FileArtifactId.TYPE, (ArtifactRepository) new TestArtifactRepository(getResource("repository/static").toURI()));
repository.addRepository(MavenArtifactId.TYPE, (ArtifactRepository) new LocalMavenArtifactRepository(metaData, getResource("repository").toURI()));
return repository;
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -24,10 +24,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import org.jboss.dependency.plugins.AbstractController;
import org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap;
import org.jboss.profileservice.dependency.LocalProfileServiceDomain;
import org.jboss.profileservice.domain.spi.DomainFeatureNode;
@@ -48,8 +45,6 @@
public class BasicProfileServiceUnitTestCase extends AbstractProfileServiceTest
{
- private final Executor executor = Executors.newCachedThreadPool();
-
public BasicProfileServiceUnitTestCase(String name)
{
super(name);
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestArtifactRepository.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestArtifactRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -25,8 +25,10 @@
import java.net.URI;
import java.net.URL;
+import org.jboss.profileservice.repository.artifact.AbstractRepositoryId;
import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
import org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -40,9 +42,11 @@
public class TestArtifactRepository extends LocalFileArtifactRepository
{
+ protected static ArtifactRepositoryId TEST_ID = new AbstractRepositoryId("Test", FileArtifactId.TYPE);
+
public TestArtifactRepository(URI rootURI) throws IOException
{
- super(rootURI);
+ super(TEST_ID, rootURI);
}
@Override
Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.test.profileservice.virtual.support;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.repository.BasicProfileDeployment;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.virtual.VirtualDeployment;
+import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.profileservice.virtual.assembly.AbstractVirtualDeploymentAssembly;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestVirtualDeploymentRepository extends AbstractVirtualDeploymentAssembly implements VirtualDeploymentRepository
+{
+ /** The repositories. */
+ private Map<String, ArtifactRepository<ArtifactId>> repositories = new ConcurrentHashMap<String, ArtifactRepository<ArtifactId>>();
+
+ /**
+ * Create a ProfileDeployment.
+ * TODO - ProfileDeployment should maybe be a virtual deployment?
+ *
+ * @param deployment the virtual deployment descriptor
+ * @return the profile deployment
+ * @throws Exception for any error
+ */
+ public ProfileDeployment createDeployment(VirtualDeployment deployment) throws IOException
+ {
+ if(deployment == null)
+ {
+ throw new IllegalArgumentException("null virtual deployment");
+ }
+ // Assemble the virtual deployment
+ VirtualDeploymentAssemblyContext ctx = assemble(deployment);
+ VirtualFile vf = ctx.getRoot();
+ if(vf == null)
+ {
+ throw new IllegalStateException("Assembled null virtual file");
+ }
+ return new BasicProfileDeployment(vf, ctx);
+ }
+
+ @Override
+ public VirtualFile getVirtualFile(ArtifactId artifact) throws IOException
+ {
+ return getRepository(artifact).getArtifactFile(artifact);
+ }
+
+ /**
+ * Resolve the artifact repository
+ *
+ * @param artifact the artifact id
+ * @return the artifact repository
+ * @throws IllegalStateException if there is no associated artifact repository
+ */
+ public ArtifactRepository<ArtifactId> getRepository(ArtifactId artifact)
+ {
+ ArtifactRepository<ArtifactId> repository = this.repositories.get(artifact.getType());
+ if(repository == null)
+ {
+ throw new IllegalStateException("failed to find repository for artifact " + artifact);
+ }
+ return repository;
+ }
+
+ public void addRepository(ArtifactRepository<ArtifactId> repository)
+ {
+ if(repository == null)
+ throw new IllegalArgumentException("null repository");
+ if(repository.getIdentifier() == null)
+ throw new IllegalArgumentException("null repository configuration");
+ if(repository.getIdentifier().getType() == null)
+ throw new IllegalArgumentException("null repository configuration type");
+ addRepository(repository.getIdentifier().getType(), repository);
+ }
+
+ public void addRepository(String type, ArtifactRepository<ArtifactId> repository)
+ {
+ this.repositories.put(type, repository);
+ }
+
+ public void removeRepository(ArtifactRepository<ArtifactId> repository)
+ {
+ if(repository == null)
+ throw new IllegalArgumentException("null repository");
+ if(repository.getIdentifier() == null)
+ throw new IllegalArgumentException("null repository configuration");
+ if(repository.getIdentifier().getType() == null)
+ throw new IllegalArgumentException("null repository configuration type");
+ removeRepository(repository.getIdentifier().getType(), repository);
+ }
+
+ public void removeRepository(String type, ArtifactRepository<ArtifactId> repository)
+ {
+ this.repositories.remove(type);
+ }
+
+}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -24,13 +24,14 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.profileservice.repository.virtual.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
import org.jboss.test.profileservice.ProfileServiceTestBase;
import org.jboss.test.profileservice.metadata.support.VirtualRepositoryMetaData;
import org.jboss.test.profileservice.virtual.support.TestArtifactRepository;
+import org.jboss.test.profileservice.virtual.support.TestVirtualDeploymentRepository;
import org.jboss.virtual.VirtualFile;
/**
@@ -50,7 +51,7 @@
protected VirtualDeploymentRepository createRepository(String name) throws Exception
{
- VirtualDeploymentRepository repository = new VirtualDeploymentRepository();
+ TestVirtualDeploymentRepository repository = new TestVirtualDeploymentRepository();
repository.addRepository(createLocalFileArtifactRepo(name));
return repository;
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -31,8 +31,8 @@
import org.jboss.deployers.spi.structure.ContextInfo;
import org.jboss.deployers.spi.structure.StructureMetaData;
import org.jboss.profileservice.deployers.VDFDeploymentBuilder;
-import org.jboss.profileservice.repository.virtual.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
import org.jboss.test.profileservice.metadata.support.VirtualRepositoryMetaData;
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -23,8 +23,8 @@
import java.util.Map;
-import org.jboss.profileservice.repository.virtual.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
import org.jboss.profileservice.version.helpers.NameAndVersionRangeSupport;
import org.jboss.profileservice.virtual.deployment.AbstractVirtualDeployment;
Modified: projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml 2009-12-08 15:36:36 UTC (rev 97546)
@@ -18,7 +18,7 @@
<!-- The bootstrap profile factory -->
<bean name="BootstrapProfileFactory" class="org.jboss.profileservice.profile.bootstrap.BootstrapProfileFactory">
- <property name="repository"><inject bean="VirtualDeploymentRepository" /></property>
+ <property name="repositoryManager"><inject bean="ArtifactRepositoryManager" /></property>
</bean>
<!-- A BasicXMlDeployer plugin -->
@@ -31,9 +31,11 @@
</bean>
<!-- The virtual deployment repository -->
- <bean name="VirtualDeploymentRepository" class="org.jboss.profileservice.repository.virtual.VirtualDeploymentRepository">
+ <bean name="ArtifactRepositoryManager" class="org.jboss.profileservice.repository.artifact.ArtifactRepositoryManager">
<incallback method="addRepository" />
- <uncallback method="removeRepository" />
+ <incallback method="addRepositoryFactory" />
+ <uncallback method="removeRepository" />
+ <uncallback method="removeRepositoryFactory" />
</bean>
<!-- The profile factories -->
@@ -42,14 +44,14 @@
<uncallback method="removeProfileFactory" />
</bean>
- <bean name="FileRepository" class="org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository">
+ <bean name="FileArtifactRepositoryFactory" class="org.jboss.profileservice.repository.artifact.file.FileArtifactRepositoryFactory">
<constructor>
<parameter class="java.net.URI">${jboss.file.repository.url}</parameter>
</constructor>
</bean>
<!--
- <bean name="ArtifactRepository" class="org.jboss.profileservice.repository.artifact.maven.LocalMavenArtifactRepository">
+ <bean name="MavenArtifactRepository" class="org.jboss.profileservice.repository.artifact.maven.LocalMavenArtifactRepository">
<constructor>
<parameter>TODO metadata</parameter>
<parameter class="java.net.URI">${jboss.artifact.repository.url}</parameter>
Modified: projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/core/src/test/resources/system/static/bootstrap/profile.xml 2009-12-08 15:36:36 UTC (rev 97546)
@@ -8,7 +8,7 @@
</bean>
<bean name="Basic Profile Factory" class="org.jboss.profileservice.profile.BasicProfileFactory">
- <property name="repository"><inject bean="VirtualDeploymentRepository" /></property>
+ <property name="repositoryManager"><inject bean="ArtifactRepositoryManager" /></property>
</bean>
<bean name="Legacy Profile Factory" class="org.jboss.profileservice.repository.legacy.LegacyProfileFactory" />
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/VirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/VirtualDeploymentRepository.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/VirtualDeploymentRepository.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.spi;
+
+import java.io.IOException;
+
+import org.jboss.profileservice.spi.virtual.VirtualDeployment;
+
+/**
+ * The virtual deployment repository.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface VirtualDeploymentRepository
+{
+
+ /**
+ * Create a profile deployment based on a virtual
+ * deployment assembly descriptor.
+ *
+ * @param virtual the virtual deployment meta data
+ * @return the profile deployment
+ * @throws IOException
+ */
+ ProfileDeployment createDeployment(VirtualDeployment virtual) throws IOException;
+
+}
+
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryFactory.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryFactory.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryFactory.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.profileservice.spi.repository;
+
+import java.io.IOException;
+
+/**
+ * The artifact repository factory.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ArtifactRepositoryFactory<T extends ArtifactId>
+{
+
+ /**
+ * Get the repository type.
+ * {@link ArtifactRepositoryId#getType()}
+ *
+ * @return the repository type.
+ */
+ String getRepositoryType();
+
+ /**
+ * Create a artifact repository.
+ *
+ * @param repositoryId the repository id
+ * @param configuration the repository configuration
+ * @return the artifact repository
+ * @throws IOException
+ */
+ ArtifactRepository<T> createArtifactRepository(ArtifactRepositoryId repositoryId,
+ ArtifactRepositoryConfiguration configuration) throws IOException;
+
+}
+
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryId.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryId.java 2009-12-08 14:35:30 UTC (rev 97545)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryId.java 2009-12-08 15:36:36 UTC (rev 97546)
@@ -36,6 +36,8 @@
/**
* Get the repository type.
*
+ * {@link ArtifactId#getType()}
+ *
* @return the repository type
*/
String getType();
More information about the jboss-cvs-commits
mailing list