壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6367|回复: 3

[安装|配置|入门|资料] 不開啟Weblogic就可單元測試MAXIMO

[复制链接]
发表于 2011/4/5 15:44:25 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
MAXIMO RMI 伺服器, 可直接執行main程式, 但記憶體要加大, 如下:
-Xms512m -Xmx1024m -XX:MaxPermSize=128m

package xxx.server;

import java.io.InputStream;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.util.Properties;
import psdi.server.MXServer;
import psdi.server.MaxPropCache;
import psdi.server.MaximoThread;
import psdi.server.MaximoThreadGroup;
import psdi.util.IBMComInstanciator;
import psdi.util.MXProperties;
import psdi.util.logging.FixedLoggers;
import psdi.util.logging.MXLogger;
import psdi.util.logging.MXLoggerFactory;

public class LocalServer  {
private static MXLogger logger = FixedLoggers.MAXIMOLOGGER;

public static void main(String[] args) {
         LocalServer lSrv = new LocalServer();
         try {
               lSrv.init();
               System.out.println("*server initialed*****");
               MXLoggerFactory.applySettings(true);
               System.in.read();
         } catch (Throwable e) {
               e.printStackTrace();
         } finally {
               System.out.println("*server destroy*****");
               lSrv.destroy();
               System.exit(0);
          }
}
public void init() {
  try {
   //
   InputStream in = getClass().getResourceAsStream("/maximo.properties");
   Properties configProperties = MXProperties.loadProperties(in, true);
   MXServer.start(configProperties);
   MXServer mxSrv = MXServer.getMXServer();
   //
   MaxPropCache propCache = (MaxPropCache)mxSrv.getFromMaximoCache("MAXPROP");
   Properties pops = propCache.getProperties();
   //不檢查WebService存在
   pops.setProperty("mxe.int.verifywebappurl", "false");
   pops.setProperty("mxe.int.resolveschema", "1");
   //
   System.out.println("mxe.int.verifywebappurl="+mxSrv.getProperty("mxe.int.verifywebappurl"));
   System.out.println("mxe.int.resolveschema="+mxSrv.getProperty("mxe.int.resolveschema"));
   //
   registerCOMDriver();
  } catch (Exception ex) {
   String msg;
   if (logger.isErrorEnabled()) {
    msg = "BMXAA6538E - Failed to initialize MAXIMO business object services.";
    logger.error(msg, ex);
   }
   ex.printStackTrace();
  }
}
public void destroy() {
  try {
   MXServer.getMXServer().destroy();
  } catch (Throwable e) {
   if (logger.isErrorEnabled()) {
    String msg = "BMXAA6540E - Failed to cleanup MAXIMO business object services.";
    logger.error(msg, e);
   }
  }
  MaximoThreadGroup mt = MaximoThreadGroup.getMXThreadGroup();
  int activeCount = mt.activeCount();
  Thread mxThreads[] = new Thread[activeCount];
  int noThreads = mt.enumerate(mxThreads);
  for (int i = 0; i < noThreads; i++) {
   MaximoThread x = (MaximoThread) mxThreads[i];
   x.markShutdown();
   x.interrupt();
  }
  try {
   String url = MXServer.getMXServer().getURL();
   if (url != null) {
    Naming.unbind(url);
    if (logger.isInfoEnabled()) {
     String msg = (new StringBuilder()).append("BMXAA6541I - Unbound ").append(url).toString();
     logger.info(msg);
    }
   }
  } catch (Throwable ex) {
   if (logger.isErrorEnabled()) {
    String msg = "BMXAA6542E - Failed to unbind MAXIMO business services.";
    logger.error(msg, ex);
   }
  }
  
}
public void registerCOMDriver() throws RemoteException {
  String propval;
  propval = MXServer.getMXServer().getConfig().getProperty("mxe.com.port");
  if (propval == null)
   return;
  try {
   System.out.println("COM Port:"+propval);
   System.setProperty("JINTEGRA_DCOM_PORT", propval);
   registerCom();
  } catch (Exception e) {
   if (logger.isErrorEnabled()) {
    String msg = "BMXAA6543E - Failed register com driver.";
    logger.error(msg, e);
   }
  }
  return;
}
private void registerCom() throws Exception {
  IBMComInstanciator oInstance = new psdi.util.IBMComInstanciator();
  String svrName = MXServer.getMXServer().getName();
  System.out.println("Server Name:"+svrName);
  com.linar.jintegra.Jvm.register(svrName, oInstance);
  System.out.println(com.linar.jintegra.Jvm.getMoniker());
  logger.info("BMXAA6544I - registered the com driver");
}

}

唯 maximo.properties要放在路徑下, 就可直接執行, RMI伺服器, 透過JUnit,或遠端RMI連線即可測試MBO,範例如下:
     MXSession session = MXSession.getSession();
     session.setHost("localhost:13400/MXServer");
     session.setUserName("wilson");
     session.setPassword("wilson");
     session.connect();
     MboSetRemote mSet = session.getMboSet("SR");
     .....




发表于 2011/4/11 16:01:23 | 显示全部楼层
com.linar.jintegra.Jvm 是什么意思呀 ,我这里无法解析!
发表于 2011/4/11 16:05:04 | 显示全部楼层
找到原因了,谢谢LZ
 楼主| 发表于 2011/4/18 22:16:53 | 显示全部楼层
回复 Kelvn 的帖子

那是COM物件的類別, 你可以將下式
System.out.println(com.linar.jintegra.Jvm.getMoniker());
在Console列印出來的Key, 利用VBA程式就可與MAXIMO溝通了
程式範例如下(將下式存成xxx.vbs,就可在Window上連線MAXIMO了)

Dim jvm
Set jvm = GetObject("objref:TUVPVwEAAAAABAIAAAAAAMAAAAAAAABGABAAAAAAAABKaW50ZWdyYVRhbGtUb01lV2hhdHNBbGxUaGlzVGhlbkcAQAAHADIAMAAwAC4AMQA2ADgALgAxAC4AMQA4ADkAWwAxADMANgA2AF0AAAAHADEAOQAyAC4AMQA2ADgALgAyADQAOQAuADEAWwAxADMANgA2AF0AAAAHADEAOQAyAC4AMQA2ADgALgAyADEANwAuADEAWwAxADMANgA2AF0AAAAAAAoA//8AAAAAAAAAAAAA:")
Dim sdk
Set sdk = jvm.get("MXServer:psdi.util.DefaultMXSessionFactory")

Dim ssn
Set ssn = sdk.getSession
ssn.setHost "localhost:13400"
ssn.setUserName "wilson"
ssn.setPassword "wilson"
ssn.setClientAddr "localhost"
ssn.connect
MsgBox ssn.getBaseLang
ssn.disconnect

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 18:42 , Processed in 0.014476 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表