A Standalone Java to call EJB and JMS
(2007-08-20 22:21:44)
下一個
I have just found that we had a standalone program to produce batch results in L system.
Anatomy:
It get LOCAL port number from environment variable
System.getProperty("APP_SERVER_PORT")
then defines all database fileds of a table and initialize them as null;next it creates a hashtable to store context pairs Hashtable h = new Hashtable(); h.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:" + lmmAppServerPort);
By using JNDI lookup, it finds the datasource and gets database connection
context = new InitialContext(h); ds =(DataSource)context.lookup("NGen");
connection = ds.getConnection();
Now it is time to use JDBC retrieve all qualified rows from DB and update each Entity Bean with related info. Then Call Remote interface of EJB to pass every request to the JMS queue for batch processing.
The source code name:GenerateBatchLetters.java