[jboss-cvs] JBossAS SVN: r86685 - in branches/Branch_5_x/system/src: main/org/jboss/system/server/profileservice/repository and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 2 13:53:16 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-04-02 13:53:15 -0400 (Thu, 02 Apr 2009)
New Revision: 86685
Added:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/clustered/
branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/clustered/
Modified:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/clustered/metadata/AbstractSortedMetadataContainer.java
Log:
Copied: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java (from rev 86675, trunk/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java)
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/StaticClusteredProfileFactory.java 2009-04-02 17:53:15 UTC (rev 86685)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.profileservice;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+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.BasicProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.BasicSubProfileMetaData;
+import org.jboss.system.server.profileservice.repository.StaticProfileFactory;
+import org.jboss.system.server.profileservice.repository.clustered.metadata.ClusteredProfileSourceMetaData;
+import org.jboss.system.server.profileservice.repository.clustered.metadata.HotDeploymentClusteredProfileSourceMetaData;
+import org.jboss.system.server.profileservice.repository.clustered.metadata.ImmutableClusteredProfileSourceMetaData;
+
+/**
+ * Expands upon the StaticProfileFactory to include a subprofiles
+ * for farmed content.
+ *
+ * @author Brian Stansberry
+ */
+public class StaticClusteredProfileFactory extends StaticProfileFactory
+{
+ /** The bootstrap profile name. */
+ private static final String BOOTSTRAP_NAME = "bootstrap";
+
+ /** The deployers profile name. */
+ private static final String DEPLOYERS_NAME = "deployers";
+
+ /** The deployers profile name. */
+ private static final String APPLICATIONS_NAME = "applications";
+
+ /** The deploy-hasingleton profile name. */
+ private static final String HASINGLETON_NAME = "deploy-hasingleton";
+
+ /** The farm profile name. */
+ private static final String FARM_NAME = "farm";
+
+ /** The hasingleton uris. */
+ private List<URI> hasingletonURIs;
+
+ /** The farm uris. */
+ private List<URI> farmURIs;
+
+// private String partitionName;
+
+ public List<URI> getHASingletonURIs()
+ {
+ return hasingletonURIs;
+ }
+
+ public void setHASingletonURIs(List<URI> hasingletonURIs)
+ {
+ this.hasingletonURIs = hasingletonURIs;
+ }
+
+ public List<URI> getFarmURIs()
+ {
+ return farmURIs;
+ }
+
+ public void setFarmURIs(List<URI> farmURIs)
+ {
+ this.farmURIs = farmURIs;
+ }
+
+// public String getPartitionName()
+// {
+// return partitionName;
+// }
+//
+// public void setPartitionName(String partitionName)
+// {
+// this.partitionName = partitionName;
+// }
+//
+// @Override
+// public void create() throws Exception
+// {
+// super.create();
+//
+// if (this.farmURIs != null || this.hasingletonURIs != null)
+// {
+// if (this.partitionName == null)
+// {
+// throw new IllegalStateException("Null partition name.");
+// }
+// }
+// }
+
+ /**
+ * Create the legacy profiles, based on the injected uris.
+ *
+ * @param rootKey the key for the root profile.
+ * @throws Exception
+ */
+ @Override
+ 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, false, new URI[] { getBootstrapURI() }, new String[0]);
+ addProfile(bootstrapKey, bootstrap);
+
+ // Create deployers profile meta data
+ ProfileKey deployersKey = new ProfileKey(DEPLOYERS_NAME);
+ ProfileMetaData deployers = createProfileMetaData(
+ DEPLOYERS_NAME, false, new URI[] { getDeployersURI() }, new String[] { BOOTSTRAP_NAME });
+ addProfile(deployersKey, deployers);
+
+ // Create applications profile;
+ ProfileKey applicationsKey = new ProfileKey(APPLICATIONS_NAME);
+ URI[] deployURIs = getApplicationURIs().toArray(new URI[getApplicationURIs().size()]);
+ String[] applicationSubProfiles = new String[] { BOOTSTRAP_NAME, DEPLOYERS_NAME };
+ ProfileMetaData applications = createProfileMetaData(
+ APPLICATIONS_NAME, true, deployURIs, applicationSubProfiles);
+ addProfile(applicationsKey, applications);
+
+ ProfileMetaData farm = null;
+ if (getFarmURIs() != null)
+ {
+ ProfileKey farmKey = new ProfileKey(FARM_NAME);
+ URI[] farmURIs = getFarmURIs().toArray(new URI[getFarmURIs().size()]);
+ String[] farmSubProfiles = new String[] { APPLICATIONS_NAME };
+ farm = createClusteredProfileMetaData(
+ FARM_NAME, true, farmURIs, farmSubProfiles);
+ addProfile(farmKey, farm);
+ }
+
+ String[] rootSubProfiles = farm == null ? new String[]{APPLICATIONS_NAME}
+ : new String[] { FARM_NAME };
+ ProfileMetaData root = createProfileMetaData(
+ rootKey.getName(), true, new URI[0], rootSubProfiles);
+ addProfile(rootKey, root);
+
+ if (getHASingletonURIs() != null)
+ {
+ ProfileKey hasingletonKey = new ProfileKey(HASINGLETON_NAME);
+ URI[] hasingletonURIs = getHASingletonURIs().toArray(new URI[getHASingletonURIs().size()]);
+ // Note HASingleton can't depend on others or it will get undeployed
+ // prematurely
+ String[] hasingletonSubProfiles = new String[0];
+ ProfileMetaData hasingletons = createProfileMetaData(
+ HASINGLETON_NAME, true, hasingletonURIs, hasingletonSubProfiles);
+ addProfile(hasingletonKey, hasingletons);
+ }
+ }
+
+ private ProfileMetaData createClusteredProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)
+ {
+ // Create profile
+ BasicProfileMetaData metaData = new BasicProfileMetaData();
+ metaData.setName(name);
+ // Create profile sources
+ ProfileSourceMetaData source = createClusteredSource(uris, hotDeployment);
+ metaData.setSource(source);
+
+ List<SubProfileMetaData> profileList = new ArrayList<SubProfileMetaData>();
+ for(String subProfile : subProfiles)
+ {
+ BasicSubProfileMetaData md = new BasicSubProfileMetaData();
+ md.setName(subProfile);
+ profileList.add(md);
+ }
+ metaData.setSubprofiles(profileList);
+
+ return metaData;
+ }
+
+ /**
+ * Create a profile repository source meta data.
+ *
+ * @param uris the uris for the repository
+ * @param hotDeployment to create a hotDeployment profile
+ *
+ * @return the profile source meta data.
+ */
+ protected ProfileSourceMetaData createClusteredSource(URI[] uris, boolean hotDeployment)
+ {
+ ClusteredProfileSourceMetaData source = null;
+ if(hotDeployment)
+ {
+ source = new HotDeploymentClusteredProfileSourceMetaData();
+ }
+ else
+ {
+ source = new ImmutableClusteredProfileSourceMetaData();
+ }
+
+// source.setPartitionName(getPartitionName());
+
+ List<String> sources = new ArrayList<String>();
+ for(URI uri : uris)
+ sources.add(uri.toString());
+ source.setSources(sources);
+ return source;
+ }
+
+}
Copied: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/clustered (from rev 86675, trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered)
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/clustered/metadata/AbstractSortedMetadataContainer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/metadata/AbstractSortedMetadataContainer.java 2009-04-02 14:28:40 UTC (rev 86675)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/clustered/metadata/AbstractSortedMetadataContainer.java 2009-04-02 17:53:15 UTC (rev 86685)
@@ -212,7 +212,12 @@
return true;
}
- return sortedItems.equals(other);
+ if (other instanceof Collection)
+ {
+ Collection<?> o = (Collection<?>) other;
+ return sortedItems.size() == o.size() && sortedItems.containsAll(o);
+ }
+ return false;
}
public int hashCode()
Copied: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/clustered (from rev 86676, trunk/system/src/tests/org/jboss/test/server/profileservice/clustered)
More information about the jboss-cvs-commits
mailing list