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: * @(#)TestDeployment.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: import com.sun.jbi.EnvironmentContext;
030: import com.sun.jbi.management.system.ManagementContext;
031: import javax.jbi.management.DeploymentServiceMBean;
032:
033: import javax.management.MBeanServer;
034: import javax.management.MBeanServerFactory;
035: import javax.management.ObjectName;
036: import javax.management.remote.JMXConnectorServer;
037: import javax.management.remote.JMXConnectorServerFactory;
038: import javax.management.remote.JMXServiceURL;
039: import javax.management.StandardMBean;
040:
041: /**
042: * Tests the deployment (management) service.
043: * @author Sun Microsystems, Inc.
044: */
045:
046: public class TestDeployment {
047: /** JMX Domain name for the jbi jmx server. */
048: public static final String JBI_DOMAIN = "com.sun.jbi";
049:
050: /** JBI MBean Object type. */
051: public static final String CONTROL_TYPE_KEY = "ControlType";
052:
053: /** JBI MBean Object type value. */
054: public static final String DEPLOYER_CONTROL_TYPE_VALUE = "Deployer";
055:
056: /** JMX Default Port. */
057: public static final int JMX_PORT_DEFAULT = 5555;
058:
059: /**
060: * main routine.
061: * @param anUnusedSetOfArgs unused.
062: */
063: public static void main(String[] anUnusedSetOfArgs) {
064: DeploymentServiceMBean dsbean = null;
065: try {
066: MBeanServer mbs = MBeanServerFactory
067: .createMBeanServer(JBI_DOMAIN);
068: System.out.println("In main. before start");
069: EnvironmentContext mContext = new com.sun.jbi.management.system.ScaffoldEnvironmentContext();
070: ManagementContext mgmtContext = new ManagementContext(
071: mContext);
072: dsbean = new com.sun.jbi.management.system.DeploymentService(
073: mgmtContext);
074: StandardMBean smbean = new StandardMBean(dsbean,
075: DeploymentServiceMBean.class);
076: String mbeanRegisteredName = JBI_DOMAIN + ":"
077: + CONTROL_TYPE_KEY + "="
078: + DEPLOYER_CONTROL_TYPE_VALUE;
079: System.out.println("MBEAN NAME : " + mbeanRegisteredName);
080: mbs.registerMBean(smbean, new ObjectName(
081: mbeanRegisteredName));
082:
083: // Create a JMXMP connector server
084:
085: System.out.println("\nCreate a JMXMP connector server");
086: JMXServiceURL url = new JMXServiceURL("jmxmp", null,
087: JMX_PORT_DEFAULT);
088: JMXConnectorServer cs = JMXConnectorServerFactory
089: .newJMXConnectorServer(url, null, mbs);
090:
091: // Start the JMXMP connector server
092: //
093: System.out.println("\nStart the JMXMP connector server");
094: cs.start();
095: System.out
096: .println("\nJMXMP connector server successfully started");
097: System.out.println("\nWaiting for incoming connections...");
098: } catch (Exception e) {
099: e.printStackTrace();
100: }
101:
102: try {
103: System.out.println("\nDeploying...");
104: //dsbean.deploy("C:\\temp\\ms1\\deploy\\AUCalc.jar");
105: } catch (Exception e) {
106: e.printStackTrace();
107: }
108:
109: //System.out.println("In main. end");
110: }
111: }
|