[jboss-cvs] JBossAS SVN: r93127 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/repository and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 2 08:47:53 EDT 2009
Author: emuckenhuber
Date: 2009-09-02 08:47:50 -0400 (Wed, 02 Sep 2009)
New Revision: 93127
Added:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicRepositoryConfiguration.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactId.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactMetaData.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java
Modified:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java
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/DelegatingArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifact.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/artifact/maven/MavenArtifact.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactReference.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactRepositoryMetaData.java
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/deployment/AbstractVirtualDeploymentRequirement.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/virtual/test/AbstractVirtualAssemblyTestCase.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java
Log:
[JBPROFILE-2] add more artifact meta data.
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/VirtualProfileDeploymentMetaData.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -40,6 +40,9 @@
implements ProfileDeploymentMetaData
{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
@Override
public void visit(ProfileMetaDataVisitor visitor)
{
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicRepositoryConfiguration.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicRepositoryConfiguration.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -0,0 +1,80 @@
+/*
+* 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;
+
+import java.net.URI;
+
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicRepositoryConfiguration implements ArtifactRepositoryConfiguration
+{
+
+ /** The repository type. */
+ private String type;
+
+ /** The repository location. */
+ private URI location;
+
+ /** IsMutable. */
+ private boolean mutable = false;
+
+ public BasicRepositoryConfiguration(String type, URI location)
+ {
+ this(type, location, false);
+ }
+
+ public BasicRepositoryConfiguration(String type, 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 URI getLocation()
+ {
+ return location;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public boolean isMutable()
+ {
+ return mutable;
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -21,14 +21,55 @@
*/
package org.jboss.profileservice.repository.artifact;
+import java.io.IOException;
+
+import org.jboss.profileservice.spi.repository.Artifact;
import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.virtual.VirtualFile;
/**
+ * The abstract artifact.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public abstract class AbstractArtifact implements ArtifactId
+public class AbstractArtifact<T extends ArtifactId> implements Artifact<T>
{
+ private final T identifier;
+ private final ArtifactRepository<T> repository;
+
+ public AbstractArtifact(T identifier, ArtifactRepository<T> repository)
+ {
+ if(identifier == null)
+ {
+ throw new IllegalArgumentException("null identifier");
+ }
+ if(repository == null)
+ {
+ throw new IllegalArgumentException("null repository");
+ }
+ this.identifier = identifier;
+ this.repository = repository;
+ }
+
+ @Override
+ public T getIdentifier()
+ {
+ return this.identifier;
+ }
+
+ @Override
+ public ArtifactRepository<T> getRepository()
+ {
+ return this.repository;
+ }
+
+ public VirtualFile getFile() throws IOException
+ {
+ return getRepository().getArtifactFile(getIdentifier());
+ }
+
}
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactId.java (from rev 93067, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactId.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactId.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -0,0 +1,34 @@
+/*
+* 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 org.jboss.profileservice.spi.repository.ArtifactId;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractArtifactId implements ArtifactId
+{
+
+}
+
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -22,10 +22,12 @@
package org.jboss.profileservice.repository.artifact;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
+import org.jboss.profileservice.repository.BasicRepositoryConfiguration;
import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -36,27 +38,42 @@
public abstract class AbstractArtifactRepository<T extends ArtifactId> implements ArtifactRepository<T>
{
+ /** The repository configuration. */
+ private ArtifactRepositoryConfiguration configuration;
+
/** The repository root. */
private VirtualFile repositoryRoot;
-
- public AbstractArtifactRepository(URL root) throws IOException
+
+ public AbstractArtifactRepository(String type, URI root) throws IOException
{
if(root == null)
{
throw new IllegalArgumentException("null repository root.");
}
this.repositoryRoot = VFS.getRoot(root);
+ this.configuration = new BasicRepositoryConfiguration(type, root);
}
- public VirtualFile getRepositoryRoot()
+ public AbstractArtifactRepository(ArtifactRepositoryConfiguration configuration) throws IOException
{
- return this.repositoryRoot;
+ if(configuration == null)
+ {
+ throw new IllegalArgumentException("null repository configuration");
+ }
+ this.repositoryRoot = VFS.getRoot(configuration.getLocation());
+ this.configuration = configuration;
}
- public boolean containsArtifact(T artifact)
+ @Override
+ public ArtifactRepositoryConfiguration getConfiguration()
{
- return false;
- };
+ return this.configuration;
+ }
+ protected VirtualFile getRepositoryRoot()
+ {
+ return this.repositoryRoot;
+ }
+
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DelegatingArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DelegatingArtifactRepository.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/DelegatingArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -25,11 +25,15 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.jboss.profileservice.spi.repository.Artifact;
import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
import org.jboss.virtual.VirtualFile;
/**
+ * Delegating artifact repository
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
@@ -40,15 +44,26 @@
private Map<String, ArtifactRepository<ArtifactId>> repositories = new ConcurrentHashMap<String, ArtifactRepository<ArtifactId>>();
@Override
+ public ArtifactRepositoryConfiguration getConfiguration()
+ {
+ return null; // TODO
+ }
+
+ @Override
public boolean containsArtifact(ArtifactId artifact)
{
return getRepository(artifact).containsArtifact(artifact);
}
+ public Artifact<ArtifactId> getArtifact(ArtifactId artifactId)
+ {
+ return getRepository(artifactId).getArtifact(artifactId);
+ }
+
@Override
- public VirtualFile getArtifact(ArtifactId artifact) throws IOException
+ public VirtualFile getArtifactFile(ArtifactId artifact) throws IOException
{
- return getRepository(artifact).getArtifact(artifact);
+ return getRepository(artifact).getArtifactFile(artifact);
}
protected ArtifactRepository<ArtifactId> getRepository(ArtifactId artifact)
@@ -59,6 +74,17 @@
return repository;
}
+ public void addRepository( ArtifactRepository<ArtifactId> repository)
+ {
+ if(repository == null)
+ throw new IllegalArgumentException("null repository");
+ if(repository.getConfiguration() == null)
+ throw new IllegalArgumentException("null repository configuration");
+ if(repository.getConfiguration().getType() == null)
+ throw new IllegalArgumentException("null repository configuration type");
+ this.repositories.put(repository.getConfiguration().getType(), repository);
+ }
+
public void addRepository(String type, ArtifactRepository<ArtifactId> repository)
{
this.repositories.put(type, repository);
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifact.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifact.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifact.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -23,13 +23,13 @@
import javax.xml.bind.annotation.XmlAttribute;
-import org.jboss.profileservice.repository.artifact.AbstractArtifact;
+import org.jboss.profileservice.repository.artifact.AbstractArtifactId;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class FileArtifact extends AbstractArtifact
+public class FileArtifact extends AbstractArtifactId
{
/** The type. */
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -22,9 +22,11 @@
package org.jboss.profileservice.repository.artifact.file;
import java.io.IOException;
+import java.net.URI;
import java.net.URL;
import org.jboss.profileservice.repository.artifact.AbstractArtifactRepository;
+import org.jboss.profileservice.spi.repository.Artifact;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -35,14 +37,33 @@
public class LocalFileArtifactRepository extends AbstractArtifactRepository<FileArtifact>
{
- public LocalFileArtifactRepository(URL rootURL) throws IOException
+ public LocalFileArtifactRepository(URI rootURI) throws IOException
{
- super(rootURL);
+ super(FileArtifact.TYPE, rootURI);
}
@Override
- public VirtualFile getArtifact(FileArtifact artifact) throws IOException
+ public boolean containsArtifact(FileArtifact artifact)
{
+ try
+ {
+ return getRepositoryRoot().getChild(artifact.getPath()).exists();
+ }
+ catch(IOException e)
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public Artifact<FileArtifact> getArtifact(FileArtifact artifactId)
+ {
+ return null;
+ }
+
+ @Override
+ public VirtualFile getArtifactFile(FileArtifact artifact) throws IOException
+ {
if(artifact == null)
{
throw new IllegalArgumentException("null artifact");
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -23,7 +23,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
import org.jboss.profileservice.repository.artifact.AbstractArtifactRepository;
import org.jboss.virtual.VirtualFile;
@@ -37,9 +37,9 @@
public abstract class AbstractMavenArtifactRepository extends AbstractArtifactRepository<MavenArtifactId>
{
- public AbstractMavenArtifactRepository(URL root) throws IOException
+ public AbstractMavenArtifactRepository(URI root) throws IOException
{
- super(root);
+ super(MavenArtifactId.TYPE, root);
}
protected VirtualFile getGroupRoot(String groupId) throws IOException
@@ -67,7 +67,7 @@
return artifact;
}
- protected VirtualFile resolveArtifact(MavenArtifact artifact) throws IOException
+ protected VirtualFile resolveArtifactFile(MavenArtifactMetaData artifact) throws IOException
{
VirtualFile artifactIdRoot = getArtifactIdRoot(artifact.getGroupId(), artifact.getArtifactId());
VirtualFile vf = artifactIdRoot.getChild(artifact.getVersion().toString());
@@ -85,7 +85,7 @@
return artifactRoot;
}
- String createArtifactName(MavenArtifact artifact)
+ String createArtifactName(MavenArtifactMetaData artifact)
{
StringBuilder builder = new StringBuilder();
builder.append(artifact.getArtifactId());
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -23,8 +23,11 @@
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.profileservice.spi.repository.Artifact;
import org.jboss.virtual.VirtualFile;
/**
@@ -37,23 +40,55 @@
/** The meta data. */
private final MavenArtifactRepositoryMetaData metaData;
- public LocalMavenArtifactRepository(MavenArtifactRepositoryMetaData metaData, URL root) throws IOException
+ /** The artifacts. */
+ private final List<MavenArtifact> artifacts = new ArrayList<MavenArtifact>();
+
+ public LocalMavenArtifactRepository(MavenArtifactRepositoryMetaData metaData, URI root) throws IOException
{
super(root);
this.metaData = metaData;
+ initialize();
}
+ protected void initialize()
+ {
+ for(MavenArtifactMetaData artifactId : metaData.getArtifacts())
+ {
+ artifacts.add(new MavenArtifact(artifactId, this));
+ }
+ }
+
@Override
- public VirtualFile getArtifact(MavenArtifactId artifactReference) throws IOException
+ public boolean containsArtifact(MavenArtifactId artifactId)
{
- for(MavenArtifact artifact : metaData.getArtifacts())
+ return resolveArtifact(artifactId) != null;
+ }
+
+ @Override
+ public Artifact<MavenArtifactId> getArtifact(MavenArtifactId artifactId)
+ {
+ return resolveArtifact(artifactId);
+ }
+
+ @Override
+ public VirtualFile getArtifactFile(MavenArtifactId artifactId) throws IOException
+ {
+ MavenArtifact artifact = resolveArtifact(artifactId);
+ if(artifact == null)
+ throw new FileNotFoundException("Artifact not found " + artifactId);
+ return resolveArtifactFile(artifact.getIdentifier());
+ }
+
+ protected MavenArtifact resolveArtifact(MavenArtifactId artifactId)
+ {
+ for(MavenArtifact artifact : artifacts)
{
- if(artifactReference.matches(artifact))
+ if(artifactId.matches(artifact.getIdentifier()))
{
- return resolveArtifact(artifact);
+ return artifact;
}
}
- throw new FileNotFoundException("Artifact not found " + artifactReference);
+ return null;
}
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifact.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifact.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifact.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -21,220 +21,26 @@
*/
package org.jboss.profileservice.repository.artifact.maven;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
+import org.jboss.profileservice.repository.artifact.AbstractArtifact;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
-import org.jboss.profileservice.version.helpers.VersionSupport;
-
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class MavenArtifact extends VersionSupport implements MavenArtifactId
+public class MavenArtifact extends AbstractArtifact<MavenArtifactId>
{
- /** The serialVersionUID */
- private static final long serialVersionUID = -4126849949276732212L;
-
- /** The default packaging type. */
- public static final String DEFAULT_PACKAGING = "jar";
-
- /** The group id. */
- private String groupId;
-
- /** The artifact id. */
- private String artifactId;
-
- /** The classifier. */
- private String classifier;
-
- /** The packaging type. */
- private String packagingType;
-
- public MavenArtifact()
+ public MavenArtifact(MavenArtifactMetaData identifier, ArtifactRepository<MavenArtifactId> repository)
{
- packagingType = DEFAULT_PACKAGING;
+ super(identifier, repository);
}
-
- public MavenArtifact(String groupId, String artifactId)
- {
- this(groupId, artifactId, DEFAULT_PACKAGING);
- }
- public MavenArtifact(String groupId, String artifactId, String packaging)
- {
- if(groupId == null)
- throw new IllegalArgumentException("null group id");
- if(artifactId == null)
- throw new IllegalArgumentException("null artifact id");
- if(packaging == null)
- throw new IllegalArgumentException("null packaging");
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.packagingType = packaging;
- }
-
@Override
- @XmlTransient
- public String getType()
+ public MavenArtifactMetaData getIdentifier()
{
- return MavenArtifact.TYPE;
+ return (MavenArtifactMetaData) super.getIdentifier();
}
- /**
- * Get the groud id.
- *
- * @return the groud id
- */
- @XmlAttribute(name = "groupId")
- public String getGroupId()
- {
- return this.groupId;
- }
-
- /**
- * Set the group id.
- *
- * @param groupId the group id
- */
- public void setGroupId(String groupId)
- {
- this.groupId = groupId;
- }
-
- /**
- * Get the artifact id.
- *
- * @return the artifact id
- */
- @XmlAttribute(name = "artifactId")
- public String getArtifactId()
- {
- return this.artifactId;
- }
-
- /**
- * Set the artifact id.
- *
- * @param artifactId the artifact id
- */
- public void setArtifactId(String artifactId)
- {
- this.artifactId = artifactId;
- }
-
- /**
- * Get the classifier.
- *
- * @return the classifier
- */
- @XmlAttribute(name = "classifier")
- public String getClassifier()
- {
- return classifier;
- }
-
- /**
- * Set the classifier.
- *
- * @param classifier the classifier
- */
- public void setClassifier(String classifier)
- {
- this.classifier = classifier;
- }
-
- /**
- * Get the packaging type.
- *
- * @return the packaging type
- */
- @XmlAttribute(name = "packaging")
- public String getPackagingType()
- {
- return packagingType;
- }
-
- /**
- * Set the packaging type.
- *
- * @param packaging the packaging type
- */
- public void setPackagingType(String packaging)
- {
- this.packagingType = packaging;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- if(groupId != null)
- result = 31 * result + groupId.hashCode();
- if(artifactId != null)
- result = 31 * result + artifactId.hashCode();
- if(classifier != null)
- result = 31 * result + classifier.hashCode();
- if(packagingType != null)
- result = 31 * result + packagingType.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if(this == obj)
- return true;
- if(obj == null || obj instanceof MavenArtifact == false)
- return false;
- MavenArtifact other = (MavenArtifact) obj;
- if(equals(this.getGroupId(), other.getGroupId()) == false)
- return false;
- if(equals(this.getArtifactId(), other.getArtifactId()) == false)
- return false;
- if(equals(this.getClassifier(), other.getClassifier()) == false)
- return false;
- if(equals(this.getPackagingType(), other.getPackagingType()) == false)
- return false;
- return super.equals(other);
- }
-
- protected static boolean equals(Object one, Object two)
- {
- if (one == null && two == null)
- return true;
- if (one == null && two != null)
- return false;
- return one.equals(two);
- }
-
- @Override
- public boolean matches(MavenArtifactId artifact)
- {
- return equals(artifact);
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getClass().getSimpleName());
- buffer.append("{");
- toString(buffer);
- buffer.append("}");
- return buffer.toString();
- }
-
- /**
- * For subclasses to override toString()
- *
- * @param buffer the buffer
- */
- protected void toString(StringBuffer buffer)
- {
- buffer.append("group=").append(getGroupId());
- buffer.append(", artifact=").append(getGroupId());
- buffer.append(", version=").append(getVersion().toString());
- }
-
}
+
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactMetaData.java (from rev 93067, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifact.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactMetaData.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactMetaData.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -0,0 +1,240 @@
+/*
+* 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.maven;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.profileservice.version.helpers.VersionSupport;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MavenArtifactMetaData extends VersionSupport implements MavenArtifactId
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -4126849949276732212L;
+
+ /** The default packaging type. */
+ public static final String DEFAULT_PACKAGING = "jar";
+
+ /** The group id. */
+ private String groupId;
+
+ /** The artifact id. */
+ private String artifactId;
+
+ /** The classifier. */
+ private String classifier;
+
+ /** The packaging type. */
+ private String packagingType;
+
+ public MavenArtifactMetaData()
+ {
+ packagingType = DEFAULT_PACKAGING;
+ }
+
+ public MavenArtifactMetaData(String groupId, String artifactId)
+ {
+ this(groupId, artifactId, DEFAULT_PACKAGING);
+ }
+
+ public MavenArtifactMetaData(String groupId, String artifactId, String packaging)
+ {
+ if(groupId == null)
+ throw new IllegalArgumentException("null group id");
+ if(artifactId == null)
+ throw new IllegalArgumentException("null artifact id");
+ if(packaging == null)
+ throw new IllegalArgumentException("null packaging");
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.packagingType = packaging;
+ }
+
+ @Override
+ @XmlTransient
+ public String getType()
+ {
+ return MavenArtifactMetaData.TYPE;
+ }
+
+ /**
+ * Get the groud id.
+ *
+ * @return the groud id
+ */
+ @XmlAttribute(name = "groupId")
+ public String getGroupId()
+ {
+ return this.groupId;
+ }
+
+ /**
+ * Set the group id.
+ *
+ * @param groupId the group id
+ */
+ public void setGroupId(String groupId)
+ {
+ this.groupId = groupId;
+ }
+
+ /**
+ * Get the artifact id.
+ *
+ * @return the artifact id
+ */
+ @XmlAttribute(name = "artifactId")
+ public String getArtifactId()
+ {
+ return this.artifactId;
+ }
+
+ /**
+ * Set the artifact id.
+ *
+ * @param artifactId the artifact id
+ */
+ public void setArtifactId(String artifactId)
+ {
+ this.artifactId = artifactId;
+ }
+
+ /**
+ * Get the classifier.
+ *
+ * @return the classifier
+ */
+ @XmlAttribute(name = "classifier")
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ /**
+ * Set the classifier.
+ *
+ * @param classifier the classifier
+ */
+ public void setClassifier(String classifier)
+ {
+ this.classifier = classifier;
+ }
+
+ /**
+ * Get the packaging type.
+ *
+ * @return the packaging type
+ */
+ @XmlAttribute(name = "packaging")
+ public String getPackagingType()
+ {
+ return packagingType;
+ }
+
+ /**
+ * Set the packaging type.
+ *
+ * @param packaging the packaging type
+ */
+ public void setPackagingType(String packaging)
+ {
+ this.packagingType = packaging;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ if(groupId != null)
+ result = 31 * result + groupId.hashCode();
+ if(artifactId != null)
+ result = 31 * result + artifactId.hashCode();
+ if(classifier != null)
+ result = 31 * result + classifier.hashCode();
+ if(packagingType != null)
+ result = 31 * result + packagingType.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(this == obj)
+ return true;
+ if(obj == null || obj instanceof MavenArtifactMetaData == false)
+ return false;
+ MavenArtifactMetaData other = (MavenArtifactMetaData) obj;
+ if(equals(this.getGroupId(), other.getGroupId()) == false)
+ return false;
+ if(equals(this.getArtifactId(), other.getArtifactId()) == false)
+ return false;
+ if(equals(this.getClassifier(), other.getClassifier()) == false)
+ return false;
+ if(equals(this.getPackagingType(), other.getPackagingType()) == false)
+ return false;
+ return super.equals(other);
+ }
+
+ protected static boolean equals(Object one, Object two)
+ {
+ if (one == null && two == null)
+ return true;
+ if (one == null && two != null)
+ return false;
+ return one.equals(two);
+ }
+
+ @Override
+ public boolean matches(MavenArtifactId artifact)
+ {
+ return equals(artifact);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(getClass().getSimpleName());
+ buffer.append("{");
+ toString(buffer);
+ buffer.append("}");
+ return buffer.toString();
+ }
+
+ /**
+ * For subclasses to override toString()
+ *
+ * @param buffer the buffer
+ */
+ protected void toString(StringBuffer buffer)
+ {
+ buffer.append("group=").append(getGroupId());
+ buffer.append(", artifact=").append(getGroupId());
+ buffer.append(", version=").append(getVersion().toString());
+ }
+
+}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactReference.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactReference.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactReference.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -82,7 +82,7 @@
@XmlTransient
public String getType()
{
- return MavenArtifact.TYPE;
+ return MavenArtifactMetaData.TYPE;
}
/**
@@ -225,10 +225,10 @@
@Override
public boolean matches(MavenArtifactId artifact)
{
- if(artifact == null || artifact instanceof MavenArtifact == false)
+ if(artifact == null || artifact instanceof MavenArtifactMetaData == false)
return false;
- MavenArtifact other = (MavenArtifact) artifact;
+ MavenArtifactMetaData other = (MavenArtifactMetaData) artifact;
if(artifactEquals(other) == false)
return false;
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactRepositoryMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactRepositoryMetaData.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactRepositoryMetaData.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -37,15 +37,15 @@
{
/** The available artifacts. */
- private List<MavenArtifact> artifacts;
+ private List<MavenArtifactMetaData> artifacts;
@XmlElement(name = "artifact")
- public List<MavenArtifact> getArtifacts()
+ public List<MavenArtifactMetaData> getArtifacts()
{
return artifacts;
}
- public void setArtifacts(List<MavenArtifact> artifacts)
+ public void setArtifacts(List<MavenArtifactMetaData> artifacts)
{
this.artifacts = artifacts;
}
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualDeploymentAssembly.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -201,7 +201,7 @@
public VirtualFile getVirtualFile(ArtifactId artifact) throws IOException
{
- return repository.getArtifact(artifact);
+ return repository.getArtifactFile(artifact);
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeploymentRequirement.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -36,12 +36,6 @@
private static final long serialVersionUID = 1L;
@Override
- public boolean isOptional()
- {
- return false;
- }
-
- @Override
public boolean isConsistent(ProfileRequirement other)
{
return isConsistent(other, AbstractVirtualDeploymentRequirement.class);
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-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -68,11 +68,11 @@
}
}
- protected DelegatingArtifactRepository createRepository(MavenArtifactRepositoryMetaData metaData) throws IOException
+ protected DelegatingArtifactRepository createRepository(MavenArtifactRepositoryMetaData metaData) throws Exception
{
DelegatingArtifactRepository repository = new DelegatingArtifactRepository();
- repository.addRepository(FileArtifact.TYPE, (ArtifactRepository) new LocalFileArtifactRepository(getResource("repository/static")));
- repository.addRepository(MavenArtifactId.TYPE, (ArtifactRepository) new LocalMavenArtifactRepository(metaData, getResource("repository")));
+ repository.addRepository(FileArtifact.TYPE, (ArtifactRepository) new LocalFileArtifactRepository(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/virtual/test/AbstractVirtualAssemblyTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/AbstractVirtualAssemblyTestCase.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.profileservice.virtual.test;
-import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -44,10 +43,10 @@
/** The repository location. */
protected final static String REPOSITORY_LOCATION = "repository/static";
- protected ArtifactRepository<ArtifactId> createArtifactRepository(String name) throws IOException
+ protected ArtifactRepository<ArtifactId> createArtifactRepository(String name) throws Exception
{
URL rootURL = getResource(name);
- return (ArtifactRepository) new LocalFileArtifactRepository(rootURL);
+ return (ArtifactRepository) new LocalFileArtifactRepository(rootURL.toURI());
}
protected void assertIncluded(VirtualFile vf, String... children) throws Exception
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -0,0 +1,49 @@
+/*
+* 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;
+
+
+/**
+ * The artifact.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface Artifact<T extends ArtifactId>
+{
+
+ /**
+ * Get the artifact id.
+ *
+ * @return the identifier
+ */
+ T getIdentifier();
+
+ /**
+ * Get the repository.
+ *
+ * @return the repository
+ */
+ ArtifactRepository<T> getRepository();
+
+}
+
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java 2009-09-02 12:41:49 UTC (rev 93126)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepository.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -26,11 +26,20 @@
import org.jboss.virtual.VirtualFile;
/**
+ * The artifact repository.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public interface ArtifactRepository<T extends ArtifactId>
{
+
+ /**
+ * Get the repository configuration.
+ *
+ * @return the configuration
+ */
+ ArtifactRepositoryConfiguration getConfiguration();
/**
* Checks whether this repository provides the specified
@@ -42,13 +51,21 @@
boolean containsArtifact(T artifact);
/**
- * Get a artifact from the repository.
+ * Get the artifact meta data.
*
+ * @param artifactId the artifact id
+ * @return the artifact
+ */
+ Artifact<T> getArtifact(T artifactId);
+
+ /**
+ * Get the artifact file from the repository.
+ *
* @param artifact the artifact
* @return the virtual file
* @throws IOException
*/
- VirtualFile getArtifact(T artifact) throws IOException;
+ VirtualFile getArtifactFile(T artifact) throws IOException;
}
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/ArtifactRepositoryConfiguration.java 2009-09-02 12:47:50 UTC (rev 93127)
@@ -0,0 +1,57 @@
+/*
+* 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.net.URI;
+
+/**
+ * The artifact repository configuration.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ArtifactRepositoryConfiguration
+{
+
+ /**
+ * Get the repository type.
+ *
+ * @return the repository type
+ */
+ String getType();
+
+ /**
+ * Get the repository location.
+ *
+ * @return the location
+ */
+ URI getLocation();
+
+ /**
+ * Returns <code>true</code> if this repository can be modified.
+ *
+ * @return whether this repository is mutable or not
+ */
+ boolean isMutable();
+
+}
+
More information about the jboss-cvs-commits
mailing list