KickJava   Java API By Example, From Geeks To Geeks.

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


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.admin.event;
25
26 import com.sun.enterprise.admin.event.AdminEvent;
27
28 //i18n import
29
import com.sun.enterprise.util.i18n.StringManager;
30
31 /**
32  * DynamicReconfigEvent - emitted by DAS upon changes
33  * "dynamic-reconfiguration-enabled" attribute in "config" element
34  */

35 public class DynamicReconfigEvent extends AdminEvent implements CommandEvent {
36
37     /**
38      * Constant denoting action code
39      */

40     public static final int ACTION_DISABLED = 0;
41     public static final int ACTION_ENABLED = 1;
42
43     /**
44      * Event type
45      */

46     public static final String JavaDoc eventType = DynamicReconfigEvent.class.getName();
47
48     /**
49      * Attributes
50      */

51     private int actionType;
52
53     // i18n StringManager
54
private static StringManager localStrings = StringManager.getManager( DynamicReconfigEvent.class );
55
56     /**
57      * Create a new DynamicReconfigEvent.
58      * @param instance name of the instance to which the event applies
59      * @param action type of action - one of DynamicReconfigEvent.ACTION_ENABLED,
60      * DynamicReconfigEvent.ACTION_DISABLED
61      * @throws IllegalArgumentException if specified action is not valid
62      */

63     public DynamicReconfigEvent(String JavaDoc instance, int action) {
64         super(eventType, instance);
65         setAction(action);
66     }
67
68
69     /**
70      * Get action type for this event.
71      */

72     public int getActionType() {
73         return actionType;
74     }
75
76     /**
77      * Set action to specified value. If action is not one of allowed,
78      * then IllegalArgumentException is thrown.
79      * @throws IllegalArgumentException if action is invalid
80      */

81     private void setAction(int action) {
82         boolean valid = false;
83         if (action==ACTION_ENABLED ||
84             action==ACTION_DISABLED)
85             valid = true;
86         if (!valid) {
87             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", ""+action );
88             throw new IllegalArgumentException JavaDoc( msg );
89         }
90         this.actionType = action;
91     }
92
93 }
94
Popular Tags