📄 statusclient.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.client;
import java.util.*;
import javax.naming.*;
import javax.management.*;
import javax.rmi.PortableRemoteObject;
import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
import org.compiere.interfaces.*;
import org.compiere.interfaces.StatusHome;
/**
*
*
* @author Jorg Janke
* @version $Id: StatusClient.java,v 1.7 2002/11/04 04:35:53 jjanke Exp $
*/
public class StatusClient
{
private static InitialContext s_Context = null;
/**
* Test
* @param args arguments - host
*/
public static void main(String[] args)
{
String serverName = "localhost";
if (args.length > 0 && args[0].length() > 0)
serverName = args[0];
System.out.println("ServerName=" + serverName);
System.out.println("JMX");
try
{
String connectorName = "jmx:" + serverName + ":rmi";
RMIAdaptor server = (RMIAdaptor) new InitialContext().lookup(connectorName);
System.out.println("- have Server");
System.out.println("- Default Domain=" + server.getDefaultDomain());
System.out.println("- MBeanCount = " + server.getMBeanCount());
ObjectName serviceName = new ObjectName ("Compiere:service=CompiereCtrl");
System.out.println("- " + serviceName + " is registered=" + server.isRegistered(serviceName));
MBeanOperationInfo[] opInfo = server.getMBeanInfo(serviceName).getOperations();
for (int i = 0; i < opInfo.length; i++)
System.out.println(" - Operation: " + opInfo[i].getName());
MBeanAttributeInfo[] attInfo = server.getMBeanInfo(serviceName).getAttributes();
for (int i = 0; i < attInfo.length; i++)
System.out.println(" - Attribute: " + attInfo[i].getName() + " = "
+ server.getAttribute(serviceName, attInfo[i].getName()));
Object[] params = {};
String[] signature = {};
// String summary = (String) server.invoke (serviceName, "getCompiereSummary", params, signature);
// System.out.println("- Invoked CompiereCtrl.getCompiereSummary() " + summary);
}
catch (Exception e)
{
e.printStackTrace();
}
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, serverName);
//
try
{
s_Context = new InitialContext(env);
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}
try
{
System.out.println(s_Context.getNameInNamespace());
System.out.println("-- Context Environment:");
System.out.println(s_Context.getEnvironment());
System.out.println("");
System.out.println("-- /");
NamingEnumeration ne = (NamingEnumeration)s_Context.list("/");
while (ne.hasMore())
System.out.println(" " + ne.nextElement());
System.out.println("");
System.out.println("-- java:");
ne = (NamingEnumeration)s_Context.list("java:");
while (ne.hasMore())
System.out.println(" " + ne.nextElement());
System.out.println("");
System.out.println("-- java:comp/env");
ne = (NamingEnumeration)s_Context.list("java:comp/env");
while (ne.hasMore())
System.out.println(" " + ne.nextElement());
System.out.println("");
System.out.println("-- ejb");
ne = (NamingEnumeration)s_Context.list("ejb");
while (ne.hasMore())
System.out.println(" " + ne.nextElement());
StatusHome statusHome = (StatusHome)s_Context.lookup ("ejb/compiere/Status");
Status status = statusHome.create();
// Get a new Id of the Test Entity
System.out.println ("Version is: " + status.getDateVersion() );
status.remove();
// s_Context.lookup("java:OracleDS");
}
catch( Exception e )
{
e.printStackTrace();
}
/**
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
env.setProperty(Context.PROVIDER_URL, "http://localhost:8080/invoker/JNDIFactory");
InitialContext ctx = new InitialContext(env);
**/
} // main
} // StatusClient
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -