KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > channel > DynamicReconfigEventListenerImpl


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  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2004 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31 package com.sun.enterprise.admin.server.core.channel;
32
33 import com.sun.enterprise.admin.event.DynamicReconfigEventListener;
34 import com.sun.enterprise.admin.event.DynamicReconfigEvent;
35 import com.sun.enterprise.admin.event.AdminEventListenerException;
36 import com.sun.enterprise.admin.server.core.channel.RMIClient;
37 import com.sun.enterprise.admin.server.core.channel.AdminChannel;
38
39 //i18n import
40
import com.sun.enterprise.util.i18n.StringManager;
41
42 /**
43  * This is implemenation of DynamicReconfigEvent listener
44  *
45  * @author Satish Viswanatham
46  */

47 public class DynamicReconfigEventListenerImpl
48                     implements DynamicReconfigEventListener {
49
50   public void processEvent(DynamicReconfigEvent event)
51                             throws AdminEventListenerException{
52
53     String JavaDoc inst = event.getInstanceName();
54     if (inst == null) {
55        String JavaDoc msg = localStrings.getString(
56             "admin.server.core.channel.impl.no_inst_name");
57        throw new AdminEventListenerException(msg);
58     }
59
60     RMIClient client = AdminChannel.getRMIClient(inst);
61
62     if (client == null) {
63        String JavaDoc msg = localStrings.getString(
64             "admin.server.core.channel.impl.no_rmi_client", inst);
65        throw new AdminEventListenerException(msg);
66     }
67     boolean resNeeded = client.isRestartNeeded();
68
69     if (event.getActionType() == DynamicReconfigEvent.ACTION_ENABLED) {
70         if (resNeeded == true) {
71             // can not set dynamic reconfig, throw exception
72
String JavaDoc msg = localStrings.getString(
73             "admin.server.core.channel.impl.restart_required", inst);
74             throw new AdminEventListenerException(msg);
75         }
76     } else if (event.getActionType() == DynamicReconfigEvent.ACTION_DISABLED) {
77         client.setRestartNeeded(true);
78     }
79   }
80
81     // i18n StringManager
82
private static StringManager localStrings =
83         StringManager.getManager( DynamicReconfigEventListenerImpl.class );
84
85
86 }
87
Popular Tags