[jboss-cvs] JBossAS SVN: r104678 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/virtual/assembly and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 11 08:36:07 EDT 2010
Author: emuckenhuber
Date: 2010-05-11 08:36:05 -0400 (Tue, 11 May 2010)
New Revision: 104678
Modified:
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/AbstractVirtualProfileFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.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/AbstractVirtualAssemblyContext.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/ImmutableAssemblyContext.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualFileArtifact.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/ClassPathLocationMetaData.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/MetaDataLocationMetaData.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/VirtualMavenArtifactMetaData.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/StructureMetaDataBuilder.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/virtual/VirtualArtifactMetaData.java
Log:
differentiate between artifact types.
Modified: 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 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -22,11 +22,17 @@
package org.jboss.profileservice.repository.virtual;
import java.io.IOException;
+import java.util.Collection;
import org.jboss.profileservice.repository.ProfileDeploymentFactory;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
+import org.jboss.profileservice.spi.deployment.MetaDataAttachmentHolder;
+import org.jboss.profileservice.spi.deployment.MetaDataAttachmentVisitor;
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.VirtualDeploymentMetaData;
import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
import org.jboss.profileservice.virtual.assembly.AbstractVirtualDeploymentAssembly;
@@ -41,6 +47,9 @@
public abstract class AbstractVirtualDeploymentRepository extends AbstractVirtualDeploymentAssembly
{
+ /** The assembled deployment attachment name. */
+ public static final String ASSEMBLED_ATTACHMENT_NAME = VirtualDeploymentAssemblyContext.class.getName();
+
/** The deployment factory. */
private static final ProfileDeploymentFactory deploymentFactory = ProfileDeploymentFactory.getInstance();
@@ -64,8 +73,12 @@
{
throw new IllegalStateException("Assembled null virtual file");
}
+ // Create the deployment
ProfileDeployment profileDeployment = deploymentFactory.createDeployment(vf, deployment);
- profileDeployment.getTransientAttachments().putAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
+ profileDeployment.getTransientAttachments().putAttachment(ASSEMBLED_ATTACHMENT_NAME, ctx);
+ // Extract additional predetermined attachments
+ visitAttachments(profileDeployment);
+ // Return
return profileDeployment;
}
@@ -86,6 +99,70 @@
* @throws IllegalStateException if the repository cannot be resolved
*/
protected abstract ArtifactRepository<ArtifactId> resolveRepository(ArtifactId id);
+
+ /**
+ * Get the virtual deployment repository.
+ *
+ * @return the virtual deployment repository
+ */
+ protected abstract VirtualDeploymentRepository getDeploymentRepository();
+ /**
+ * Extract the additional attachment information based on the deployment meta data.
+ *
+ * @param deployment the profile deployment
+ */
+ protected void visitAttachments(ProfileDeployment deployment)
+ {
+ VirtualDeploymentMetaData deploymentMetaData = deployment.getDeploymentInfo().getMetaData();
+ if(deploymentMetaData instanceof MetaDataAttachmentHolder)
+ {
+ MetaDataAttachmentVisitor visitor = new BasicAttachmentVisitor(deployment, getDeploymentRepository());
+ visitor.visit(MetaDataAttachmentHolder.class.cast(deploymentMetaData));
+ }
+ }
+
+ public static class BasicAttachmentVisitor implements MetaDataAttachmentVisitor, VirtualDeploymentRepository
+ {
+ final ProfileDeployment deployment;
+ final VirtualDeploymentRepository deploymentRepository;
+
+ public BasicAttachmentVisitor(ProfileDeployment deployment, VirtualDeploymentRepository deploymentRepository)
+ {
+ this.deployment = deployment;
+ this.deploymentRepository = deploymentRepository;
+ }
+
+ public DeploymentAttachments getPredeterminedAttachments()
+ {
+ return deployment.getPredeterminedAttachments();
+ }
+
+ public DeploymentAttachments getTransientAttachments()
+ {
+ return deployment.getTransientAttachments();
+ }
+
+ public void visit(MetaDataAttachmentHolder attachmentHolder)
+ {
+ attachmentHolder.visit(this);
+ }
+
+ public ProfileDeployment createDeployment(VirtualDeploymentMetaData virtual) throws IOException
+ {
+ return deploymentRepository.createDeployment(virtual);
+ }
+
+ public Collection<ArtifactRepositoryId> getRepositoryIDs()
+ {
+ return deploymentRepository.getRepositoryIDs();
+ }
+
+ public <T extends ArtifactId> ArtifactRepository<T> resolveArtifactRepository(T artifactId)
+ {
+ return deploymentRepository.resolveArtifactRepository(artifactId);
+ }
+ }
+
}
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 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualProfileFactory.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
import org.jboss.profileservice.config.ProfileServiceConfig;
import org.jboss.profileservice.profile.metadata.FileRepositorySourceConfiguration;
@@ -32,13 +31,11 @@
import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
import org.jboss.profileservice.repository.artifact.file.FileRepositoryConfiguration;
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.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
-import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
/**
@@ -52,9 +49,6 @@
/** The maven artifact repository id. */
protected static final ArtifactRepositoryId MVN_ID = LocalMavenArtifactRepository.REPOSITORY_ID;
-
- /** A unconfigured virtual repository instance. */
- protected final static VirtualDeploymentRepository UNCONFIGURED;
/** The PS config. */
private final ProfileServiceConfig config;
@@ -71,11 +65,6 @@
this.config = config;
}
- static
- {
- UNCONFIGURED = new UnconfiguredVirtualDeploymentRepository();
- }
-
public ArtifactRepositoryManager getRepositoryManager()
{
return repositoryManager;
@@ -129,7 +118,7 @@
fileRepository.getIdentifier(), MVN_ID);
}
}
- return UNCONFIGURED;
+ return new DelegatingDeploymentRepository(getRepositoryManager(), config.getAssemblyConfiguration(), MVN_ID);
}
/**
@@ -153,26 +142,6 @@
{
return new AbstractRepositoryId(group, FileArtifactId.TYPE);
}
-
- static class UnconfiguredVirtualDeploymentRepository implements VirtualDeploymentRepository
- {
-
- public Collection<ArtifactRepositoryId> getRepositoryIDs()
- {
- return Collections.emptySet();
- }
-
- public ArtifactRepository<ArtifactId> resolveArtifactRepository(ArtifactId artifactId)
- {
- return null;
- }
-
- @Override
- public ProfileDeployment createDeployment(VirtualDeploymentMetaData virtual) throws IOException
- {
- throw new RuntimeException("repository not configured");
- }
- }
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/DelegatingDeploymentRepository.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -98,6 +98,11 @@
return resolveRepository(artifactId);
}
+ protected VirtualDeploymentRepository getDeploymentRepository()
+ {
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
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 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/VirtualDeploymentProfile.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -40,7 +40,7 @@
/**
* A immutable profile implementation getting it's deployments from
- * the virtual deployment descriptors.
+ * the virtual deployment meta data.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualAssemblyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualAssemblyContext.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/AbstractVirtualAssemblyContext.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -37,8 +37,8 @@
public abstract class AbstractVirtualAssemblyContext implements Closeable
{
- /** The roots. */
- private final List<String> roots = new ArrayList<String>();
+ private final List<String> metaDataLocations = new ArrayList<String>();
+ private final List<String> classPathLocations = new ArrayList<String>();
/** The child contexts. */
private final List<VirtualDeploymentAssemblyContext> children = new ArrayList<VirtualDeploymentAssemblyContext>();
@@ -48,16 +48,29 @@
return children;
}
- public List<String> getRoots()
+ public List<String> getMetaDataLocations()
{
- return roots;
+ return metaDataLocations;
}
- protected void addRoot(String root)
+ protected void addMetaDataLocation(String path)
{
- roots.add(root);
+ if(this.metaDataLocations.contains(path) == false)
+ {
+ this.metaDataLocations.add(path);
+ }
}
+ public List<String> getClassPathLocations()
+ {
+ return classPathLocations;
+ }
+
+ public void addClassPathLocation(String path)
+ {
+ this.classPathLocations.add(path);
+ }
+
protected void addChild(VirtualDeploymentAssemblyContext ctx)
{
if(ctx != null)
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -28,6 +28,7 @@
import org.jboss.profileservice.spi.virtual.PathRestriction;
import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData.ArtifactType;
import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
@@ -119,7 +120,7 @@
{
targetPath = "";
}
- addArtifact(targetPath, resolved, new RecurseFilter(resolved, artifactId));
+ addArtifact(targetPath, resolved, new RecurseFilter(resolved, artifactId), artifactId.getArtifactType());
}
/**
@@ -130,29 +131,36 @@
* @param filter the include/exclude filter
* @throws IOException for any error
*/
- void addArtifact(String targetPath, final VirtualFile location, final VirtualFileFilter filter) throws IOException
+ void addArtifact(String targetPath, final VirtualFile location, final VirtualFileFilter filter, ArtifactType type) throws IOException
{
if(location.isFile())
{
- boolean isMetaInf = targetPath.startsWith(META_INF);
- targetPath += location.getName();
- getAssemblyRoot().add(targetPath, location);
- if(isMetaInf == false)
+ String name;
+ if(targetPath.isEmpty())
{
- getRoots().add(targetPath);
+ name = location.getName();
}
+ else
+ {
+ name = targetPath + "/" + location.getName();
+ }
+ if(type == ArtifactType.METADATA_LOCATION)
+ {
+ addMetaDataLocation(targetPath);
+ }
+ else if(type == ArtifactType.CLASSPATH_LOCATION)
+ {
+ addClassPathLocation(name);
+ }
+ getAssemblyRoot().add(name, location);
}
else
{
- if(targetPath.isEmpty() == false)
- {
- targetPath = targetPath.endsWith("/") ? targetPath : targetPath + "/";
- }
for(VirtualFile child : location.getChildren())
{
if(filter.accepts(child))
{
- addArtifact(targetPath, child, filter);
+ addArtifact(targetPath, child, filter, type);
}
}
}
@@ -183,7 +191,7 @@
}
public boolean accepts(VirtualFile file)
- {
+ {
boolean matched = false;
String path = file.getPathNameRelativeTo(parent);
if(getIncludes() == null || getIncludes().isEmpty())
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/ImmutableAssemblyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/ImmutableAssemblyContext.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/ImmutableAssemblyContext.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -59,7 +59,7 @@
public void addArtifact(VirtualArtifactMetaData artifact) throws IOException
{
- throw new IllegalStateException("TODO");
+ // throw new IllegalStateException("TODO");
}
@Override
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualDeployment.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -87,7 +87,6 @@
*/
@XmlElements({
@XmlElement(name = "file", type = AbstractVirtualFileArtifact.class)
- // @XmlElement(name = "artifact", type = VirtualMavenArtifactMetaData.class)
})
public VirtualArtifactMetaData getArtifact()
{
@@ -112,6 +111,7 @@
@XmlElements({
@XmlElement(name = "meta-inf", type = MetaDataLocationMetaData.class),
@XmlElement(name = "classpath", type = ClassPathLocationMetaData.class),
+ @XmlElement(name = "file", type = AbstractVirtualFileArtifact.class),
@XmlElement(name = "artifact", type = VirtualMavenArtifactMetaData.class)
})
public List<VirtualArtifactMetaData> getArtifacts()
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualFileArtifact.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualFileArtifact.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/AbstractVirtualFileArtifact.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -23,6 +23,7 @@
import java.util.List;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@@ -36,9 +37,12 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
- at XmlType(propOrder = { "path", "includes", "excludes" })
+ at XmlType(propOrder = { "targetPath", "path", "includes", "excludes" })
public class AbstractVirtualFileArtifact extends FileArtifactId implements VirtualArtifactMetaData
{
+
+ /** The target path. */
+ private String targetPath;
/** The includes. */
private List<PathRestriction> includes;
@@ -51,14 +55,25 @@
//
}
+ protected AbstractVirtualFileArtifact(String targetPath)
+ {
+ super();
+ this.targetPath = targetPath;
+ }
+
/**
* {@inheritDoc}
*/
- @Override
+ @XmlAttribute(name = "target-path")
public String getTargetPath()
{
- return null;
+ return targetPath;
}
+
+ public void setTargetPath(String targetPath)
+ {
+ this.targetPath = targetPath;
+ }
/**
* Get the includes.
@@ -101,6 +116,14 @@
{
this.excludes = excludes;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public ArtifactType getArtifactType()
+ {
+ return ArtifactType.FILE;
+ }
@Override
public String toString()
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/ClassPathLocationMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/ClassPathLocationMetaData.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/ClassPathLocationMetaData.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -30,7 +30,7 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
- at XmlType(propOrder = { "path", "includes", "excludes" })
+ at XmlType(propOrder = { "targetPath", "path", "includes", "excludes" })
public class ClassPathLocationMetaData extends AbstractVirtualFileArtifact
{
@@ -39,5 +39,13 @@
super();
}
+ /**
+ * {@inheritDoc}
+ */
+ public ArtifactType getArtifactType()
+ {
+ return ArtifactType.CLASSPATH_LOCATION;
+ }
+
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/MetaDataLocationMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/MetaDataLocationMetaData.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/MetaDataLocationMetaData.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -21,7 +21,6 @@
*/
package org.jboss.profileservice.virtual.deployment;
-import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
@@ -33,20 +32,21 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
- at XmlType(propOrder = { "path", "includes", "excludes" })
+ at XmlType(propOrder = { "targetPath", "path", "includes", "excludes" })
public class MetaDataLocationMetaData extends AbstractVirtualFileArtifact implements VirtualArtifactMetaData
{
public MetaDataLocationMetaData()
{
- super();
+ super(BasicVirtualAssemblyContext.META_INF);
}
- @Override
- @XmlTransient
- public String getTargetPath()
+ /**
+ * {@inheritDoc}
+ */
+ public ArtifactType getArtifactType()
{
- return BasicVirtualAssemblyContext.META_INF;
+ return ArtifactType.METADATA_LOCATION;
}
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/VirtualMavenArtifactMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/VirtualMavenArtifactMetaData.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/deployment/VirtualMavenArtifactMetaData.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -100,6 +100,14 @@
{
this.excludes = excludes;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public ArtifactType getArtifactType()
+ {
+ return ArtifactType.CLASSPATH_LOCATION;
+ }
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/metadata/test/BasicDomainMetaDataUnitTestCase.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -23,18 +23,15 @@
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import org.jboss.profileservice.dependency.ProfileDependencyContext;
import org.jboss.profileservice.domain.spi.DomainMetaData;
import org.jboss.profileservice.metadata.ProfilesMetaDataFactory;
+import org.jboss.profileservice.profile.metadata.domain.XmlDomainMetaDataRepository;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.dependency.ProfileCapability;
-import org.jboss.profileservice.spi.dependency.ProfileRequirement;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.test.profileservice.ProfileServiceTestBase;
-import org.jboss.test.profileservice.domain.support.DomainMetaDataRepoSupport;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -58,32 +55,16 @@
metaDataFactory.parse(profiles);
URL domain = findResource("metadata/domain/domain1.xml");
- DomainMetaDataRepoSupport support = new DomainMetaDataRepoSupport(domain);
+ XmlDomainMetaDataRepository support = new XmlDomainMetaDataRepository(domain);
DomainMetaData metaData = support.getDomainMetaData();
assertNotNull(metaData);
-
for(ProfileMetaData md : metaDataFactory.getProfiles().values())
{
ProfileDependencyContext ctx = new ProfileDependencyContext(new ProfileKey(md.getName()), md, null);
ctx.visit(md);
profileCtxs.add(ctx);
}
-
-
-
-// AbstractDomainMetaDataVisitor visitor = new AbstractDomainMetaDataVisitor(new LocalProfileServiceDomain(domain, server));
-// for(DomainFeatureNode node : metaData.getFeatures())
-// {
-// visitor.visit(node);
-// }
-// for(ProfileRequirement requirement : visitor.getRequirements())
-// {
-// ProfileKey key = resolve(null, requirement);
-// getLog().debug(requirement + " resolved " + key);
-//
-// }
-//
}
static URL findResource(String name)
@@ -91,31 +72,5 @@
return Thread.currentThread().getContextClassLoader().getResource(name);
}
- protected ProfileKey resolve(ProfileDependencyContext ctx, ProfileRequirement requirement)
- {
- // Resolve the requirements based on the exposed capabilities
- final boolean trace = log.isTraceEnabled();
- for(ProfileDependencyContext child : profileCtxs)
- {
- Collection<ProfileCapability> capabilities = child.getCapabilities();
- if(capabilities != null && capabilities.isEmpty() == false)
- {
- for(ProfileCapability capability : capabilities)
- {
- if(capability.resolves(requirement))
- {
- if(trace)
- {
- log.trace(child.getKey() + ":" + capability + " resolved " + requirement);
- }
- return child.getKey();
- }
- }
- }
- }
- // Unresolved
- return null;
- }
-
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/support/VDFDeploymentBuilder.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -21,9 +21,6 @@
*/
package org.jboss.test.profileservice.support;
-import java.util.ArrayList;
-import java.util.List;
-
import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
@@ -45,18 +42,12 @@
/** The vfs deployment factory. */
private static final VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
- /** The attachment processor. */
- private final List<DeploymentAttachmentsProcessor<Deployment>> attachmentProcessors = new ArrayList<DeploymentAttachmentsProcessor<Deployment>>();
+ private final static StructureMetaDataBuilder structureBuilder = new StructureMetaDataBuilder();
public static VDFDeploymentBuilder getInstance()
{
return instance;
}
-
- protected VDFDeploymentBuilder()
- {
- attachmentProcessors.add(new StructureMetaDataBuilder());
- }
public Deployment createDeployment(ProfileDeployment profileDeployment)
{
@@ -67,21 +58,10 @@
}
else
{
- d = deploymentFactory.createVFSDeployment(profileDeployment.getRoot());
+ d = deploymentFactory.createVFSDeployment(profileDeployment.getName(), profileDeployment.getRoot());
}
- for(DeploymentAttachmentsProcessor<Deployment> processor : attachmentProcessors)
- {
- processor.processDeployment(profileDeployment, d);
- }
+ structureBuilder.processDeployment(profileDeployment, d);
return d;
}
- public void addAttachmentsProcessor(DeploymentAttachmentsProcessor<Deployment> processor)
- {
- synchronized(attachmentProcessors)
- {
- attachmentProcessors.add(processor);
- }
- }
-
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/StructureMetaDataBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/StructureMetaDataBuilder.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/StructureMetaDataBuilder.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -22,7 +22,6 @@
package org.jboss.test.profileservice.virtual.support;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.jboss.deployers.client.spi.Deployment;
@@ -38,7 +37,7 @@
/**
* The structure meta data builder.
*
- * TODO move this out of the profileservice project.
+ * TODO move the tests out of the profileservice project.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -47,6 +46,7 @@
{
/** The deployment factory. */
+ // TODO we don't need a VFS deployment factory here.
private static final DeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
public void processDeployment(ProfileDeployment deployment, Deployment target)
@@ -73,7 +73,7 @@
protected ContextInfo createStructureMetaData(Deployment deployment, String path, BasicVirtualAssemblyContext ctx)
{
- List<String> metaDataLocations = Collections.singletonList(BasicVirtualAssemblyContext.META_INF);
+ List<String> metaDataLocations = ctx.getMetaDataLocations();
List<ClassPathEntry> classPathEntries = getClassPathEntries(ctx);
ContextInfo info = deploymentFactory.addContext(deployment, path, metaDataLocations, classPathEntries);
@@ -91,11 +91,11 @@
protected List<ClassPathEntry> getClassPathEntries(BasicVirtualAssemblyContext ctx)
{
List<ClassPathEntry> entries = new ArrayList<ClassPathEntry>();
- if(ctx.getRoots() != null && ctx.getRoots().isEmpty() == false)
+ if(ctx.getClassPathLocations() != null && ctx.getClassPathLocations().isEmpty() == false)
{
- for(String s : ctx.getRoots())
+ for(String s : ctx.getClassPathLocations())
{
- entries.add(VFSDeploymentFactory.createClassPathEntry(s));
+ entries.add(DeploymentFactory.createClassPathEntry(s));
}
}
return entries;
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 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/StructureMetaDataUnitTestCase.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -115,9 +115,17 @@
protected void assertMetaDataLocations(ContextInfo info)
{
+ assertMetaDataLocations(info, "META-INF");
+ }
+
+ protected void assertMetaDataLocations(ContextInfo info, String... metaDataLocations)
+ {
assertNotNull("null meta data path", info.getMetaDataPath());
- assertEquals("same size", info.getMetaDataPath().size(), 1);
- assertTrue(info.getMetaDataPath().contains(new MetaDataEntryImpl("META-INF")));
+ assertEquals("same size", metaDataLocations.length, info.getMetaDataPath().size());
+ for(String location : metaDataLocations)
+ {
+ assertTrue(info.getMetaDataPath().contains(new MetaDataEntryImpl(location)));
+ }
}
protected void assertClassPathEntries(ContextInfo info, String... paths)
@@ -128,7 +136,7 @@
for(ClassPathEntry entry : info.getClassPath())
generated.add(entry.getPath());
assertEquals("same size" + generated, original.size(), generated.size());
- assertTrue(generated.containsAll(original));
+ assertTrue("expected " + original + " was "+ generated, generated.containsAll(original));
}
protected ProfileDeployment createProfileDeployment(VirtualDeploymentMetaData deployment) throws Exception
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/virtual/VirtualArtifactMetaData.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/virtual/VirtualArtifactMetaData.java 2010-05-11 12:33:10 UTC (rev 104677)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/virtual/VirtualArtifactMetaData.java 2010-05-11 12:36:05 UTC (rev 104678)
@@ -34,6 +34,13 @@
public interface VirtualArtifactMetaData extends ArtifactId
{
+ public enum ArtifactType
+ {
+ METADATA_LOCATION,
+ CLASSPATH_LOCATION,
+ FILE
+ }
+
/**
* Get the target path.
*
@@ -42,6 +49,13 @@
String getTargetPath();
/**
+ * Get the artifact type.
+ *
+ * @return the artifact type
+ */
+ ArtifactType getArtifactType();
+
+ /**
* Get the includes.
*
* @return the includes
@@ -54,6 +68,6 @@
* @return the excludes
*/
List<PathRestriction> getExcludes();
-
+
}
More information about the jboss-cvs-commits
mailing list