KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > IncompleteDeploymentException


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.deployment;
23
24 import java.io.IOException JavaDoc;
25 import java.io.ObjectInputStream JavaDoc;
26 import java.io.ObjectOutputStream JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 /**
31  * IncompleteDeploymentException
32  *
33  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
34  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
35  * @version $Revision: 57108 $
36  */

37 public class IncompleteDeploymentException extends DeploymentException
38 {
39    /** @since 4.0.2 */
40    private static final long serialVersionUID = 1428860525880893167L;
41    
42    /** non-serializable info */
43    private transient final Collection JavaDoc mbeansWaitingForClasses;
44    private transient final Collection JavaDoc mbeansWaitingForDepends;
45    private transient final Collection JavaDoc rootCause;
46    private transient final Collection JavaDoc incompletePackages;
47    private transient final Collection JavaDoc waitingForDeployer;
48
49    /** only serializable info */
50    private String JavaDoc string;
51
52    /**
53     * CTOR
54     *
55     * @param mbeansWaitingForClasses
56     * @param mbeansWaitingForDepends
57     * @param rootCause
58     * @param incompletePackages
59     * @param waitingForDeployer
60     */

61    public IncompleteDeploymentException(final Collection JavaDoc mbeansWaitingForClasses,
62                                         final Collection JavaDoc mbeansWaitingForDepends,
63                                         final Collection JavaDoc rootCause,
64                                         final Collection JavaDoc incompletePackages,
65                                         final Collection JavaDoc waitingForDeployer)
66    {
67       if (mbeansWaitingForClasses == null
68           || mbeansWaitingForDepends == null
69           || rootCause == null
70           ||incompletePackages == null
71           || waitingForDeployer == null)
72       {
73          throw new IllegalArgumentException JavaDoc("All lists in IncompleteDeploymentException constructor must be supplied");
74       } // end of if ()
75

76       this.mbeansWaitingForClasses = mbeansWaitingForClasses;
77       this.mbeansWaitingForDepends = mbeansWaitingForDepends;
78       this.rootCause = rootCause;
79       this.incompletePackages = incompletePackages;
80       this.waitingForDeployer = waitingForDeployer;
81    }
82
83    /**
84     * Get the MbeansWaitingForClasses value.
85     * @return the MbeansWaitingForClasses value.
86     */

87    public Collection JavaDoc getMbeansWaitingForClasses()
88    {
89       return mbeansWaitingForClasses;
90    }
91
92    /**
93     * Get the MbeansWaitingForDepends value.
94     * @return the MbeansWaitingForDepends value.
95     */

96    public Collection JavaDoc getMbeansWaitingForDepends()
97    {
98       return mbeansWaitingForDepends;
99    }
100
101    /**
102     * Get the IncompletePackages value.
103     * @return the IncompletePackages value.
104     */

105    public Collection JavaDoc getIncompletePackages()
106    {
107       return incompletePackages;
108    }
109
110    /**
111     * Get the WaitingForDeployer value.
112     * @return the WaitingForDeployer value.
113     */

114    public Collection JavaDoc getWaitingForDeployer()
115    {
116       return waitingForDeployer;
117    }
118
119    /**
120     * @return true is no information is contained at all
121     */

122    public boolean isEmpty()
123    {
124       return mbeansWaitingForClasses.size() == 0
125          && mbeansWaitingForDepends.size() == 0
126          && rootCause.size() == 0
127          && incompletePackages.size() == 0
128          && waitingForDeployer.size() == 0;
129    }
130
131    /**
132     * Convert to String and cache the deployment information
133     */

134    public String JavaDoc toString()
135    {
136       if (string != null)
137       {
138          return string;
139       }
140       
141       StringBuffer JavaDoc result = new StringBuffer JavaDoc("Incomplete Deployment listing:\n\n");
142       if (waitingForDeployer.size() != 0)
143       {
144          result.append("--- Packages waiting for a deployer ---\n");
145          appendCollection(result, waitingForDeployer);
146       }
147       
148       if (incompletePackages.size() != 0)
149       {
150          result.append("--- Incompletely deployed packages ---\n");
151          appendCollection(result, incompletePackages);
152       }
153       
154       if (mbeansWaitingForClasses.size() != 0)
155       {
156          result.append("--- MBeans waiting for classes ---\n");
157          appendCollection(result, mbeansWaitingForClasses);
158       }
159       
160       if (mbeansWaitingForDepends.size() != 0)
161       {
162          result.append("--- MBeans waiting for other MBeans ---\n");
163          appendCollection(result, mbeansWaitingForDepends);
164       }
165       
166       if (rootCause.size() != 0)
167       {
168          result.append("--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---\n");
169          appendCollection(result, rootCause);
170       }
171       
172       string = result.toString();
173       return string;
174    }
175       
176    private void appendCollection(StringBuffer JavaDoc result, Collection JavaDoc c)
177    {
178       for (Iterator JavaDoc i = c.iterator(); i.hasNext();)
179          result.append(i.next().toString()).append('\n');
180    }
181
182    /**
183     * Read-in the string-fied information produced by writeObject()
184     */

185    private void readObject(ObjectInputStream JavaDoc s) throws IOException JavaDoc, ClassNotFoundException JavaDoc
186    {
187       s.defaultReadObject();
188    }
189
190    /**
191     * String-ify the contained information when serializing
192     */

193    private void writeObject(ObjectOutputStream JavaDoc s) throws IOException JavaDoc
194    {
195       toString();
196       s.defaultWriteObject();
197    }
198    
199 }
200
Popular Tags