KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > alert > AlertSubscriptionInfo


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 package com.sun.enterprise.admin.alert;
24
25 import javax.management.NotificationListener JavaDoc;
26 import javax.management.NotificationFilter JavaDoc;
27
28 import java.util.List JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.StringTokenizer JavaDoc;
31
32 /**
33  * Class AlertSubscriptionInfo contains a list of ObjectNames (only the name
34  * elements of Monitors and MBeans whose notifications it's interested in) and
35  * the NotificationListener and the NotificationFilter if any.
36  *
37  * @AUTHOR: Hemanth Puttaswamy
38  */

39 public class AlertSubscriptionInfo {
40     // monitorNames (subscribe-listener-with attribute) from domain.xml
41
private List JavaDoc monitorNames;
42
43     // NotificationListner to subscribe
44
private NotificationListener JavaDoc listener;
45
46     // NotificationFilter to subscribe
47
private NotificationFilter JavaDoc filter;
48  
49     /**
50      * A comma separated list of monitor names will be passed as is read from
51      * domain.xml's alert-service, subscribe-listener-with attribute.
52      */

53     public AlertSubscriptionInfo(String JavaDoc subscribeListenersWith,
54         NotificationListener JavaDoc listener, NotificationFilter JavaDoc filter )
55     {
56         // No need to check for null as it is already done by domain.xml's
57
// validation.
58
StringTokenizer JavaDoc tokenizer =
59             new StringTokenizer JavaDoc( subscribeListenersWith, "," );
60         ArrayList JavaDoc list = new ArrayList JavaDoc( );
61         while( tokenizer.hasMoreTokens( ) ) {
62             String JavaDoc monitorName = tokenizer.nextToken( );
63             list.add( monitorName.trim() );
64         }
65         monitorNames = list;
66         this.listener = listener;
67         this.filter = filter;
68     }
69         
70     List JavaDoc getMonitorNames( ) {
71         return monitorNames;
72     }
73
74     NotificationListener JavaDoc getNotificationListener( ) {
75         return listener;
76     }
77
78     NotificationFilter JavaDoc getNotificationFilter( ) {
79         return filter;
80     }
81 }
82
Popular Tags