EJBLocalHome getEjbLocalHome(beanname)
switch beanname
case ...
ejbname = ...
return ctx.lookup(ejbname)
switch beanname
case ...
ejbname = ...
return ctx.lookup(ejbname)
解决方案 »
- struts2
- [散分]08年最后一次发帖,最后一个问题,顺祝09年大家开心~
- ssi spring 依赖注入为什么出错,报空指针的错误?
- 如何在程序运行中,能用鼠标拉拽jTextArea和jTable之类控件的边框,而在程序界面大小没变的情况下动态改变程序里控件的大小?
- 请问在JAVA如何实现http请求的header字段的赋值?
- 装完Oracle9i后..为什么TOMCAT不能启动了?
- 在tomcat服务器上发布soap的问题,高分相赠
- 100分 tomcat 连接sqlserver时 (在tomcat启动的dos界面中出现超时连接,但程序连接数据库没问题 ,这是怎么回事啊???
- 一个关于BMP的问题
- 终于配置成功了jboss应用服务器
- cmp小问题
- 你遇到过类似的问题吗?(JBuilder9+Weblogic7)
EJBLocalHome home = null;
Context ctx = new InitialContext();
try {
switch(localHome)
case ..
home = (EJBLocalHome) ctx.lookup(localHome);
}
catch (Exception e) {
e.printStackTrace();
}
return home;
}
这样,我怎么调用子类里的方法?
就意味这,我就要改一下这个方法。我想要的是,dispatcher与后面的业务逻辑的bean无关。
可能,我的j2ee学的还不是很好。这个方案,我以前用com+,实现了的。我现在想把这个机构迁移到ejb上。请大家帮忙啊,谢谢
{ private static ServiceLocator serviceLocator = null;
private static Hashtable dataSourceCache = null;
private static Hashtable ejgHomeCache = null;
public static String DATASOURCENAME=JNDINames.DATASOURCENAME; static
{
serviceLocator = new ServiceLocator();
} private ServiceLocator()
{
dataSourceCache = new Hashtable();
ejgHomeCache = new Hashtable(); } public static ServiceLocator getInstance()
{
return serviceLocator;
} public Connection getConnection(String jdbcName) throws
ServiceLocatorException
{
Connection conn = null; try { if (dataSourceCache.containsKey(jdbcName)) {
DataSource oldDs = (DataSource) dataSourceCache.get(jdbcName);
conn= oldDs.getConnection();
return conn;
}
else {
javax.naming.InitialContext ictx = new javax.naming.InitialContext();
DataSource newDs = (DataSource) ictx.lookup(jdbcName);
dataSourceCache.put(jdbcName, newDs);
conn= newDs.getConnection();
return conn;
}
}
catch (SQLException e1) {
throw new ServiceLocatorException("SQL error has occurred in get connection"+e1);
}
catch (NamingException e2) {
throw new ServiceLocatorException(" JDNI naming has occurred" +e2);
}
catch (Exception e3) {
throw new ServiceLocatorException("exception has occurred in get connection"+e3);
} } public EJBHome getEJBHome(String jndiName, Class className) throws
ServiceLocatorException
{
EJBHome ejbHome = null;
try {
if (dataSourceCache.containsKey(jndiName)) {
ejbHome = (EJBHome) dataSourceCache.get(jndiName);
return ejbHome;
}
else {
javax.naming.InitialContext ictx = new javax.naming.InitialContext();
Object jndiRef = ictx.lookup(jndiName);
ejbHome = (EJBHome) PortableRemoteObject.narrow(jndiRef,
className);
dataSourceCache.put(jndiName, ejbHome);
return ejbHome;
}
}
catch (NamingException e2) {
throw new ServiceLocatorException(" JDNI naming has occurred" +e2);
}
catch (Exception e3) {
throw new ServiceLocatorException("exception has occurred in get connection"+e3);
}
}}