KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > BaseDeployEvent


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 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31 package com.sun.enterprise.admin.event;
32
33 import com.sun.enterprise.admin.event.AdminEvent;
34
35 //i18n import
36
import com.sun.enterprise.util.i18n.StringManager;
37
38 /**
39  * Base deployment event. A deployment event is one of - deployed, undeployed,
40  * redeployed, enabled or disabled on J2ee application, standalone J2EE
41  * module or application server resource. The word deploy is used in two
42  * meanings here - one to denote the group of actions that are related to
43  * deployment and another to denote the specific action of initial deployment
44  * of application, module or resource.
45  */

46 public class BaseDeployEvent extends AdminEvent implements Cloneable JavaDoc{
47
48     /**
49      * Constant denoting J2EE application.
50      */

51     public static final String JavaDoc APPLICATION = "application";
52
53     /**
54      * Constant denoting standalone J2EE module.
55      */

56     public static final String JavaDoc MODULE = "module";
57
58     /**
59      * Constant denoting application server resource.
60      */

61     public static final String JavaDoc RESOURCE = "resource";
62
63     /**
64      * Constant denoting deployment action
65      */

66     public static final String JavaDoc DEPLOY = "deploy";
67
68     /**
69      * Constant denoting undeployment action
70      */

71     public static final String JavaDoc UNDEPLOY = "undeploy";
72
73     /**
74      * Constant denoting redeployment action
75      */

76     public static final String JavaDoc REDEPLOY = "redeploy";
77
78     /**
79      * Constant denoting enable action
80      */

81     public static final String JavaDoc ENABLE = "enable";
82
83     /**
84      * Constant denoting disable action
85      */

86     public static final String JavaDoc DISABLE = "disable";
87
88     /**
89      * Constant denoting add reference action
90      */

91     public static final String JavaDoc ADD_REFERENCE = "reference-added";
92
93     /**
94      * Constant denoting remove reference action
95      */

96     public static final String JavaDoc REMOVE_REFERENCE = "reference-removed";
97     
98     /**
99      * Application deploy event
100      */

101     public static final int APPLICATION_DEPLOYED = 1;
102     
103     /**
104      * Application undeploy event
105      */

106     public static final int APPLICATION_UNDEPLOYED = 2;
107
108     /**
109      * Application redeploy event
110      */

111     public static final int APPLICATION_REDEPLOYED = 3;
112     
113     /**
114      * Module deploy event
115      */

116     public static final int MODULE_DEPLOYED = 4;
117     
118     /**
119      * Module undeploy event
120      */

121     public static final int MODULE_UNDEPLOYED = 5;
122
123     /**
124      * Module redeploy event
125      */

126     public static final int MODULE_REDEPLOYED = 6;
127
128     /**
129      * Module enable event
130      */

131     public static final int MODULE_ENABLE = 7;
132
133     /**
134      * Module disable event
135      */

136     public static final int MODULE_DISABLE = 8;
137     
138     /**
139      * Application enable event
140      */

141     public static final int APPLICATION_ENABLE = 9;
142
143     /**
144      * Application disable event
145      */

146     public static final int APPLICATION_DISABLE = 10;
147
148     /**
149      * Application reference event
150      */

151     public static final int APPLICATION_REFERENCED = 11;
152     public static final int APPLICATION_UNREFERENCED = 12;
153     
154     /**
155      * Event type
156      */

157     static final String JavaDoc eventType = BaseDeployEvent.class.getName();
158
159     protected String JavaDoc j2eeComponentType;
160     protected String JavaDoc j2eeComponentName;
161     protected String JavaDoc actionName;
162     protected boolean cascade = false;
163
164     // i18n StringManager
165
private static StringManager localStrings =
166         StringManager.getManager( BaseDeployEvent.class );
167
168     /**
169      * Create a new BaseDeployEvent.
170      * @param instance name of the instance to which the deployment event
171      * applies
172      * @param componentType type of the component on which event happened. One
173      * of BaseDeployEvent.APPLICATION, BaseDeployEvent.MODULE or
174      * BaseDeployEvent.RESOURCE
175      * @param componentName name of the component on which event happened, this
176      * is either a J2EE application name or a standalone J2EE module
177      * name or an application server resource.
178      * @param action deployment action - one of BaseDeployEvent.DEPLOY,
179      * BaseDeployEvent.UNDEPLOY, BaseDeployEvent.REDEPLOY,
180      * BaseDeployEvent.ENABLE, BaseDeployEvent.DISABLE
181      * @throws IllegalArgumentException if specified action is not valid
182      */

183     public BaseDeployEvent(String JavaDoc instance, String JavaDoc componentType,
184             String JavaDoc componentName, String JavaDoc action) {
185         this(eventType, instance, componentType, componentName, action);
186     }
187
188     /**
189      * Create a new BaseDeployEvent.
190      * @param type event type, a string representation for the event
191      * @param instance name of the instance to which the deployment event
192      * applies
193      * @param componentType type of the component on which event happened. One
194      * of BaseDeployEvent.APPLICATION, BaseDeployEvent.MODULE or
195      * BaseDeployEvent.RESOURCE
196      * @param componentName name of the component on which event happened, this
197      * is either a J2EE application name or a standalone J2EE module
198      * name or an application server resource.
199      * @param action deployment action - one of BaseDeployEvent.DEPLOY,
200      * BaseDeployEvent.UNDEPLOY, BaseDeployEvent.REDEPLOY,
201      * BaseDeployEvent.ENABLE, BaseDeployEvent.DISABLE
202      * @throws IllegalArgumentException if specified action is not valid
203      */

204     public BaseDeployEvent(String JavaDoc type, String JavaDoc instance, String JavaDoc componentType,
205             String JavaDoc componentName, String JavaDoc action) {
206         this(type, instance, componentType, componentName, action, false);
207     }
208     
209     public BaseDeployEvent(String JavaDoc type, String JavaDoc instance, String JavaDoc componentType,
210             String JavaDoc componentName, String JavaDoc action, boolean cascade) {
211         super(type, instance);
212         j2eeComponentType = componentType;
213         j2eeComponentName = componentName;
214         setAction(action);
215         setCascade(cascade);
216     }
217
218     public BaseDeployEvent(String JavaDoc type, Object JavaDoc source,
219                            long seqNumber,long time) {
220         super(type, source, seqNumber, time);
221     }
222
223     /**
224      * Get type of component on which this event happened.
225      * @return one of BaseDeployEvent.APPLICATION, BaseDeployEvent.MODULE or
226      * BaseDeployEvent.RESOURCE
227      */

228     public String JavaDoc getJ2EEComponentType() {
229         return j2eeComponentType;
230     }
231
232     /**
233      * Get name of the component on which this event happened. This is either
234      * application name, module name or resource name.
235      */

236     public String JavaDoc getJ2EEComponentName() {
237         return j2eeComponentName;
238     }
239
240     /**
241      * Get deployment action for this event.
242      */

243     public String JavaDoc getAction() {
244         return actionName;
245     }
246
247     /**
248      * Set action to specified value. If action is not one of DEPLOY, UNDEPLOY,
249      * REDEPLOY, ENABLE or DISABLE then IllegalArgumentException is thrown.
250      * @throws IllegalArgumentException if action is invalid
251      */

252     protected void setAction(String JavaDoc action) {
253         boolean valid = false;
254         if (DEPLOY.equals(action) || UNDEPLOY.equals(action)
255                 || REDEPLOY.equals(action) || ENABLE.equals(action)
256                 || DISABLE.equals(action) || ADD_REFERENCE.equals(action)
257                 || REMOVE_REFERENCE.equals(action)) {
258             valid = true;
259         }
260         if (!valid) {
261             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", action );
262             throw new IllegalArgumentException JavaDoc( msg );
263         }
264         this.actionName = action;
265     }
266
267     /**
268      *
269      */

270     public boolean getCascade() {
271         return cascade;
272     }
273     
274     /**
275      *
276      */

277     public void setCascade(boolean cascade) {
278         this.cascade = cascade;
279     }
280     
281     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
282         return super.clone();
283     }
284 }
285
Popular Tags