package org.jboss.deployment;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Collection;
import java.util.Iterator;
public class IncompleteDeploymentException extends DeploymentException
{
private static final long serialVersionUID = 1428860525880893167L;
private transient final Collection mbeansWaitingForClasses;
private transient final Collection mbeansWaitingForDepends;
private transient final Collection rootCause;
private transient final Collection incompletePackages;
private transient final Collection waitingForDeployer;
private String string;
public IncompleteDeploymentException(final Collection mbeansWaitingForClasses,
final Collection mbeansWaitingForDepends,
final Collection rootCause,
final Collection incompletePackages,
final Collection waitingForDeployer)
{
if (mbeansWaitingForClasses == null
|| mbeansWaitingForDepends == null
|| rootCause == null
||incompletePackages == null
|| waitingForDeployer == null)
{
throw new IllegalArgumentException("All lists in IncompleteDeploymentException constructor must be supplied");
}
this.mbeansWaitingForClasses = mbeansWaitingForClasses;
this.mbeansWaitingForDepends = mbeansWaitingForDepends;
this.rootCause = rootCause;
this.incompletePackages = incompletePackages;
this.waitingForDeployer = waitingForDeployer;
}
public Collection getMbeansWaitingForClasses()
{
return mbeansWaitingForClasses;
}
public Collection getMbeansWaitingForDepends()
{
return mbeansWaitingForDepends;
}
public Collection getIncompletePackages()
{
return incompletePackages;
}
public Collection getWaitingForDeployer()
{
return waitingForDeployer;
}
public boolean isEmpty()
{
return mbeansWaitingForClasses.size() == 0
&& mbeansWaitingForDepends.size() == 0
&& rootCause.size() == 0
&& incompletePackages.size() == 0
&& waitingForDeployer.size() == 0;
}
public String toString()
{
if (string != null)
{
return string;
}
StringBuffer result = new StringBuffer("Incomplete Deployment listing:\n\n");
if (waitingForDeployer.size() != 0)
{
result.append("--- Packages waiting for a deployer ---\n");
appendCollection(result, waitingForDeployer);
}
if (incompletePackages.size() != 0)
{
result.append("--- Incompletely deployed packages ---\n");
appendCollection(result, incompletePackages);
}
if (mbeansWaitingForClasses.size() != 0)
{
result.append("--- MBeans waiting for classes ---\n");
appendCollection(result, mbeansWaitingForClasses);
}
if (mbeansWaitingForDepends.size() != 0)
{
result.append("--- MBeans waiting for other MBeans ---\n");
appendCollection(result, mbeansWaitingForDepends);
}
if (rootCause.size() != 0)
{
result.append("--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---\n");
appendCollection(result, rootCause);
}
string = result.toString();
return string;
}
private void appendCollection(StringBuffer result, Collection c)
{
for (Iterator i = c.iterator(); i.hasNext();)
result.append(i.next().toString()).append('\n');
}
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
{
s.defaultReadObject();
}
private void writeObject(ObjectOutputStream s) throws IOException
{
toString();
s.defaultWriteObject();
}
}