KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > spi > SerializableTargetModuleID


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.spi;
23
24 import java.io.Serializable JavaDoc;
25 import java.util.ArrayList JavaDoc;
26
27 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
28
29 /**
30  * A Serializable representation of the TargetModuleID
31  *
32  * @author Scott.Stark@jboss.org
33  * @version $Revision: 58055 $
34  */

35 public class SerializableTargetModuleID implements Serializable JavaDoc
36 {
37    private static final long serialVersionUID = 6856468929226666749L;
38
39    private SerializableTargetModuleID parentModuleID;
40    private ArrayList JavaDoc childModuleIDs = new ArrayList JavaDoc();
41    private String JavaDoc moduleID;
42    private int moduleType;
43    private boolean isRunning;
44
45    public SerializableTargetModuleID(TargetModuleIDImpl impl)
46    {
47       this(null, impl);
48    }
49
50    public SerializableTargetModuleID(SerializableTargetModuleID parent, TargetModuleIDImpl impl)
51    {
52       parentModuleID = parent;
53       moduleID = impl.getModuleID();
54       moduleType = impl.getModuleType().getValue();
55
56       TargetModuleID JavaDoc[] children = impl.getChildTargetModuleID();
57       int length = children != null ? children.length : 0;
58       for (int n = 0; n < length; n++)
59       {
60          TargetModuleIDImpl child = (TargetModuleIDImpl)children[n];
61          childModuleIDs.add(new SerializableTargetModuleID(this, child));
62       }
63    }
64
65    public SerializableTargetModuleID(SerializableTargetModuleID parent, String JavaDoc moduleID, int moduleType, boolean isRunning)
66    {
67       parentModuleID = parent;
68       this.moduleID = moduleID;
69       this.moduleType = moduleType;
70       this.isRunning = isRunning;
71    }
72
73    public SerializableTargetModuleID getParentModuleID()
74    {
75       return parentModuleID;
76    }
77
78    public void addChildTargetModuleID(SerializableTargetModuleID child)
79    {
80       childModuleIDs.add(child);
81    }
82
83    public void clearChildModuleIDs()
84    {
85       childModuleIDs.clear();
86    }
87
88    public SerializableTargetModuleID[] getChildModuleIDs()
89    {
90       SerializableTargetModuleID[] ids = new SerializableTargetModuleID[childModuleIDs.size()];
91       childModuleIDs.toArray(ids);
92       return ids;
93    }
94
95    public String JavaDoc getModuleID()
96    {
97       return moduleID;
98    }
99
100    public int getModuleType()
101    {
102       return moduleType;
103    }
104
105    public boolean isRunning()
106    {
107       return isRunning;
108    }
109
110    public void setRunning(boolean flag)
111    {
112       this.isRunning = flag;
113    }
114
115    public String JavaDoc toString()
116    {
117       return "SerializableTargetModuleID{" + "parentModuleID=@" + System.identityHashCode(parentModuleID) + ", childModuleIDs=" + childModuleIDs + ", moduleID='"
118             + moduleID + "'" + ", moduleType=" + moduleType + ", isRunning=" + isRunning + "}";
119    }
120
121 }
122
Popular Tags