
EJB
™
Development Using Borland
®
JBuilder
®
8 and BEA WebLogic Server
™
7.0
51
Enter the name of the class as Client. Change the contents of Client.java in JBuilder editor
pane as follows:
Client.java
package com.borland.demo.ejb;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
import java.util.Hashtable;
public class Client {
public final static String
JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
public final static String URL = "t3://localhost:7001";
private static final String QUEUE_CONNECTION_FACTORY =
"DemoJMSConnectionFactory";
private static final String QUEUE = "DemoJMSQueue";
private static InitialContext getInitialContext(String url)
throws NamingException
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}
public static void main(String[] args) throws Exception {
Context ctx = getInitialContext(URL);
QueueConnectionFactory qConnFact =
(QueueConnectionFactory) ctx.lookup(QUEUE_CONNECTION_FACTORY);
Kommentare zu diesen Handbüchern