jp.terasoluna.fw.web.struts.plugins
Class BLogicIOPlugIn

java.lang.Object
  extended by jp.terasoluna.fw.web.struts.plugins.BLogicIOPlugIn
All Implemented Interfaces:
org.apache.struts.action.PlugIn

public class BLogicIOPlugIn
extends java.lang.Object
implements org.apache.struts.action.PlugIn

Plugin that loads the configuration information of business logic I/O.

At the time of initializing the servlet, PlugIn function of Struts loads the business logic I/O settings and stores it in the servlet context.
To use this function, perform the following settings in struts-config.xml. (digesterRules, mapperClass can be omitted) When the property is "resources", the file can be joined with comma.

 <plug-in
   className="jp.terasoluna.fw.web.struts.plugins.BLogicIOPlugIn">
    <set-property
        property="resources"
        value="/WEB-INF/blogic-io.xml"/>
    <set-property
        property="digesterRules"
        value="/WEB-INF/blogic-io-rules.xml"/>
    <set-property
        property="mapperClass"
        value="jp.terasoluna.fw.service.thin.BLogicMapper"/>
 </plug-in>
 

To change the business logic I/O information mapping class to the extended class, set the subclass of AbstractBLogicMapper in "value" attribute of mapperClass or set the class which is extended from BLogicMapper.

In blogic-io.xml, set the business logic I/O information for each action.
Settings in blogic-io.xml are as follows.
 <blogic-io>
   <action path="/logon/logonAction">
     <blogic-param bean-name="jp.terasoluna.sample.blogic.LogonBean">
       <set-property property="userName"
                        blogic-property="userName"
                        source="form" />
       <set-property property="sessionId"
                        blogic-property="id"
                        source="session" />
     </blogic-param>
     <blogic-result>
       <set-property property="resultStr"
                        blogic-property="result"
                        dest="form" />
       <set-property property="USER_VALUE_OBJECT"
                        blogic-property="uvo"
                        dest="session" />
     </blogic-result>
   </action>
   ...
 </blogic-io>
 

Set the input value information of business logic in "<blogic-param>" element. In "bean-name" attribute, specify the class name of JavaBean that stores input value. This JavaBean should possess the property which is specified in "blogic-property" attribute.
When the business logic does not contain input value, the business logic can be executed by omitting the "bean-name" attribute and passing the argument as null.
The source of the input is Web tier objects like actionform and session. The location to fetch this data can be identified from the value of "source" attribute of "<set-property>" element. By default, by specifying any one of form or session in the "source" attribute, it can be identified whether the information source is actionform or session.
Specify the property name of input source data in the "property" attribute. For example,
When property="field1" source="form", actionForm.get("field1") is executed. When property="field2" source="session", session.getAttribute("field2") is executed.
The value mentioned above can be fetched in the business logic as the property value of JavaBean instance which is specified in "bean-name" attribute. At the time of fetching the value from JavaBean, the value specified in blogic-property becomes the property name. When "blogic-property" attribute is not specified, the value mentioned in "property" attribute is considered as property name of JavaBean.

At the time of fetching the value from field1 of action form by performing the following settings, the value of action form can be fetched by executing bean.getBlogicField1().

   <set-property property="field1" blogic-property="blogicField1"
                   source="form" />
 
,
Even in case of session, the value can be fetched in similar way as that of form. In order to fetch the value of session in the business logic, perform the following settings and using the key as field2, execute bean.getBlogicField2().
  <set-property property="field2" blogic-property="blogicField2"
                   source="session" />
 
In the business logic, it is not required to identify whether the source of input is action form or session.
This configuration information is loaded to the instance of BLogicResources and stored in the servlet context.


To change the public identifier and DTD URL,
override getPublicIdentifier() and getDtdUrl().

See Also:
BLogicAction, BLogic, BLogicResources, BLogicResult, AbstractBLogicMapper, BLogicMapper

Field Summary
static java.lang.String BLOGIC_MAPPER_KEY
          Prefix key of BLogicMapper which is registered in the servlet context.
private  AbstractBLogicMapper blogicMapper
          Business logic I/O information mapper.
private  BLogicResources blogicResources
          Instance that retains the business logic I/O information.
private static org.apache.commons.digester.Digester digester
          Digester instance.
private static java.lang.String DIGESTER_RULES_PATH
          Path of default blogic-io-rules.xml.
private  java.lang.String digesterRules
          Business logic I/O information rule definition file (blogic-io-rules.xml).
private  java.lang.String dtdUrl
          DTD path.
private static org.apache.commons.logging.Log log
          Log class.
private  java.lang.String mapperStr
          Class file name in which BLogicMapper is specified. When it is not specified, default class name is used.
private  java.lang.String publicIdentifier
          DTD public identifier.
private  java.lang.String resources
          Business logic I/O information definition file (blogic-io.xml).
