KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > DeployedItemConfigBase


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 package com.sun.enterprise.management.config;
24
25 import java.util.Map JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28
29 import com.sun.appserv.management.base.XTypes;
30
31 import com.sun.appserv.management.config.Libraries;
32
33 import com.sun.appserv.management.util.misc.StringUtil;
34 import com.sun.appserv.management.util.misc.ExceptionUtil;
35 import com.sun.appserv.management.util.stringifier.ArrayStringifier;
36
37 import com.sun.enterprise.management.support.Delegate;
38
39 /**
40     Base class for certain subclasses
41  */

42 public class DeployedItemConfigBase extends AMXConfigImplBase
43     implements Libraries, ConfigFactoryCallback
44 {
45         public
46     DeployedItemConfigBase( final Delegate delegate )
47     {
48         super( delegate );
49     }
50     
51
52         protected static String JavaDoc
53     getPathSeparator()
54     {
55         return System.getProperty( "path.separator" );
56     }
57     
58     private static final String JavaDoc LIBRARIES_ATTR = "Libraries";
59     
60         public String JavaDoc[]
61     getLibraries()
62     {
63         final String JavaDoc s = (String JavaDoc)delegateGetAttributeNoThrow( LIBRARIES_ATTR );
64         
65         final String JavaDoc[] libraries = s == null ?
66             EMPTY_STRING_ARRAY : s.split( getPathSeparator() );
67             
68         return libraries;
69     }
70     
71     /**
72         Note: some system apps make this Attribute read-only,
73         though the MBeanInfo advertises it as read/write.
74      */

75         public void
76     setLibraries( final String JavaDoc[] libraries )
77     {
78         if ( libraries == null || libraries.length == 0 )
79         {
80             final String JavaDoc[] current = getLibraries();
81             if ( current.length == 0 )
82             {
83                 // OK, no change
84
}
85             else
86             {
87                 delegateSetAttributeNoThrow( LIBRARIES_ATTR, null );
88             }
89         }
90         else
91         {
92             final String JavaDoc SEP = getPathSeparator();
93             
94             for( final String JavaDoc s : libraries )
95             {
96                 if ( s == null || s.length() == 0 || s.indexOf( SEP ) >= 0 )
97                 {
98                     throw new IllegalArgumentException JavaDoc( StringUtil.quote( "" + s ) );
99                 }
100             }
101             final String JavaDoc libs = StringUtil.toString( SEP, (Object JavaDoc[])libraries );
102             
103             delegateSetAttributeNoThrow( LIBRARIES_ATTR, libs );
104         }
105     }
106 }
107
108
109
110
111
112
113
114
Popular Tags