[jboss-cvs] JBossAS SVN: r83388 - in trunk/system/src: main/org/jboss/system/server/profile/repository/metadata and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 23 18:45:06 EST 2009
Author: emuckenhuber
Date: 2009-01-23 18:45:05 -0500 (Fri, 23 Jan 2009)
New Revision: 83388
Added:
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
trunk/system/src/resources/parsing-tests/common/profiles/clustering.profile
trunk/system/src/resources/parsing-tests/common/profiles/common.profile
trunk/system/src/resources/parsing-tests/common/profiles/ejb3.profile
trunk/system/src/resources/parsing-tests/common/profiles/jmx.profile
trunk/system/src/resources/parsing-tests/common/profiles/web.profile
trunk/system/src/resources/parsing-tests/config/profiles/default.profile
trunk/system/src/resources/parsing-tests/config/profiles/seam.profile
trunk/system/src/resources/parsing-tests/parsing/
trunk/system/src/resources/parsing-tests/parsing/test.xml
trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileSourceMetaData.java
trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
Removed:
trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml
trunk/system/src/resources/parsing-tests/common/profiles/common.xml
trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml
trunk/system/src/resources/parsing-tests/common/profiles/web.xml
trunk/system/src/resources/parsing-tests/config/profiles/default.xml
trunk/system/src/resources/parsing-tests/config/profiles/seam.xml
Modified:
trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java
trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
Log:
update profileservice
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Set;
-import org.jboss.dependency.spi.DependencyItem;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.profileservice.spi.DeploymentRepository;
@@ -55,7 +54,7 @@
final private DeploymentRepository repository;
/** The profile dependencies */
- private List<DependencyItem> dependencies;
+ List<ProfileKey> subProfiles;
/** Is hot deployment checking enabled */
private volatile boolean hotdeployEnabled = false;
@@ -65,7 +64,7 @@
this(repository, key, null);
}
- public AbstractProfile(DeploymentRepository repository, ProfileKey key, List<DependencyItem> dependencies)
+ public AbstractProfile(DeploymentRepository repository, ProfileKey key, List<ProfileKey> subProfiles)
{
if(key == null)
throw new IllegalArgumentException("Null profile key.");
@@ -74,7 +73,7 @@
this.key = key;
this.repository = repository;
- this.dependencies = dependencies;
+ this.subProfiles = subProfiles;
}
public void addDeployment(VFSDeployment d) throws Exception
@@ -110,6 +109,16 @@
{
return this.key;
}
+
+ public Collection<ProfileKey> getSubProfiles()
+ {
+ return this.subProfiles;
+ }
+
+ public void setSubProfiles(List<ProfileKey> subProfiles)
+ {
+ this.subProfiles = subProfiles;
+ }
public long getLastModified()
{
@@ -172,17 +181,7 @@
{
// nothing here
}
-
- public Collection<DependencyItem> getDependencies()
- {
- return this.dependencies;
- }
- public void setDependencies(List<DependencyItem> dependencies)
- {
- this.dependencies = dependencies;
- }
-
public String toString()
{
StringBuilder builder = new StringBuilder();
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+
+/**
+ * A abstract profile source meta data, which type is based on the
+ * runtime class name.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractProfileSourceMetaData implements ProfileSourceMetaData
+{
+
+ /** The source. */
+ private List<String> sources;
+
+ @XmlTransient
+ public String getType()
+ {
+ return getClass().getName();
+ }
+
+ @XmlElement(name = "source")
+ public List<String> getSources()
+ {
+ return sources;
+ }
+
+ public void setSources(List<String> sources)
+ {
+ this.sources = sources;
+ }
+
+}
+
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicProfileDeploymentMetaData implements ProfileDeploymentMetaData
+{
+
+ /** The deployment name. */
+ private String name;
+
+ @XmlValue
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
+
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicProfileMetaData implements ProfileMetaData
+{
+
+ /** The profile name. */
+ private String name;
+
+ /** The server. */
+ private String server;
+
+ /** The doamin. */
+ private String domain;
+
+ /** The profile sources. */
+ private ProfileSourceMetaData source;
+
+ /** The sub profiles. */
+ private List<SubProfileMetaData> subprofiles;
+
+ /** The deployments. */
+ private List<ProfileDeploymentMetaData> deployments;
+
+ @XmlAttribute(name = "name")
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @XmlAttribute(name = "server")
+ public String getServer()
+ {
+ return server;
+ }
+
+ public void setServer(String server)
+ {
+ this.server = server;
+ }
+
+ @XmlAttribute(name = "domain")
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
+
+ @XmlElements
+ ({
+ @XmlElement(name = "profile-source", type = FilteredProfileSourceMetaData.class),
+ @XmlElement(name = "hotdeployment-source", type = HotDeploymentProfileSourceMetaData.class)
+ })
+ @XmlAnyElement
+ public ProfileSourceMetaData getSource()
+ {
+ return source;
+ }
+
+ public void setSource(ProfileSourceMetaData source)
+ {
+ this.source = source;
+ }
+
+ @XmlElement(name = "sub-profile", type = BasicSubProfileMetaData.class)
+ public List<SubProfileMetaData> getSubprofiles()
+ {
+ return subprofiles;
+ }
+
+ public void setSubprofiles(List<SubProfileMetaData> subprofiles)
+ {
+ this.subprofiles = subprofiles;
+ }
+
+ @XmlElement(name = "deployment", type = BasicProfileDeploymentMetaData.class)
+ public List<ProfileDeploymentMetaData> getDeployments()
+ {
+ return deployments;
+ }
+
+ public void setDeployments(List<ProfileDeploymentMetaData> deployments)
+ {
+ this.deployments = deployments;
+ }
+
+}
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicSubProfileMetaData implements SubProfileMetaData
+{
+
+ /** The name. */
+ private String name;
+
+ /** The server. */
+ private String server;
+
+ /** The doamin. */
+ private String domain;
+
+ @XmlValue
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @XmlAttribute(name = "server")
+ public String getServer()
+ {
+ return server;
+ }
+
+ public void setServer(String server)
+ {
+ this.server = server;
+ }
+
+ @XmlAttribute(name = "domain")
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
+
+}
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A filtered profile source meta data. This is a workaround, that the
+ * we can create a filtered deploymentRepository based on the source
+ * meta data only.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at JBossXmlSchema(namespace="urn:jboss:profileservice:source:filtered:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "profile-source")
+public class FilteredProfileSourceMetaData extends AbstractProfileSourceMetaData
+{
+
+ /** The deployments */
+ List<ProfileDeploymentMetaData> deployments;
+
+ @XmlTransient
+ public List<ProfileDeploymentMetaData> getDeployments()
+ {
+ return deployments;
+ }
+
+ public void setDeployments(List<ProfileDeploymentMetaData> deployments)
+ {
+ this.deployments = deployments;
+ }
+
+}
+
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at JBossXmlSchema(namespace="urn:jboss:profileservice:source:hotdeployment:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "hotdeployment-source")
+public class HotDeploymentProfileSourceMetaData extends AbstractProfileSourceMetaData
+{
+
+}
+
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ImmutableProfileSourceMetaData extends AbstractProfileSourceMetaData
+{
+
+}
+
Added: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profile.repository.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * The a container xml format for profile meta data.
+ *
+ * <profiles xmlns="urn:jboss:profileservice:profiles:1.0" />
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at XmlRootElement(name = "profiles")
+ at JBossXmlSchema(
+ ignoreUnresolvedFieldOrClass=false,
+ namespace= "urn:jboss:profileservice:profiles:1.0",
+ elementFormDefault=XmlNsForm.QUALIFIED,
+ normalizeSpace=true)
+public class ProfilesMetaData implements ProfileKeyMetaData
+{
+ /** The name. */
+ private String name;
+
+ /** The server. */
+ private String server;
+
+ /** The doamin. */
+ private String domain;
+
+ /** The profiles. */
+ private List<ProfileMetaData> profiles;
+
+ @XmlAttribute(name = "name")
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @XmlAttribute(name = "server")
+ public String getServer()
+ {
+ return server;
+ }
+
+ public void setServer(String server)
+ {
+ this.server = server;
+ }
+
+ @XmlAttribute(name = "domain")
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
+
+ @XmlElement(name = "profile", type = BasicProfileMetaData.class)
+ public List<ProfileMetaData> getProfiles()
+ {
+ return profiles;
+ }
+
+ public void setProfiles(List<ProfileMetaData> profiles)
+ {
+ this.profiles = profiles;
+ }
+
+}
+
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -22,10 +22,10 @@
package org.jboss.system.server.profileservice;
import java.lang.annotation.Annotation;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -215,7 +215,7 @@
profileName = server.getConfig().getServerName();
this.profileKey = new ProfileKey(profileName);
- List<Profile> bootstrapProfiles = profileFactory.createProfiles(server);
+ Collection<Profile> bootstrapProfiles = profileFactory.createProfiles(profileKey, null);
for(Profile profile : bootstrapProfiles)
{
profileService.registerProfile(profile);
@@ -255,7 +255,7 @@
try
{
// Release
- profileService.releaseProfile(profileKey);
+ profileService.deactivateProfile(profileKey);
}
catch(Throwable t)
{
@@ -278,7 +278,7 @@
try
{
// Release
- profileService.releaseProfile(key);
+ profileService.deactivateProfile(key);
}
catch(NoSuchProfileException e)
{
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -585,6 +585,6 @@
*/
private VirtualFile getVFforURI(URI uri) throws IOException
{
- return VFS.getCachedFile(uri);
+ return VFS.getRoot(uri);
}
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -359,7 +359,7 @@
VirtualFile vf = this.applicationVFCache.get(uri.toString());
if(vf == null)
{
- vf = VFS.getCachedFile(uri);
+ vf = VFS.getRoot(uri);
this.applicationVFCache.put(uri.toString(), vf);
}
return vf;
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -21,19 +21,19 @@
*/
package org.jboss.system.server.profileservice.repository;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
import org.jboss.system.server.profile.repository.AbstractProfile;
@@ -46,7 +46,6 @@
*/
public abstract class AbstractProfileFactory
{
-
/** The profile map. */
private Map<ProfileKey, ProfileMetaData> profileMap = new HashMap<ProfileKey, ProfileMetaData>();
@@ -55,6 +54,9 @@
/** The deployment repository factory. */
private ProfileRepository profileRepository;
+
+ /** The logger */
+ protected final Logger log = Logger.getLogger(getClass());
public ProfileRepository getProfileRepository()
{
@@ -66,162 +68,150 @@
this.profileRepository = profileRepository;
}
- public ProfileMetaData getProfileMetaData(ProfileKey key)
- {
- return this.profileMap.get(key);
- }
-
/**
- * Create the profile meta data.
+ * Create the meta data required for this profile.
*
- * @param server The Server.
+ * @param key the root profile key.
* @throws Exception
*/
- protected abstract void createProfileMetaData(Server server) throws Exception;
+ protected abstract void createProfileMetaData(ProfileKey key, URL url) throws Exception;
/**
- * Create a list of profiles, based on the profile meta data.
+ * Create the profiles required for this profile.
*
- * @param server the Server.
- * @return a list of profiles.
+ * @param rootKey the root profile key.
+ * @param uri the profile root uri for parsing.
+ * @return a collection of profiles
* @throws Exception
*/
- public List<Profile> createProfiles(Server server) throws Exception
+ public Collection<Profile> createProfiles(ProfileKey rootKey, URL url) throws Exception
{
- // Create the metadata
- createProfileMetaData(server);
- List<Profile> profiles = new ArrayList<Profile>();
-
- // Create profiles for all known stuff
- // TODO should we maybe base this just on a profileKey ?
- for(ProfileKey key : profileMap.keySet())
- {
- ProfileMetaData metaData = profileMap.get(key);
- Profile profile = createProfile(key, metaData);
- profiles.add(profile);
- }
- return profiles;
+ if(rootKey == null)
+ throw new IllegalArgumentException("Null profile key");
+
+ // Create the profile meta data.
+ createProfileMetaData(rootKey, url);
+
+ Map<ProfileKey, Profile> profiles = new HashMap<ProfileKey, Profile>();
+ // Create the real profiles
+ createProfiles(profiles, rootKey);
+
+ return profiles.values();
}
-
+
/**
- * Create a single profile based on the profile meta data.
- * All sub-profiles need to be registered previously as we try to resolve
- * and generate all dependencies for this profile.
+ * Create profiles
*
- * @param key the ProfileKey.
- * @param metaData the profile meta data.
- * @return the profile.
+ * @param profiles the profiles map
+ * @param key the ProfileKey
* @throws Exception
*/
- public Profile createProfile(ProfileKey key, ProfileMetaData metaData) throws Exception
+ public void createProfiles(Map<ProfileKey, Profile> profiles, ProfileKey key) throws Exception
{
- if(key == null)
- throw new IllegalArgumentException("Null profile key.");
- if(metaData == null)
- throw new IllegalArgumentException("Null profile metaData");
+ ProfileMetaData profileMetaData = this.profileMap.get(key);
+ if(profileMetaData == null)
+ throw new IllegalStateException("Could not find metaData for key: " + key);
+
+ List<ProfileKey> subProfiles = new ArrayList<ProfileKey>();
- DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
-
- // Create profile
- AbstractProfile profile = new AbstractProfile(repository, key);
-
- // Create dependencies
- List<DependencyItem> dependencies = new ArrayList<DependencyItem>();
- // Profile dependencies
- createSubProfileDependencies(dependencies, key, metaData);
- // TODO other service dependencies ?
- // createDependencies(dependencies, key, metaData);
- profile.setDependencies(dependencies);
+ // Create the profile
+ createProfile(profiles, subProfiles, key, profileMetaData);
- return profile;
}
-
+
/**
- * Create some dependencies to other profiles based on the sub profile meta data.
+ * Create a Profile with it's sub-profiles.
*
- * @param dependencies the dependency list.
- * @param key the profile key.
- * @param metaData the profile meta data.
+ * @param profiles the profiles map
+ * @param subProfiles the sub-profiles list
+ * @param key the ProfileKey
+ * @param profileMetaData the profile meta data
+ * @throws Exception
*/
- protected void createSubProfileDependencies(List<DependencyItem> dependencies, ProfileKey key, ProfileMetaData metaData)
+ public void createProfile(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfiles, ProfileKey key, ProfileMetaData profileMetaData) throws Exception
{
- if(metaData.getSubprofiles() != null && ! metaData.getSubprofiles().isEmpty())
- {
- for(SubProfileMetaData subProfile : metaData.getSubprofiles())
- {
- ProfileKey IDependOn = new ProfileKey(subProfile.getDomain(), subProfile.getServer(), subProfile.getName());
- // If it's a reference to a <profile>
- if(this.profileMap.containsKey(IDependOn))
- {
- dependencies.add(createDependencyItem(key, IDependOn));
- }
- // Reference to <profiles> with more <profile>
- else if(this.profilesMetaData.containsKey(IDependOn))
- {
- List<ProfileMetaData> subProfileList = this.profilesMetaData.get(IDependOn);
- createSubProfilesDependencies(dependencies, key, subProfileList);
- }
- else
- {
- throw new IllegalStateException("Cannot not resolve profile: "+ IDependOn);
- }
- }
- }
+ // Don't process a profile twice
+ if(profiles.containsKey(key))
+ return;
+
+ if(log.isTraceEnabled())
+ log.trace("Creating profile for key: " + key);
+
+ // First recursively process the sub profiles
+ processSubProfiles(profiles, subProfiles, profileMetaData.getSubprofiles());
+
+ // Start to create the profile
+ DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, profileMetaData);
+
+ // Create the profile
+ AbstractProfile profile = new AbstractProfile(repository, key);
+
+ // Copy the sub-profile keys
+ List<ProfileKey> sub = new ArrayList<ProfileKey>();
+ sub.addAll(subProfiles);
+ profile.setSubProfiles(sub);
+
+ // Add to the profileMap
+ profiles.put(key, profile);
+
+ // FIXME add a implicit dependency for the next
+ if(subProfiles.contains(key) == false)
+ subProfiles.add(key);
}
/**
- * Create dependencies based on the profile dependencies list.
+ * Process the sub-profiles.
*
- * @param dependencies the dependency list.
- * @param key the profile key.
- * @param metaData the profile meta data.
+ * @param profiles the profiles map
+ * @param subProfileKeys the sub-profiles
+ * @param subProfilesMetaData a list of sub-profile metadata
+ * @throws Exception
*/
- protected void createDependencies(List<DependencyItem> dependencies, ProfileKey key, ProfileMetaData metaData)
+ private void processSubProfiles(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<SubProfileMetaData> subProfilesMetaData) throws Exception
{
- // TODO maybe service dependencies with ParentLookup ?
- if(metaData.getDependencies() != null && metaData.getDependencies().isEmpty() == false)
+ if(subProfilesMetaData == null || subProfilesMetaData.isEmpty())
+ return;
+
+ for(SubProfileMetaData subProfile : subProfilesMetaData)
{
- for(Object dependency : metaData.getDependencies())
+ ProfileKey subProfileKey = createProfileKey(subProfile);
+ if(this.profileMap.containsKey(subProfileKey))
{
- DependencyItem item = createDependencyItem(key, dependency);
- dependencies.add(item);
+ createProfile(profiles, subProfileKeys, subProfileKey, this.profileMap.get(subProfileKey));
}
- }
+ else if(this.profilesMetaData.containsKey(subProfileKey))
+ {
+ List<ProfileMetaData> subProfileAliases = this.profilesMetaData.get(subProfileKey);
+ processSubProfileAlias(profiles, subProfileKeys, subProfileAliases);
+ }
+ else
+ {
+ throw new IllegalStateException("Could not resolve profile meta data for key: " + subProfileKey);
+ }
+ }
}
/**
- * Create the dependencies if the sub-profile references to <profiles/>
- * where it can contain more sub-profiles as a dependency.
+ * Process the profiles alias for a sub-profile.
*
- * @param dependencies the dependency list.
- * @param key the profile key.
- * @param subProfileList a list of profiles.
+ * @param profiles the profiles map
+ * @param subProfileKeys the sub-profiles
+ * @param subprofileAliases the profile meta data for the sub-profiles
+ * @throws Exception
*/
- protected void createSubProfilesDependencies(List<DependencyItem> dependencies, ProfileKey key, List<ProfileMetaData> subProfileList)
+ private void processSubProfileAlias(Map<ProfileKey, Profile> profiles, List<ProfileKey> subProfileKeys, List<ProfileMetaData> subprofileAliases) throws Exception
{
- if(subProfileList != null && subProfileList.isEmpty() == false)
+ if(subprofileAliases == null || subprofileAliases.isEmpty())
+ return;
+
+ for(ProfileMetaData metaData : subprofileAliases)
{
- for(ProfileMetaData subProfile : subProfileList)
- {
- ProfileKey IDependOn = new ProfileKey(subProfile.getDomain(), subProfile.getServer(), subProfile.getName());
- dependencies.add(createDependencyItem(key, IDependOn));
- }
+ ProfileKey key = createProfileKey(metaData);
+ createProfile(profiles, subProfileKeys, key, metaData);
}
}
/**
- * Create a DependencyItem.
- *
- * @param key the profile key.
- * @param IDependOn the Object i depend on.
- * @return the dependency item.
- */
- protected DependencyItem createDependencyItem(ProfileKey key, Object IDependOn)
- {
- return new AbstractDependencyItem(key, IDependOn, ControllerState.PRE_INSTALL, ControllerState.INSTALLED);
- }
-
- /**
* Add a profile.
*
* @param key the profile key.
@@ -276,4 +266,8 @@
}
}
-}
+ public static ProfileKey createProfileKey(ProfileKeyMetaData md)
+ {
+ return new ProfileKey(md.getDomain(), md.getServer(), md.getName());
+ }
+}
\ No newline at end of file
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -311,12 +311,12 @@
}
/**
- * Release the profile.
+ * Deactivate the profile.
*
* @param key the profile key.
* @throws NoSuchProfileException if the profile is not active.
*/
- public void releaseProfile(ProfileKey key) throws NoSuchProfileException
+ public void deactivateProfile(ProfileKey key) throws NoSuchProfileException
{
if(key == null)
throw new IllegalArgumentException("Null profile key.");
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -34,8 +34,9 @@
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
import org.jboss.virtual.VirtualFileFilter;
/**
@@ -48,10 +49,10 @@
{
/** The mutable type. */
- public final static String MUTABLE_TYPE = "mutable";
+ public final static String MUTABLE_TYPE = HotDeploymentProfileSourceMetaData.class.getName();
/** The immutable type. */
- public final static String IMMUTABLE_TYPE = "immutable";
+ public final static String IMMUTABLE_TYPE = ImmutableProfileSourceMetaData.class.getName();
/** The repository types. */
public final static Collection<String> types;
@@ -117,26 +118,15 @@
{
this.mainDeployer = mainDeployer;
}
-
- public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+
+ public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileSourceMetaData metaData)
+ throws Exception
{
if(metaData == null)
throw new IllegalArgumentException("Null metaData");
- String repositoryType = null;
- if(metaData.getSources() != null && ! metaData.getSources().isEmpty())
- {
- for( ProfileSourceMetaData source : metaData.getSources())
- {
- // FIXME - check for different source types
- if(repositoryType == null && source.getType() != null)
- {
- repositoryType = source.getType();
- break;
- }
- }
- }
-
+ // Sanity check
+ String repositoryType = metaData.getType();
if(repositoryType == null)
throw new IllegalArgumentException("Null repository type.");
if(types.contains(repositoryType) == false)
@@ -148,7 +138,6 @@
mutable = true;
}
- // create a default deployment repository
return createDeploymentRepository(mutable, key, createUris(metaData));
}
@@ -181,12 +170,12 @@
}
}
- protected URI[] createUris(ProfileMetaData metaData) throws URISyntaxException
+ protected URI[] createUris(ProfileSourceMetaData metaData) throws URISyntaxException
{
List<URI> uris = new ArrayList<URI>();
- for(ProfileSourceMetaData source : metaData.getSources())
+ for(String source : metaData.getSources())
{
- URI uri = new URI(source.getSource());
+ URI uri = new URI(source);
uris.add(uri);
}
return uris.toArray(new URI[uris.size()]);
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -30,21 +30,22 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.profileservice.spi.AttachmentStore;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
import org.jboss.virtual.VirtualFile;
/**
* TODO
*
* Create a filtered deployment repository, based on the deployments
- * of the profile meta data.
+ * of the filtered profile source meta data.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -53,14 +54,14 @@
{
/** The filtered immutable type. */
- public final static String FILTERED_IMMUTABLE_TYPE = "filtered";
+ public final static String[] FACTORY_TYPE = new String[] { FilteredProfileSourceMetaData.class.getName() };
/** The attachment store. */
private AttachmentStore store;
public String[] getTypes()
{
- return new String[] { FILTERED_IMMUTABLE_TYPE };
+ return FACTORY_TYPE;
}
public AttachmentStore getAttachmentStore()
@@ -73,8 +74,17 @@
this.store = store;
}
- public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
+ public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileSourceMetaData metaData)
+ throws Exception
{
+ if(metaData instanceof FilteredProfileSourceMetaData == false)
+ throw new IllegalArgumentException("Wrong profileSource meta data");
+
+ return internalCreateRepository(key, (FilteredProfileSourceMetaData) metaData);
+ }
+
+ protected DeploymentRepository internalCreateRepository(ProfileKey key, FilteredProfileSourceMetaData metaData) throws Exception
+ {
if(metaData == null)
throw new IllegalArgumentException("Null metadata");
@@ -83,7 +93,9 @@
{
for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
{
- deploymentList.add(deployment.getName());
+ String deploymentName = deployment.getName();
+ if(deploymentName != null)
+ deploymentList.add(deploymentName);
}
}
@@ -95,12 +107,12 @@
return repository;
}
- protected URI[] createUris(ProfileMetaData metaData) throws URISyntaxException
+ protected URI[] createUris(ProfileSourceMetaData metaData) throws URISyntaxException
{
List<URI> uris = new ArrayList<URI>();
- for(ProfileSourceMetaData source : metaData.getSources())
+ for(String source : metaData.getSources())
{
- URI uri = new URI(source.getSource());
+ URI uri = new URI(source);
uris.add(uri);
}
return uris.toArray(new URI[uris.size()]);
@@ -124,8 +136,12 @@
// Load deployment names
for(String deploymentName : deploymentNames)
{
+ // Get the deployment content
VirtualFile vf = getDeploymentContent(deploymentName);
- loadApplications(vf);
+ // Load the deployment
+ VFSDeployment deployment = getAttachmentStore().loadDeploymentData(vf);
+ // Add the deployment
+ addDeployment(deployment.getName(), deployment);
}
updateLastModfied();
}
@@ -145,6 +161,5 @@
{
// nothing
}
- }
-
+ }
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileContext.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -24,8 +24,10 @@
import java.util.Collection;
import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
import org.jboss.dependency.spi.ControllerContextActions;
import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.DependencyItem;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
@@ -53,7 +55,7 @@
{
super(getProfileKey(profile), actions);
setMode(ControllerMode.ON_DEMAND);
- addDependencies(profile.getDependencies());
+ createDependencies(profile.getKey(), profile.getSubProfiles());
this.profile = profile;
}
@@ -62,14 +64,22 @@
return this.profile;
}
- private void addDependencies(Collection<DependencyItem> dependencies)
+ private void createDependencies(ProfileKey key, Collection<ProfileKey> subProfiles)
{
- if(dependencies != null && dependencies.isEmpty() == false)
+ if(subProfiles != null && subProfiles.isEmpty() == false)
{
- for(DependencyItem dependency : dependencies)
- getDependencyInfo().addIDependOn(dependency);
+ for(ProfileKey iDependOn : subProfiles)
+ {
+ getDependencyInfo().addIDependOn(createDependencyItem(key, iDependOn));
+ }
}
+
}
+
+ private DependencyItem createDependencyItem(ProfileKey key, ProfileKey iDependOn)
+ {
+ return new AbstractDependencyItem(key, iDependOn, ControllerState.DESCRIBED, ControllerState.INSTALLED);
+ }
@Override
public String toString()
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -23,14 +23,19 @@
import java.io.File;
import java.net.URI;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import org.jboss.bootstrap.spi.Server;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.AbstractProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.BasicSubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
/**
* A profile factory based on a static configuration.
@@ -112,30 +117,28 @@
* @throws Exception
*/
@Override
- protected void createProfileMetaData(Server server) throws Exception
- {
- if(server == null)
- throw new IllegalArgumentException("Null server");
+ protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
+ {
+ if(rootKey == null)
+ throw new IllegalArgumentException("Null root profile key.");
// Create bootstrap profile meta data
ProfileKey bootstrapKey = new ProfileKey(BOOTSTRAP_NAME);
ProfileMetaData bootstrap = createProfileMetaData(
- BOOTSTRAP_NAME, DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE, new URI[] { bootstrapURI }, new String[0]);
+ BOOTSTRAP_NAME, false, new URI[] { bootstrapURI }, new String[0]);
addProfile(bootstrapKey, bootstrap);
// Create deployers profile meta data
ProfileKey deployersKey = new ProfileKey(DEPLOYERS_NAME);
ProfileMetaData deployers = createProfileMetaData(
- DEPLOYERS_NAME, DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE, new URI[] { deployersURI }, new String[] { BOOTSTRAP_NAME });
+ DEPLOYERS_NAME, false, new URI[] { deployersURI }, new String[] { BOOTSTRAP_NAME });
addProfile(deployersKey, deployers);
- // Create ${serverName} profile meta data
- String rootName = server.getConfig().getServerName();
- ProfileKey rootKey = new ProfileKey(rootName);
+ // Create root profile;
URI[] rootURIs = applicationURIs.toArray(new URI[applicationURIs.size()]);
String[] rootSubProfiles = new String[] { BOOTSTRAP_NAME, DEPLOYERS_NAME };
ProfileMetaData root = createProfileMetaData(
- rootName, DefaultDeploymentRepositoryFactory.MUTABLE_TYPE, rootURIs, rootSubProfiles);
+ rootKey.getName(), false, rootURIs, rootSubProfiles);
// Add to profile map
addProfile(rootKey, root);
}
@@ -149,21 +152,19 @@
* @param subProfiles a list of profile dependencies.
* @return the profile meta data.
*/
- protected ProfileMetaData createProfileMetaData(String name, String repositoryType, URI[] uris, String[] subProfiles)
+ protected ProfileMetaData createProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)
{
// Create profile
- ProfileMetaData metaData = new ProfileMetaData();
+ BasicProfileMetaData metaData = new BasicProfileMetaData();
metaData.setName(name);
// Create profile sources
- List<ProfileSourceMetaData> sources = new ArrayList<ProfileSourceMetaData>();
- for(URI uri : uris)
- sources.add(createSource(repositoryType, uri));
- metaData.setSources(sources);
+ ProfileSourceMetaData source = createSource(uris, hotDeployment);
+ metaData.setSource(source);
List<SubProfileMetaData> profileList = new ArrayList<SubProfileMetaData>();
for(String subProfile : subProfiles)
{
- SubProfileMetaData md = new SubProfileMetaData();
+ BasicSubProfileMetaData md = new BasicSubProfileMetaData();
md.setName(subProfile);
profileList.add(md);
}
@@ -179,11 +180,21 @@
* @param uri the uri
* @return the profile source meta data.
*/
- protected ProfileSourceMetaData createSource(String type, URI uri)
+ protected ProfileSourceMetaData createSource(URI[] uris, boolean hotDeployment)
{
- ProfileSourceMetaData source = new ProfileSourceMetaData();
- source.setType(type);
- source.setSource(uri.toString());
+ AbstractProfileSourceMetaData source = null;
+ if(hotDeployment)
+ {
+ source = new HotDeploymentProfileSourceMetaData();
+ }
+ else
+ {
+ source = new ImmutableProfileSourceMetaData();
+ }
+ List<String> sources = new ArrayList<String>();
+ for(URI uri : uris)
+ sources.add(uri.toString());
+ source.setSources(sources);
return source;
}
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -32,6 +32,7 @@
import org.jboss.profileservice.spi.ProfileRepository;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
/**
* The profile repository.
@@ -41,7 +42,7 @@
* the exposed types.
*
* TODO reuse DeploymentRepositories with the same sources ?
- * TODO handle different profileSources in one Profile
+ * TODO check if there are
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -49,7 +50,7 @@
public class TypedProfileRepository implements ProfileRepository
{
/** The default repository type. */
- private static final String DEFAULT_REPOSITORY_TYPE = DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE;
+ private static final String IMMUTABLE_TYPE = DefaultDeploymentRepositoryFactory.IMMUTABLE_TYPE;
/** The repository factories. */
private Map<String, DeploymentRepositoryFactory> repositoryFactories = new ConcurrentHashMap<String, DeploymentRepositoryFactory>();
@@ -82,23 +83,24 @@
if(repository == null)
{
String type = null;
- if(metaData.getSources() == null || metaData.getSources().isEmpty())
- throw new IllegalStateException("No profile sources.");
+ if(metaData.getSource() == null)
+ throw new IllegalStateException("No profile source.");
+
+ // Extract the profile source type
+ type = metaData.getSource().getType();
+ if( type == null )
+ throw new IllegalArgumentException("Null profile source type.");
+
+ ProfileSourceMetaData source = metaData.getSource();
- for(ProfileSourceMetaData source : metaData.getSources())
+ // TODO the filtering should be done by the profile itself!
+ if(source instanceof FilteredProfileSourceMetaData)
{
- if(type == null && source.getType() != null)
- {
- // TODO handle different source types.
- type = source.getType();
- break;
- }
+ ((FilteredProfileSourceMetaData) source).setDeployments(metaData.getDeployments());
}
- if( type == null )
- type = DEFAULT_REPOSITORY_TYPE;
-
- // TODO maybe reuse already created repositories
- repository = createProfileDeploymentRepository(key, type , metaData);
+
+ // TODO check if there is a conflict with hotdeployment repositories
+ repository = createProfileDeploymentRepository(key, type , source);
if(repository != null)
{
this.repositories.put(key, repository);
@@ -107,7 +109,7 @@
return repository;
}
- protected DeploymentRepository createProfileDeploymentRepository(ProfileKey key, String repositoryType, ProfileMetaData metaData) throws Exception
+ protected DeploymentRepository createProfileDeploymentRepository(ProfileKey key, String repositoryType, ProfileSourceMetaData metaData) throws Exception
{
DeploymentRepositoryFactory factory = this.repositoryFactories.get(repositoryType);
if(factory == null)
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -21,16 +21,19 @@
*/
package org.jboss.system.server.profileservice.repository;
+import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.ProfilesMetaData;
-import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
@@ -38,6 +41,7 @@
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
/**
* A profile factory based which generates the ProfileMetaData based on .xml files.
@@ -48,61 +52,81 @@
public class XmlProfileFactory extends AbstractProfileFactory
{
/** The profiles directory name. */
- public final static String PROFILES_DIRECTORY = "profiles";
+ public final static String PROFILES_SUFFIX = ".profile";
+ /** The unmarshaller. */
+ private Unmarshaller unmarshaller;
+
+ /** Profile directories */
+ private Collection<VirtualFile> profileDirectories;
+
/** The schema resolver. */
- private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
/** A xml include filter. */
- private final static VirtualFileFilter xmlIncludeFilter = new XmlIncludeFilter();
+ private final static VirtualFileFilter fileIncludeFilter = new FileIncludeFilter();
- /** The unmarshaller. */
- private Unmarshaller unmarshaller;
+ /** The attachment store uri. */
+ private File attachmentStoreRoot;
- /** The logger. */
- private static final Logger log = Logger.getLogger(XmlProfileFactory.class);
-
static
{
- // TODO namespace and xsd.
- resolver.addClassBinding("", ProfilesMetaData.class);
+ // Add schema bindings
+ resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
+ resolver.addClassBinding("urn:jboss:profileservice:source:filtered:1.0", FilteredProfileSourceMetaData.class);
+ resolver.addClassBinding("urn:jboss:profileservice:source:hotdeployment:1.0", HotDeploymentProfileSourceMetaData.class);
}
+ public XmlProfileFactory(URI[] profileDirectories) throws Exception
+ {
+ if(profileDirectories == null)
+ throw new IllegalArgumentException("Null directories");
+ this.profileDirectories = new ArrayList<VirtualFile>();
+ for(URI uri : profileDirectories)
+ {
+ VirtualFile vf = VFS.getRoot(uri);
+ if(vf == null)
+ throw new IllegalArgumentException("Could not find uri: " + vf);
+ if(vf.isLeaf())
+ throw new IllegalArgumentException("Not a directory: " + vf);
+ this.profileDirectories.add(vf);
+ }
+ }
+
+ public Collection<VirtualFile> getProfileDirectories()
+ {
+ return profileDirectories;
+ }
+
+ public void setProfileDirectories(Collection<VirtualFile> profileDirectories)
+ {
+ this.profileDirectories = profileDirectories;
+ }
+
+ public File getAttachmentStoreRoot()
+ {
+ return attachmentStoreRoot;
+ }
+
+ public void setAttachmentStoreRoot(File attachmentStoreRoot)
+ {
+ this.attachmentStoreRoot = attachmentStoreRoot;
+ }
+
/**
- * Create the profile meta data based on the .xml files found in the folders:
- * - server/${config}/conf/profiles
- * - common/profiles
+ * Create the profile meta data based on the .xml files found in the folders.
*
* @param server The Server.
* @throws Exception
*/
@Override
- protected void createProfileMetaData(Server server) throws Exception
+ protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
{
- // Setup the profile directories
- VirtualFile serverConfig = VFS.getCachedFile(server.getConfig().getServerConfigURL());
- VirtualFile commonDir = VFS.getCachedFile(server.getConfig().getCommonBaseURL());
-
- /** The server/${config}/conf/profiles directory */
- VirtualFile profilesDir = serverConfig.getChild(PROFILES_DIRECTORY);
- /** The common/profiles directory */
- VirtualFile commonProfilesDir = commonDir.getChild(PROFILES_DIRECTORY);
-
// Create the unmarshaller
this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- // Parse the conf/profiles dir
- if(profilesDir != null && profilesDir.exists())
- {
- parseProfiles(profilesDir);
- }
- // Parse the common/profiles dir
- if(commonProfilesDir != null && commonProfilesDir.exists())
- {
- parseProfiles(commonProfilesDir);
- }
- if(profilesDir == null && commonDir == null)
- throw new IllegalArgumentException("No profile directories found.");
+ for(VirtualFile vf : getProfileDirectories())
+ parseProfiles(vf);
}
/**
@@ -114,7 +138,7 @@
*/
protected void parseProfiles(VirtualFile profileDirectory) throws IOException, JBossXBException
{
- List<VirtualFile> fileList = profileDirectory.getChildren(xmlIncludeFilter);
+ List<VirtualFile> fileList = profileDirectory.getChildren(fileIncludeFilter);
if(fileList != null && fileList.isEmpty() == false)
{
for(VirtualFile vf : fileList)
@@ -130,30 +154,21 @@
/**
* Process the <profiles> meta data.
- * FIXME this sets some additional dependencies based on the ordering of xml.
+ * This will add dependencies based on the ordering of the xml.
*
* @param profilesMetaData the profiles meta data
*/
protected void processProfilesMetaData(ProfilesMetaData profilesMetaData)
{
// The <profiles> key
- ProfileKey profilesKey = new ProfileKey(profilesMetaData.getDomain(), profilesMetaData.getServer(), profilesMetaData.getName());
+ ProfileKey profilesKey = createProfileKey(profilesMetaData);
if(profilesMetaData.getProfiles() != null && profilesMetaData.getProfiles().isEmpty() == false)
{
- ProfileKey profileDependencyHack = null;
for(ProfileMetaData profile : profilesMetaData.getProfiles())
{
// The <profile> key
- ProfileKey profileKey = new ProfileKey(profile.getDomain(), profile.getServer(), profile.getName());
-
- // FIXME Add a dependency as subprofile to the profile based on the xml ordering
- if(profileDependencyHack != null)
- {
- addDependency(profileDependencyHack, profile);
- }
-
+ ProfileKey profileKey = createProfileKey(profile);
addProfile(profileKey, profile);
- profileDependencyHack = profileKey;
}
}
// Add the profiles for later resolution
@@ -161,37 +176,6 @@
}
/**
- * Add a dependency to another profile as sub-profile, based on the
- * ProfileKey
- *
- * @param key the profile key.
- * @param metaData the profile meta data.
- */
- protected void addDependency(ProfileKey key, ProfileMetaData metaData)
- {
- if(key == null)
- throw new IllegalArgumentException("Null key.");
- if(metaData == null)
- throw new IllegalArgumentException("Null metaData");
-
- if(log.isTraceEnabled())
- log.trace("Adding sub-profile dependency (" + key + ") for profile: " + metaData.getName());
-
- SubProfileMetaData subProfileDependency = new SubProfileMetaData();
- subProfileDependency.setDomain(key.getDomain());
- subProfileDependency.setServer(key.getServer());
- subProfileDependency.setName(key.getName());
-
- List<SubProfileMetaData> subProfiles = metaData.getSubprofiles();
- if(subProfiles == null)
- {
- subProfiles = new ArrayList<SubProfileMetaData>();
- metaData.setSubprofiles(subProfiles);
- }
- subProfiles.add(subProfileDependency);
- }
-
- /**
* Parse a profile file.
*
* @param vf the virtual file.
@@ -206,11 +190,11 @@
return (ProfilesMetaData) unmarshaller.unmarshal(vf.openStream(), resolver);
}
- private static final class XmlIncludeFilter implements VirtualFileFilter
+ private static final class FileIncludeFilter implements VirtualFileFilter
{
public boolean accepts(VirtualFile file)
{
- return file.getName().endsWith(".xml");
+ return file.getName().endsWith(PROFILES_SUFFIX);
}
}
}
Copied: trunk/system/src/resources/parsing-tests/common/profiles/clustering.profile (from rev 83100, trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/clustering.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/clustering.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="clustering">
+
+ <profile name="clustering-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <deployment>clustering-deployer-jboss-beans.xml</deployment>
+ </profile>
+
+ <profile name="clustering-runtime">
+ <profile-source>
+ <source>${jboss.server.base.url}deploy</source>
+ </profile-source>
+ <deployment>httpha-invoker.sar</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/common/profiles/clustering.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/common/profiles/clustering.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,13 +0,0 @@
-<profiles name="clustering">
-
- <profile name="clustering-deployers">
- <source>${jboss.server.base.url}deployers</source>
- <deployment>clustering-deployer-jboss-beans.xml</deployment>
- </profile>
-
- <profile name="clustering-runtime">
- <source type="mutable">${jboss.server.base.url}deploy</source>
- <deployment>httpha-invoker.sar</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/common/profiles/common.profile (from rev 83100, trunk/system/src/resources/parsing-tests/common/profiles/common.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/common.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/common.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+ <profile name="metadata-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <deployment>metadata-deployer-jboss-beans.xml</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/common/profiles/common.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/common.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/common.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/common/profiles/common.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,8 +0,0 @@
-<profiles>
-
- <profile name="metadata-deployers">
- <source>${jboss.server.base.url}deployers</source>
- <deployment>metadata-deployer-jboss-beans.xml</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/common/profiles/ejb3.profile (from rev 83100, trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/ejb3.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/ejb3.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="ejb3">
+
+ <profile name="ejb3-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <sub-profile>metadata-deployers</sub-profile>
+ <deployment>ejb3.deployer</deployment>
+ </profile>
+
+ <profile name="ejb3-runtime">
+ <profile-source>
+ <source>${jboss.server.base.url}deploy</source>
+ </profile-source>
+ <deployment>ejb3-container-jboss-beans.xml</deployment>
+ <deployment>ejb3-interceptors-aop.xml</deployment>
+ <deployment>ejb3-timer-service.xml</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/common/profiles/ejb3.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/common/profiles/ejb3.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,16 +0,0 @@
-<profiles name="ejb3">
-
- <profile name="ejb3-deployers">
- <source>${jboss.server.base.url}deployers</source>
- <sub-profile>metadata-deployers</sub-profile>
- <deployment>ejb3.deployer</deployment>
- </profile>
-
- <profile name="ejb3-runtime">
- <source>${jboss.server.base.url}deploy</source>
- <deployment>ejb3-container-jboss-beans.xml</deployment>
- <deployment>ejb3-interceptors-aop.xml</deployment>
- <deployment>ejb3-timer-service.xml</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Added: trunk/system/src/resources/parsing-tests/common/profiles/jmx.profile
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/jmx.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/jmx.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="jmx">
+
+ <profile name="bootstrap">
+ <profile-source>
+ <source>${jboss.server.base.url}conf</source>
+ </profile-source>
+ <deployment>jboss-service.xml</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/common/profiles/web.profile (from rev 83100, trunk/system/src/resources/parsing-tests/common/profiles/web.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/web.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/common/profiles/web.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="jboss-web">
+
+ <profile name="jboss-web-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <sub-profile>metadata-deployers</sub-profile>
+ <deployment>jbossweb.deployer</deployment>
+ </profile>
+
+ <profile name="jboss-web-runtime">
+ <profile-source>
+ <source>${jboss.server.base.url}deploy</source>
+ </profile-source>
+ <deployment>jbossweb.sar</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/common/profiles/web.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/common/profiles/web.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/common/profiles/web.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/common/profiles/web.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,14 +0,0 @@
-<profiles name="jboss-web">
-
- <profile name="jboss-web-deployers">
- <source>${jboss.server.base.url}deployers</source>
- <sub-profile>metadata-deployers</sub-profile>
- <deployment>jbossweb.deployer</deployment>
- </profile>
-
- <profile name="jboss-web-runtime">
- <source>${jboss.server.base.url}deploy</source>
- <deployment>jbossweb.sar</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/config/profiles/default.profile (from rev 83100, trunk/system/src/resources/parsing-tests/config/profiles/default.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/default.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/config/profiles/default.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
+
+ <profile name="ignored-profile">
+ <profile-source>
+ <source>${jboss.server.base.url}conf</source>
+ </profile-source>
+ <deployment>someDeployment</deployment>
+ </profile>
+
+ <profile name="default">
+ <profile-source>
+ <source>${jboss.server.base.url}deploy</source>
+ <source>${jboss.server.base.url}deploy2</source>
+ </profile-source>
+ <sub-profile>jmx</sub-profile>
+ <sub-profile>seam</sub-profile>
+ <sub-profile>jboss-web</sub-profile>
+ <sub-profile>clustering</sub-profile>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/config/profiles/default.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/config/profiles/default.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/default.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/config/profiles/default.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,18 +0,0 @@
-<profiles>
-
- <profile name="bootstrap">
- <source>${jboss.server.base.url}conf</source>
- <deployment>jboss-service.xml</deployment>
- </profile>
-
- <profile name="default">
- <source>${jboss.server.base.url}deploy</source>
- <source>${jboss.server.base.url}deploy2</source>
- <sub-profile>seam</sub-profile>
- <sub-profile>jboss-web</sub-profile>
- <sub-profile>clustering</sub-profile>
- <deployment>myDeployment.jar</deployment>
- <deployment>myDeployment12.jar</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Copied: trunk/system/src/resources/parsing-tests/config/profiles/seam.profile (from rev 83100, trunk/system/src/resources/parsing-tests/config/profiles/seam.xml)
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/seam.profile (rev 0)
+++ trunk/system/src/resources/parsing-tests/config/profiles/seam.profile 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="seam">
+
+ <profile name="seam-deployers">
+ <profile-source>
+ <source>${jboss.server.base.url}deployers</source>
+ </profile-source>
+ <sub-profile>ejb3</sub-profile>
+ <deployment>seam.deployer</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Property changes on: trunk/system/src/resources/parsing-tests/config/profiles/seam.profile
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/system/src/resources/parsing-tests/config/profiles/seam.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/config/profiles/seam.xml 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/resources/parsing-tests/config/profiles/seam.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -1,9 +0,0 @@
-<profiles name="seam">
-
- <profile name="seam-deployers">
- <source>${jboss.server.base.url}deployers</source>
- <sub-profile>ejb3</sub-profile>
- <deployment>seam.deployer</deployment>
- </profile>
-
-</profiles>
\ No newline at end of file
Added: trunk/system/src/resources/parsing-tests/parsing/test.xml
===================================================================
--- trunk/system/src/resources/parsing-tests/parsing/test.xml (rev 0)
+++ trunk/system/src/resources/parsing-tests/parsing/test.xml 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,30 @@
+<profiles
+ xmlns="urn:jboss:profileservice:profiles:1.0"
+ name="profiles">
+
+ <profile name="immutable">
+ <profile-source>
+ <source>${jboss.server.home.url}deployers</source>
+ <source>${jboss.server.home.url}conf</source>
+ </profile-source>
+ <sub-profile>ejb3</sub-profile>
+ <deployment>myEjb3Deployment.ear</deployment>
+ </profile>
+
+ <profile name="mutable-source">
+ <hotdeployment-source>
+ <source>${jboss.server.home.url}deploy</source>
+ <source>${jboss.server.home.url}deploy2</source>
+ </hotdeployment-source>
+ <sub-profile>immutable</sub-profile>
+ </profile>
+
+ <profile name="maven-source">
+ <maven-source xmlns="urn:jboss:profileservice:source:maven:1.0">
+ <source>http://repository.jboss.org/maven2</source>
+ </maven-source>
+ <sub-profile>hotdeployment</sub-profile>
+ <deployment>org/jboss/jboss-profileservice/6.0.0-GA/profileservice-spi.jar</deployment>
+ </profile>
+
+</profiles>
\ No newline at end of file
Added: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileSourceMetaData.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileSourceMetaData.java (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MavenProfileSourceMetaData.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.server.profileservice.support;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.system.server.profile.repository.metadata.AbstractProfileSourceMetaData;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at JBossXmlSchema(namespace="urn:jboss:profileservice:source:maven:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "maven-source")
+public class MavenProfileSourceMetaData extends AbstractProfileSourceMetaData
+{
+ /** The sources */
+ List<String> sources;
+
+ @XmlElement(name = "source")
+ public List<String> getSources()
+ {
+ return null;
+ }
+
+ public void setSources(List<String> sources)
+ {
+ this.sources = sources;
+ }
+
+}
+
Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -30,8 +30,11 @@
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileRepository;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
/**
+ * Create a filtered deployment repository
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
@@ -48,7 +51,11 @@
public DeploymentRepository createProfileDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
{
- return repository.createDeploymentRepository(key, metaData);
+ // Fill the filtered source with deployments
+ FilteredProfileSourceMetaData source = (FilteredProfileSourceMetaData) metaData.getSource();
+ source.setDeployments(metaData.getDeployments());
+
+ return repository.createDeploymentRepository(key, source);
}
public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
Added: trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.server.profileservice.test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
+import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BootstrapProfileFactoryUnitTestCase extends AbstractProfileServiceTestBase
+{
+
+ /** The profiles */
+ Map<String, Profile> profileMap;
+
+ public BootstrapProfileFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testParsing() throws Exception
+ {
+ enableTrace("org.jboss.system.server.profileservice.repository");
+
+ // Set the server base url as system property for the repository generation.
+ File serverBaseDir = new File("src/resources/server-root/");
+ System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm());
+
+ // Setup profile locations
+ File f = new File("src/resources/parsing-tests/");
+ File one = new File(f, "config/profiles");
+ File two = new File(f, "common/profiles");
+
+ // A filtered deployment factory
+ FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
+ repositoryFactory.setAttachmentStore(createAttachmentStore());
+ // The xml profile factory
+ AbstractProfileFactory profileFactory = new XmlProfileFactory(
+ new URI[] { one.toURI(), two.toURI() });
+ profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
+
+ // Clear jar suffixes.
+ JarUtils.clearSuffixes();
+
+ // Parse
+ Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null);
+ assertNotNull(profiles);
+
+ // 2 profiles in default.xml
+ // 1 profile in seam.xml
+ // 2 profiles in clustering.xml
+ // 2 profiles in ejb3.xml
+ // 2 profiles in web.xml
+ assertEquals(10, profiles.size());
+
+ this.profileMap = new HashMap<String, Profile>();
+ for(Profile profile : profiles)
+ {
+ assertNotNull(profile.getKey());
+ String name = profile.getKey().getName();
+ assertNotNull(name);
+ this.profileMap.put(name, profile);
+ }
+
+ // Assert Profiles
+ assertProfiles();
+
+ // Try to load the profiles, this will try to resolve the deploymentNames
+ // when loading the filtered repository in serverBaseDir.
+ for(Profile profile : profiles)
+ {
+ profile.create();
+ }
+
+ // TODO assert metadata
+ }
+
+ protected void assertProfiles()
+ {
+ // Assert bootstrap profile
+ assertProfile("bootstrap", 0);
+
+ // Assert ejb3-runtime profile
+ assertProfile("metadata-deployers", 1,
+ new String[] { "bootstrap" } );
+
+ // Assert ejb3-deployers profile
+ assertProfile("ejb3-deployers", 2,
+ new String[] { "metadata-deployers", "bootstrap" } );
+
+ // Assert ejb3-runtime profile
+ assertProfile("ejb3-runtime", 3,
+ new String[] { "ejb3-deployers", "metadata-deployers", "bootstrap" } );
+
+ // Assert seam profile
+ assertProfile("seam-deployers", 4,
+ new String[] { "ejb3-deployers", "ejb3-runtime", "metadata-deployers", "bootstrap" });
+
+ // Assert web-deployers profile
+ assertProfile("jboss-web-deployers", 5,
+ new String[] { "seam-deployers", "ejb3-deployers", "ejb3-runtime", "metadata-deployers", "bootstrap" } );
+
+ // Assert web-runtime profile
+ assertProfile("jboss-web-runtime", 6,
+ new String[] { "jboss-web-deployers",
+ "seam-deployers", "ejb3-deployers", "ejb3-runtime", "metadata-deployers", "bootstrap" } );
+
+ // Assert clustering-deployers
+ assertProfile("clustering-deployers", 7, new String[] {
+ "bootstrap",
+ "metadata-deployers",
+ "ejb3-deployers",
+ "ejb3-runtime",
+ "seam-deployers",
+ "jboss-web-deployers",
+ "jboss-web-runtime"});
+
+ // Assert hasingleton
+ assertProfile("clustering-runtime", 8, new String[] {
+ "bootstrap",
+ "metadata-deployers",
+ "ejb3-deployers",
+ "ejb3-runtime",
+ "seam-deployers",
+ "jboss-web-deployers",
+ "jboss-web-runtime",
+ "clustering-deployers"});
+
+ // Assert default profile
+ assertProfile("default", 9, new String[] {
+ "bootstrap",
+ "metadata-deployers",
+ "ejb3-deployers",
+ "ejb3-runtime",
+ "seam-deployers",
+ "jboss-web-deployers",
+ "jboss-web-runtime",
+ "clustering-deployers",
+ "clustering-runtime"});
+ }
+
+ protected void assertProfile(String name, int dependencySize, String[] dependencyNames)
+ {
+ Profile profile = profileMap.get(name);
+ assertNotNull("Null profile: " + name, profile);
+ assertNotNull("Null dependencies for profile: " + name, profile.getSubProfiles());
+ assertDependenciesSize(dependencySize, profile);
+ assertDependencies(dependencyNames, profile.getSubProfiles());
+ }
+
+ protected void assertProfile(String name, int dependencySize)
+ {
+ assertProfile(name, dependencySize, new String[0]);
+ }
+
+ protected void assertDependenciesSize(int size, Profile profile)
+ {
+ assertEquals("dependency size for profile: " + profile.getKey(), size, profile.getSubProfiles().size());
+ }
+
+ protected void assertDependencies(String[] dependencyNames, Collection<ProfileKey> subProfiles)
+ {
+ if(dependencyNames == null || dependencyNames.length == 0)
+ return;
+
+ List<String> iDependOn = new ArrayList<String>();
+ for(ProfileKey key : subProfiles)
+ {
+ iDependOn.add(key.getName());
+ }
+ // Assert dependency keys
+ for(String name : dependencyNames)
+ {
+ assertTrue("contains name: " + name, iDependOn.contains(name));
+ }
+ }
+
+}
+
Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileParsingUnitTestCase.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -22,163 +22,78 @@
package org.jboss.test.server.profileservice.test;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
-import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
-import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
+import org.jboss.test.server.profileservice.support.MavenProfileSourceMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
/**
+ * Basic xml parsing test case.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public class ProfileParsingUnitTestCase extends AbstractProfileServiceTestBase
{
- /** The profiles */
- Map<String, Profile> profileMap;
+ private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
- public ProfileParsingUnitTestCase(String name)
+ static
{
- super(name);
+ // Add schema bindings
+ resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
+ resolver.addClassBinding("urn:jboss:profileservice:source:filtered:1.0", FilteredProfileSourceMetaData.class);
+ resolver.addClassBinding("urn:jboss:profileservice:source:hotdeployment:1.0", HotDeploymentProfileSourceMetaData.class);
+ resolver.addClassBinding("urn:jboss:profileservice:source:maven:1.0", MavenProfileSourceMetaData.class);
}
- public void testParsing() throws Exception
- {
- enableTrace("org.jboss.system.server.profileservice.repository");
-
- // Set the server base url as system property for the repository generation.
- File serverBaseDir = new File("src/resources/server-root/");
- System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm());
-
- //
- FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
- repositoryFactory.setAttachmentStore(createAttachmentStore());
- AbstractProfileFactory profileFactory = new XmlProfileFactory();
- profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
-
- // Clear jar suffixes.
- JarUtils.clearSuffixes();
-
- // Parse
- List<Profile> profiles = profileFactory.createProfiles(createDefaultServer("default"));
- assertNotNull(profiles);
-
- // 2 profiles in default.xml
- // 1 profile in seam.xml
- // 2 profiles in clustering.xml
- // 2 profiles in ejb3.xml
- // 2 profiles in web.xml
- assertEquals(10, profiles.size());
-
- this.profileMap = new HashMap<String, Profile>();
- for(Profile profile : profiles)
- {
- assertNotNull(profile.getKey());
- String name = profile.getKey().getName();
- assertNotNull(name);
- this.profileMap.put(name, profile);
- }
-
- // Assert Profiles
- assertProfiles();
-
- // Try to load the profiles, this will try to resolve the deploymentNames
- // when loading the filtered repository in serverBaseDir.
- for(Profile profile : profiles)
- {
- profile.create();
- }
-
- // TODO assert metadata
- }
- protected void assertProfiles()
+ public ProfileParsingUnitTestCase(String name)
{
- // Assert bootstrap profile
- assertProfile("bootstrap", 0);
-
- // Assert default profile
- assertProfile("default", 6, new String[] {
- "bootstrap",
- "seam-deployers",
- "jboss-web-deployers",
- "jboss-web-runtime",
- "clustering-deployers",
- "clustering-runtime"});
-
- // Assert seam profile
- assertProfile("seam-deployers", 2,
- new String[] { "ejb3-deployers", "ejb3-runtime" });
-
- // Assert ejb3-deployers profile
- assertProfile("ejb3-deployers", 1,
- new String[] { "metadata-deployers" } );
-
- // Assert ejb3-runtime profile
- assertProfile("ejb3-runtime", 1,
- new String[] { "ejb3-deployers" } );
-
- // Assert web-deployers profile
- assertProfile("jboss-web-deployers", 1,
- new String[] { "metadata-deployers" } );
-
- // Assert web-runtime profile
- assertProfile("jboss-web-runtime", 1,
- new String[] { "jboss-web-deployers" } );
-
- // Assert clustering-deployers
- assertProfile("clustering-deployers", 0);
-
- // Assert hasingleton
- assertProfile("clustering-runtime", 1,
- new String[] { "clustering-deployers" } );
+ super(name);
}
-
- protected void assertProfile(String name, int dependencySize, String[] dependencyNames)
- {
- Profile profile = profileMap.get(name);
- assertNotNull("Null profile: " + name, profile);
- assertNotNull("Null dependencies for profile: " + name, profile.getDependencies());
- assertDependenciesSize(dependencySize, profile);
- assertDependencies(dependencyNames, profile.getDependencies());
- }
-
- protected void assertProfile(String name, int dependencySize)
- {
- assertProfile(name, dependencySize, new String[0]);
- }
-
- protected void assertDependenciesSize(int size, Profile profile)
- {
- assertEquals("dependency size for profile: " + profile.getKey(), size, profile.getDependencies().size());
- }
- protected void assertDependencies(String[] dependencyNames, Collection<DependencyItem> dependencies)
+ public void testParsing() throws Exception
{
- if(dependencyNames == null || dependencyNames.length == 0)
- return;
-
- List<String> idependon = new ArrayList<String>();
- for(DependencyItem item : dependencies)
+ try
{
- ProfileKey key = (ProfileKey) item.getIDependOn();
- assertNotNull(key);
- idependon.add(key.getName());
+ File f = new File("src/resources/parsing-tests/parsing/test.xml");
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ ProfilesMetaData md = (ProfilesMetaData) unmarshaller.unmarshal(f.toURL().openStream(), resolver);
+ assertNotNull(md);
+ assertEquals("profiles", md.getName());
+
+ assertNotNull(md.getProfiles());
+ assertEquals(3, md.getProfiles().size());
+
+ // test immutable
+ ProfileMetaData immutable = md.getProfiles().get(0);
+ assertTrue(immutable.getSource() instanceof FilteredProfileSourceMetaData);
+
+ // test hotdeployment
+ ProfileMetaData hotdeployment = md.getProfiles().get(1);
+ assertTrue(hotdeployment.getSource() instanceof HotDeploymentProfileSourceMetaData);
+
+ // test maven as wildcard
+ ProfileMetaData maven = md.getProfiles().get(2);
+ assertTrue(maven.getSource() instanceof MavenProfileSourceMetaData);
+
+ for(ProfileMetaData profile: md.getProfiles())
+ log.debug(profile.getSource().getClass());
+
}
-
- // Assert dependency keys
- for(String name : dependencyNames)
+ catch(Exception e)
{
- assertTrue("contains name: " + name, idependon.contains(name));
+ getLog().error("failed", e);
+ throw e;
}
}
Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java 2009-01-23 23:43:39 UTC (rev 83387)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java 2009-01-23 23:45:05 UTC (rev 83388)
@@ -22,7 +22,8 @@
package org.jboss.test.server.profileservice.test;
import java.io.File;
-import java.util.List;
+import java.net.URI;
+import java.util.Collection;
import org.jboss.dependency.plugins.AbstractController;
import org.jboss.profileservice.spi.Profile;
@@ -68,17 +69,23 @@
File serverBaseDir = new File("src/resources/server-root/");
System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm());
+ // Setup profile locations
+ File f = new File("src/resources/parsing-tests/");
+ File one = new File(f, "config/profiles");
+ File two = new File(f, "common/profiles");
+
//
FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
repositoryFactory.setAttachmentStore(createAttachmentStore());
- AbstractProfileFactory profileFactory = new XmlProfileFactory();
+ AbstractProfileFactory profileFactory = new XmlProfileFactory(
+ new URI[] { one.toURI(), two.toURI() });
profileFactory.setProfileRepository(createProfileRepository(repositoryFactory));
// Clear jar suffixes.
JarUtils.clearSuffixes();
// Parse
- List<Profile> profiles = profileFactory.createProfiles(createDefaultServer("default"));
+ Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null);
for(Profile profile : profiles)
{
// Register
More information about the jboss-cvs-commits
mailing list