Source Code Cross Referenced for PersisterTest.java in  » J2EE » enhydra » mx4j » examples » tools » persister » 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 » J2EE » enhydra » mx4j.examples.tools.persister 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */
008:        package mx4j.examples.tools.persister;
009:
010:        import javax.management.MBeanServer;
011:        import javax.management.MBeanServerFactory;
012:        import javax.management.ObjectName;
013:        import javax.management.loading.MLet;
014:
015:        /**
016:         * Our agent which instantiates 2 MLets to load the MBeans contained in their separate jars
017:         *
018:         * @version $Revision: 1.1 $
019:         */
020:        public class PersisterTest {
021:            private MBeanServer m_server = null;
022:
023:            public PersisterTest() {
024:
025:            }
026:
027:            public void endExample() {
028:                System.out.println("----- example completed -----");
029:                MBeanServerFactory.releaseMBeanServer(m_server);
030:                System.exit(0);
031:            }
032:
033:            public void doDemo(String[] args) {
034:                String jarPath1 = args[0];
035:                String jarPath2 = args[1];
036:                String storePath = args[2];
037:                String filename = args[3];
038:
039:                m_server = MBeanServerFactory.createMBeanServer("test");
040:                try {
041:                    // register the mlet used to load the MBeans MLet one
042:                    ObjectName mName1 = new ObjectName("loading:test=mlet1");
043:                    MLet mlet1 = new MLet();
044:                    m_server.registerMBean(mlet1, mName1);
045:                    mlet1.addURL(jarPath1);
046:                    //			mlet1.addURL(new File("one.jar").toURL());
047:
048:                    ObjectName mName2 = new ObjectName("loading:test=mlet2");
049:                    MLet mlet2 = new MLet();
050:                    m_server.registerMBean(mlet2, mName2);
051:                    mlet2.addURL(jarPath2);
052:                    //			mlet2.addURL(new File("two.jar").toURL());
053:
054:                    String mbeanClass1 = "mx4j.examples.tools.persister.MBeanOne";
055:                    ObjectName mbeanName1 = new ObjectName("test:name=MBeanOne");
056:                    m_server.createMBean(mbeanClass1, mbeanName1, mName1,
057:                            new Object[] { storePath, filename }, new String[] {
058:                                    "java.lang.String", "java.lang.String" });
059:
060:                    String mbeanClass2 = "mx4j.examples.tools.persister.MBeanTwo";
061:                    ObjectName mbeanName2 = new ObjectName("test:name=MBeanTwo");
062:                    m_server.createMBean(mbeanClass2, mbeanName2, mName2,
063:                            new Object[] { new Integer(15) },
064:                            new String[] { "java.lang.Integer" });
065:
066:                    m_server.invoke(mbeanName2, "storeIt", new Object[] {
067:                            m_server, mbeanName1 }, new String[] {
068:                            "javax.management.MBeanServer",
069:                            "javax.management.ObjectName" });
070:
071:                    Object a = m_server.invoke(mbeanName2, "loadIt",
072:                            new Object[] { m_server, mbeanName1 },
073:                            new String[] { "javax.management.MBeanServer",
074:                                    "javax.management.ObjectName" });
075:
076:                    if (a.getClass().getName() == mbeanClass2)
077:                        System.out.println("Objects are equal and the same");
078:                } catch (Exception ex) {
079:                    ex.printStackTrace();
080:                } finally {
081:                    endExample();
082:                }
083:            }
084:
085:            public static void usage() {
086:                System.out
087:                        .println("Four arguments are needed to run this example:");
088:                System.out
089:                        .println("arg[0] = <path to jar containing MBeanOne> eg: file:C:/dev/one.jar");
090:                System.out
091:                        .println("arg[1] = <path to jar containing MBeanTwo> eg: file:C:/dev/two.jar");
092:                System.out.println("arg[2] = <path store file> eg: C:/dev");
093:                System.out.println("arg[3] = <name of file> eg: myMBean.ser");
094:
095:                System.out.println("Program is exiting.......");
096:                System.exit(1);
097:            }
098:
099:            public static void main(String[] args) {
100:                PersisterTest test = new PersisterTest();
101:                if (args.length < 4) {
102:                    usage();
103:                }
104:
105:                test.doDemo(args);
106:            }
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.