KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > ejb > examples > HelloWorld


1 package Jt.ejb.examples;
2
3 import Jt.*;
4 import java.io.*;
5 import Jt.ejb.*;
6
7
8 // This class demonstrates the use of
9
// the J2EE Business Delegate design pattern
10

11 public class HelloWorld extends JtObject {
12
13
14
15   // Test program
16

17   public static void main(String JavaDoc[] args) {
18
19     JtFactory factory = new JtFactory (); // Jt Factory
20
String JavaDoc reply;
21     JtBusinessDelegate main;
22
23     
24     // Create an instance of JtBusinessDelegate (Jt implementation of
25
// the J2EE business delegate pattern)
26

27     main = (JtBusinessDelegate) factory.createObject ("Jt.ejb.JtBusinessDelegate",
28      "businessDelegate");
29
30
31     // Create a remote instance of the HelloWorld class. JtBusinessDelegate
32
// can be used to create remote instances of any Jt Framework class.
33
// HelloWorld is used as an example.
34

35
36     main.createObject ("Jt.examples.HelloWorld", "helloWorld");
37
38     // Set the greetingMessage attribute
39

40     main.setValue ("helloWorld", "greetingMessage", "Hello World...");
41
42     // Send JtHello to the remote helloWorld object
43

44     main.handleTrace ("main:sending a message (JtHello) to the helloWorld object ...");
45     reply = (String JavaDoc) main.sendMessage ("helloWorld", new JtMessage ("JtHello"));
46
47     // Print the reply message (Greeting)
48
System.out.println (reply);
49
50     // Remove helloWorld
51

52     main.removeObject ("helloWorld");
53
54         
55   }
56
57 }
58
59
60
61
Popular Tags