KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > selfmanagement > event > LifeCycleEvent


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  * LifeCycleEvent.java
26  *
27  */

28
29 package com.sun.enterprise.admin.selfmanagement.event;
30
31 import javax.management.NotificationBroadcasterSupport JavaDoc;
32 import javax.management.NotificationListener JavaDoc;
33 import javax.management.NotificationFilter JavaDoc;
34 import javax.management.Notification JavaDoc;
35 import javax.management.ObjectName JavaDoc;
36 import javax.management.MalformedObjectNameException JavaDoc;
37 import com.sun.enterprise.util.i18n.StringManager;
38 import java.util.logging.Logger JavaDoc;
39 import java.util.logging.Level JavaDoc;
40 import com.sun.logging.LogDomains;
41
42
43
44 /**
45  *
46  * @author Sun Micro Systems, Inc
47  */

48 public class LifeCycleEvent implements Event {
49     
50     private static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.SELF_MANAGEMENT_LOGGER);
51     private static StringManager sm = StringManager.getManager(LifeCycleEvent.class);
52     
53     public LifeCycleEvent(String JavaDoc type, LifeCycleNotificationFilter lfilter, String JavaDoc description) {
54         this.type = type;
55         this.lfilter = lfilter;
56         if (description != null)
57             this.description = description;
58         else
59             this.description = defaultDescription;
60     }
61     
62     public ObjectName JavaDoc getObjectName() {
63         return objName;
64     }
65     
66     
67     public String JavaDoc getType() {
68         return type;
69     }
70     
71     public NotificationFilter JavaDoc getNotificationFilter( ){
72         return lfilter;
73     }
74     
75     public String JavaDoc getDescription() {
76         return description;
77     }
78     
79     public void destroy() {
80         // do nothing
81
}
82     
83     static ObjectName JavaDoc getLifeCycleImplObjectName() {
84         if (objName != null)
85             return objName;
86         try {
87             objName = new ObjectName JavaDoc( DOMAIN_NAME,DEFAULT_KEY, "lifecycle");
88         }catch (MalformedObjectNameException JavaDoc mex) {
89             _logger.log(Level.WARNING,"smgt.internal_error", mex);
90         }
91         return objName;
92     }
93
94     public static boolean isValidType(String JavaDoc type) {
95         if ("*".equals(type) || READY_EVENT.equals(type) ||
96                 SHUTDOWN_EVENT.equals(type) || TERMINATION_EVENT.equals(type) ) {
97             return true;
98         }
99         return false;
100     }
101     
102     private static ObjectName JavaDoc objName = null;
103     private static String JavaDoc defaultDescription =
104             sm.getString("selfmgmt_event.lifecycle_event_description");
105     private LifeCycleNotificationFilter lfilter = null;
106     private String JavaDoc description = null;
107     private String JavaDoc type = null;
108
109     /**
110      * Constant to denote the eventType ready
111      */

112     public static final String JavaDoc READY_EVENT = "lifecycle.ready";
113                                                                                                                                                
114     /**
115      * Constant to denote the eventType shutdown
116      */

117     public static final String JavaDoc SHUTDOWN_EVENT = "lifecycle.shutdown";
118                                                                                                                                                
119     /**
120      * Constant to denote the eventType termination
121      */

122     public static final String JavaDoc TERMINATION_EVENT = "lifecycle.termination";
123
124 }
125
Popular Tags