Source Code Cross Referenced for ComponentConfig.java in  » ESB » open-esb » testcomponent » 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 » testcomponent 
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:         * @(#)ComponentConfig.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package testcomponent;
030:
031:        import javax.management.MBeanException;
032:        import javax.management.openmbean.ArrayType;
033:        import javax.management.openmbean.CompositeData;
034:        import javax.management.openmbean.CompositeDataSupport;
035:        import javax.management.openmbean.CompositeType;
036:        import javax.management.openmbean.TabularData;
037:        import javax.management.openmbean.TabularDataSupport;
038:        import javax.management.openmbean.TabularType;
039:        import javax.management.openmbean.OpenType;
040:        import javax.management.openmbean.SimpleType;
041:
042:        public class ComponentConfig implements  ComponentConfigMBean {
043:            private String mInfo;
044:            private String mA, mB, mC;
045:            /** The application variables TabularData */
046:            private TabularDataSupport mAppVars;
047:
048:            /** Application Variable Composite Type */
049:            private static CompositeType sAppVarComposite;
050:
051:            /** Application Variable Tabular Type */
052:            private static TabularType sAppVarTable;
053:
054:            /** Application Variable Composite Item Names */
055:            private static String[] sAppVarItemNames;
056:
057:            /** The index of the Application Variables **/
058:            private static String[] sappVarRowIndex;
059:
060:            /** The application configuration TabularData */
061:            private TabularDataSupport mAppConfigs;
062:
063:            /** Application Configuration Composite Type */
064:            private static CompositeType sAppConfigComposite;
065:
066:            /** Application Configuration Tabular Type */
067:            private static TabularType sAppConfigTable;
068:
069:            /** Application Configuration Composite Item Names */
070:            private static String[] sAppConfigItemNames;
071:
072:            /** The index of the Application Configurations **/
073:            private static String[] sAppConfigRowIndex;
074:
075:            private static final String CONFIG_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
076:                    + "<componentConfig:Configuration name=\"sun-http-binding\" "
077:                    + "xmlns:componentConfig=\"http://com.sun.jbi.component/schema/configuration\"> "
078:                    + "<componentConfig:A displayName=\"A\" "
079:                    + "displayDescription=\"A\" "
080:                    + "isPasswordField=\"false\">10</componentConfig:A> "
081:                    +
082:
083:                    "<componentConfig:B displayName=\"B\" "
084:                    + "displayDescription=\"B\" "
085:                    + "isPasswordField=\"false\">1111</componentConfig:B> "
086:                    +
087:
088:                    "<componentConfig:C displayName=\"C\" "
089:                    + "displayDescription=\"C\" "
090:                    + "isPasswordField=\"false\">2222</componentConfig:C> "
091:                    +
092:
093:                    "<componentConfig:ApplicationConfiguration>"
094:                    +
095:
096:                    "<componentConfig:configurationName displayName=\"Application Configuration Name\" "
097:                    + "displayDescription=\"Specifies the name of the application configuration.\" "
098:                    + "isPasswordField=\"false\" isRequiredField=\"true\">dummy</componentConfig:configurationName >"
099:                    +
100:
101:                    "<componentConfig:connectionURL displayName=\"Connection URL\" "
102:                    + "displayDescription=\"Connection URL\" "
103:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:connectionURL>"
104:                    +
105:
106:                    "<componentConfig:connectionFactoryName displayName=\"Connection factory Name\" "
107:                    + "displayDescription=\"Connection factory Name\" "
108:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:connectionFactoryName>"
109:                    +
110:
111:                    "<componentConfig:initialContextFactory displayName=\"Initial Context factory \" "
112:                    + "displayDescription=\"Initial Context factory\" "
113:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:initialContextFactory>"
114:                    +
115:
116:                    "<componentConfig:providerURL displayName=\"Provider URL Location\" "
117:                    + "displayDescription=\"Provider URL location.\" "
118:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:providerURL>"
119:                    +
120:
121:                    "<componentConfig:securityPrincipal displayName=\"HTTP URL Location\" "
122:                    + "displayDescription=\"Specifies the HTTP URL location.\" "
123:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:securityPrincipal>"
124:                    +
125:
126:                    "<componentConfig:securityCredentials displayName=\"User Password\" "
127:                    + "displayDescription=\"Specifies the user password.\" "
128:                    + "isPasswordField=\"true\" isRequiredField=\"true\">secret</componentConfig:securityCredentials>"
129:                    +
130:
131:                    "<componentConfig:username displayName=\"User Name\" "
132:                    + "displayDescription=\"Specifies the User Name.\" "
133:                    + "isPasswordField=\"false\" isRequiredField=\"true\">http://</componentConfig:username>"
134:                    +
135:
136:                    "<componentConfig:password displayName=\"User Password\" "
137:                    + "displayDescription=\"Specifies the user password.\" "
138:                    + "isPasswordField=\"true\" isRequiredField=\"true\">secret</componentConfig:password>"
139:                    +
140:
141:                    "<componentConfig:jndienv displayName=\"HTTP URL Location\" "
142:                    + "displayDescription=\"Specifies the HTTP URL location.\" "
143:                    + "isPasswordField=\"false\" isRequiredField=\"false\">http://</componentConfig:jndienv>"
144:                    +
145:
146:                    "</componentConfig:ApplicationConfiguration>"
147:                    + "</componentConfig:Configuration>";
148:
149:            private void initOpenTypes()
150:                    throws javax.management.openmbean.OpenDataException {
151:                // Define the Application Variables CompositeType
152:                sAppVarItemNames = new String[] { "name", "value", "type" };
153:
154:                String[] appVarItemDesc = { "Application variable name",
155:                        "Application variable value",
156:                        "Application variable type" };
157:
158:                OpenType[] appVarRowAttrTypes = { SimpleType.STRING,
159:                        SimpleType.STRING, SimpleType.STRING };
160:
161:                sappVarRowIndex = new String[] { "name" };
162:
163:                sAppVarComposite = new CompositeType(
164:                        "ApplicationVariableComposite",
165:                        "Application variable name and value pair",
166:                        sAppVarItemNames, appVarItemDesc, appVarRowAttrTypes);
167:
168:                sAppVarTable = new TabularType("ApplicationVariableList",
169:                        "List of application variables", sAppVarComposite,
170:                        sappVarRowIndex);
171:
172:                // Define the Application Configuration OpenType
173:                sAppConfigItemNames = new String[] { "configurationName",
174:                        "connectionURL", "connectionFactoryName",
175:                        "initialContextFactory", "providerURL",
176:                        "securityPrincipal", "securityCredentials", "username",
177:                        "password", "jndienv" };
178:
179:                String[] appConfigItemDesc = {
180:                        "Application configuration name", "Connection URL",
181:                        "Connection Factory Name", "Initial Context Factory",
182:                        "Provider URL", "Security Principal",
183:                        "Security Credential", "User Name", "Password",
184:                        "JNDI Properties" };
185:
186:                ArrayType jndiEnvArrayType = new ArrayType(1, SimpleType.STRING);
187:                OpenType[] appConfigRowAttrTypes = { SimpleType.STRING,
188:                        SimpleType.STRING, SimpleType.STRING,
189:                        SimpleType.STRING, SimpleType.STRING,
190:                        SimpleType.STRING, SimpleType.STRING,
191:                        SimpleType.STRING, SimpleType.STRING, jndiEnvArrayType };
192:
193:                sAppConfigRowIndex = new String[] { "configurationName" };
194:
195:                sAppConfigComposite = new CompositeType(
196:                        "ApplicationConfigurationComposite",
197:                        "Application Configuration Composite",
198:                        sAppConfigItemNames, appConfigItemDesc,
199:                        appConfigRowAttrTypes);
200:
201:                sAppConfigTable = new TabularType(
202:                        "ApplicationConfigurationList",
203:                        "List of application configurations",
204:                        sAppConfigComposite, sAppConfigRowIndex);
205:            }
206:
207:            public ComponentConfig(String info) {
208:                mInfo = info;
209:                try {
210:                    initOpenTypes();
211:                    mAppVars = new TabularDataSupport(sAppVarTable);
212:                    mAppConfigs = new TabularDataSupport(sAppConfigTable);
213:
214:                    // Add a default app var
215:                    CompositeDataSupport cd = new CompositeDataSupport(
216:                            sAppVarComposite, sAppVarItemNames, new String[] {
217:                                    "default", "defValue", "STRING" });
218:                    mAppVars.put(cd);
219:
220:                    // Add a default application configuration
221:                    CompositeDataSupport appCfgCD = new CompositeDataSupport(
222:                            sAppConfigComposite,
223:                            sAppConfigItemNames,
224:                            new Object[] {
225:                                    "defaultConfig",
226:                                    "http://www.sun.com",
227:                                    "com.sun.connxn.factory.name",
228:                                    "com.sun.initialContextFactory",
229:                                    "https://localhost:2506",
230:                                    "administrator",
231:                                    "abc",
232:                                    "john",
233:                                    "mySecret",
234:                                    new String[] { "env1=value1", "env2=value2" } });
235:                    mAppConfigs.put(appCfgCD);
236:                } catch (Exception ex) {
237:                    System.out
238:                            .println("Error in populating the Application Variables");
239:                    System.out.println(ex.getMessage());
240:                }
241:            }
242:
243:            /**
244:             * Test method.
245:             */
246:            public String getComponentCustomInfo() {
247:                return mInfo;
248:            }
249:
250:            /**
251:             * Get the CompositeType definition for the components application configuration 
252:             *
253:             * @return the CompositeType for the components application configuration.
254:             */
255:            public CompositeType queryApplicationConfigurationType() {
256:                return sAppConfigComposite;
257:            }
258:
259:            /**
260:             * Add an application configuration. The configuration name is a part of the CompositeData.
261:             * The itemName for the configuration name is "configurationName" and the type is SimpleType.STRING
262:             *
263:             * @param name - configuration name, must match the value of the field "name" in the namedConfig
264:             * @param appConfig - application configuration composite 
265:             * @throws MBeanException if the application configuration cannot be added.
266:             * @return management message string which gives the status of the operation. For 
267:             *         target=cluster, instance specific details are included. 
268:             */
269:            public void addApplicationConfiguration(String name,
270:                    CompositeData appConfig) throws MBeanException {
271:                mAppConfigs.put(appConfig);
272:            }
273:
274:            /**
275:             * Delete an application configuration. 
276:             *
277:             * @param name - identification of the application configuration to be deleted
278:             * @throws MBeanException if the configuration cannot be deleted.
279:             * @return management message string which gives the status of the operation. For 
280:             *         target=cluster, instance specific details are included. 
281:             */
282:            public void deleteApplicationConfiguration(String name)
283:                    throws MBeanException {
284:                CompositeData cd = (CompositeData) mAppConfigs
285:                        .get(new String[] { name });
286:
287:                if (cd != null) {
288:                    mAppConfigs.remove(new String[] { name });
289:                }
290:            }
291:
292:            /**
293:             * Update a application configuration. The configuration name is a part of the CompositeData.
294:             * The itemName for the configuration name is "configurationName" and the type is SimpleType.STRING
295:             *
296:             * @param name - configuration name, must match the value of the field "configurationName" in the appConfig
297:             * @param appConfig - application configuration composite
298:             * @throws MBeanException if there are errors encountered when updating the configuration.
299:             * @return management message string which gives the status of the operation. For 
300:             *         target=cluster, instance specific details are included. 
301:             */
302:            public void setApplicationConfiguration(String name,
303:                    CompositeData appConfig) throws MBeanException {
304:                CompositeData cd = (CompositeData) mAppConfigs
305:                        .get(new String[] { name });
306:
307:                if (cd != null) {
308:                    mAppConfigs.remove(new String[] { name });
309:                    mAppConfigs.put(appConfig);
310:                }
311:            }
312:
313:            /**
314:             * Get a Map of all application configurations for the component.
315:             *
316:             * @return a TabularData of all the application configurations for a 
317:             *         component keyed by the configuration name. 
318:             */
319:            public TabularData getApplicationConfigurations() {
320:                return mAppConfigs;
321:            }
322:
323:            /**
324:             * Attribute getters/setters
325:             */
326:            public String getA() {
327:                return mA;
328:            }
329:
330:            public void setA(String a) {
331:                mA = a;
332:            }
333:
334:            public String getB() {
335:                return mB;
336:            }
337:
338:            public void setB(String b) {
339:                mB = b;
340:            }
341:
342:            public String getC() {
343:                return mC;
344:            }
345:
346:            public void setC(String c) {
347:                mC = c;
348:            }
349:
350:            /**
351:             * This operation adds a new application variable. If a variable already exists with 
352:             * the same name as that specified then the operation fails.
353:             * 
354:             * @param name - name of the application variable
355:             * @param appVar - this is the application variable compoiste
356:             * @throws MBeanException if an error occurs in adding the application variables to the 
357:             *         component. 
358:             * @return management message string which gives the status of the operation. For 
359:             *         target=cluster, instance specific details are included. 
360:             */
361:            public void addApplicationVariable(String name, CompositeData appVar)
362:                    throws MBeanException {
363:                mAppVars.put(appVar);
364:            }
365:
366:            /**
367:             * This operation sets an application variable. If a variable does not exist with 
368:             * the same name, its an error.
369:             * 
370:             * @param name - name of the application variable
371:             * @param appVar - this is the application variable compoiste to be updated.
372:             * @throws MBeanException if one or more application variables cannot be deleted
373:             * @return management message string which gives the status of the operation. For 
374:             *         target=cluster, instance specific details are included. 
375:             */
376:            public void setApplicationVariable(String name, CompositeData appVar)
377:                    throws MBeanException {
378:                CompositeData cd = (CompositeData) mAppVars
379:                        .get(new String[] { name });
380:
381:                if (cd != null) {
382:                    mAppVars.remove(new String[] { name });
383:                    mAppVars.put(appVar);
384:                }
385:            }
386:
387:            /**
388:             * This operation deletes an application variable, if a variable with the specified name does
389:             * not exist, it's an error.
390:             *
391:             * @param name - name of the application variable
392:             * @throws MBeanException on errors.
393:             * @return management message string which gives the status of the operation. For 
394:             *         target=cluster, instance specific details are included. 
395:             */
396:            public void deleteApplicationVariable(String name)
397:                    throws MBeanException {
398:                mAppVars.remove(new String[] { name });
399:            }
400:
401:            /**
402:             * Get the Application Variable set for a component.
403:             *
404:             * @return  a TabularData which has all the applicationvariables set on the component. 
405:             */
406:            public TabularData getApplicationVariables() {
407:                return mAppVars;
408:            }
409:
410:            /** 
411:             * Retrieves the component specific configuration schema.
412:             *
413:             * @return a String containing the configuration schema.
414:             */
415:            public String retrieveConfigurationDisplaySchema() {
416:                return CONFIG_XML;
417:            }
418:
419:            /** 
420:             * Retrieves the component configuration metadata.
421:             * The XML data conforms to the component 
422:             * configuration schema.
423:             *
424:             * @return a String containing the configuration metadata.
425:             */
426:            public String retrieveConfigurationDisplayData() {
427:                return CONFIG_XML;
428:            }
429:
430:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.