businessdelegateexample.java

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

JAVA
79
字号
package Jt.ejb.examples;

import Jt.*;
import Jt.axis.JtWebServicesAdapter;
import Jt.ejb.*;
import Jt.examples.HelloWorld;


// This class demonstrates the use of  
// the J2EE Business Delegate design pattern

public class BusinessDelegateExample  {



  // Test program

  public static void main(String[] args) {

    JtFactory factory = new JtFactory ();  // Jt Factory
    String reply;
    JtBusinessDelegate delegate;
    JtMessage msg;
    JtProxy proxy;
    String tmp;
    Exception ex;
    
    // Create an instance of JtBusinessDelegate (Jt implementation of
    // the J2EE business delegate pattern)

    delegate = (JtBusinessDelegate) factory.createObject (JtBusinessDelegate.JtCLASS_NAME, 
     "businessDelegate");
    // send a test message (JtTEST) to the adapter

    msg = new JtMessage (JtWebServicesAdapter.JtCREATE_PROXY);
    msg.setMsgContent(HelloWorld.JtCLASS_NAME);
    //msg.setMsgData("helloWorld");

    // Create a remote instance of the HelloWorld class. JtBusinessDelegate
    // can be used to create remote object. A local proxy is returned.

    proxy = (JtProxy) factory.sendMessage (delegate, msg);
    factory.setValue (proxy, "logLevel", "0");
    factory.setValue (proxy, "logging", "true");

    factory.setValue (proxy, "greetingMessage", "Hello there...");

    tmp = (String) factory.getValue (proxy, "greetingMessage");

    System.out.println ("greetingMessage:" + tmp);

    msg = new JtMessage (HelloWorld.JtHELLO);

    // Send JtHello to the remote helloWorld object

    reply = (String) factory.sendMessage (proxy, msg);    


    ex = (Exception) proxy.getObjException();


    // Display the reply unless an exception is detected

    if (ex == null)    
        System.out.println (reply);

    // Remove the instance of JtBusinessDelegate and the proxy

    factory.removeObject (proxy);
    factory.removeObject (delegate);

        
  }

}



⌨️ 快捷键说明

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