KickJava   Java API By Example, From Geeks To Geeks.

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


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 //i18n import
27
import com.sun.enterprise.util.i18n.StringManager;
28
29 /**
30  * EjbTimerEvent - emitted by DAS to send requests to Ejb Timer Service
31  * Attibutes: actionType, from, servers
32  */

33 public class EjbTimerEvent extends AdminEvent implements CommandEvent {
34
35     /**
36      * Attribute name in EventResult to return results of calls to timer service
37      */

38     public static final String JavaDoc EJB_TIMER_CALL_RESULT_ATTRNAME = "ejb_timer_call_result";
39
40     /**
41      * Constant denoting action code
42      */

43     public static final int ACTION_MIGRATETIMER = 1;
44     public static final int ACTION_LISTTIMERS = 2;
45
46     /**
47      * Event type
48      */

49     static final String JavaDoc eventType = EjbTimerEvent.class.getName();
50
51     /**
52      * Attributes ()
53      */

54     private int actionType;
55     private String JavaDoc from;
56     private String JavaDoc[] servers;
57
58     // i18n StringManager
59
private static StringManager localStrings = StringManager.getManager( EjbTimerEvent.class );
60
61     /**
62      * Create a new EjbTimerEvent.
63      * @param instance name of the instance to which the event applies
64      * @param realm name of the AuthRealm on which event happened.
65      * @param action type of action - one of EjbTimerEvent.ACTION_MIGRATETIMER,
66      * EjbTimerEvent.ACTION_LISTTIMERS
67      * @param serverFrom name of server instance (for ACTION_MIGRATETIMER)
68      * @param serverNames names of server instances (for ACTION_LISTTIMERS)
69      * @throws IllegalArgumentException if specified action is not valid
70      */

71     public EjbTimerEvent(String JavaDoc instance, int action, String JavaDoc serverFrom, String JavaDoc[] serverNames) {
72         this(eventType, instance, action, serverFrom, serverNames);
73     }
74
75     /**
76      * Create a new EjbTimerEvent.
77      * @param type event type, a string representation for the event
78      * @param action type of action - one of EjbTimerEvent.ACTION_MIGRATETIMER,
79      * EjbTimerEvent.ACTION_LISTTIMERS
80      * @param serverFrom name of server instance (for ACTION_MIGRATETIMER)
81      * @param serverNames names of server instances (for ACTION_LISTTIMERS)
82      * @throws IllegalArgumentException if specified action is not valid
83      */

84     public EjbTimerEvent(String JavaDoc type, String JavaDoc instance, int action, String JavaDoc serverFrom, String JavaDoc[] serverNames) {
85         super(type, instance);
86         from = serverFrom;
87         servers = serverNames;
88         setAction(action);
89     }
90
91     /**
92      * Get from param
93      */

94     public String JavaDoc getFromServerName() {
95         return from;
96     }
97
98     /**
99      * Get servers param
100      */

101     public String JavaDoc[] getServerNames() {
102         return servers;
103     }
104
105     /**
106      * Get action type for this event.
107      */

108     public int getActionType() {
109         return actionType;
110     }
111
112     /**
113      * Set action to specified value. If action is not one of allowed,
114      * then IllegalArgumentException is thrown.
115      * @throws IllegalArgumentException if action is invalid
116      */

117     private void setAction(int action) {
118         boolean valid = false;
119         if (action==ACTION_MIGRATETIMER ||
120             action==ACTION_LISTTIMERS )
121             valid = true;
122         if (!valid) {
123             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", ""+action );
124             throw new IllegalArgumentException JavaDoc( msg );
125         }
126         this.actionType = action;
127     }
128    
129 }
130
Popular Tags