KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > admingui > handlers > PersistenceHandlers


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.tools.admingui.handlers;
25
26 import java.util.EventObject JavaDoc;
27
28 import com.iplanet.jato.RequestContext;
29 import com.iplanet.jato.RequestManager;
30 import com.iplanet.jato.view.View;
31
32 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
33 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
34
35 import com.sun.enterprise.tools.admingui.util.MBeanUtil;
36 import com.sun.enterprise.tools.admingui.util.Util;
37
38
39 /**
40  * PersistenceHandlers.java
41  */

42 public class PersistenceHandlers {
43
44     public void getConnectionPool(RequestContext ctx, HandlerContext handlerCtx) throws Exception JavaDoc {
45     View view = handlerCtx.getView();
46         DescriptorContainerView descView = (DescriptorContainerView)(view.getParent());
47         String JavaDoc objectName = (String JavaDoc) handlerCtx.getInputValue("objectName");
48         if (objectName == null) {
49             return;
50     }
51     if (Util.isLoggableFINEST()) {
52         Util.logFINEST("PM : objectname = " + objectName);
53     }
54         Object JavaDoc jdbcResource = MBeanUtil.getAttribute(objectName, "jdbc-resource-jndi-name");
55     if (Util.isLoggableFINEST()) {
56         Util.logFINEST("PM : jdbc = " + jdbcResource);
57     }
58         if (jdbcResource != null) {
59             String JavaDoc jdbcObjectName = "com.sun.appserv:type=jdbc-resource,category=config,jndi-name=" + jdbcResource.toString();
60             //mbean will thrown not found exception if user deleted the jdbc resource on purpose,
61
// but the attribute is still pointing to the jdbc resource
62
try {
63                 descView.setDisplayFieldValue("ConnectionPool", MBeanUtil.getAttribute(jdbcObjectName, "pool-name"));
64             }catch (Exception JavaDoc ex){
65                 //ignore
66
}
67         }
68     }
69 }
70
Popular Tags