private static boolean initialized = false;
public static synchronized void init()
{
TradeHome tradeHome=null;
if (initialized) return;
if (Log.doTrace())
Log.trace("TradeDirect:init -- *** initializing");
try
{
if (Log.doTrace())
Log.trace("TradeDirect: init");
context = new InitialContext();
datasource = (DataSource) context.lookup(dsName);
}
catch (Exception e)
{
Log.error("TradeDirect:init -- error on JNDI lookups of DataSource -- TradeDirect will not work", e);
return;
}
try {
tradeHome = (TradeHome) ( javax.rmi.PortableRemoteObject.narrow(
context.lookup("java:comp/env/ejb/Trade"), TradeHome.class));
}
catch (Exception e)
{
Log.error("TradeDirect:init -- error on JNDI lookup of Trade Session Bean -- TradeDirect will not work", e);
return;
}
try
{
qConnFactory = (ConnectionFactory) context.lookup("java:comp/env/jms/QueueConnectionFactory");
}
catch (Exception e)
{
Log.error("TradeDirect:init Unable to locate QueueConnectionFactory.\n\t -- Asynchronous mode will not work correctly and Quote Price change publishing will be disabled");
publishQuotePriceChange = false;
}
try
{
queue = (Queue) context.lookup("java:comp/env/jms/TradeBrokerQueue");
}
catch (Exception e)
{
Log.error("TradeDirect:init Unable to locate TradeBrokerQueue.\n\t -- Asynchronous mode will not work correctly and Quote Price change publishing will be disabled");
publishQuotePriceChange = false;
}
try
{
tConnFactory = (ConnectionFactory) context.lookup("java:comp/env/jms/TopicConnectionFactory");
}
catch (Exception e)
{
Log.error("TradeDirect:init Unable to locate TopicConnectionFactory.\n\t -- Asynchronous mode will not work correctly and Quote Price change publishing will be disabled");
publishQuotePriceChange = false;
}
try
{
streamerTopic = (Topic) context.lookup("java:comp/env/jms/TradeStreamerTopic");
}
catch (Exception e)
{
Log.error("TradeDirect:init Unable to locate TradeStreamerTopic.\n\t -- Asynchronous mode will not work correctly and Quote Price change publishing will be disabled");
publishQuotePriceChange = false;
}
try
{
tradeEJB = (Trade) tradeHome.create();
}
catch (Exception e)
{
Log.error("TradeDirect:init -- error looking up TradeEJB -- Asynchronous 1-phase will not work", e);
}