Source Code Cross Referenced for TestComponentConfigMetaData.java in  » ESB » open-esb » java4ant » 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 » java4ant 
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:         * @(#)TestComponentConfiguration.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package java4ant;
030:
031:        import java.util.Map;
032:        import java.util.Properties;
033:        import java.util.Set;
034:        import javax.management.openmbean.*;
035:        import javax.management.remote.*;
036:        import javax.management.*;
037:
038:        /**
039:         */
040:        public class TestComponentConfigMetaData {
041:
042:            private MBeanServerConnection mbns;
043:            private static final String RESULT_PREFIX = "##### Result of ";
044:
045:            private static final String USER = "jmx.user";
046:            private static final String PASSWORD = "jmx.password";
047:            private static final String PROVIDER = "jmx.provider";
048:            private static final String COMPONENT_NAME = "component.name";
049:            private static final String TARGET = "target";
050:
051:            public void initMBeanServerConnection() throws Exception {
052:                java.util.Map<String, String[]> env = new java.util.HashMap();
053:                String user = System.getProperty(USER);
054:                String pass = System.getProperty(PASSWORD);
055:                String[] credentials = new String[] { user, pass };
056:                env.put("jmx.remote.credentials", credentials);
057:
058:                String jmxProvider = System.getProperty(PROVIDER);
059:
060:                JMXConnector connector = JMXConnectorFactory.connect(
061:                        new JMXServiceURL(jmxProvider), env);
062:
063:                mbns = connector.getMBeanServerConnection();
064:            }
065:
066:            public ObjectName getJbiAdminCommandsUI() throws Exception {
067:                String admin = "com.sun.jbi:"
068:                        + "ServiceName=JbiReferenceAdminUiService,ComponentType=System";
069:                return new ObjectName(admin);
070:            }
071:
072:            public void retrieveConfigurationDisplayData(
073:                    boolean expectingException) throws Exception {
074:
075:                String target = System.getProperty(TARGET);
076:                Object[] params = new Object[2];
077:                params[0] = System.getProperty(COMPONENT_NAME);
078:                params[1] = target;
079:
080:                String[] signature = new String[2];
081:                signature[0] = "java.lang.String";
082:                signature[1] = "java.lang.String";
083:
084:                String data = null;
085:
086:                try {
087:                    data = (String) mbns.invoke(getJbiAdminCommandsUI(),
088:                            "retrieveConfigurationDisplayData", params,
089:                            signature);
090:
091:                    System.out.println(RESULT_PREFIX
092:                            + " retrieveConfigurationDisplayData( target="
093:                            + target + " ):");
094:                    if (expectingException) {
095:                        System.out
096:                                .println("*** Was expecting exception, but didn't get one! ***");
097:                    } else {
098:                        System.out.print(" " + data);
099:                    }
100:
101:                } catch (Exception e) {
102:                    if (expectingException) {
103:                        System.out.println(RESULT_PREFIX
104:                                + " retrieveConfigurationDisplayData( target="
105:                                + target + " ): caught expected exception.");
106:                    } else {
107:                        System.out.println(RESULT_PREFIX
108:                                + " retrieveConfigurationDisplayData( target="
109:                                + target + " ): caught unexpected Exception: ");
110:                    }
111:                    printExceptionMessage(e, "retrieveConfigurationDisplayData");
112:                }
113:            }
114:
115:            public void retrieveConfigurationDisplaySchema(
116:                    boolean expectingException) throws Exception {
117:
118:                String target = System.getProperty(TARGET);
119:                Object[] params = new Object[2];
120:                params[0] = System.getProperty(COMPONENT_NAME);
121:                params[1] = target;
122:
123:                String[] signature = new String[2];
124:                signature[0] = "java.lang.String";
125:                signature[1] = "java.lang.String";
126:
127:                String schema = null;
128:
129:                try {
130:                    schema = (String) mbns.invoke(getJbiAdminCommandsUI(),
131:                            "retrieveConfigurationDisplaySchema", params,
132:                            signature);
133:
134:                    System.out.println(RESULT_PREFIX
135:                            + " retrieveConfigurationDisplaySchema( target="
136:                            + target + " ):");
137:                    if (expectingException) {
138:                        System.out
139:                                .println("*** Was expecting exception, but didn't get one! ***");
140:                    } else {
141:                        System.out.print(" " + schema);
142:                    }
143:                } catch (Exception e) {
144:                    if (expectingException) {
145:                        System.out
146:                                .println(RESULT_PREFIX
147:                                        + " retrieveConfigurationDisplaySchema( target="
148:                                        + target
149:                                        + " ): caught expected exception.");
150:                    } else {
151:                        System.out
152:                                .println(RESULT_PREFIX
153:                                        + " retrieveConfigurationDisplaySchema( target="
154:                                        + target
155:                                        + " ): caught unexpected exception");
156:                    }
157:                    printExceptionMessage(e,
158:                            "retrieveConfigurationDisplaySchema");
159:                }
160:            }
161:
162:            public void retrieveAppConfigType(boolean expectingException)
163:                    throws Exception {
164:
165:                String target = System.getProperty(TARGET);
166:                Object[] params = new Object[2];
167:                params[0] = System.getProperty(COMPONENT_NAME);
168:                params[1] = target;
169:
170:                String[] signature = new String[2];
171:                signature[0] = "java.lang.String";
172:                signature[1] = "java.lang.String";
173:
174:                try {
175:                    CompositeType ct = (CompositeType) mbns.invoke(
176:                            getJbiAdminCommandsUI(),
177:                            "queryApplicationConfigurationType", params,
178:                            signature);
179:
180:                    System.out.println(RESULT_PREFIX
181:                            + " queryApplicationConfigurationType( target="
182:                            + target + " ):" + ct);
183:                    if (expectingException) {
184:                        System.out
185:                                .println("*** Was expecting exception, but didn't get one! ***");
186:                    }
187:                } catch (Exception e) {
188:                    if (expectingException) {
189:                        System.out.println(RESULT_PREFIX
190:                                + " queryApplicationConfigurationType( target="
191:                                + target + " ): caught expected exception.");
192:                    } else {
193:                        System.out.println(RESULT_PREFIX
194:                                + " queryApplicationConfigurationType( target="
195:                                + target + " ): caught unexpected exception");
196:                    }
197:                    printExceptionMessage(e,
198:                            "queryApplicationConfigurationType");
199:                }
200:            }
201:
202:            private void printExceptionMessage(Exception ex, String opName) {
203:                Throwable cause = ex;
204:
205:                while (cause instanceof  javax.management.JMException
206:                        && cause != null) {
207:                    cause = cause.getCause();
208:                }
209:
210:                System.out.println("Exception " + cause.getClass()
211:                        + " thrown by " + opName + " with Message \n"
212:                        + cause.getMessage().replace("en_US", "en"));
213:            }
214:
215:            public static void main(String[] params) throws Exception {
216:                // test setup
217:                TestComponentConfigMetaData test = new TestComponentConfigMetaData();
218:                test.initMBeanServerConnection();
219:
220:                // test
221:                test.retrieveConfigurationDisplayData(true);
222:                test.retrieveConfigurationDisplaySchema(true);
223:                test.retrieveAppConfigType(true);
224:
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.