⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iiopdown.java

📁 利用JAVA采用IIOP通讯的方式,支持weblogic及websphere
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * IiopComm.java
 *
 * Created on 2004年1月2日, 下午1:33
 */

package collector.iiop;

import java.rmi.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.*; //import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;
//import collector.serversession.sessionejb.*;
import javax.rmi.*;

import collector.common.*;
import pbs.service.valueobject.*; //import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;//import collector.serversession.sessionejb.*;
import pbs.sessionbean.ejb.*;

//import collector.serversession.sessionejb.*;

/**
 *
 * @author  wj
 */
public class IIopDown {
  private FSessionEjbHome m_FSessionEjbHome = null;

  private FSessionEjb m_FSessionEjb = null;

  private String m_InitContextFac = null;
  private String m_IIopURL = null;
  private String m_JndiName = null;

  private Context m_Context = null;
  private Object m_Object = null;

  /** Creates a new instance of IiopComm */
  public IIopDown() {
  }

  public int setIIopParam(String m_InitContextFac, String m_IIopURL,
                          String m_JndiName) {
    this.m_InitContextFac = m_InitContextFac;
    this.m_IIopURL = m_IIopURL;
    this.m_JndiName = m_JndiName;

    return 1;
  }

  public int initConnect() {
    try {
      Properties m_Env = new Properties();
      m_Env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, m_InitContextFac);
      m_Env.put(javax.naming.InitialContext.PROVIDER_URL, m_IIopURL);
//      m_Env.put("java.naming.factory.initial", m_InitContextFac);
//      m_Env.put("java.naming.provider.url", m_IIopURL);

      //CollectorDefine.SystemPrintln ("START TO INITIAL CONTEXT 。。。");
      m_Context = new InitialContext(m_Env);

      //CollectorDefine.SystemPrintln ("START TO LOOKUP 。。。");
      m_Object = m_Context.lookup(m_JndiName);
      m_FSessionEjbHome = (FSessionEjbHome) PortableRemoteObject.narrow(
          m_Object, FSessionEjbHome.class);

      //CollectorDefine.SystemPrintln ("START TO CREATE ");
//            this.m_FSessionEjb = null;
//            this.m_FSessionEjb = m_FSessionEjbHome.create ();

      CollectorDefine.SystemPrintln("IIOP SUCCESS !!" + "url : " + m_IIopURL +
                                    "m_JndiName : " + m_JndiName);

    }
    catch (Exception m_Exception) {
      CollectorDefine.SystemPrintln(" Caught an unexpected exception!" +
                                    m_Exception.getMessage());
      CFunction.writeLog(" Caught an unexpected exception!", m_Exception);

      return -1;
    }

    return 1;
  }

  public int initConnect(int m_debug_no) {

    try {
      Properties m_Env = new Properties();
      m_Env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, m_InitContextFac);
      m_Env.put(javax.naming.InitialContext.PROVIDER_URL, m_IIopURL);
      //m_Env.put("java.naming.factory.initial", m_InitContextFac);
//      m_Env.put("java.naming.provider.url", m_IIopURL);

      CollectorDefine.SystemPrintln("START TO INITIAL CONTEXT 。。。");
      //System.out.print(m_InitContextFac);
      //System.out.print(m_IIopURL);
      m_Context = new InitialContext(m_Env);

      //CollectorDefine.SystemPrintln ("START TO LOOKUP 。。。");
      m_Object = m_Context.lookup(m_JndiName);
      m_FSessionEjbHome = (FSessionEjbHome) PortableRemoteObject.narrow(
          m_Object, FSessionEjbHome.class);

      //CollectorDefine.SystemPrintln ("START TO CREATE ");
//            this.m_FSessionEjb = null;
//            this.m_FSessionEjb = m_FSessionEjbHome.create ();

      CollectorDefine.SystemPrintln("IIOP SUCCESS !!" + "url : " + m_IIopURL +
                                    "m_JndiName : " + m_JndiName);

    }
    catch (Exception m_Exception) {
      CollectorDefine.SystemPrintln(" Caught an unexpected exception!" +
                                    m_Exception.getMessage());
      CFunction.writeLog(" Caught an unexpected exception!", m_Exception);

      return -1;
    }

    return 1;
  }

  public int reConnect(int m_debug_no) {
    try {
      m_Object = m_Context.lookup(m_JndiName);
      m_FSessionEjbHome = (FSessionEjbHome) PortableRemoteObject.narrow(
          m_Object, FSessionEjbHome.class);

      //CollectorDefine.SystemPrintln ("START TO CREATE ");
//            this.m_FSessionEjb = null;
//            this.m_FSessionEjb = m_FSessionEjbHome.create ();

      CollectorDefine.SystemPrintln("IIOP SUCCESS !!" + "url : " + m_IIopURL +
                                    "m_JndiName : " + m_JndiName);

    }
    catch (Exception m_Exception) {
      CollectorDefine.SystemPrintln(" Caught an unexpected exception!" +
                                    m_Exception.getMessage());

      CFunction.writeLog(" Caught an unexpected exception!", m_Exception);
      return -1;
    }

    return 1;

  }

  public FSessionEjb connect() throws CreateException, RemoteException {
    this.m_FSessionEjb = m_FSessionEjbHome.create();
    return m_FSessionEjb;
  }

  public int close() throws RemoteException, RemoveException {
    if (this.m_FSessionEjb != null) {
      this.m_FSessionEjb.remove();
      this.m_FSessionEjb = null;
    }

    return 1;
  }

  public Collection findByTerminalId(int m_debug_no, long m_TerminalId) throws
      RemoteException {
    try {
      return m_FSessionEjb.findByTerminalId(m_debug_no, m_TerminalId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findByTerminalId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }
  }

  public Collection findAllChannel(int m_debug_no) throws RemoteException {
    try {
      return this.m_FSessionEjb.findAllChannel(m_debug_no);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findAllChannel In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public channel findChannelByPrimaryKey(int m_debug_no, long m_ChannelId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findChannelByPrimaryKey(m_debug_no, m_ChannelId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findChannelByPrimaryKey In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public Collection findAllTerminal(int m_debug_no) throws RemoteException {
    try {
      return this.m_FSessionEjb.findAllTerminal(m_debug_no);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findAllTerminal In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public terminal findTerminalByTerminalId(int m_debug_no, long m_TerminalId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findTerminalByTerminalId(m_debug_no,
          m_TerminalId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findTerminalByTerminalId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public int updateTerminal(int m_debug_no, terminal m_terminal) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.updateTerminal(m_debug_no, m_terminal);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("updateTerminal In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public Collection findAllMeterByTerminalId(int m_debug_no, long m_TerminalId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findAllMeterByTerminalId(m_debug_no,
          m_TerminalId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findAllMeterByTerminalId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public meter findMeterByMeterId(int m_debug_no, long m_MeterId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findMeterByMeterId(m_debug_no, m_MeterId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findMeterByMeterId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public Collection findAllPulseByMeterId(int m_debug_no, long m_MeterId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findAllPulseByMeterId(m_debug_no, m_MeterId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findAllPulseByMeterId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

  public pulse findPulseByPulseId(int m_debug_no, long m_PulseId) throws
      RemoteException {
    try {
      return this.m_FSessionEjb.findPulseByPulseId(m_debug_no, m_PulseId);
    }
    catch (java.rmi.RemoteException m_RemoteException) {
      CFunction.writeLog("findPulseByPulseId In IIopDown Error #1",
                         m_RemoteException);
      throw new RemoteException();
    }

  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -