KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > mbeans > ConfigsMBean


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  * $Id: ConfigsMBean.java,v 1.9 2005/12/25 03:42:14 tcfujii Exp $
26  */

27
28 package com.sun.enterprise.admin.mbeans;
29
30 //jdk imports
31
import java.util.ArrayList JavaDoc;
32 import java.util.Properties JavaDoc;
33 import java.util.Set JavaDoc;
34 import java.util.HashSet JavaDoc;
35 import java.util.Enumeration JavaDoc;
36 import java.util.Iterator JavaDoc;
37 import java.util.Collection JavaDoc;
38 import java.io.File JavaDoc;
39 import java.util.logging.Level JavaDoc;
40 import java.util.logging.Logger JavaDoc;
41
42
43 //JMX imports
44
import javax.management.AttributeList JavaDoc;
45 import javax.management.Attribute JavaDoc;
46 import javax.management.ObjectName JavaDoc;
47 import javax.management.MBeanException JavaDoc;
48 import javax.management.InstanceNotFoundException JavaDoc;
49 import javax.management.MBeanServer JavaDoc;
50
51 //config imports
52
import com.sun.enterprise.config.ConfigContext;
53 import com.sun.enterprise.config.ConfigException;
54 import com.sun.enterprise.config.ConfigBean;
55 import com.sun.enterprise.config.ConfigBeansFactory;
56 import com.sun.enterprise.config.serverbeans.ServerTags;
57 import com.sun.enterprise.util.SystemPropertyConstants;
58
59 import com.sun.enterprise.config.serverbeans.Config;
60 import com.sun.enterprise.config.serverbeans.SecurityService;
61 import com.sun.enterprise.config.serverbeans.MessageSecurityConfig;
62 import com.sun.enterprise.config.serverbeans.ProviderConfig;
63 import com.sun.enterprise.config.serverbeans.RequestPolicy;
64 import com.sun.enterprise.config.serverbeans.ResponsePolicy;
65 import com.sun.enterprise.config.serverbeans.ElementProperty;
66 import com.sun.enterprise.config.serverbeans.IiopService;
67 import com.sun.enterprise.config.serverbeans.Ssl;
68 import com.sun.enterprise.config.serverbeans.SslClientConfig;
69 import com.sun.enterprise.config.serverbeans.AuthRealm;
70
71
72
73 import com.sun.enterprise.util.i18n.StringManager;
74 import com.sun.enterprise.admin.config.BaseConfigMBean;
75 import com.sun.enterprise.admin.config.ManagedConfigBean;
76 import com.sun.enterprise.admin.config.MBeanConfigException;
77 import com.sun.enterprise.admin.config.ConfigMBeanHelper;
78 import com.sun.enterprise.admin.meta.MBeanRegistry;
79 import com.sun.enterprise.admin.meta.MBeanRegistryEntry;
80 import com.sun.enterprise.admin.meta.naming.MBeanNamingInfo;
81 import com.sun.enterprise.admin.meta.MBeanRegistryFactory;
82 import com.sun.enterprise.admin.util.jmx.AttributeListUtils;
83
84 import com.sun.enterprise.config.serverbeans.ServerHelper;
85 import com.sun.enterprise.config.serverbeans.ClusterHelper;
86 import com.sun.enterprise.config.serverbeans.ConfigAPIHelper;
87 import com.sun.enterprise.config.serverbeans.PropertyResolver;
88
89 import com.sun.enterprise.admin.mbeanapi.IConfigsMBean;
90
91 import com.sun.enterprise.admin.target.Target;
92 import com.sun.enterprise.admin.target.ConfigTarget;
93 import com.sun.enterprise.admin.target.TargetType;
94 import com.sun.enterprise.admin.target.TargetBuilder;
95
96 import com.sun.enterprise.admin.meta.MBeanRegistry;
97
98 import com.sun.enterprise.admin.util.JvmOptionsHelper;
99 import com.sun.enterprise.admin.util.InvalidJvmOptionException;
100
101 public class ConfigsMBean extends BaseConfigMBean
102     implements IConfigsMBean
103 {
104
105      /**
106      * Default http-acceptor-threads for PE.
107      *
108      */

109     public static final String JavaDoc DEFAULT_HTTP_LISTENER_ACCEPTOR_THREADS = "1";
110     
111
112     /**
113      * Valid targets for the configuration mbeans are 1) a named configuration,
114      * 2) a named server instance 3) a named cluster
115      *
116      * FIXTHIS: This needs to be made pluggable.
117      */

118     private static final TargetType[] VALID_CREATE_DELETE_TYPES = new TargetType[] {
119         TargetType.CLUSTER, TargetType.CONFIG, TargetType.UNCLUSTERED_SERVER, TargetType.DAS};
120         
121     private static final TargetType[] VALID_LIST_TYPES = new TargetType[] {
122         TargetType.CLUSTER, TargetType.CONFIG, TargetType.SERVER, TargetType.DAS};
123         
124     /**
125      * i18n strings manager object
126      */

127     private static final StringManager localStrings =
128         StringManager.getManager(ConfigsMBean.class);
129
130     /**
131      */

132     public ConfigsMBean()
133     {
134         super();
135     }
136     
137     /**
138      * Resolve target name to associated config name.
139      *
140      * @param targetName target name to resolve
141      *
142      * @returns config name associated with given target
143      */

144     public String JavaDoc getConfigNameForTarget(String JavaDoc targetName)
145          throws Exception JavaDoc
146     {
147         final Target target = getTarget(targetName);
148         final ConfigTarget configTarget = target.getConfigTarget();
149         return configTarget.getName();
150      }
151 //HTTP Listener
152

153     public ObjectName JavaDoc createHttpListener( AttributeList JavaDoc attrList,
154                                             Properties JavaDoc props,
155                                             String JavaDoc targetName)
156         throws MBeanException JavaDoc
157     {
158         final Target target = getTarget(targetName);
159         check1ToN(target);
160
161         //set the default acceptor threads if not specified in attrList
162
if(!ConfigMBeanUtil.attributeDefinedInList(attrList,
163                 ServerTags.ACCEPTOR_THREADS)) {
164            attrList.add(new Attribute JavaDoc(ServerTags.ACCEPTOR_THREADS,
165                 getDefaultHTTPListenerAcceptorThreads()));
166         }
167
168
169         ObjectName JavaDoc httpService = getHttpServiceMBean(target);
170         ObjectName JavaDoc mbean = (ObjectName JavaDoc)invoke1(httpService,
171             "createHttpListener", attrList, AttributeList JavaDoc.class.getName());
172         setProperties(mbean, props);
173         //4954870
174
try
175         {
176             HttpListenerVirtualServerAssociationMgr mgr =
177                 new HttpListenerVirtualServerAssociationMgr(getConfigContext(),
178                     target.getConfigRef());
179             mgr.addHttpListenerRef(mbean.getKeyProperty("id"));
180         }
181         catch (ConfigException ce)
182         {
183             throw MBeanExceptionFormatter.toMBeanException(ce, null);
184         }
185         //4954870
186
return mbean;
187     }
188
189     public boolean deleteHttpListener(String JavaDoc listenerId, String JavaDoc targetName)
190         throws MBeanException JavaDoc
191     {
192         final Target target = getTarget(targetName);
193         //4954870
194
try
195         {
196             HttpListenerVirtualServerAssociationMgr mgr =
197                 new HttpListenerVirtualServerAssociationMgr(getConfigContext(),
198                     target.getConfigRef());
199             mgr.deleteHttpListenerRef(listenerId);
200         }
201         catch (ConfigException ce)
202         {
203             throw MBeanExceptionFormatter.toMBeanException(ce, null);
204         }
205         //4954870
206
check1ToN(target);
207         final ObjectName JavaDoc httpService = getHttpServiceMBean(target);
208         invoke1(httpService, "removeHttpListenerById", listenerId,
209                 String JavaDoc.class.getName());
210         return true;
211     }
212
213     public ObjectName JavaDoc[] listHttpListeners(String JavaDoc targetName)
214         throws MBeanException JavaDoc
215     {
216         final Target target = getListTarget(targetName);
217         ObjectName JavaDoc httpService = getHttpServiceMBean(target);
218         ObjectName JavaDoc[] ret = (ObjectName JavaDoc[])invoke0(httpService,
219                                                  "getHttpListener");
220         return ret;
221     }
222
223 //IIOP Listener
224
public ObjectName JavaDoc createIiopListener( AttributeList JavaDoc attrList,
225                                             Properties JavaDoc props,
226                                             String JavaDoc targetName)
227         throws MBeanException JavaDoc
228     {
229         final Target target = getTarget(targetName);
230         check1ToN(target);
231         ObjectName JavaDoc iiopService = getIiopServiceMBean(target);
232         ObjectName JavaDoc mbean = (ObjectName JavaDoc)invoke1(iiopService,
233             "createIiopListener", attrList, AttributeList JavaDoc.class.getName());
234         setProperties(mbean, props);
235         return mbean;
236     }
237
238     public boolean deleteIiopListener(String JavaDoc listenerId, String JavaDoc targetName)
239         throws MBeanException JavaDoc
240     {
241         final Target target = getTarget(targetName);
242         check1ToN(target);
243         final ObjectName JavaDoc iiopService = getIiopServiceMBean(target);
244         invoke1(iiopService, "removeIiopListenerById", listenerId,
245                 String JavaDoc.class.getName());
246         return true;
247     }
248
249     public ObjectName JavaDoc[] listIiopListeners(String JavaDoc targetName)
250         throws MBeanException JavaDoc
251     {
252         final Target target = getListTarget(targetName);
253         ObjectName JavaDoc iiopService = getIiopServiceMBean(target);
254         ObjectName JavaDoc[] ret = (ObjectName JavaDoc[])invoke0(iiopService,
255                                                  "getIiopListener");
256         return ret;
257     }
258
259 //SSL
260
public ObjectName JavaDoc createSsl(AttributeList JavaDoc al,
261                                 String JavaDoc id,
262                                 String JavaDoc type,
263                                 String JavaDoc targetName)
264         throws Exception JavaDoc
265     {
266         final Target target = getTarget(targetName);
267         check1ToN(target);
268         ObjectName JavaDoc targetON = getSslTargetObjectName(target, id, type);
269         if ("iiop-service".equals(type))
270         {
271             Config config = getConfigBeanForTarget(target);
272             IiopService iiopService = config.getIiopService();
273             SslClientConfig sslCfg = new SslClientConfig();
274             sslCfg.setXPath(sslCfg.getAbsoluteXPath(iiopService.getXPath()));
275             ManagedConfigBean mb = new ManagedConfigBean(
276                     (ConfigBean)sslCfg, m_registry, getDomainName());
277             mb.createChildByType("ssl", al, null, true);
278             iiopService.setSslClientConfig(sslCfg);
279             return (ObjectName JavaDoc)ConfigMBeanHelper.getConfigBeanObjectName(
280                     m_registry,
281                     getDomainName(), sslCfg.getSsl());
282         }
283         checkElementDoesnotExist(targetON, "getSsl",
284             localStrings.getString("configsMBean.ssl_exists"));
285         ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke1(targetON, "createSsl", al,
286                                     AttributeList JavaDoc.class.getName());
287         return ret;
288     }
289
290     public boolean deleteSsl(String JavaDoc id, String JavaDoc type, String JavaDoc targetName)
291         throws MBeanException JavaDoc
292     {
293         final Target target = getTarget(targetName);
294         check1ToN(target);
295         final ObjectName JavaDoc targetON = getSslTargetObjectName(target, id, type);
296         final String JavaDoc opName = "iiop-service".equals(type) ?
297             "removeSslClientConfig" : "removeSsl";
298         invoke0(targetON, opName);
299         return true;
300     }
301
302 //Virtual servers
303
public ObjectName JavaDoc createVirtualServer( AttributeList JavaDoc al,
304                                             Properties JavaDoc props,
305                                             String JavaDoc targetName)
306         throws MBeanException JavaDoc
307     {
308         final Target target = getTarget(targetName);
309         check1ToN(target);
310         ObjectName JavaDoc httpService = getHttpServiceMBean(target);
311         ObjectName JavaDoc mbean = (ObjectName JavaDoc)invoke1(httpService,
312             "createVirtualServer", al, AttributeList JavaDoc.class.getName());
313         final Properties JavaDoc nProps = copyProperties(props);
314         addMandatoryVirtualServerProperties(al, nProps); //"optional properties"
315
setProperties(mbean, nProps);
316         return mbean;
317     }
318
319     public boolean deleteVirtualServer(String JavaDoc id, String JavaDoc targetName)
320         throws MBeanException JavaDoc
321     {
322         final Target target = getTarget(targetName);
323         check1ToN(target);
324         final ObjectName JavaDoc httpService = (ObjectName JavaDoc)getHttpServiceMBean(target);
325         invoke1(httpService, "removeVirtualServerById", id,
326                 String JavaDoc.class.getName());
327         return true;
328     }
329
330     public ObjectName JavaDoc[] listVirtualServers(String JavaDoc targetName)
331         throws MBeanException JavaDoc
332     {
333         final Target target = getListTarget(targetName);
334         ObjectName JavaDoc httpService = getHttpServiceMBean(target);
335         ObjectName JavaDoc[] ret = (ObjectName JavaDoc[])invoke0(httpService,
336                                                  "getVirtualServer");
337         return ret;
338     }
339
340 //Auth realms
341
public ObjectName JavaDoc createAuthRealm(AttributeList JavaDoc attrs,
342                                       Properties JavaDoc props,
343                                       String JavaDoc targetName)
344         throws Exception JavaDoc
345     {
346         final Target target = getTarget(targetName);
347         check1ToN(target);
348         
349         //first, create standalone auth-realm
350
Config config = getConfigBeanForTarget(target);
351         SecurityService secService = config.getSecurityService();
352         ManagedConfigBean mcbSecService = getManagedConfigBean(secService);
353         AuthRealm authRealm = (AuthRealm)mcbSecService.createChildByType(
354                 ServerTags.AUTH_REALM, attrs, props);
355         
356         // Second, check keyfile
357
// we need to create empty keyfile if it's not exist
358
// file should exist already - synchronization problems???
359
checkAndCreateAuthRealmKeyFile(authRealm);
360         
361         
362         // Finally, add auth-realm o config context
363
mcbSecService.addChildBean(ServerTags.AUTH_REALM, authRealm, false);
364         return getConfigBeanObjectName(authRealm);
365     }
366     
367     
368     static final String JavaDoc FILE_REALM_CLASSNAME = "com.sun.enterprise.security.auth.realm.file.FileRealm";
369     static final String JavaDoc KEYFILE_PATH_PROPERTY_NAME = "file";
370     
371     //creates empty keyfile for file-realms if it's not exist
372
private void checkAndCreateAuthRealmKeyFile(AuthRealm authRealm)
373         throws MBeanConfigException
374     {
375         if(!FILE_REALM_CLASSNAME.equals(authRealm.getClassname()))
376             return; //only file realms have keyfile reference
377
ElementProperty prop = authRealm.getElementPropertyByName(KEYFILE_PATH_PROPERTY_NAME);
378         if(prop==null)
379         {
380 // String msg = localStrings.getString("configsMBean.no_keyfile_name_property");
381
// _sLogger.log(Level.WARNING, msg);
382
// throw new MBeanConfigException(msg);
383
return; //leave validation exception to config validator
384
}
385         String JavaDoc path=null;
386         try
387         {
388                 path = resolveTokensForDas(prop.getValue());
389                 // this is patch for file-realm only
390
// we need to create empty keyfile if it's not exist
391
File JavaDoc file;
392                 if((file = new File JavaDoc(path))!=null && !file.exists())
393                         file.createNewFile();
394         }
395         catch (Exception JavaDoc e)
396         {
397             String JavaDoc msg = localStrings.getString("configsMBean.can_not_create_keyfile", new Object JavaDoc[]{path});
398             _sLogger.log(Level.WARNING, msg);
399             throw new MBeanConfigException(msg);
400         }
401     }
402     private String JavaDoc resolveTokensForDas(String JavaDoc value) throws ConfigException
403     {
404         String JavaDoc instanceName=MBeanRegistryFactory.getAdminContext().getServerName();
405         PropertyResolver resolver = new PropertyResolver(getConfigContext(), instanceName);
406         return resolver.resolve(value, true);
407     }
408     
409     
410     public boolean deleteAuthRealm(String JavaDoc name, String JavaDoc targetName)
411         throws MBeanException JavaDoc
412     {
413         final Target target = getTarget(targetName);
414         check1ToN(target);
415         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
416         invoke1(securityService, "removeAuthRealmByName", name,
417                 String JavaDoc.class.getName());
418         return true;
419     }
420
421     public ObjectName JavaDoc[] listAuthRealms(String JavaDoc targetName)
422         throws MBeanException JavaDoc
423     {
424         final Target target = getListTarget(targetName);
425         ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
426         ObjectName JavaDoc[] ret = (ObjectName JavaDoc[])invoke0(securityService,
427                                                  "getAuthRealm");
428         return ret;
429     }
430
431     public void addUser(String JavaDoc user,
432                         String JavaDoc password,
433                         String JavaDoc[] grps,
434                         String JavaDoc realmName,
435                         String JavaDoc targetName)
436         throws MBeanException JavaDoc
437     {
438         final Target target = getTarget(targetName);
439         check1ToN(target);
440         realmName = (realmName != null) ?
441                     realmName : getDefaultAuthRealm(target);
442         final ObjectName JavaDoc authRealm = getAuthRealmMBean(target, realmName);
443         invokeN(authRealm, "addUser", new Object JavaDoc[] {user, password, grps},
444                 new String JavaDoc[] {String JavaDoc.class.getName(), String JavaDoc.class.getName(),
445                               new String JavaDoc[0].getClass().getName()});
446     }
447
448     public void updateUser( String JavaDoc user,
449                             String JavaDoc password,
450                             String JavaDoc[] grps,
451                             String JavaDoc realmName,
452                             String JavaDoc targetName)
453         throws MBeanException JavaDoc
454     {
455         final Target target = getTarget(targetName);
456         check1ToN(target);
457         realmName = (realmName != null) ?
458                     realmName : getDefaultAuthRealm(target);
459         final ObjectName JavaDoc authRealm = getAuthRealmMBean(target, realmName);
460         invokeN(authRealm, "updateUser", new Object JavaDoc[] {user, password, grps},
461                 new String JavaDoc[] {String JavaDoc.class.getName(), String JavaDoc.class.getName(),
462                               new String JavaDoc[0].getClass().getName()});
463     }
464
465     public void removeUser( String JavaDoc user,
466                             String JavaDoc realmName,
467                             String JavaDoc targetName)
468         throws MBeanException JavaDoc
469     {
470         final Target target = getTarget(targetName);
471         check1ToN(target);
472         realmName = (realmName != null) ?
473                     realmName : getDefaultAuthRealm(target);
474         final ObjectName JavaDoc authRealm = getAuthRealmMBean(target, realmName);
475         invoke1(authRealm, "removeUser", user, String JavaDoc.class.getName());
476     }
477
478     public String JavaDoc[] getUserNames(String JavaDoc realmName, String JavaDoc targetName)
479         throws MBeanException JavaDoc
480     {
481         final Target target = getListTarget(targetName);
482         realmName = (realmName != null) ?
483                     realmName : getDefaultAuthRealm(target);
484         final ObjectName JavaDoc authRealm = getAuthRealmMBean(target, realmName);
485         return (String JavaDoc[])invoke0(authRealm, "getUserNames");
486     }
487
488     public String JavaDoc[] getGroupNames( String JavaDoc user,
489                                     String JavaDoc realmName,
490                                     String JavaDoc targetName)
491         throws MBeanException JavaDoc
492     {
493         final Target target = getListTarget(targetName);
494         realmName = (realmName != null) ?
495                     realmName : getDefaultAuthRealm(target);
496         final ObjectName JavaDoc authRealm = getAuthRealmMBean(target, realmName);
497         return (String JavaDoc[])invoke1(authRealm, "getUserGroupNames",
498                                 user, String JavaDoc.class.getName());
499     }
500
501 //Profiler
502
public ObjectName JavaDoc createProfiler(AttributeList JavaDoc al,
503                                      Properties JavaDoc props,
504                                      String JavaDoc targetName)
505         throws MBeanException JavaDoc
506     {
507         final Target target = getTarget(targetName);
508         check1ToN(target);
509         final ObjectName JavaDoc javaConfig = getJavaConfigMBean(target);
510         checkElementDoesnotExist(javaConfig, "getProfiler",
511             localStrings.getString("configsMBean.profiler_exists"));
512         final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(javaConfig,
513             "createProfiler", al, AttributeList JavaDoc.class.getName());
514         setProperties(on, props);
515         return on;
516     }
517
518     public boolean deleteProfiler(String JavaDoc targetName) throws MBeanException JavaDoc
519     {
520         final Target target = getTarget(targetName);
521         check1ToN(target);
522         final ObjectName JavaDoc javaConfig = getJavaConfigMBean(target);
523         invoke0(javaConfig, "removeProfiler");
524         return true;
525     }
526
527 //JVM options
528
public String JavaDoc[] getJvmOptions(boolean isProfiler, String JavaDoc targetName)
529         throws MBeanException JavaDoc
530     {
531         return getJvmOptions(isProfiler, getListTarget(targetName));
532     }
533
534     /**
535          Adds the given jvm options to the existing set of jvm options.
536          Excludes the jvm options that already exist.
537          @param options jvm options to be added.
538          @param isProfiler jvm-options can be added either to the java
539          config element or to the profiler element.
540          @param targetName
541          @return Returns an array of jvm options that could not be added.
542          This array will be atleast of 0 length so that callers donot have
543          to check for null. A non zero length indicates that some of the
544          specified options could not be added successfully.
545          @throws MBeanException
546          @throws IllegalArgumentException if the options argument is null.
547          @throws InvalidJvmOptionException
548      */

549     public String JavaDoc[] createJvmOptions(String JavaDoc[] options,
550                                      boolean isProfiler,
551                                      String JavaDoc targetName)
552         throws MBeanException JavaDoc, InvalidJvmOptionException
553     {
554         if (null == options)
555         {
556             throw new IllegalArgumentException JavaDoc(
557                 localStrings.getString("configsMBean.null_jvm_options"));
558         }
559         final Target target = getTarget(targetName);
560         quoteOptionsWithSpaces(options);
561         check1ToN(target);
562         final String JavaDoc[] oldOptions = getJvmOptions(isProfiler, target);
563         final JvmOptionsHelper jvmOptions = new JvmOptionsHelper(oldOptions);
564         final String JavaDoc[] invalid = jvmOptions.addJvmOptions(options);
565         final ObjectName JavaDoc targetON = getJvmOptionsTargetObjectName(
566                                         target, isProfiler);
567         setAttribute0(targetON, "jvm_options", jvmOptions.getJvmOptionsAsStoredInXml());
568         postInvoke("createJvmOptions", null);
569
570         return invalid;
571     }
572     
573     private void quoteOptionsWithSpaces(String JavaDoc[] options)
574     {
575        for(int i=0; i<options.length; i++)
576        {
577            if(options[i].indexOf(' ')>=0 &&
578               (!options[i].startsWith("\"") || !options[i].endsWith("\"")))
579            {
580                options[i] = "\"" + options[i] + "\"";
581            }
582        }
583     }
584
585     /**
586          Deletes the given jvm options from the existing set of jvm options.
587          @param options jvm options to be deleted.
588          @param isProfiler jvm-options can exist in either the java config
589          element or the profiler element.
590          @param targetName
591          @return Returns an array of jvm options that could not be deleted.
592          This array will be atleast of 0 length so that callers donot have
593          to check for null. A non zero length indicates that some of the
594          specified options could not be deleted successfully.
595          @throws MBeanException
596          @throws IllegalArgumentException if the options argument is null.
597      */

598     public String JavaDoc[] deleteJvmOptions(String JavaDoc[] options,
599                                      boolean isProfiler,
600                                      String JavaDoc targetName)
601         throws MBeanException JavaDoc, InvalidJvmOptionException
602     {
603         if (null == options)
604         {
605             throw new IllegalArgumentException JavaDoc(
606                 localStrings.getString("configsMBean.null_jvm_options"));
607         }
608         quoteOptionsWithSpaces(options);
609         final Target target = getTarget(targetName);
610         check1ToN(target);
611         final String JavaDoc[] oldOptions = getJvmOptions(isProfiler, target);
612         final JvmOptionsHelper jvmOptions = new JvmOptionsHelper(oldOptions);
613         final String JavaDoc[] invalid = jvmOptions.deleteJvmOptions(options);
614         final ObjectName JavaDoc targetON = getJvmOptionsTargetObjectName(
615                                         target, isProfiler);
616         setAttribute0(targetON, "jvm_options", jvmOptions.getJvmOptionsAsStoredInXml());
617         postInvoke("deleteJvmOptions", null);
618
619         return invalid;
620     }
621
622 //Audit module
623
public ObjectName JavaDoc createAuditModule(AttributeList JavaDoc attrs,
624                                         Properties JavaDoc props,
625                                         String JavaDoc targetName)
626         throws MBeanException JavaDoc
627     {
628         final Target target = getTarget(targetName);
629         check1ToN(target);
630         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
631         final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(securityService,
632             "createAuditModule", attrs, AttributeList JavaDoc.class.getName());
633         setProperties(on, props);
634         return on;
635     }
636
637     public ObjectName JavaDoc[] listAuditModules(String JavaDoc targetName)
638         throws MBeanException JavaDoc
639     {
640         final Target target = getListTarget(targetName);
641         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
642         return (ObjectName JavaDoc[])invoke0(securityService, "getAuditModule");
643     }
644
645     public boolean deleteAuditModule(String JavaDoc name, String JavaDoc targetName)
646         throws MBeanException JavaDoc
647     {
648         final Target target = getTarget(targetName);
649         check1ToN(target);
650         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
651         invoke1(securityService, "removeAuditModuleByName", name,
652                 String JavaDoc.class.getName());
653         return true;
654     }
655
656 //Jms host
657
public ObjectName JavaDoc createJmsHost(AttributeList JavaDoc attrs,
658                                     Properties JavaDoc props,
659                                     String JavaDoc targetName)
660         throws MBeanException JavaDoc
661     {
662         final Target target = getTarget(targetName);
663         check1ToN(target);
664         final ObjectName JavaDoc jmsService = getJmsServiceMBean(target, true);
665         final ObjectName JavaDoc jmsHost = (ObjectName JavaDoc)invoke1(jmsService,
666             "createJmsHost", attrs, AttributeList JavaDoc.class.getName());
667         setProperties(jmsHost, props);
668         return jmsHost;
669     }
670
671     public boolean deleteJmsHost(String JavaDoc name, String JavaDoc targetName)
672         throws MBeanException JavaDoc
673     {
674         final Target target = getTarget(targetName);
675         check1ToN(target);
676         final ObjectName JavaDoc jmsService = getJmsServiceMBean(target, false);
677         assertIt((jmsService != null),
678             localStrings.getString("configsMBean.no_jms_service"));
679
680     //START_BUG_FIX: 6178076
681
if(name.equals(getAttribute0(jmsService, "default_jms_host"))) {
682         // set it to null since the jms host is being deleted.
683
// runtime has default anyway.
684
setAttribute0(jmsService, "default_jms_host", null);
685             _sLogger.log(Level.FINE,
686         "default-jms-host attribute of jms-service for target "
687         + targetName
688         + " has been set to null");
689     }
690     //END_BUG_FIX: 6178076
691

692         invoke1(jmsService, "removeJmsHostByName", name,
693                 String JavaDoc.class.getName());
694         return true;
695     }
696
697     public ObjectName JavaDoc[] listJmsHosts(String JavaDoc targetName) throws MBeanException JavaDoc
698     {
699         final Target target = getListTarget(targetName);
700         final ObjectName JavaDoc jmsService = getJmsServiceMBean(target, false);
701         assertIt((jmsService != null),
702             localStrings.getString("configsMBean.no_jms_service"));
703         return (ObjectName JavaDoc[])invoke0(jmsService, "getJmsHost");
704     }
705
706     //**********************************************************************
707
private ElementProperty[] convertPropertiesToElementProperties(Properties JavaDoc props)
708     {
709         ArrayList JavaDoc list = new ArrayList JavaDoc();
710         Enumeration JavaDoc keys = props.keys();
711         while (keys.hasMoreElements())
712         {
713             final String JavaDoc key = (String JavaDoc)keys.nextElement();
714             ElementProperty property = new ElementProperty();
715             property.setName(key);
716             property.setValue((String JavaDoc)props.get(key));
717             list.add(property);
718         }
719         return (ElementProperty[])list.toArray(new ElementProperty[list.size()]);
720     }
721     
722 static final String JavaDoc PROVIDER_TYPE_SERVER = "server";
723 static final String JavaDoc PROVIDER_TYPE_CLIENT = "client";
724
725     //**********************************************************************
726
//message-security
727
/*
728      * Creates the message-security-config and provider-config sub elements
729      * for the security-service.
730      * If the message-layer doesnt exist a new subelement for message-security-config
731      * is created and then the provider-config is created under it.
732      */

733     public ObjectName JavaDoc createMessageSecurityProvider(
734         String JavaDoc messageLayer, // auth-layer attribute of message-security-config
735

736         String JavaDoc providerId, // provider id
737
String JavaDoc providerType, // "client"/"server"/"client-server"
738
String JavaDoc providerClassName, // The class-name of java class of the provider.
739

740         String JavaDoc requestAuthSource, // requirement for message layer sender authentication (can be null)
741
String JavaDoc requestAuthRecipient, // requirement for message layer receiver authentication (can be null)
742

743         String JavaDoc responseAuthSource, // requirement for message layer sender authentication (can be null)
744
String JavaDoc responseAuthRecipient, // requirement for message layer receiver authentication (can be null)
745

746         boolean isDefaultProvider, // set pro
747
Properties JavaDoc props, //provider's properties
748
String JavaDoc targetName // target name (config, instance, cluster, or 'server')
749
)
750         throws Exception JavaDoc
751     {
752         final Target target = getTarget(targetName);
753         check1ToN(target);
754         final ConfigTarget configTarget = target.getConfigTarget();
755         boolean bMessageConfigJustCreated = false;
756         Config config = ConfigAPIHelper.getConfigByName(getConfigContext(), configTarget.getName());
757         SecurityService securityService = config.getSecurityService();
758         
759         //message-security-config
760
MessageSecurityConfig messageSecurity = securityService.getMessageSecurityConfigByAuthLayer(messageLayer);
761         if(messageSecurity==null)
762         {
763           // we have to create it
764
messageSecurity = new MessageSecurityConfig();
765            messageSecurity.setAuthLayer(messageLayer);
766            bMessageConfigJustCreated = true;
767         }
768         
769         //provider-config
770
ProviderConfig provider = new ProviderConfig();
771         provider.setClassName(providerClassName);
772         provider.setProviderId(providerId);
773         provider.setProviderType(providerType);
774         
775         //properties
776
if (null != props)
777         {
778             provider.setElementProperty(convertPropertiesToElementProperties(props));
779         }
780
781         //request-policy
782
if(requestAuthSource!=null || requestAuthRecipient!=null )
783         {
784             RequestPolicy requestPolicy = new RequestPolicy();
785             if(requestAuthSource!=null)
786                 requestPolicy.setAuthSource(requestAuthSource);
787             if(requestAuthRecipient!=null)
788                 requestPolicy.setAuthRecipient(requestAuthRecipient);
789             provider.setRequestPolicy(requestPolicy);
790         }
791
792         //response-policy
793
if(responseAuthSource!=null || responseAuthRecipient!=null )
794         {
795             ResponsePolicy responsePolicy = new ResponsePolicy();
796             if(responseAuthSource!=null)
797                 responsePolicy.setAuthSource(responseAuthSource);
798             if(responseAuthRecipient!=null)
799                 responsePolicy.setAuthRecipient(responseAuthRecipient);
800             provider.setResponsePolicy(responsePolicy);
801         }
802
803         messageSecurity.addProviderConfig(provider);
804         //set default provider
805
if(isDefaultProvider)
806         {
807             if(PROVIDER_TYPE_SERVER.equals(providerType))
808                 messageSecurity.setDefaultProvider(providerId);
809             else if(PROVIDER_TYPE_CLIENT.equals(providerType))
810                 messageSecurity.setDefaultClientProvider(providerId);
811             else
812             {
813                 messageSecurity.setDefaultProvider(providerId);
814                 messageSecurity.setDefaultClientProvider(providerId);
815             }
816         }
817         if(bMessageConfigJustCreated)
818         {
819             securityService.addMessageSecurityConfig(messageSecurity);
820         }
821         
822         return getMBeanRegistry().getMbeanObjectName("provider-config",
823                    new String JavaDoc[]{getDomainName(), configTarget.getName(), messageLayer, providerId});
824     }
825
826     //**********************************************************************
827
/*
828      * Deletes the provider-config sub element for the given message-layer.
829      * If this is the last provider for the given message-layer,
830      * then the message-layer subelement is also deleted
831      */

832     public boolean deleteMessageSecurityProvider(
833         String JavaDoc messageLayer, // auth-layer attribute of message-security-config
834
String JavaDoc providerId, // provider id
835
String JavaDoc targetName // target name (config, instance, cluster, or 'server')
836
) throws Exception JavaDoc
837     {
838         final Target target = getTarget(targetName);
839         check1ToN(target);
840         Config config = ConfigAPIHelper.getConfigByName(getConfigContext(),
841                         target.getConfigTarget().getName());
842         SecurityService securityService = config.getSecurityService();
843         MessageSecurityConfig messageSecurity =
844             securityService.getMessageSecurityConfigByAuthLayer(messageLayer);
845         if(messageSecurity==null)
846         {
847             String JavaDoc msg = localStrings.getString( "admin.mbeans.configs.message_security_config_not_found",
848                     new Object JavaDoc[]{messageLayer, targetName});
849             throw new MBeanConfigException(msg);
850         }
851         ProviderConfig[] providers = messageSecurity.getProviderConfig();
852         if(providers.length==1 && providerId.equals(providers[0].getProviderId()))
853         {
854             securityService.removeMessageSecurityConfig(messageSecurity);
855             return true;
856         }
857         ProviderConfig provider = messageSecurity.getProviderConfigByProviderId(providerId);
858         if(provider==null)
859         {
860             String JavaDoc msg = localStrings.getString( "admin.mbeans.configs.security_provider_not_found", new Object JavaDoc[]{providerId, messageLayer, targetName});
861             throw new MBeanConfigException(msg);
862         }
863         messageSecurity.removeProviderConfig(provider);
864
865         return true;
866     }
867
868     //**********************************************************************
869
//* Lists all the providers for a given message-layer.
870
public ObjectName JavaDoc[] listMessageSecurityProviders(
871         String JavaDoc messageLayer, // auth-layer attribute of message-security-config
872
String JavaDoc targetName // target name (config, instance, cluster, or 'server')
873
) throws Exception JavaDoc
874     {
875         final Target target = getListTarget(targetName);
876         Config config = ConfigAPIHelper.getConfigByName(getConfigContext(),
877                         target.getConfigTarget().getName());
878         SecurityService securityService = config.getSecurityService();
879         if(securityService==null)
880             return null;
881         if(messageLayer!=null)
882         {
883             MessageSecurityConfig messageSecurity =
884                    securityService.getMessageSecurityConfigByAuthLayer(messageLayer);
885             if(messageSecurity==null)
886             {
887                 String JavaDoc msg = localStrings.getString( "admin.mbeans.configs.message_security_config_not_found",
888                         new Object JavaDoc[]{messageLayer, targetName});
889                 throw new MBeanConfigException(msg);
890             }
891             return getMessageSecurityProviders(messageSecurity);
892         }
893         //here we are for null-messageLayer only
894
MessageSecurityConfig[] messageSecurities =
895                securityService.getMessageSecurityConfig();
896         ArrayList JavaDoc arr = new ArrayList JavaDoc();
897         if(messageSecurities!=null)
898             for(int i=0; i<messageSecurities.length; i++)
899             {
900                 ObjectName JavaDoc[] names = getMessageSecurityProviders(messageSecurities[i]);
901                 if(names!=null)
902                     for(int j=0; j<names.length; j++)
903                         arr.add(names[j]);
904             }
905         return (ObjectName JavaDoc[])arr.toArray(new ObjectName JavaDoc[arr.size()]);
906     }
907
908     //**********************************************************************
909
//* Lists all the providers for a given message-layer.
910
private ObjectName JavaDoc[] getMessageSecurityProviders(
911         MessageSecurityConfig messageSecurity
912         ) throws Exception JavaDoc
913     {
914         ProviderConfig[] providers = messageSecurity.getProviderConfig();
915         return ConfigMBeanHelper.getConfigBeansObjectNames(
916             this.getMBeanRegistry(), this.getDomainName(), providers);
917     }
918     //**********************************************************************
919

920     //JACC provider
921
public ObjectName JavaDoc createJaccProvider( AttributeList JavaDoc attrs,
922                                             Properties JavaDoc props,
923                                             String JavaDoc targetName)
924         throws MBeanException JavaDoc
925     {
926         final Target target = getTarget(targetName);
927         check1ToN(target);
928         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
929         final ObjectName JavaDoc jaccProvider = (ObjectName JavaDoc)invoke1(securityService,
930             "createJaccProvider", attrs, AttributeList JavaDoc.class.getName());
931         setProperties(jaccProvider, props);
932         return jaccProvider;
933     }
934
935     public boolean deleteJaccProvider(String JavaDoc name, String JavaDoc targetName)
936         throws MBeanException JavaDoc
937     {
938         final Target target = getTarget(targetName);
939         check1ToN(target);
940         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
941         invoke1(securityService, "removeJaccProviderByName", name,
942                 String JavaDoc.class.getName());
943         return true;
944     }
945
946     public ObjectName JavaDoc[] listJaccProviders(String JavaDoc targetName)
947         throws MBeanException JavaDoc
948     {
949         final Target target = getListTarget(targetName);
950         final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
951         return (ObjectName JavaDoc[])invoke0(securityService, "getJaccProvider");
952     }
953
954 //Thread pool
955
public ObjectName JavaDoc createThreadPool(AttributeList JavaDoc attrs,
956                                        Properties JavaDoc props,
957                                        String JavaDoc targetName)
958         throws MBeanException JavaDoc
959     {
960         final Target target = getTarget(targetName);
961         check1ToN(target);
962         final ObjectName JavaDoc threadPools = getThreadPoolsMBean(target);
963         final ObjectName JavaDoc threadPool = (ObjectName JavaDoc)invoke1(threadPools,
964             "createThreadPool", attrs, AttributeList JavaDoc.class.getName());
965         setProperties(threadPool, props);
966         return threadPool;
967     }
968
969     public boolean deleteThreadPool(String JavaDoc threadPoolId, String JavaDoc targetName)
970         throws MBeanException JavaDoc
971     {
972         final Target target = getTarget(targetName);
973         check1ToN(target);
974         final ObjectName JavaDoc threadPools = getThreadPoolsMBean(target);
975         invoke1(threadPools, "removeThreadPoolByThreadPoolId",
976             threadPoolId, String JavaDoc.class.getName());
977         return true;
978     }
979
980     public ObjectName JavaDoc[] listThreadPools(String JavaDoc targetName)
981         throws MBeanException JavaDoc
982     {
983         final Target target = getListTarget(targetName);
984         final ObjectName JavaDoc threadPools = getThreadPoolsMBean(target);
985         return (ObjectName JavaDoc[])invoke0(threadPools, "getThreadPool");
986     }
987
988 //EJB Timer Service
989
public ObjectName JavaDoc createEjbTimerService(AttributeList JavaDoc al,
990                                             Properties JavaDoc props,
991                                             String JavaDoc targetName)
992         throws MBeanException JavaDoc
993     {
994         final ObjectName JavaDoc ejbContainer = getEjbContainer(targetName);
995         final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(ejbContainer,
996             "createEjbTimerService", al, AttributeList JavaDoc.class.getName());
997         setProperties(on, props);
998         return on;
999     }
1000
1001    public boolean deleteEjbTimerService(String JavaDoc targetName)
1002        throws MBeanException JavaDoc
1003    {
1004        final ObjectName JavaDoc ejbContainer = getEjbContainer(targetName);
1005        invoke0(ejbContainer, "removeEjbTimerService");
1006        return true;
1007    }
1008
1009//Session Properties
1010
public ObjectName JavaDoc createSessionProperties( AttributeList JavaDoc al,
1011                                                Properties JavaDoc props,
1012                                                String JavaDoc targetName)
1013        throws MBeanException JavaDoc
1014    {
1015        final Target target = getTarget(targetName);
1016        check1ToN(target);
1017        final ObjectName JavaDoc sessionConfig = getSessionConfigMBean(target, true);
1018        final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(sessionConfig,
1019            "createSessionProperties", al, AttributeList JavaDoc.class.getName());
1020        setProperties(on, props);
1021        return on;
1022    }
1023
1024    public boolean deleteSessionProperties(String JavaDoc targetName)
1025        throws MBeanException JavaDoc
1026    {
1027        final Target target = getTarget(targetName);
1028        check1ToN(target);
1029        final ObjectName JavaDoc sessionConfig = getSessionConfigMBean(target, false);
1030        invoke0(sessionConfig, "removeSessionProperties");
1031        return true;
1032    }
1033
1034//Manager Properties
1035
public ObjectName JavaDoc createManagerProperties( AttributeList JavaDoc al,
1036                                                Properties JavaDoc props,
1037                                                String JavaDoc targetName)
1038        throws MBeanException JavaDoc
1039    {
1040        final Target target = getTarget(targetName);
1041        check1ToN(target);
1042        final ObjectName JavaDoc sessionManager = getSessionManagerMBean(target, true);
1043        final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(sessionManager,
1044            "createManagerProperties", al, AttributeList JavaDoc.class.getName());
1045        setProperties(on, props);
1046        return on;
1047    }
1048
1049    public boolean deleteManagerProperties(String JavaDoc targetName)
1050        throws MBeanException JavaDoc
1051    {
1052        final Target target = getTarget(targetName);
1053        check1ToN(target);
1054        final ObjectName JavaDoc sessionManager = getSessionManagerMBean(target, false);
1055        invoke0(sessionManager, "removeManagerProperties");
1056        return true;
1057    }
1058
1059//Store Properties
1060
public ObjectName JavaDoc createStoreProperties(AttributeList JavaDoc al,
1061                                            Properties JavaDoc props,
1062                                            String JavaDoc targetName)
1063        throws MBeanException JavaDoc
1064    {
1065        final Target target = getTarget(targetName);
1066        check1ToN(target);
1067        final ObjectName JavaDoc sessionManager = getSessionManagerMBean(target, true);
1068        final ObjectName JavaDoc on = (ObjectName JavaDoc)invoke1(sessionManager,
1069            "createStoreProperties", al, AttributeList JavaDoc.class.getName());
1070        setProperties(on, props);
1071        return on;
1072    }
1073
1074    public boolean deleteStoreProperties(String JavaDoc targetName)
1075        throws MBeanException JavaDoc
1076    {
1077        final Target target = getTarget(targetName);
1078        check1ToN(target);
1079        final ObjectName JavaDoc sessionManager = getSessionManagerMBean(target, false);
1080        invoke0(sessionManager, "removeStoreProperties");
1081        return true;
1082    }
1083
1084//Session Config
1085
public boolean deleteSessionConfig(String JavaDoc targetName)
1086        throws MBeanException JavaDoc
1087    {
1088        final Target target = getTarget(targetName);
1089        check1ToN(target);
1090        final ObjectName JavaDoc webContainer = getChild("web-container", null, target);
1091        invoke0(webContainer, "removeSessionConfig");
1092        return true;
1093    }
1094
1095//Get methods
1096
public ObjectName JavaDoc getHttpService(String JavaDoc targetName) throws MBeanException JavaDoc
1097    {
1098        return getChild("http-service", null, targetName);
1099    }
1100
1101    public ObjectName JavaDoc getIiopService(String JavaDoc targetName) throws MBeanException JavaDoc
1102    {
1103        return getChild("iiop-service", null, targetName);
1104    }
1105
1106    public ObjectName JavaDoc getEjbContainer(String JavaDoc targetName) throws MBeanException JavaDoc
1107    {
1108        return getChild("ejb-container", null, targetName);
1109    }
1110
1111    public ObjectName JavaDoc getWebContainer(String JavaDoc targetName) throws MBeanException JavaDoc
1112    {
1113        return getChild("web-container", null, targetName);
1114    }
1115
1116    public ObjectName JavaDoc getMdbContainer(String JavaDoc targetName) throws MBeanException JavaDoc
1117    {
1118        return getChild("mdb-container", null, targetName);
1119    }
1120
1121    public ObjectName JavaDoc getJmsService(String JavaDoc targetName) throws MBeanException JavaDoc
1122    {
1123        return getChild("jms-service", null, targetName);
1124    }
1125
1126    public ObjectName JavaDoc getLogService(String JavaDoc targetName) throws MBeanException JavaDoc
1127    {
1128        return getChild("log-service", null, targetName);
1129    }
1130
1131    public ObjectName JavaDoc getSecurityService(String JavaDoc targetName) throws MBeanException JavaDoc
1132    {
1133        return getChild("security-service", null, targetName);
1134    }
1135
1136    public ObjectName JavaDoc getTransactionService(String JavaDoc targetName)
1137        throws MBeanException JavaDoc
1138    {
1139        return getChild("transaction-service", null, targetName);
1140    }
1141
1142    public ObjectName JavaDoc getMonitoringService(String JavaDoc targetName)
1143        throws MBeanException JavaDoc
1144    {
1145        return getChild("monitoring-service", null, targetName);
1146    }
1147
1148    public ObjectName JavaDoc getJavaConfig(String JavaDoc targetName) throws MBeanException JavaDoc
1149    {
1150        return getChild("java-config", null, targetName);
1151    }
1152
1153    public ObjectName JavaDoc getHttpListener(String JavaDoc id, String JavaDoc targetName)
1154        throws MBeanException JavaDoc
1155    {
1156        return getChild("http-listener", new String JavaDoc[]{id}, targetName);
1157    }
1158
1159    public ObjectName JavaDoc getVirtualServer(String JavaDoc id, String JavaDoc targetName)
1160        throws MBeanException JavaDoc
1161    {
1162        return getChild("virtual-server", new String JavaDoc[]{id}, targetName);
1163    }
1164
1165    public ObjectName JavaDoc getIiopListener(String JavaDoc id, String JavaDoc targetName)
1166        throws MBeanException JavaDoc
1167    {
1168        return getChild("iiop-listener", new String JavaDoc[]{id}, targetName);
1169    }
1170
1171    public ObjectName JavaDoc getOrb(String JavaDoc targetName) throws MBeanException JavaDoc
1172    {
1173        return getChild("orb", null, targetName);
1174    }
1175
1176    public ObjectName JavaDoc getJmsHost(String JavaDoc name, String JavaDoc targetName)
1177        throws MBeanException JavaDoc
1178    {
1179        return getChild("jms-host", new String JavaDoc[]{name}, targetName);
1180    }
1181
1182    public ObjectName JavaDoc getAuthRealm(String JavaDoc name, String JavaDoc targetName)
1183        throws MBeanException JavaDoc
1184    {
1185        return getChild("auth-realm", new String JavaDoc[]{name}, targetName);
1186    }
1187
1188    public ObjectName JavaDoc getAuditModule(String JavaDoc name, String JavaDoc targetName)
1189        throws MBeanException JavaDoc
1190    {
1191        return getChild("audit-module", new String JavaDoc[]{name}, targetName);
1192    }
1193
1194    public ObjectName JavaDoc getJaccProvider(String JavaDoc name, String JavaDoc targetName)
1195        throws MBeanException JavaDoc
1196    {
1197        return getChild("jacc-provider", new String JavaDoc[]{name}, targetName);
1198    }
1199
1200    public ObjectName JavaDoc getModuleLogLevels(String JavaDoc targetName)
1201        throws MBeanException JavaDoc
1202    {
1203        return getChild("module-log-levels", null, targetName);
1204    }
1205
1206    public ObjectName JavaDoc getModuleMonitoringLevels(String JavaDoc targetName)
1207        throws MBeanException JavaDoc
1208    {
1209        return getChild("module-monitoring-levels", null, targetName);
1210    }
1211
1212    public ObjectName JavaDoc getThreadPool(String JavaDoc threadPoolId, String JavaDoc targetName)
1213        throws MBeanException JavaDoc
1214    {
1215        return getChild("thread-pool", new String JavaDoc[] {threadPoolId}, targetName);
1216    }
1217
1218    public ObjectName JavaDoc getEjbTimerService(String JavaDoc targetName)
1219        throws MBeanException JavaDoc
1220    {
1221        return getChild("ejb-timer-service", null, targetName);
1222    }
1223
1224    public ObjectName JavaDoc getProfiler(String JavaDoc targetName) throws MBeanException JavaDoc
1225    {
1226        return getChild("profiler", null, targetName);
1227    }
1228
1229    public ObjectName JavaDoc getSsl(String JavaDoc type, String JavaDoc id, String JavaDoc targetName)
1230        throws MBeanException JavaDoc
1231    {
1232        final Target target = getListTarget(targetName);
1233        ObjectName JavaDoc sslTarget = getSslTargetObjectName(target, id, type);
1234        if ("iiop-service".equals(type))
1235        {
1236            sslTarget = (ObjectName JavaDoc)invoke0(sslTarget, "getSslClientConfig");
1237        }
1238        return (ObjectName JavaDoc)invoke0(sslTarget, "getSsl");
1239    }
1240
1241    public ObjectName JavaDoc getSessionProperties(String JavaDoc targetName)
1242        throws MBeanException JavaDoc
1243    {
1244        return getChild("session-properties", null, targetName);
1245    }
1246
1247    public ObjectName JavaDoc getManagerProperties(String JavaDoc targetName)
1248        throws MBeanException JavaDoc
1249    {
1250        return getChild("manager-properties", null, targetName);
1251    }
1252
1253    public ObjectName JavaDoc getStoreProperties(String JavaDoc targetName)
1254        throws MBeanException JavaDoc
1255    {
1256        return getChild("store-properties", null, targetName);
1257    }
1258
1259    /**
1260     * A generic operation that returns the ObjectName of a child element
1261     * given its type & parent's location.
1262     * eg:-
1263     * getChild("http-listener", new String[]{"http-listener-1"}, "server")
1264     * getChild("ssl", new String[] {"http-listener-1"}, null);
1265     * getChild("ejb-container", null, null);
1266     * @type The type of the child elemenet. The types are standardized for all
1267     * the config elements that are exposed via config mbeans. Please read the
1268     * mbean descriptor doc for a list of valid types.
1269     * @location an array of tokens that will be used to locate the parent.
1270     * Please note that the order of the tokens is important in order to obtain
1271     * the ObjectName of the parent mbean.
1272     * @targetName
1273     * @throws MBeanException
1274     */

1275    public ObjectName JavaDoc getChild( String JavaDoc type,
1276                                String JavaDoc[] location,
1277                                String JavaDoc targetName) throws MBeanException JavaDoc
1278    {
1279        return getChild(type, location, getListTarget(targetName));
1280    }
1281
1282    protected ObjectName JavaDoc getChild(String JavaDoc type,
1283                                  String JavaDoc[] location,
1284                                  Target target) throws MBeanException JavaDoc
1285    {
1286        final MBeanRegistryEntry entry = getMBeanRegistryEntry(type);
1287        final MBeanNamingInfo namingInfo = getMBeanNamingInfo(entry, type,
1288                    getObjectNameTokens(target, location));
1289        doPersistenceCheck(namingInfo, getConfigContext());
1290        final ObjectName JavaDoc on = getObjectName(namingInfo);
1291        postInvoke("getChild", on);
1292        return on;
1293    }
1294
1295    protected MBeanRegistry getMBeanRegistry() throws MBeanException JavaDoc
1296    {
1297        assertIt((super.m_registry != null),
1298            localStrings.getString("configsMBean.null_registry"));
1299        return super.m_registry;
1300    }
1301  
1302    Target getListTarget(String JavaDoc targetName) throws MBeanException JavaDoc
1303    {
1304        try
1305        {
1306            return TargetBuilder.INSTANCE.createTarget(VALID_LIST_TYPES, targetName,
1307                getConfigContext());
1308        }
1309        catch (Exception JavaDoc e)
1310        {
1311            throw MBeanExceptionFormatter.toMBeanException(e, null);
1312        }
1313    }
1314    
1315    Target getTarget(String JavaDoc targetName) throws MBeanException JavaDoc
1316    {
1317        try
1318        {
1319            Target target = TargetBuilder.INSTANCE.createTarget(VALID_CREATE_DELETE_TYPES, targetName,
1320                getConfigContext());
1321            if (target.getType() == TargetType.SERVER ||
1322                target.getType() == TargetType.DAS) {
1323                //If we are operating on a server, ensure that the server is the only entity
1324
//referencing its config
1325
String JavaDoc configName = ServerHelper.getConfigForServer(getConfigContext(),
1326                    target.getName()).getName();
1327                if (!ConfigAPIHelper.isConfigurationReferencedByServerOnly(getConfigContext(),
1328                    configName, target.getName())) {
1329                        throw new ConfigException(localStrings.getString(
1330                            "configurationHasMultipleRefs", target.getName(), configName,
1331                            ConfigAPIHelper.getConfigurationReferenceesAsString(
1332                                getConfigContext(), configName)));
1333                }
1334            } else if (target.getType() == TargetType.CLUSTER) {
1335                //If we are operating on a cluster, ensure that the cluster is the only entity
1336
//referencing its config
1337
String JavaDoc configName = ClusterHelper.getConfigForCluster(getConfigContext(),
1338                    target.getName()).getName();
1339                if (!ConfigAPIHelper.isConfigurationReferencedByClusterOnly(getConfigContext(),
1340                    configName, target.getName())) {
1341                        throw new ConfigException(localStrings.getString(
1342                            "configurationHasMultipleRefs", target.getName(), configName,
1343                            ConfigAPIHelper.getConfigurationReferenceesAsString(
1344                                getConfigContext(), configName)));
1345                }
1346            }
1347            return target;
1348        }
1349        catch (Exception JavaDoc e)
1350        {
1351            throw MBeanExceptionFormatter.toMBeanException(e, null);
1352        }
1353    }
1354
1355    
1356    void check1ToN(Target target) throws MBeanException JavaDoc
1357    {
1358         /*
1359         * Assumption: A domain should not have an associated config.
1360         * Calling getConfigTarget() on a DomainTarget must raise an
1361         * exception.
1362         */

1363         /* XXX QQ. Comment out to build. FIXME
1364        boolean is1ToN = false;
1365        try
1366        {
1367            final ConfigTarget ct = target.getConfigTarget();
1368            is1ToN = ct.is1ToN(target);
1369        }
1370        catch (Exception e)
1371        {
1372            throw MBeanExceptionFormatter.toMBeanException(e, null);
1373        }
1374        if (is1ToN)
1375        {
1376            throw MBeanExceptionFormatter.toMBeanException(null,
1377                localStrings.getString("configsMBean.multiple_refs"));
1378        }
1379        */

1380    }
1381   
1382    protected ObjectName JavaDoc getConfigMBean(Target target) throws MBeanException JavaDoc
1383    {
1384        ObjectName JavaDoc configMBean = null;
1385        try
1386        {
1387            final ConfigTarget ct = target.getConfigTarget();
1388            configMBean = new ObjectName JavaDoc(ct.getTargetObjectName(
1389                                         new String JavaDoc[] {getDomainName()}));
1390            
1391            postInvoke("getConfigMBean", configMBean);
1392        }
1393        catch (Exception JavaDoc e)
1394        {
1395            throw MBeanExceptionFormatter.toMBeanException(e, null);
1396        }
1397        return configMBean;
1398    }
1399
1400    protected ObjectName JavaDoc getHttpServiceMBean(Target target)
1401        throws MBeanException JavaDoc
1402    {
1403        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1404        ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke0(configMBean, "getHttpService");
1405        return ret;
1406    }
1407
1408    protected ObjectName JavaDoc getIiopServiceMBean(Target target)
1409        throws MBeanException JavaDoc
1410    {
1411        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1412        ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke0(configMBean, "getIiopService");
1413        return ret;
1414    }
1415
1416    protected ObjectName JavaDoc getSecurityServiceMBean(Target target)
1417        throws MBeanException JavaDoc
1418    {
1419        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1420        ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke0(configMBean, "getSecurityService");
1421        return ret;
1422    }
1423
1424    protected ObjectName JavaDoc getJavaConfigMBean(Target target)
1425        throws MBeanException JavaDoc
1426    {
1427        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1428        final ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke0(
1429                                    configMBean, "getJavaConfig");
1430        assertIt((ret != null),
1431            localStrings.getString("configsMBean.no_java_config"));
1432        return ret;
1433    }
1434
1435    protected ObjectName JavaDoc getHttpListenerMBean(Target target, String JavaDoc id)
1436        throws MBeanException JavaDoc
1437    {
1438        return (ObjectName JavaDoc)invoke1(getHttpServiceMBean(target),
1439            "getHttpListenerById", id, String JavaDoc.class.getName());
1440    }
1441
1442    protected ObjectName JavaDoc getIiopListenerMBean(Target target, String JavaDoc id)
1443        throws MBeanException JavaDoc
1444    {
1445        return (ObjectName JavaDoc)invoke1(getIiopServiceMBean(target),
1446            "getIiopListenerById", id, String JavaDoc.class.getName());
1447    }
1448
1449    protected ObjectName JavaDoc getSslTargetObjectName(Target target,
1450                                                String JavaDoc id,
1451                                                String JavaDoc type)
1452        throws MBeanException JavaDoc
1453    {
1454        ObjectName JavaDoc on = null;
1455        if ("http-listener".equals(type))
1456        {
1457            on = getHttpListenerMBean(target, id);
1458        }
1459        else if ("iiop-listener".equals(type))
1460        {
1461            on = getIiopListenerMBean(target, id);
1462        }
1463        else if ("iiop-service".equals(type))
1464        {
1465            on = getIiopServiceMBean(target);
1466        }
1467        else
1468        {
1469            throw MBeanExceptionFormatter.toMBeanException(null,
1470                localStrings.getString("configsMBean.invalid_ssl_target_type",
1471                                       type));
1472        }
1473        assertIt((on != null),
1474            localStrings.getString("configsMBean.target_for_ssl_not_found"));
1475        return on;
1476    }
1477
1478    protected ObjectName JavaDoc getAuthRealmMBean(Target target, String JavaDoc name)
1479        throws MBeanException JavaDoc
1480    {
1481        final ObjectName JavaDoc securityService = getSecurityServiceMBean(target);
1482        final ObjectName JavaDoc authRealm = (ObjectName JavaDoc)invoke1(securityService,
1483            "getAuthRealmByName", name, String JavaDoc.class.getName());
1484        assertIt((authRealm != null), localStrings.getString(
1485                                    "configsMBean.auth_realm_not_found", name));
1486        return authRealm;
1487    }
1488
1489    protected ObjectName JavaDoc getJmsServiceMBean(Target target, boolean create)
1490        throws MBeanException JavaDoc
1491    {
1492        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1493        ObjectName JavaDoc on = null;
1494        try
1495        {
1496            on = (ObjectName JavaDoc)invoke0(configMBean, "getJmsService");
1497        }
1498        catch (Exception JavaDoc e)
1499        {
1500            //log
1501
}
1502        if ((null == on) && create)
1503        {
1504            on = (ObjectName JavaDoc)invoke1(configMBean,
1505                "createJmsService", null, AttributeList JavaDoc.class.getName());
1506        }
1507        return on;
1508    }
1509
1510    protected ObjectName JavaDoc getThreadPoolsMBean(Target target)
1511        throws MBeanException JavaDoc
1512    {
1513        final ObjectName JavaDoc configMBean = getConfigMBean(target);
1514        ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke0(configMBean, "getThreadPools");
1515        return ret;
1516    }
1517
1518    protected ObjectName JavaDoc getSessionConfigMBean(Target target, boolean create)
1519        throws MBeanException JavaDoc
1520    {
1521        ObjectName JavaDoc sessionConfig = null;
1522        try
1523        {
1524            sessionConfig = getChild("session-config", null, target);
1525        }
1526        catch (MBeanException JavaDoc mbe)
1527        {
1528            if (create)
1529            {
1530                //Create it
1531
final ObjectName JavaDoc webContainer =
1532                    getChild("web-container", null, target);
1533                sessionConfig = (ObjectName JavaDoc)invoke1(webContainer,
1534                    "createSessionConfig", null, AttributeList JavaDoc.class.getName());
1535            }
1536            else
1537            {
1538                throw mbe;
1539            }
1540        }
1541        return sessionConfig;
1542    }
1543
1544    protected ObjectName JavaDoc getSessionManagerMBean(Target target, boolean create)
1545        throws MBeanException JavaDoc
1546    {
1547        final ObjectName JavaDoc sessionConfig = getSessionConfigMBean(target, create);
1548        ObjectName JavaDoc sessionManager = null;
1549        try
1550        {
1551            sessionManager = getChild("session-manager", null, target);
1552        }
1553        catch (MBeanException JavaDoc mbe)
1554        {
1555            if (create)
1556            {
1557                //Create it
1558
sessionManager = (ObjectName JavaDoc)invoke1(sessionConfig,
1559                   "createSessionManager", null, AttributeList JavaDoc.class.getName());
1560            }
1561            else
1562            {
1563                throw mbe;
1564            }
1565        }
1566        return sessionManager;
1567    }
1568
1569    protected MBeanServer JavaDoc getMBeanServer() throws MBeanException JavaDoc
1570    {
1571        return com.sun.enterprise.admin.common.MBeanServerFactory.getMBeanServer();
1572    }
1573
1574    protected void preInvoke(String JavaDoc opName, Object JavaDoc[] params, String JavaDoc[] signature)
1575        throws MBeanException JavaDoc
1576    {
1577    }
1578
1579    protected void postInvoke(String JavaDoc opName, Object JavaDoc ret) throws MBeanException JavaDoc
1580    {
1581    }
1582
1583    protected String JavaDoc getDefaultAuthRealm(Target target) throws MBeanException JavaDoc
1584    {
1585        final ObjectName JavaDoc on = getSecurityServiceMBean(target);
1586        return (String JavaDoc)getAttribute0(on, "default_realm");
1587    }
1588
1589    protected String JavaDoc[] getObjectNameTokens(Target target, String JavaDoc[] location)
1590        throws MBeanException JavaDoc
1591    {
1592        if (null == location) { location = new String JavaDoc[0]; }
1593        final String JavaDoc[] onTokens = new String JavaDoc[location.length + 2];
1594        onTokens[0] = getDomainName();
1595        onTokens[1] = getConfigRef(target);
1596        for (int i = 0; i < location.length; i++)
1597        {
1598            onTokens[i+2] = location[i];
1599        }
1600        return onTokens;
1601    }
1602
1603    protected String JavaDoc getConfigRef(Target target) throws MBeanException JavaDoc
1604    {
1605        String JavaDoc configRef = null;
1606        try
1607        {
1608            configRef = target.getConfigRef();
1609        }
1610        catch (Exception JavaDoc e)
1611        {
1612            throw MBeanExceptionFormatter.toMBeanException(e, null);
1613        }
1614        return configRef;
1615    }
1616
1617    protected String JavaDoc[] getJvmOptions(boolean isProfiler, Target target)
1618        throws MBeanException JavaDoc
1619    {
1620        final ObjectName JavaDoc targetON = getJvmOptionsTargetObjectName(
1621                                        target, isProfiler);
1622        String JavaDoc[] jvmOptions = (String JavaDoc[])getAttribute0(targetON, "jvm_options");
1623        if (null == jvmOptions) { jvmOptions = new String JavaDoc[0]; }
1624        return jvmOptions;
1625    }
1626
1627    private ObjectName JavaDoc createSslClientConfig(ObjectName JavaDoc iiopService)
1628        throws MBeanException JavaDoc
1629    {
1630        ObjectName JavaDoc ret = (ObjectName JavaDoc)invoke1(iiopService,
1631                            "createSslClientConfig", null,
1632                            AttributeList JavaDoc.class.getName());
1633        return ret;
1634    }
1635
1636    private Object JavaDoc invoke0(ObjectName JavaDoc on, String JavaDoc opName) throws MBeanException JavaDoc
1637    {
1638        return invokeN(on, opName, null, null);
1639    }
1640
1641    private Object JavaDoc invoke1(ObjectName JavaDoc on, String JavaDoc opName, Object JavaDoc o, String JavaDoc cls)
1642        throws MBeanException JavaDoc
1643    {
1644        return invokeN( on, opName, new Object JavaDoc[] {o}, new String JavaDoc[] {cls} );
1645    }
1646
1647    private Object JavaDoc invokeN(ObjectName JavaDoc on,
1648                           String JavaDoc opName,
1649                           Object JavaDoc[] params,
1650                           String JavaDoc[] signature)
1651        throws MBeanException JavaDoc
1652    {
1653        Object JavaDoc ret = null;
1654        try
1655        {
1656            ret = getMBeanServer().invoke(on, opName, params, signature);
1657            postInvoke(opName, ret);
1658        }
1659        catch (Exception JavaDoc e)
1660        {
1661            throw MBeanExceptionFormatter.toMBeanException(e, null);
1662        }
1663        return ret;
1664    }
1665
1666    private Object JavaDoc getPropertyValue0(ObjectName JavaDoc on, String JavaDoc propName)
1667        throws MBeanException JavaDoc
1668    {
1669        Object JavaDoc value = null;
1670        try
1671        {
1672            value = invoke1(on, "getPropertyValue", propName, "java.lang.String");
1673        }
1674        catch (Exception JavaDoc e)
1675        {
1676            throw MBeanExceptionFormatter.toMBeanException(e, null);
1677        }
1678        return value;
1679    }
1680
1681    private Object JavaDoc getAttribute0(ObjectName JavaDoc on, String JavaDoc attrName)
1682        throws MBeanException JavaDoc
1683    {
1684        Object JavaDoc value = null;
1685        try
1686        {
1687            value = getMBeanServer().getAttribute(on, attrName);
1688        }
1689        catch (Exception JavaDoc e)
1690        {
1691            throw MBeanExceptionFormatter.toMBeanException(e, null);
1692        }
1693        return value;
1694    }
1695
1696    private void setAttribute0(ObjectName JavaDoc on, String JavaDoc attrName, Object JavaDoc value)
1697        throws MBeanException JavaDoc
1698    {
1699        try
1700        {
1701            final Attribute JavaDoc attr = new Attribute JavaDoc(attrName, value);
1702            getMBeanServer().setAttribute(on, attr);
1703        }
1704        catch (Exception JavaDoc e)
1705        {
1706            throw MBeanExceptionFormatter.toMBeanException(e, null);
1707        }
1708    }
1709
1710    private ObjectName JavaDoc getJvmOptionsTargetObjectName(Target target,
1711                                                     boolean isProfiler)
1712        throws MBeanException JavaDoc
1713    {
1714        ObjectName JavaDoc on = getJavaConfigMBean(target);
1715        if (isProfiler)
1716        {
1717            on = (ObjectName JavaDoc)invoke0(on, "getProfiler");
1718        }
1719        assertIt((on != null), localStrings.getString(
1720            "configsMBean.target_for_jvm_options_not_found"));
1721        return on;
1722    }
1723
1724    private void setProperties(ObjectName JavaDoc on, Properties JavaDoc props)
1725        throws MBeanException JavaDoc
1726    {
1727        if (null != props)
1728        {
1729            Enumeration JavaDoc keys = props.keys();
1730            while (keys.hasMoreElements())
1731            {
1732                final String JavaDoc key = (String JavaDoc)keys.nextElement();
1733                final Attribute JavaDoc property = new Attribute JavaDoc(key, props.get(key));
1734                invoke1(on, "setProperty", property, Attribute JavaDoc.class.getName());
1735            }
1736        }
1737    }
1738
1739    private void assertIt(boolean b, Object JavaDoc msg)
1740        throws MBeanException JavaDoc
1741    {
1742        if (!b)
1743        {
1744            throw MBeanExceptionFormatter.toMBeanException(
1745                    null, msg.toString());
1746        }
1747    }
1748
1749    private MBeanRegistryEntry getMBeanRegistryEntry(String JavaDoc type)
1750        throws MBeanException JavaDoc
1751    {
1752        
1753        MBeanRegistryEntry entry = null;
1754        try
1755        {
1756            entry = getMBeanRegistry().findMBeanRegistryEntryByType(type);
1757        }
1758        catch (Exception JavaDoc e)
1759        {
1760            throw MBeanExceptionFormatter.toMBeanException(e, null);
1761        }
1762        assertIt((entry != null),
1763            localStrings.getString("configsMBean.no_registry_entry", type));
1764        return entry;
1765    }
1766    
1767    private MBeanNamingInfo getMBeanNamingInfo(MBeanRegistryEntry entry,
1768                                                 String JavaDoc type,
1769                                                 String JavaDoc[] loc)
1770        throws MBeanException JavaDoc
1771    {
1772        
1773        MBeanNamingInfo namingInfo = null;
1774        try
1775        {
1776            namingInfo = new MBeanNamingInfo(entry.getNamingDescriptor(),
1777                            type, loc);
1778        }
1779        catch (Exception JavaDoc e)
1780        {
1781            throw MBeanExceptionFormatter.toMBeanException(e, null);
1782        }
1783        return namingInfo;
1784    }
1785
1786    private void doPersistenceCheck(MBeanNamingInfo info, ConfigContext ctx)
1787        throws MBeanException JavaDoc
1788    {
1789        ConfigBean cb = null;
1790        try
1791        {
1792            final String JavaDoc xpath = info.getXPath();
1793            cb = ConfigBeansFactory.getConfigBeanByXPath(ctx, xpath);
1794            if (null == cb)
1795            {
1796                throw new InstanceNotFoundException JavaDoc(
1797                    localStrings.getString("configsMBean.mbean_not_found",
1798                    info.getObjectName()));
1799            }
1800        }
1801        catch (Exception JavaDoc e)
1802        {
1803            throw MBeanExceptionFormatter.toMBeanException(e, null);
1804        }
1805    }
1806
1807    private ObjectName JavaDoc getObjectName(MBeanNamingInfo info)
1808        throws MBeanException JavaDoc
1809    {
1810        ObjectName JavaDoc on = null;
1811        try
1812        {
1813            on = info.getObjectName();
1814        }
1815        catch (Exception JavaDoc e)
1816        {
1817            throw MBeanExceptionFormatter.toMBeanException(e, null);
1818        }
1819        return on;
1820    }
1821
1822    private void checkElementDoesnotExist(ObjectName JavaDoc targetON,
1823                                          String JavaDoc getter,
1824                                          Object JavaDoc msg)
1825        throws MBeanException JavaDoc
1826    {
1827       ObjectName JavaDoc on = null;
1828       try
1829       {
1830           on = (ObjectName JavaDoc)invoke0(targetON, getter);
1831       }
1832       catch (MBeanException JavaDoc mbe)
1833       {
1834           //log??
1835
}
1836       if (on != null)
1837       {
1838           throw MBeanExceptionFormatter.toMBeanException(
1839               null, msg.toString());
1840       }
1841    }
1842    /** Adds the properties while creating the virtual server. This method
1843        is required because of the bug 4963449. Once the dtd is modified,
1844        we may not use this method and its call.
1845        <P> Date: Dec 09, 2003
1846    */

1847    private void addMandatoryVirtualServerProperties(final AttributeList JavaDoc al,
1848                                                     final Properties JavaDoc p)
1849    {
1850        setProperty(p, false, SystemPropertyConstants.ACCESSLOG_PROPERTY,
1851                    SystemPropertyConstants.getAccessLogDefaultValue());
1852        final String JavaDoc ca =
1853            AttributeListUtils.toJmx12Attribute(ServerTags.DEFAULT_WEB_MODULE);
1854        if (! AttributeListUtils.
1855              containsNamedAttribute(al, ca))
1856        {
1857            setProperty(p, false, SystemPropertyConstants.DOCROOT_PROPERTY,
1858                      SystemPropertyConstants.getDocRootDefaultValue());
1859        }
1860        else
1861        {
1862            final Attribute JavaDoc defaultWb =
1863                (Attribute JavaDoc)AttributeListUtils.asNameMap(al).get(ca);
1864            final String JavaDoc val = (String JavaDoc)defaultWb.getValue();
1865            if ((val == null) || "".equals(val))
1866            {
1867                setProperty(p, false, SystemPropertyConstants.DOCROOT_PROPERTY,
1868                      SystemPropertyConstants.getDocRootDefaultValue());
1869            }
1870        }
1871    }
1872    
1873    private void setProperty(final Properties JavaDoc table, final boolean force,
1874                             final String JavaDoc name, final String JavaDoc value)
1875    {
1876        if (force)
1877            table.setProperty(name, value);
1878        else
1879            if (! table.containsKey(name))
1880                table.setProperty(name, value);
1881    }
1882 
1883    /** Always returns a non null instance of {@link java.util.Properties}.
1884     * Following rules apply:
1885     * <ul>
1886     * <li> If the passed argument is null a non null empty Properties instance
1887     * is returned. </li>
1888     * <li> All property mappings from the passed argument are copied "as-is"
1889     * to the new Properties instance, that is returned. </li>
1890     * <ul>
1891     * Note that the constructor {@link Properties#Properties} is not useful for
1892     * this purpose.
1893     */

1894    private Properties JavaDoc copyProperties(final Properties JavaDoc p)
1895    {
1896        final Properties JavaDoc nn = new Properties JavaDoc();
1897        if (p != null)
1898        {
1899            final Enumeration JavaDoc e = p.propertyNames();
1900            while (e.hasMoreElements())
1901            {
1902                final String JavaDoc key = (String JavaDoc)e.nextElement();
1903                final String JavaDoc value = p.getProperty(key);
1904                nn.setProperty(key, value);
1905            }
1906        }
1907        return ( nn );
1908    }
1909
1910
1911    /**
1912     *
1913     *
1914     */

1915    protected String JavaDoc getDefaultHTTPListenerAcceptorThreads() {
1916        return DEFAULT_HTTP_LISTENER_ACCEPTOR_THREADS;
1917    }
1918
1919    /**
1920     *
1921     *
1922     */

1923    protected Config getConfigBeanForTarget(Target target) throws Exception JavaDoc
1924    {
1925        final ConfigTarget configTarget = target.getConfigTarget();
1926        return ConfigAPIHelper.getConfigByName(getConfigContext(), configTarget.getName());
1927    }
1928}
1929
Popular Tags