KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > mbean > config > ManagedORBListener


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.admin.server.core.mbean.config;
25
26 //JMX imports
27
import javax.management.*;
28
29 //Config imports
30
import com.sun.enterprise.config.ConfigException;
31 import com.sun.enterprise.config.serverbeans.ServerTags;
32 import com.sun.enterprise.config.serverbeans.ServerXPathHelper;
33 import com.sun.enterprise.config.serverbeans.IiopListener;
34 import com.sun.enterprise.config.serverbeans.Ssl;
35
36
37 //Admin imports
38
import com.sun.enterprise.admin.common.ObjectNames;
39 import com.sun.enterprise.admin.common.exception.MBeanConfigException;
40 import com.sun.enterprise.admin.common.constant.ConfigAttributeName;
41
42 //i18n import
43
import com.sun.enterprise.util.i18n.StringManager;
44
45 /**
46     This Config MBean represents a ORB Listener.
47     It extends ConfigMBeanBase class which provides get/set attribute(s) and getMBeanInfo services according to text descriptions.
48     ObjectName of this MBean is:
49         ias: type=orblistener, instance-name=<instance-name>, name=<listener-name>
50 */

51 public class ManagedORBListener extends ConfigMBeanBase implements ConfigAttributeName.ORBListener
52 {
53     /**
54      * MAPLIST array defines mapping between "external" name and its location in XML relatively base node
55      */

56     private static final String JavaDoc[][] MAPLIST =
57     {
58         {kId , ATTRIBUTE + ServerTags.ID},
59         {kAddress , ATTRIBUTE + ServerTags.ADDRESS},
60         {kPort , ATTRIBUTE + ServerTags.PORT},
61         {kEnabled , ATTRIBUTE + ServerTags.ENABLED},
62         //----- SSL -------- Ssl interface attributes appended here
63
};
64     /**
65      * ATTRIBUTES array specifies attributes descriptions in format defined for MBeanEasyConfig
66      */

67     private static final String JavaDoc[] ATTRIBUTES =
68     {
69         kId +", String, R" ,
70         kAddress +", String, RW" ,
71         kPort +", int, RW" ,
72         kEnabled +", Boolean, RW" ,
73         //----- SSL -------- Ssl interface attributes appended here
74
};
75     /**
76      * OPERATIONS array specifies operations descriptions in format defined for MBeanEasyConfig
77      */

78     private static final String JavaDoc[] OPERATIONS =
79     {
80         "createSsl(String certNickname, Boolean ssl2Enabled, String ssl2Ciphers, Boolean ssl3Enabled, String ssl3TlsCiphers, Boolean tlsEnabled, Boolean tlsRollbackEnabled, Boolean clientAuthEnabled), ACTION",
81         "deleteSsl(), ACTION",
82         "isSslCreated(), INFO",
83     };
84     
85     
86     // i18n StringManager
87
private static StringManager localStrings =
88         StringManager.getManager( ManagedORBListener.class );
89     
90     /**
91         Default constructor sets MBean description tables
92     */

93     public ManagedORBListener() throws MBeanConfigException
94     {
95         Object JavaDoc[] mergedAttrs = MergeAttributesWithAnotherMbean(
96              MAPLIST, ATTRIBUTES, SslBase.MAPLIST, SslBase.ATTRIBUTES,
97              ServerTags.SSL , null);
98         this.setDescriptions((String JavaDoc[][])mergedAttrs[0], (String JavaDoc[])mergedAttrs[1], OPERATIONS);
99     }
100
101     /**
102         Constructs Config MBean for ORB Listener.
103         @param instanceName The server instance name.
104         @param listenerId Listener id for given resource
105     */

106     public ManagedORBListener(String JavaDoc instanceName, String JavaDoc listenerId) throws MBeanConfigException
107     {
108         this(); //set description tables
109
initialize(ObjectNames.kOrbListenerType, new String JavaDoc[]{instanceName, listenerId});
110     }
111     
112     /**
113     This operation checks Ssl existance in current element;
114      */

115     public boolean isSslCreated() throws ConfigException
116     {
117         IiopListener listener = (IiopListener)getConfigBeanByXPath( getBasePath() );
118         return (listener.getSsl()!=null);
119     }
120
121     /**
122     This operation deletes Ssl sub-element from current element;
123      */

124     public void deleteSsl() throws ConfigException
125     {
126         IiopListener listener = (IiopListener)getConfigBeanByXPath( getBasePath() );
127         listener.setSsl(null);
128         
129         getConfigContext().flush();
130     }
131     /**
132      * This operation creates Ssl ConfigBean according to attributes and adds(links) it to current config bean;
133      * If attribute is 'null' then default value will be set.
134      */

135     public void createSsl(String JavaDoc certNickname, Boolean JavaDoc ssl2Enabled, String JavaDoc ssl2Ciphers,
136     Boolean JavaDoc ssl3Enabled, String JavaDoc ssl3TlsCiphers,
137     Boolean JavaDoc tlsEnabled, Boolean JavaDoc tlsRollbackEnabled, Boolean JavaDoc clientAuthEnabled) throws ConfigException
138     {
139         IiopListener listener = (IiopListener)getConfigBeanByXPath( getBasePath() );
140         try
141         {
142             if(listener.getSsl()!=null)
143             {
144                 listener = null;
145                 String JavaDoc msg = localStrings.getString( "admin.server.core.mbean.config.orblistener_has_ssl_created" );
146                 throw new ConfigException( msg );
147             }
148         }
149         catch (ConfigException e)
150         {
151             if(listener==null)
152                 throw e;
153         }
154         
155         Ssl ssl = new Ssl();
156         //strings
157
if(certNickname!=null)
158             ssl.setCertNickname(certNickname);
159         if(ssl2Ciphers!=null)
160             ssl.setSsl2Ciphers(ssl2Ciphers);
161         if(ssl3TlsCiphers!=null)
162             ssl.setSsl3TlsCiphers(ssl3TlsCiphers);
163         //Booleans
164
if(ssl2Enabled!=null)
165             ssl.setSsl2Enabled(ssl2Enabled.booleanValue());
166         if(ssl3Enabled!=null)
167             ssl.setSsl3Enabled(ssl3Enabled.booleanValue());
168         if(tlsEnabled!=null)
169             ssl.setTlsEnabled(tlsEnabled.booleanValue());
170         if(tlsRollbackEnabled!=null)
171             ssl.setTlsRollbackEnabled(tlsRollbackEnabled.booleanValue());
172         if(clientAuthEnabled!=null)
173             ssl.setClientAuthEnabled(clientAuthEnabled.booleanValue());
174         
175         listener.setSsl(ssl);
176         
177         getConfigContext().flush();
178     }
179     
180 }
181
Popular Tags