private  org.apache.struts.action.ActionServlet servlet
          Servlet that has generated this plugin.
 
Constructor Summary
BLogicIOPlugIn()
           
 
Method Summary
 void destroy()
          Process at the time of termination.
 java.lang.String getDtdUrl()
          Returns DTD URL. To change DTD URL, override this method.
 java.lang.String getPublicIdentifier()
          Returns public identifier. To change the public identifier, override this method.
 void init(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)
          Process at the time of PlugIn initialization.
private  void initMapper()
          Mapper registration process.
private  void initResources()
          Business logic I/O information initialization process.
 void setDigesterRules(java.lang.String digesterRules)
          Sets blogic-io-rules.xml.
 void setDtdUrl(java.lang.String dtdUrl)
          Sets DTD URL.
 void setMapperClass(java.lang.String mapperStr)
          Sets business logic I/O information mapping class.
 void setPublicIdentifier(java.lang.String publicIdentifier)
          Sets public identifier.
 void setResources(java.lang.String resources)
          Sets blogic-io.xml.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log class.


BLOGIC_MAPPER_KEY

public static final java.lang.String BLOGIC_MAPPER_KEY
Prefix key of BLogicMapper which is registered in servlet context.

See Also:
Constant Field Values

DIGESTER_RULES_PATH

private static final java.lang.String DIGESTER_RULES_PATH
Path of default blogic-io-rules.xml.

See Also:
Constant Field Values

publicIdentifier

private java.lang.String publicIdentifier
DTD public identifier.


dtdUrl

private java.lang.String dtdUrl
DTD path.


servlet

private org.apache.struts.action.ActionServlet servlet
Servlet that has generated this plugin.


digesterRules

private java.lang.String digesterRules
Business logic I/O information rule definition file (blogic-io-rules.xml).


resources

private java.lang.String resources
Business logic I/O information definition file (blogic-io-rules.xml).


mapperStr

private java.lang.String mapperStr
Class file name in which BLogicMapper is specified. When it is not specified, default class name is used.


blogicResources

private BLogicResources blogicResources
Instance that retains business logic I/O information.


blogicMapper

private AbstractBLogicMapper blogicMapper
Business logic I/O information mapper.


digester

private static org.apache.commons.digester.Digester digester
Digester instance.

Constructor Detail

BLogicIOPlugIn

public BLogicIOPlugIn()
Method Detail

destroy

public void destroy()
Process at the time of termination.

Specified by:
destroy in interface org.apache.struts.action.PlugIn

init

public void init(org.apache.struts.action.ActionServlet servlet,
                 org.apache.struts.config.ModuleConfig config)
          throws javax.servlet.ServletException
Process at the time of PlugIn initialization.

Registers BLogicResources and BLogicMapper in servlet context.

NullPointerException occurs when the servlet that invokes this plugin and module configuration are null.

Specified by:
init in interface org.apache.struts.action.PlugIn
Parameters:
servlet - Servlet that invokes this plugin
config - Module configuration
Throws:
javax.servlet.ServletException - Exception at the time of initialization

initResources

private void initResources()
                    throws javax.servlet.ServletException
Business logic I/O information initialization process.

Use blogic-io.xml and blogic-io-rules.xml and load the configuration information into Bean.

When the format of XML configuration file is invalid or when IO exception occurs, throw this exception after wrapping with ServletException.

Throws:
javax.servlet.ServletException - Exception which occurs at the time of initialization process of business logic I/O information

getPublicIdentifier

public java.lang.String getPublicIdentifier()
Returns public identifier. To change the public identifier, override this method.

Returns:
Public identifier

getDtdUrl

public java.lang.String getDtdUrl()
Returns DTD URL. To change DTD URL, override this method.

Returns:
DTD URL

initMapper

private void initMapper()
                 throws javax.servlet.ServletException
Mapper registration process.

Loads BLogicMapper and registers the configuration information in the instance field.

When the class loading of BLogicMapper which is retained in the instance fails, ServletException is thrown.

Throws:
javax.servlet.ServletException - Servlet exception

setDigesterRules

public void setDigesterRules(java.lang.String digesterRules)
Sets blogic-io-rules.xml.

Parameters:
digesterRules - blogic-io-rules.xml

setResources

public void setResources(java.lang.String resources)
Sets blogic-io.xml.

Parameters:
resources - blogic-io.xml

setMapperClass

public void setMapperClass(java.lang.String mapperStr)
Sets business logic I/O information mapping class.

Parameters:
mapperStr - Business logic I/O information mapping class name

setPublicIdentifier

public void setPublicIdentifier(java.lang.String publicIdentifier)
Sets public identifier.

Parameters:
publicIdentifier - Public identifier

setDtdUrl

public void setDtdUrl(java.lang.String dtdUrl)
Sets DTD URL.

Parameters:
dtdUrl - DTD URL