📄 valueobject.java
字号:
package Jt.ejb.examples;
import Jt.*;
import Jt.ejb.*;
import java.util.*;
import Jt.examples.*;
// This class demonstrates the Jt implementation of
// the J2EE value object design pattern. A remote instance
// of an object is created. A single request is used to return
// its value object
public class ValueObject {
public static void main(String[] args) {
JtFactory factory = new JtFactory (); // Jt Factory
JtBusinessDelegate delegate;
Member valueObject;
JtMessage msg;
JtProxy proxy;
// Create an instance of JtBusinessDelegate (Jt implementation of
// the J2EE business delegate pattern)
delegate = (JtBusinessDelegate) factory.createObject (JtBusinessDelegate.JtCLASS_NAME,
"businessDelegate");
msg = new JtMessage (JtEJBAdapter.JtCREATE_PROXY);
msg.setMsgContent("Jt.examples.Member");
//msg.setMsgData("helloWorld");
proxy = (JtProxy) factory.sendMessage (delegate, msg);
// Create a remote instance of the Member class.
//delegate.createObject ("Jt.examples.Member", "member");
// Set the attributes of the remote object
factory.setValue (proxy, "email", "test@hotmail.com");
factory.setValue (proxy, "tstamp", new Date ());
factory.setValue (proxy, "status", "1");
factory.setValue (proxy, "firstname", "John");
factory.setValue (proxy, "lastname", "Doe");
// This single request returns the Value Object
valueObject = (Member) factory.sendMessage (proxy, new JtMessage (JtObject.JtVALUE_OBJECT));
factory.sendMessage (valueObject, new JtMessage (JtObject.JtPRINT));
//valueObject = (Member) delegate.sendMessage ("member", new JtMessage (JtObject.JtVALUE_OBJECT));
//factory.sendMessage (valueObject, new JtMessage (JtObject.JtPRINT));
// Print the attribute values using the local instance of the Value Object
// This is much faster and efficient.
System.out.println ("Email =" + valueObject.getEmail());
System.out.println ("Tstamp =" + valueObject.getTstamp());
System.out.println ("Status =" + valueObject.getStatus());
System.out.println ("First Name =" + valueObject.getFirstname());
System.out.println ("Last Name =" + valueObject.getLastname());
// Remove the remote object instance
factory.removeObject (proxy);
factory.removeObject(delegate);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -