KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > helper > NotificationServiceHelper


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  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/helper/NotificationServiceHelper.java,v 1.4 2006/03/09 20:30:27 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:27 $
28  */

29 package com.sun.appserv.management.helper;
30
31 import java.util.Map JavaDoc;
32
33 import javax.management.Notification JavaDoc;
34
35 import com.sun.appserv.management.base.NotificationService;
36
37 /**
38     Helps make it easier to get Notifications from a NotificationService
39  */

40 public final class NotificationServiceHelper
41 {
42     final NotificationService mProxy;
43     final Object JavaDoc mBufferID;
44     long mNextSequenceNumber;
45     
46         public
47     NotificationServiceHelper(
48         final NotificationService proxy,
49         final Object JavaDoc bufferID )
50     {
51         mProxy = proxy;
52         mBufferID = bufferID;
53         
54         mNextSequenceNumber = 0;
55     }
56     
57     
58         public NotificationService
59     get()
60     {
61         return( mProxy );
62     }
63     
64     /**
65         Get any outstanding Notifications and return them.
66      */

67         public Notification JavaDoc[]
68     getNotifications()
69     {
70         final Map JavaDoc<String JavaDoc,Object JavaDoc> result =
71             mProxy.getBufferNotifications( mBufferID, mNextSequenceNumber);
72         
73         final Long JavaDoc nextSequenceNumber = (Long JavaDoc)
74             result.get( mProxy.NEXT_SEQUENCE_NUMBER_KEY );
75         mNextSequenceNumber = nextSequenceNumber.longValue();
76         
77         final Notification JavaDoc[] notifs =
78             (Notification JavaDoc[])result.get( mProxy.NOTIFICATIONS_KEY );
79         
80         return( notifs );
81     }
82 }
83
84
85
Popular Tags