KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > spi > DottedNameRegistrar


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  * DottedNameRegistrar.java
26  * $Id: DottedNameRegistrar.java,v 1.3 2005/12/25 03:43:33 tcfujii Exp $
27  * $Revision: 1.3 $
28  * $Date: 2005/12/25 03:43:33 $
29  * Indentation Information:
30  * 0. Please (try to) preserve these settings.
31  * 1. Tabs are preferred over spaces.
32  * 2. In vi/vim -
33  * :set tabstop=4 :set shiftwidth=4 :set softtabstop=4
34  * 3. In S1 Studio -
35  * 1. Tools->Options->Editor Settings->Java Editor->Tab Size = 4
36  * 2. Tools->Options->Indentation Engines->Java Indentation Engine->Expand Tabs to Spaces = False.
37  * 3. Tools->Options->Indentation Engines->Java Indentation Engine->Number of Spaces per Tab = 4.
38  *
39  * Created on September 4, 2003, 5:19 PM
40  */

41
42 package com.sun.enterprise.admin.monitor.registry.spi;
43 import javax.management.*;
44 import com.sun.enterprise.admin.common.ObjectNames;
45 import java.util.logging.*;
46 import com.sun.enterprise.admin.common.constant.AdminConstants; // for logger name
47

48 /**
49  * Mediates calls to the DottedNameRegistry to add or
50  * remove dottedName to Object Name maps.
51  * @author Shreedhar Ganapathy<mailto:shreedhar.ganapathy@sun.com>
52  */

53
54 class DottedNameRegistrar {
55     final MBeanServer server;
56     final ObjectName registryName;
57     private static final Logger logger = Logger.getLogger(AdminConstants.kLoggerName);
58
59     /** Creates a new instance of DottedNameRegistryMediator */
60     DottedNameRegistrar(MBeanServer server) {
61         this.server=server;
62         registryName = ObjectNames.getDottedNameMonitoringRegistryObjectName();
63     }
64     
65     void registerDottedName(java.lang.String JavaDoc dottedName, ObjectName objectName) {
66         try{
67             server.invoke(registryName, "add",
68                 new Object JavaDoc[]{dottedName, objectName},
69                 new String JavaDoc[]{String JavaDoc.class.getName(), ObjectName.class.getName()});
70         }
71         catch(Exception JavaDoc e){
72             logger.fine(e.getClass().getName()+":"+e.getLocalizedMessage());
73         }
74     }
75     
76     void unregisterDottedName(java.lang.String JavaDoc dottedName) {
77         try{
78             server.invoke(registryName, "remove",
79                 new Object JavaDoc[]{dottedName},
80                 new String JavaDoc[]{String JavaDoc.class.getName()});
81         }
82         catch(Exception JavaDoc e){
83             logger.fine(e.getClass().getName()+":"+e.getLocalizedMessage());
84         }
85     }
86 }
87
Popular Tags