[jboss-cvs] JBossAS SVN: r63679 - in projects/microcontainer/trunk: deployers-client-spi and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 27 11:56:18 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-27 11:56:18 -0400 (Wed, 27 Jun 2007)
New Revision: 63679
Added:
projects/microcontainer/trunk/deployers-client-spi/
projects/microcontainer/trunk/deployers-client-spi/.classpath
projects/microcontainer/trunk/deployers-client-spi/.project
projects/microcontainer/trunk/deployers-client-spi/pom.xml
projects/microcontainer/trunk/deployers-client-spi/src/
projects/microcontainer/trunk/deployers-client-spi/src/main/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeployerClient.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeploymentFactory.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeploymentException.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeployments.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/MissingDependency.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/main/
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/main/MainDeployer.java
projects/microcontainer/trunk/deployers-client-spi/src/resources/
Log:
Import refactored deployers code
Added: projects/microcontainer/trunk/deployers-client-spi/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/.classpath (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/.classpath 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-core-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-managed"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: projects/microcontainer/trunk/deployers-client-spi/.project
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/.project (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/.project 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-deployers-client-spi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/microcontainer/trunk/deployers-client-spi/pom.xml
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/pom.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/pom.xml 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-microcontainer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-deployers-client-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Deployers Client SPI</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Deployers Client SPI</description>
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeployerClient.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeployerClient.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeployerClient.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.client.spi;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.DeploymentState;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.util.graph.Graph;
+
+/**
+ * DeployerClient.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeployerClient
+{
+ /**
+ * Get the top level deployments
+ *
+ * @return the top level deployments
+ */
+ Collection<Deployment> getTopLevel();
+
+ /**
+ * Get a deployment
+ *
+ * @param name the name of the deployment
+ * @return the deployment or null if not found
+ */
+ Deployment getDeployment(String name);
+
+ /**
+ * Add a deployment
+ *
+ * @param deployment the deployment
+ * @throws DeploymentException for any error
+ */
+ void addDeployment(Deployment deployment) throws DeploymentException;
+
+ /**
+ * Remove a deployment
+ *
+ * @param deployment the deployment to remove
+ * @return false when the context was previously unknown
+ * @throws DeploymentException for any error
+ */
+ boolean removeDeployment(Deployment deployment) throws DeploymentException;
+
+ /**
+ * Remove a deployment by name
+ *
+ * @param name the name of the deployment
+ * @return false when the context was previously unknown
+ * @throws DeploymentException for any error
+ */
+ boolean removeDeployment(String name) throws DeploymentException;
+
+ /**
+ * Process the outstanding deployments.
+ */
+ void process();
+
+ /**
+ * Deploy a deployment
+ *
+ * @param deployment the deployment
+ * @throws DeploymentException for any error
+ */
+ void deploy(Deployment deployment) throws DeploymentException;
+
+ /**
+ * Undeploy a deployment
+ *
+ * @param deployment the deployment
+ * @return true when the deployment was undeployed
+ * @throws DeploymentException for any error
+ */
+ boolean undeploy(Deployment deployment) throws DeploymentException;
+
+ /**
+ * Check all the deployments are complete
+ *
+ * @throws DeploymentException when some deployment is not complete
+ */
+ void checkComplete() throws DeploymentException;
+
+ /**
+ * Check a single deployment is complete
+ *
+ * @param deployment the deployment
+ * @throws DeploymentException when the deployment is not complete
+ */
+ void checkComplete(Deployment deployment) throws DeploymentException;
+
+ /**
+ * Check a single deployment is complete
+ *
+ * @param name the deployment name
+ * @throws DeploymentException when the deployment is not complete
+ */
+ void checkComplete(String name) throws DeploymentException;
+
+ /**
+ * Undeploy a deployment by name
+ *
+ * @param name the name of the deployment
+ * @return true when the deployment was undeployed
+ * @throws DeploymentException for any error
+ */
+ boolean undeploy(String name) throws DeploymentException;
+
+ /**
+ * Get a the state of deployment
+ *
+ * @param name the name of the deployment
+ * @return the deployment state
+ */
+ DeploymentState getDeploymentState(String name);
+
+ /**
+ * Get the managed objects for a deployment context. This is a
+ * mapping of the attachment names to the associated ManagedObject.
+ *
+ * @param name the name of the deployment
+ * @return the managed object map keyed by the attachment names.
+ * @throws DeploymentException for any error
+ */
+ Map<String, ManagedObject> getManagedObjects(String name) throws DeploymentException;
+
+ /**
+ * Get the graph of managed objects starting with the top-level deployment associated with name.
+ *
+ * @param name - the name of the top-level DeploymentContext to process.
+ * @return the graph of managed objects for the top-level DeploymentContex and its children.
+ * @throws DeploymentException
+ */
+ Graph<Map<String, ManagedObject>> getDeepManagedObjects(String name) throws DeploymentException;
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/Deployment.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.client.spi;
+
+import java.io.Serializable;
+
+import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
+
+/**
+ * Deployment.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Deployment extends PredeterminedManagedObjectAttachments, Serializable
+{
+ /**
+ * Get the deployment name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Get the simple name
+ *
+ * @return the name
+ */
+ String getSimpleName();
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeploymentFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeploymentFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/DeploymentFactory.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployers.client.spi;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.attachments.AttachmentsFactory;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
+import org.jboss.deployers.spi.structure.ClassPathEntry;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
+
+/**
+ * DeploymentFactory.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentFactory
+{
+ /**
+ * Add a context to a deployment
+ *
+ * @param context the context
+ * @param path the path
+ * @return the context info
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public ContextInfo addContext(PredeterminedManagedObjectAttachments context, String path)
+ {
+ StructureMetaData structure = assureStructure(context);
+ ContextInfo result = StructureMetaDataFactory.createContextInfo(path);
+ structure.addContext(result);
+ return result;
+ }
+
+ /**
+ * Add a context to a deployment
+ *
+ * @param context the context
+ * @param path the path
+ * @param classPath the classpath
+ * @return the context info
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public ContextInfo addContext(PredeterminedManagedObjectAttachments context, String path, List<ClassPathEntry> classPath)
+ {
+ StructureMetaData structure = assureStructure(context);
+ ContextInfo result = StructureMetaDataFactory.createContextInfo(path, classPath);
+ structure.addContext(result);
+ return result;
+ }
+
+ /**
+ * Add a context to a deployment
+ *
+ * @param context the context
+ * @param path the path
+ * @param metaDataPath the meta data path
+ * @param classPath the classpath
+ * @return the context info
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public ContextInfo addContext(PredeterminedManagedObjectAttachments context, String path, String metaDataPath, List<ClassPathEntry> classPath)
+ {
+ StructureMetaData structure = assureStructure(context);
+ ContextInfo result = StructureMetaDataFactory.createContextInfo(path, metaDataPath, classPath);
+ structure.addContext(result);
+ return result;
+ }
+
+ /**
+ * Create a new classpath entry
+ *
+ * @param path the path
+ * @return the classpath entry
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ClassPathEntry createClassPathEntry(String path)
+ {
+ return StructureMetaDataFactory.createClassPathEntry(path, null);
+ }
+
+ /**
+ * Create a new classpath
+ *
+ * @param path the path
+ * @return the classpath
+ * @throws IllegalArgumentException for a null path
+ */
+ public static List<ClassPathEntry> createClassPath(String path)
+ {
+ return Collections.singletonList(createClassPathEntry(path));
+ }
+
+ /**
+ * Create a new classpath entry
+ *
+ * @param path the path
+ * @param suffixes the suffixes
+ * @return the classpath entry
+ * @throws IllegalArgumentException for a null path
+ */
+ public static ClassPathEntry createClassPathEntry(String path, String suffixes)
+ {
+ return StructureMetaDataFactory.createClassPathEntry(path, suffixes);
+ }
+
+ /**
+ * Create a new classpath
+ *
+ * @param path the path
+ * @param suffixes the suffixes
+ * @return the classpath
+ * @throws IllegalArgumentException for a null path
+ */
+ public static List<ClassPathEntry> createClassPath(String path, String suffixes)
+ {
+ return Collections.singletonList(createClassPathEntry(path, suffixes));
+ }
+
+ /**
+ * Assure the context has a predetermined structure
+ *
+ * @param context the context
+ * @return the structure
+ */
+ protected static StructureMetaData assureStructure(PredeterminedManagedObjectAttachments context)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null context");
+
+ MutableAttachments mutable;
+
+ Attachments attachments = context.getPredeterminedManagedObjects();
+
+ // Nothing predetermined yet
+ if (attachments == null)
+ {
+ mutable = AttachmentsFactory.createMutableAttachments();;
+ context.setPredeterminedManagedObjects(mutable);
+ }
+ // Some predetermined but needs to be made mutable
+ else if (attachments instanceof MutableAttachments == false)
+ {
+ mutable = AttachmentsFactory.createMutableAttachments();
+ Map<String, Object> map = attachments.getAttachments();
+ if (map != null)
+ mutable.setAttachments(map);
+ context.setPredeterminedManagedObjects(mutable);
+ }
+ else
+ {
+ mutable = (MutableAttachments) attachments;
+ }
+
+ StructureMetaData structure = mutable.getAttachment(StructureMetaData.class);
+ // No previous structure
+ if (structure == null)
+ {
+ structure = StructureMetaDataFactory.createStructureMetaData();
+ mutable.addAttachment(StructureMetaData.class, structure);
+ }
+ return structure;
+ }
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeploymentException.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeploymentException.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeploymentException.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,157 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.client.spi;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * IncompleteDeploymentException.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class IncompleteDeploymentException extends DeploymentException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1433292979582684692L;
+
+ /** Incomplete deployments */
+ private IncompleteDeployments incompleteDeployments;
+
+ /**
+ * For serialization
+ */
+ public IncompleteDeploymentException()
+ {
+ }
+
+ /**
+ * Create a new IncompleteDeploymentException.
+ *
+ * @param incompleteDeployments the incomplete deployments
+ * @throws IllegalArgumentException for null incompleteDeployments
+ */
+ public IncompleteDeploymentException(IncompleteDeployments incompleteDeployments)
+ {
+ if (incompleteDeployments == null)
+ throw new IllegalArgumentException("Null incompleteDeployments");
+ this.incompleteDeployments = incompleteDeployments;
+ }
+
+ /**
+ * Get the incompleteDeployments.
+ *
+ * @return the incompleteDeployments.
+ */
+ public IncompleteDeployments getIncompleteDeployments()
+ {
+ return incompleteDeployments;
+ }
+
+ // TODO Some of the calculations done in this method should be done upfront in IncompleteDeployments instead!
+ @Override
+ public String getMessage()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):\n");
+
+ // Display all the missing deployers
+ Collection<String> deploymentsMissingDeployers = incompleteDeployments.getDeploymentsMissingDeployer();
+ if (deploymentsMissingDeployers.isEmpty() == false)
+ {
+ buffer.append("\n*** DEPLOYMENTS MISSING DEPLOYERS: Name\n\n");
+ for (String name : deploymentsMissingDeployers)
+ buffer.append(name).append('\n');
+ }
+
+ // Display all the incomplete deployments
+ Map<String, Throwable> deploymentsInError = incompleteDeployments.getDeploymentsInError();
+ if (deploymentsInError.isEmpty() == false)
+ {
+ buffer.append("\n*** DEPLOYMENTS IN ERROR: Name -> Error\n\n");
+ for (Map.Entry<String, Throwable> entry : deploymentsInError.entrySet())
+ buffer.append(entry.getKey()).append(" -> ").append(entry.getValue().toString()).append("\n\n");
+ }
+
+ // Popluate the potential root causes
+ Map<String, String> rootCauses = new HashMap<String, String>();
+
+ // Missing dependencies are root causes
+ Map<String, Set<MissingDependency>> contextsMissingDependencies = incompleteDeployments.getContextsMissingDependencies();
+ if (contextsMissingDependencies.isEmpty() == false)
+ {
+ for (Map.Entry<String, Set<MissingDependency>> entry : contextsMissingDependencies.entrySet())
+ {
+ for (MissingDependency dependency : entry.getValue())
+ rootCauses.put(dependency.getDependency(), dependency.getActualState());
+ }
+ }
+
+ // Errors are root causes
+ Map<String, Throwable> contextsInError = incompleteDeployments.getContextsInError();
+ if (contextsInError.isEmpty() == false)
+ {
+ for (Map.Entry<String, Throwable> entry : contextsInError.entrySet())
+ {
+ Throwable t = entry.getValue();
+ if (t == null)
+ rootCauses.put(entry.getKey(), "** UNKNOWN ERROR **");
+ else
+ rootCauses.put(entry.getKey(), t.toString());
+ }
+ }
+
+ // Display all the missing dependencies
+ if (contextsMissingDependencies.isEmpty() == false)
+ {
+ buffer.append("\n*** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}\n\n");
+ for (Map.Entry<String, Set<MissingDependency>> entry : contextsMissingDependencies.entrySet())
+ {
+ String name = entry.getKey();
+ buffer.append(name).append("\n");
+ for (MissingDependency dependency : entry.getValue())
+ {
+ buffer.append(" -> ").append(dependency.getDependency());
+ buffer.append('{').append(dependency.getRequiredState());
+ buffer.append(':').append(dependency.getActualState()).append("}");
+ buffer.append("\n");
+ }
+ buffer.append('\n');
+
+ // It is not a root cause if it has missing dependencies
+ rootCauses.remove(name);
+ }
+ }
+ if (rootCauses.isEmpty() == false)
+ {
+ buffer.append("\n*** CONTEXTS IN ERROR: Name -> Error\n\n");
+ for (Map.Entry<String, String> entry : rootCauses.entrySet())
+ buffer.append(entry.getKey()).append(" -> ").append(entry.getValue()).append("\n\n");
+ }
+ return buffer.toString();
+ }
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeployments.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeployments.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/IncompleteDeployments.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,206 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.client.spi;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * IncompleteDeployments.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class IncompleteDeployments implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8413355643801749950L;
+
+ /** Deployments in error */
+ private Map<String, Throwable> deploymentsInError;
+
+ /** Deployments missing deployer */
+ private Collection<String> deploymentsMissingDeployer;
+
+ /** Contexts in error */
+ private Map<String, Throwable> contextsInError;
+
+ /** Contexts missing dependencies */
+ private Map<String, Set<MissingDependency>> contextsMissingDependencies;
+
+ /**
+ * Create a new IncompleteDeploymentException.
+ *
+ * @param deploymentsInError deployments in error
+ * @param deploymentsMissingDeployer deployments missing deployer
+ * @param contextsInError contexts in error
+ * @param contextsMissingDependencies contexts missing dependencies
+ */
+ public IncompleteDeployments(Map<String, Throwable> deploymentsInError, Collection<String> deploymentsMissingDeployer, Map<String, Throwable> contextsInError, Map<String, Set<MissingDependency>> contextsMissingDependencies)
+ {
+ if (deploymentsInError != null && deploymentsInError.isEmpty() == false)
+ {
+ this.deploymentsInError = new TreeMap<String, Throwable>();
+ this.deploymentsInError.putAll(deploymentsInError);
+ }
+ if (deploymentsMissingDeployer != null && deploymentsMissingDeployer.isEmpty() == false)
+ {
+ this.deploymentsMissingDeployer = new TreeSet<String>();
+ this.deploymentsMissingDeployer.addAll(deploymentsMissingDeployer);
+ }
+ if (contextsInError != null && contextsInError.isEmpty() == false)
+ {
+ this.contextsInError = new TreeMap<String, Throwable>();
+ this.contextsInError.putAll(contextsInError);
+ }
+ if (contextsMissingDependencies != null && contextsMissingDependencies.isEmpty() == false)
+ {
+ this.contextsMissingDependencies = new TreeMap<String, Set<MissingDependency>>();
+ this.contextsMissingDependencies.putAll(contextsMissingDependencies);
+ }
+ }
+
+ /**
+ * Whether it is incomplete
+ *
+ * @return true when incomplete
+ */
+ public boolean isIncomplete()
+ {
+ if (deploymentsInError != null)
+ return true;
+ if (deploymentsMissingDeployer != null )
+ return true;
+ if (contextsInError != null)
+ return true;
+ if (contextsMissingDependencies != null)
+ return true;
+ return false;
+ }
+
+ /**
+ * Whether deployment unit is responsible for incomplete deployment.
+ *
+ * @param deploymentName deployment unit name
+ * @return true when deployment unit is responsible
+ */
+ public boolean isInvalidDeployment(String deploymentName)
+ {
+ if (isIncomplete() == false)
+ return false;
+
+ if (matchComponentName(deploymentName, getDeploymentsInError().keySet()))
+ return true;
+ if (matchComponentName(deploymentName, getDeploymentsMissingDeployer()))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Whether context is responsible for incomplete deployment.
+ *
+ * @param contextName context's name
+ * @return true when context is responsible
+ */
+ public boolean isInvalidContext(String contextName)
+ {
+ if (isIncomplete() == false)
+ return false;
+
+ if (matchComponentName(contextName, getContextsInError().keySet()))
+ return true;
+ if (matchComponentName(contextName, getContextsMissingDependencies().keySet()))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Search for componentName in strings.
+ *
+ * @param componentName component's name
+ * @param strings collection of strings
+ * @return true if strings contains component name
+ */
+ protected boolean matchComponentName(String componentName, Collection<String> strings)
+ {
+ return strings.contains(componentName);
+ }
+
+ /**
+ * Get the contextsInError.
+ *
+ * @return the contextsInError.
+ */
+ public Map<String, Throwable> getContextsInError()
+ {
+ if (contextsInError == null)
+ return Collections.emptyMap();
+ else
+ return Collections.unmodifiableMap(contextsInError);
+ }
+
+ /**
+ * Get the contextsMissingDependencies.
+ *
+ * @return the contextsMissingDependencies.
+ */
+ public Map<String, Set<MissingDependency>> getContextsMissingDependencies()
+ {
+ if (contextsMissingDependencies == null)
+ return Collections.emptyMap();
+ else
+ return Collections.unmodifiableMap(contextsMissingDependencies);
+ }
+
+ /**
+ * Get the deploymentsInError.
+ *
+ * @return the deploymentsInError.
+ */
+ public Map<String, Throwable> getDeploymentsInError()
+ {
+ if (deploymentsInError == null)
+ return Collections.emptyMap();
+ else
+ return Collections.unmodifiableMap(deploymentsInError);
+ }
+
+ /**
+ * Get the deploymentsMissingDeployer.
+ *
+ * @return the deploymentsMissingDeployer.
+ */
+ public Collection<String> getDeploymentsMissingDeployer()
+ {
+ if (deploymentsMissingDeployer == null)
+ return Collections.emptySet();
+ else
+ return Collections.unmodifiableCollection(deploymentsMissingDeployer);
+ }
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/MissingDependency.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/MissingDependency.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/MissingDependency.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,111 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.client.spi;
+
+import java.io.Serializable;
+
+/**
+ * MissingDependency.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MissingDependency implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1159684023853245283L;
+
+ /** The name */
+ private String name;
+
+ /** The dependency */
+ private String dependency;
+
+ /** The required state */
+ private String requiredState;
+
+ /** The actual state */
+ private String actualState;
+
+ /**
+ * For serialization
+ */
+ public MissingDependency()
+ {
+ }
+
+ /**
+ * Create a new MissingDependency.
+ *
+ * @param name the name
+ * @param dependency the dependency
+ * @param requiredState the required state
+ * @param actualState the actual state
+ */
+ public MissingDependency(String name, String dependency, String requiredState, String actualState)
+ {
+ this.name = name;
+ this.dependency = dependency;
+ this.requiredState = requiredState;
+ this.actualState = actualState;
+ }
+
+ /**
+ * Get the actualState.
+ *
+ * @return the actualState.
+ */
+ public String getActualState()
+ {
+ return actualState;
+ }
+
+ /**
+ * Get the dependency.
+ *
+ * @return the dependency.
+ */
+ public String getDependency()
+ {
+ return dependency;
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the requiredState.
+ *
+ * @return the requiredState.
+ */
+ public String getRequiredState()
+ {
+ return requiredState;
+ }
+}
Added: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/main/MainDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/main/MainDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/client/spi/main/MainDeployer.java 2007-06-27 15:56:18 UTC (rev 63679)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.client.spi.main;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+
+/**
+ * MainDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface MainDeployer extends DeployerClient
+{
+ /**
+ * Shutdown. Removes all the deployments.
+ */
+ void shutdown();
+}
More information about the jboss-cvs-commits
mailing list