简体   繁体   English

支柱1单身人士班

[英]struts 1 singleton classes

1) I would like to know which main classes in Struts 1 are are Singleton classes. 1)我想知道Struts 1中哪些主要类是Singleton类。 Main classes like ActionServlet , RequestProcessor , Action , ActionForm etc. 主要类如ActionServletRequestProcessorActionActionForm等。

2) Also, I heard from somebody that if we have multiple struts confix xml file in our struts application then for each module a new RequestProcessor will be instanstiated. 2)另外,我听说有人说,如果我们的struts应用程序中有多个struts confix xml文件,那么将为每个模块实例化一个新的RequestProcessor Is this true ? 这是真的 ?

Thanks. 谢谢。

1) there is Actionclass which will be singleton like as we are not going to generate object explicitly. 1)有Actionclass,它将是单例的,因为我们不会显式生成对象。

2) and whatever number of struts-config file is there for that only requestProcessor instantiated 2)以及仅实例化的requestProcessor的任何数量的struts-config文件

  1. To understand classes that are used by the Struts framework better look the the source code. 为了更好地理解Struts框架使用的类,请查看源代码。 If you did it you'll see that none of the classes you've mentioned implement a Singlton pattern . 如果您这样做了,将会发现您提到的所有类都没有实现Singlton模式 That means that nothing prevent them to make as many instances as you needed. 这意味着没有什么可以阻止它们创建所需数量的实例。 But it depends on how these instances are managed. 但这取决于如何管理这些实例。

  2. Not exactly, the request processor is created for each module in the case if there's not one is already created for a concrete module. 不完全是,如果还没有为具体模块创建请求处理器,则会为每个模块创建请求处理器。 See ActionServlet.getRequestProcessor 请参见ActionServlet.getRequestProcessor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM