jtaxisproxy.java

来自「Java Pattern Oriented Framework (Jt) 是为了」· Java 代码 · 共 177 行

JAVA
177
字号
package Jt.axis;

import Jt.JtAdapter;
import Jt.JtMessage;
import Jt.JtObject;
import Jt.JtProxy;



/**
 * An Axis Proxy to a remote object.
 */


public class JtAxisProxy extends JtProxy {


  private Object proxyId;
  
  private static final long serialVersionUID = 1L;

  public JtAxisProxy() {
  }




  public Object getProxyId() {
    return proxyId;
}




public void setProxyId(Object proxyId) {
    this.proxyId = proxyId;
}




/**
 * Process object messages by forwarding them to the proxy's subject. 

 * @param event Jt Message    
 */

public Object processMessage (Object event) {
    JtMessage msg;
    JtObject adapter;
    Object output;

    String msgid = null;
    JtMessage e = (JtMessage) event;

    if (e == null)
        return null;

    msgid = (String) e.getMsgId ();

    if (msgid == null)
        return null;

    // Set the attribute value of a remote object
    // using a Web services adapter
    
    this.setObjException(null);

    if (msgid.equals (JtObject.JtSET_VALUE)) {
        msg = new JtMessage (JtObject.JtSET_VALUE);
        msg.setMsgSubject(proxyId);       
        msg.setMsgContent(e.getMsgContent());
        msg.setMsgData(e.getMsgData());

        adapter = (JtObject) this.getSubject();        

        if (adapter == null) {
            handleError ("JtAxisProxy.processMessage: the subject attribute needs to be set");
            return (null);
        }
        output = adapter.processMessage (msg);
        propagateException (adapter);
        return (null);     
    }

    if (msgid.equals (JtObject.JtGET_VALUE)) {
        msg = new JtMessage (JtObject.JtGET_VALUE);
        msg.setMsgSubject(proxyId);       
        msg.setMsgContent(e.getMsgContent());

        adapter = (JtAdapter) this.getSubject();

        if (adapter == null) {
            handleError ("JtAxisProxy.processMessage: the subject attribute needs to be set");
            return (null);
        }

        output = adapter.processMessage (msg); 
        propagateException (adapter);
        return (output);     
    }

    /*
    if (msgid.equals (JtObject.JtSEND_MESSAGE)) {
        msg = new JtMessage (JtObject.JtSEND_MESSAGE);
        msg.setMsgContent(proxyId);
        msg.setMsgData(e.getMsgData());

        adapter = (JtAdapter) this.getSubject();

        if (adapter == null) {
            handleError ("JtAxixProxy.processMessage: the subject attribute needs to be set");
            return (null);
        }
        output = adapter.processMessage (msg); 
        propagateException (adapter);
        return (output); 
    }
    */
    
    if (msgid.equals (JtObject.JtREMOVE_OBJECT)) {
        msg = new JtMessage (JtObject.JtREMOVE_OBJECT);
        msg.setMsgContent(proxyId);

        adapter = (JtAdapter) this.getSubject();

        if (adapter == null) {
            handleError ("JtAxixProxy.processMessage: the subject attribute needs to be set");
            return (null);
        }
        output = adapter.processMessage (msg); 
        propagateException (adapter);
        return (output); 
    }

    
    msg = new JtMessage (JtObject.JtSEND_MESSAGE);
    msg.setMsgContent(proxyId);
    msg.setMsgData(event);

    adapter = (JtAdapter) this.getSubject();

    if (adapter == null) {
        handleError ("JtAxixProxy.processMessage: the subject attribute needs to be set");
        return (null);
    }
    output = adapter.processMessage (msg); 
    propagateException (adapter);
    return (output); 


    //handleError ("processMessage: invalid message ID:" + msgid); // check
    //return (null);

}

  // Propagate Exceptions 

  private Exception propagateException (JtObject obj)
  {
    Exception ex;

    if (obj == null)
      return null;

    ex = (Exception) obj.getObjException();


    if (ex != null)
        this.setObjException(ex);

    return (ex);
  }
  
  
}

⌨️ 快捷键说明

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