Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 plug-in只能加载一个类的实例的问题
webdev





发贴: 9
于 2004-10-19 10:11 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
struts-config.xm配置 如下:
<struts-config>

..........

<plug-in className="gxfc.service.news.impl.ArticleServiceFactoryImpl" />
<plug-in className="gxfc.service.user.impl.UserServiceFactoryImpl" />
</struts-config>

2个类是工厂类,分别生成2个对象的实例,代码如下:

public class ArticleServiceFactoryImpl
implements IArticleServiceFactory, PlugIn {
private ActionServlet servlet = null;
String serviceClassname = "gxfc.service.news.impl.ArticleServiceImpl";

public IArticleService createService() throws ClassNotFoundException,
IllegalAccessException, InstantiationException {
String className = servlet.getInitParameter(IConstants.
ARTICLESERVICE_CLASS_KEY);

if (className != null) {
serviceClassname = className;
}

try {
IArticleService instance =
(IArticleService) Class.forName(serviceClassname).newInstance();
instance.setServletContext(servlet.getServletContext());
return instance;
}
catch (Exception e) {
e.printStackTrace();
return null;
}

}

public void destroy() {
/**@todo Implement this gxfc.service.news.IArticleServiceFactory method*/
throw new java.lang.UnsupportedOperationException(
"Method destroy() not yet implemented.");
}

public void init(ActionServlet servlet, ModuleConfig config) {
this.servlet = servlet;
servlet.getServletContext().setAttribute(IConstants.
ARTICLESERVICE_FACTORY_KEY, this);

}

}

gxfc.service.news.impl.ArticleServiceFactoryImpl这个工厂运行是正常的,但是gxfc.service.user.impl.UserServiceFactoryImpl这个工厂无法生产出类的实例,后查明,发现是servlet这个变量为空的,也就是plug-in没有加载,但是代码都是一样,而且配置也是一样,为什么会一个加载了,另外一个没加载呢?




话题树型展开
人气 标题 作者 字数 发贴时间
1342 plug-in只能加载一个类的实例的问题 webdev 1775 2004-10-19 10:11

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923