public class Client
{
public static void main(String[] args) throws Exception
{
InitialContext ctx = new InitialContext();
ExampleProducerRemote remote = (ExampleProducerRemote) ctx.lookup(ExampleProducerRemote.class.getName());
// you can typecast the returned proxy to obtain a ProducerManager interface that allows you to manage
// interaction with JMS.
ProducerManager manager = ((ProducerObject) remote).getProducerManager();
// connect
manager.connect();
try
{
// Call method1
remote.method1("Remote method1 called", 1);
System.out.println("Remote method1 called");
// Call method2
Map<String, String> map = new HashMap<String, String>();
map.put("hello", "world");
map.put("great", "ejb3");
remote.method2("Remote method2 called", map);
System.out.println("Remote method2 called");
}
finally
{
// instead of typecasting, you can use a helper class that does everything for you.