Source Code Cross Referenced for CustomConfig.java in  » ESB » open-esb » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)CustomConfig.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package test;
030:
031:        import javax.management.MBeanException;
032:        import javax.management.openmbean.CompositeData;
033:        import javax.management.openmbean.CompositeDataSupport;
034:        import javax.management.openmbean.CompositeType;
035:        import javax.management.openmbean.TabularData;
036:        import javax.management.openmbean.TabularDataSupport;
037:        import javax.management.openmbean.TabularType;
038:        import javax.management.openmbean.OpenType;
039:        import javax.management.openmbean.SimpleType;
040:        import javax.management.openmbean.ArrayType;
041:
042:        public class CustomConfig implements  CustomConfigMBean {
043:            private String mInfo;
044:
045:            private int mPort;
046:            private String mHostName;
047:
048:            /** The application variables TabularData */
049:            private TabularDataSupport mAppVars;
050:
051:            /** Application Variable Composite Type */
052:            private static CompositeType sAppVarComposite;
053:
054:            /** Application Variable Tabular Type */
055:            private static TabularType sAppVarTable;
056:
057:            /** Application Variable Composite Item Names */
058:            private static String[] sAppVarItemNames;
059:
060:            /** The index of the Application Variables **/
061:            private static String[] sappVarRowIndex;
062:
063:            /** The application configuration TabularData */
064:            private TabularDataSupport mAppConfigs;
065:
066:            /** Application Configuration Composite Type */
067:            private static CompositeType sAppConfigComposite;
068:
069:            /** Application Configuration Tabular Type */
070:            private static TabularType sAppConfigTable;
071:
072:            /** Application Configuration Composite Item Names */
073:            private static String[] sAppConfigItemNames;
074:
075:            /** The index of the Application Configurations **/
076:            private static String[] sAppConfigRowIndex;
077:
078:            private void initOpenTypes()
079:                    throws javax.management.openmbean.OpenDataException {
080:                // Define the Application Variables CompositeType
081:                sAppVarItemNames = new String[] { "name", "value", "type" };
082:
083:                String[] appVarItemDesc = { "Application variable name",
084:                        "Application variable value",
085:                        "Application variable type" };
086:
087:                OpenType[] appVarRowAttrTypes = { SimpleType.STRING,
088:                        SimpleType.STRING, SimpleType.STRING };
089:
090:                sappVarRowIndex = new String[] { "name" };
091:
092:                sAppVarComposite = new CompositeType(
093:                        "ApplicationVariableComposite",
094:                        "Application variable name and value pair",
095:                        sAppVarItemNames, appVarItemDesc, appVarRowAttrTypes);
096:
097:                sAppVarTable = new TabularType("ApplicationVariableList",
098:                        "List of application variables", sAppVarComposite,
099:                        sappVarRowIndex);
100:
101:                // Define the Application Configuration OpenType
102:                sAppConfigItemNames = new String[] { "configurationName",
103:                        "connectionURL", "securityPrincipal",
104:                        "securityCredential", "jndienv" };
105:
106:                String[] appConfigItemDesc = {
107:                        "Application configuration name", "Connection URL",
108:                        "Security Principal", "Security Credential",
109:                        "JNDI Properties" };
110:
111:                ArrayType jndiEnvArrayType = new ArrayType(1, SimpleType.STRING);
112:                OpenType[] appConfigRowAttrTypes = { SimpleType.STRING,
113:                        SimpleType.STRING, SimpleType.STRING,
114:                        SimpleType.STRING, jndiEnvArrayType };
115:
116:                sAppConfigRowIndex = new String[] { "configurationName" };
117:
118:                sAppConfigComposite = new CompositeType(
119:                        "ApplicationConfigurationComposite",
120:                        "Application Configuration Composite",
121:                        sAppConfigItemNames, appConfigItemDesc,
122:                        appConfigRowAttrTypes);
123:
124:                sAppConfigTable = new TabularType(
125:                        "ApplicationConfigurationList",
126:                        "List of application configurations",
127:                        sAppConfigComposite, sAppConfigRowIndex);
128:            }
129:
130:            /**
131:             * HostName gettter/setter
132:             */
133:            public void setHostName(String hostName) {
134:                mHostName = hostName;
135:            }
136:
137:            public String getHostName() {
138:                return mHostName;
139:            }
140:
141:            /**
142:             * Port get/set
143:             */
144:            public void setPort(int port) {
145:                mPort = port;
146:            }
147:
148:            public int getPort() {
149:                return mPort;
150:            }
151:
152:            public CustomConfig(String info) {
153:                mInfo = info;
154:                try {
155:                    initOpenTypes();
156:                    mAppVars = new TabularDataSupport(sAppVarTable);
157:                    mAppConfigs = new TabularDataSupport(sAppConfigTable);
158:
159:                    // Add a default app var
160:                    CompositeDataSupport cd = new CompositeDataSupport(
161:                            sAppVarComposite, sAppVarItemNames, new String[] {
162:                                    "default", "defValue", "STRING" });
163:                    mAppVars.put(cd);
164:
165:                    // Add a default app config
166:                    CompositeDataSupport appCfgCD = new CompositeDataSupport(
167:                            sAppConfigComposite,
168:                            sAppConfigItemNames,
169:                            new Object[] {
170:                                    "defaultConfig",
171:                                    "http://www.sun.com",
172:                                    "administrator",
173:                                    "abc",
174:                                    new String[] { "env1=value1", "env2=value2" } });
175:                    mAppConfigs.put(appCfgCD);
176:                } catch (Exception ex) {
177:                    System.out
178:                            .println("Error in populating the Application Variables");
179:                    System.out.println(ex.getMessage());
180:                }
181:            }
182:
183:            /**
184:             * Test method.
185:             */
186:            public String getComponentCustomInfo() {
187:                return mInfo;
188:            }
189:
190:            /**
191:             * Get the CompositeType definition for the components application configuration 
192:             *
193:             * @return the CompositeType for the components application configuration.
194:             */
195:            public CompositeType queryApplicationConfigurationType() {
196:                return sAppConfigComposite;
197:            }
198:
199:            /**
200:             * Add an application configuration. The configuration name is a part of the CompositeData.
201:             * The itemName for the configuration name is "configurationName" and the type is SimpleType.STRING
202:             *
203:             * @param name - configuration name, must match the value of the field "name" in the namedConfig
204:             * @param appConfig - application configuration composite 
205:             * @throws MBeanException if the application configuration cannot be added.
206:             * @return management message string which gives the status of the operation. For 
207:             *         target=cluster, instance specific details are included. 
208:             */
209:            public void addApplicationConfiguration(String name,
210:                    CompositeData appConfig) throws MBeanException {
211:                mAppConfigs.put(appConfig);
212:            }
213:
214:            /**
215:             * Delete an application configuration. 
216:             *
217:             * @param name - identification of the application configuration to be deleted
218:             * @throws MBeanException if the configuration cannot be deleted.
219:             * @return management message string which gives the status of the operation. For 
220:             *         target=cluster, instance specific details are included. 
221:             */
222:            public void deleteApplicationConfiguration(String name)
223:                    throws MBeanException {
224:                CompositeData cd = (CompositeData) mAppConfigs
225:                        .get(new String[] { name });
226:
227:                if (cd != null) {
228:                    mAppConfigs.remove(new String[] { name });
229:                }
230:            }
231:
232:            /**
233:             * Update a application configuration. The configuration name is a part of the CompositeData.
234:             * The itemName for the configuration name is "configurationName" and the type is SimpleType.STRING
235:             *
236:             * @param name - configuration name, must match the value of the field "configurationName" in the appConfig
237:             * @param appConfig - application configuration composite
238:             * @throws MBeanException if there are errors encountered when updating the configuration.
239:             * @return management message string which gives the status of the operation. For 
240:             *         target=cluster, instance specific details are included. 
241:             */
242:            public void setApplicationConfiguration(String name,
243:                    CompositeData appConfig) throws MBeanException {
244:                CompositeData cd = (CompositeData) mAppConfigs
245:                        .get(new String[] { name });
246:
247:                if (cd != null) {
248:                    mAppConfigs.remove(new String[] { name });
249:                    mAppConfigs.put(appConfig);
250:                }
251:            }
252:
253:            /**
254:             * Get a Map of all application configurations for the component.
255:             *
256:             * @return a TabularData of all the application configurations for a 
257:             *         component keyed by the configuration name. 
258:             */
259:            public TabularData getApplicationConfigurations() {
260:                return mAppConfigs;
261:            }
262:
263:            /**
264:             * This operation adds a new application variable. If a variable already exists with 
265:             * the same name as that specified then the operation fails.
266:             * 
267:             * @param name - name of the application variable
268:             * @param appVar - this is the application variable compoiste
269:             * @throws MBeanException if an error occurs in adding the application variables to the 
270:             *         component. 
271:             * @return management message string which gives the status of the operation. For 
272:             *         target=cluster, instance specific details are included. 
273:             */
274:            public void addApplicationVariable(String name, CompositeData appVar)
275:                    throws MBeanException {
276:                mAppVars.put(appVar);
277:            }
278:
279:            /**
280:             * This operation sets an application variable. If a variable does not exist with 
281:             * the same name, its an error.
282:             * 
283:             * @param name - name of the application variable
284:             * @param appVar - this is the application variable compoiste to be updated.
285:             * @throws MBeanException if one or more application variables cannot be deleted
286:             * @return management message string which gives the status of the operation. For 
287:             *         target=cluster, instance specific details are included. 
288:             */
289:            public void setApplicationVariable(String name, CompositeData appVar)
290:                    throws MBeanException {
291:                CompositeData cd = (CompositeData) mAppVars
292:                        .get(new String[] { name });
293:
294:                if (cd != null) {
295:                    mAppVars.remove(new String[] { name });
296:                    mAppVars.put(appVar);
297:                }
298:            }
299:
300:            /**
301:             * This operation deletes an application variable, if a variable with the specified name does
302:             * not exist, it's an error.
303:             *
304:             * @param name - name of the application variable
305:             * @throws MBeanException on errors.
306:             * @return management message string which gives the status of the operation. For 
307:             *         target=cluster, instance specific details are included. 
308:             */
309:            public void deleteApplicationVariable(String name)
310:                    throws MBeanException {
311:                mAppVars.remove(new String[] { name });
312:            }
313:
314:            /**
315:             * Get the Application Variable set for a component.
316:             *
317:             * @return  a TabularData which has all the applicationvariables set on the component. 
318:             */
319:            public TabularData getApplicationVariables() {
320:                return mAppVars;
321:            }
322:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.