KickJava   Java API By Example, From Geeks To Geeks.

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


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.selfmanagement.event;
25 import javax.management.ObjectName JavaDoc;
26 import javax.management.NotificationFilter JavaDoc;
27 import javax.management.MalformedObjectNameException JavaDoc;
28 import com.sun.enterprise.util.i18n.StringManager;
29 import java.util.logging.Logger JavaDoc;
30 import java.util.logging.Level JavaDoc;
31 import com.sun.logging.LogDomains;
32
33
34 public class TimerEvent implements Event {
35     private static StringManager sm = StringManager.getManager(TimerEvent.class);
36     private static Logger JavaDoc _logger=LogDomains.getLogger(LogDomains.SELF_MANAGEMENT_LOGGER);
37     TimerEvent(Integer JavaDoc id, NotificationFilter JavaDoc filter, String JavaDoc description) {
38         this.id = id;
39         this.filter = filter;
40         if (description != null)
41             this.description = description;
42         else
43             this.description = defaultDescription;
44     }
45     public ObjectName JavaDoc getObjectName() {
46         return getTimerObjectName();
47     }
48     public String JavaDoc getType() {
49         return "timer";
50     }
51     public NotificationFilter JavaDoc getNotificationFilter() {
52         return filter;
53     }
54     public String JavaDoc getDescription() {
55         return description;
56     }
57     public void destroy() {
58         TimerEventFactory.getInstance().removeEvent(id);
59     }
60     static ObjectName JavaDoc getTimerObjectName() {
61         if (objName != null)
62             return objName;
63         try {
64             objName = new ObjectName JavaDoc(DOMAIN_NAME, DEFAULT_KEY,"timer");
65             return objName;
66         } catch (MalformedObjectNameException JavaDoc ex) {
67             _logger.log(Level.WARNING,"smgt.internal_error", ex);
68         }
69         return null;
70     }
71     
72     private static ObjectName JavaDoc objName = null;
73     private NotificationFilter JavaDoc filter = null;
74     private String JavaDoc description = null;
75     private static String JavaDoc defaultDescription = sm.getString("selfmgmt_event.timer_event_description");
76     private int id;
77 }
78
Popular Tags