KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployapi > SunTargetModuleID


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployapi;
25
26 import java.io.Serializable JavaDoc;
27 import java.util.Vector JavaDoc;
28 import java.util.Set JavaDoc;
29 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
30 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
31 import javax.enterprise.deploy.spi.Target JavaDoc;
32
33
34 /**
35  *
36  * @author Jerome Dochez
37  */

38 public class SunTargetModuleID extends SunTarget implements TargetModuleID JavaDoc, Serializable JavaDoc {
39     
40     private String JavaDoc moduleID;
41     private ModuleType JavaDoc moduleType;
42     private boolean initialized=false;
43     private SunTargetModuleID parent = null;
44     private Vector JavaDoc children = null;
45     private String JavaDoc webUrl=null;
46     
47     /** Creates a new instance of SunTargetModuleID */
48     public SunTargetModuleID(String JavaDoc moduleID, SunTarget target) {
49         super(target);
50         this.moduleID = moduleID;
51     }
52     
53     /** Retrieve a list of identifiers of the children
54      * of this deployed module.
55      *
56      * @return a list of TargetModuleIDs identifying the
57      * childern of this object. A <code>null</code>
58      * value means this module has no childern
59      */

60     public TargetModuleID JavaDoc[] getChildTargetModuleID() {
61         if (children==null)
62             return null;
63         
64         TargetModuleID JavaDoc[] list = new TargetModuleID JavaDoc[children.size()];
65         children.copyInto(list);
66         return list;
67     }
68     
69     /** Retrieve the id assigned to represent
70      * the deployed module.
71      */

72     public String JavaDoc getModuleID() {
73         return moduleID;
74     }
75     
76     /** Retrieve the identifier of the parent
77      * object of this deployed module. If there
78      * is no parent then this is the root object
79      * deployed. The root could represent an EAR
80      * file or it could be a stand alone module
81      * that was deployed.
82      *
83      * @return the TargetModuleID of the parent
84      * of this object. A <code>null</code>
85      * value means this module is the root
86      * object deployed.
87      */

88     public TargetModuleID JavaDoc getParentTargetModuleID() {
89         return parent;
90     }
91     
92     /** Retrieve the name of the target server.
93      * this module was deployed to.
94      *
95      * @return Target an object representing
96      * a server target.
97      */

98     public Target JavaDoc getTarget() {
99         return this;
100     }
101     
102     /** If this TargetModulID represents a web
103      * module retrieve the URL for it.
104      *
105      * @return the URL of a web module or null
106      * if the module is not a web module.
107      */

108     public String JavaDoc getWebURL() {
109         return webUrl;
110     }
111     
112     /**
113      * set the URL of a web module if the module is a web module.
114      */

115     public void setWebURL(String JavaDoc webUrl) {
116         this.webUrl = webUrl;
117     }
118     
119     /**
120      * Add a child TargetModuleID to this TargetModuleID
121      */

122     public void addChildTargetModuleID(SunTargetModuleID child) {
123         if (children==null) {
124             children = new Vector JavaDoc();
125         }
126         child.setParentTargetModuleID(this);
127         children.add(child);
128     }
129     
130     /**
131      * Sets the parent TargetModuleID
132      */

133     public void setParentTargetModuleID(SunTargetModuleID parent) {
134         this.parent = parent;
135     }
136     
137     /**
138      * Sets the module type for this deployed module
139      * @param the module type
140      */

141     public void setModuleType(ModuleType JavaDoc moduleType) {
142         this.moduleType = moduleType;
143     }
144     
145     /**
146      * @return the module type of this deployed module
147      */

148     public ModuleType JavaDoc getModuleType() {
149         return moduleType;
150     }
151     
152     /**
153      * @return a meaningful string for myself
154      */

155     public String JavaDoc toString() {
156         return moduleID + "_" + super.toString();
157     }
158
159     
160     /**
161      * @return a meaningful string for myself
162      */

163     public String JavaDoc debugString() {
164         String JavaDoc s = "TargetModuleID type " + getModuleType() + " moduleID " + toString() + " on target = " + super.toString();
165         if (ModuleType.WAR.equals(moduleType)) {
166             s = s + " at " + getWebURL();
167         }
168         return s;
169     }
170         
171     /**
172      * @return true if I am the equals to the other object
173      */

174     public boolean equals(Object JavaDoc other) {
175         if (other instanceof SunTargetModuleID) {
176             SunTargetModuleID theOther = (SunTargetModuleID) other;
177             return (moduleID.equals(theOther.moduleID) && super.equals(theOther));
178         }
179         return false;
180     }
181 }
182
Popular Tags