|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjp.terasoluna.fw.web.struts.plugins.BLogicIOPlugIn
public class BLogicIOPlugIn
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.
<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().
In the business logic, it is not required to identify whether the source
of input is action form or session.
<set-property property="field2" blogic-property="blogicField2"
source="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().
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 |
---|
private static org.apache.commons.logging.Log log
public static final java.lang.String BLOGIC_MAPPER_KEY
private static final java.lang.String DIGESTER_RULES_PATH
private java.lang.String publicIdentifier
private java.lang.String dtdUrl
private org.apache.struts.action.ActionServlet servlet
private java.lang.String digesterRules
private java.lang.String resources
private java.lang.String mapperStr
private BLogicResources blogicResources
private AbstractBLogicMapper blogicMapper
private static org.apache.commons.digester.Digester digester
Constructor Detail |
---|
public BLogicIOPlugIn()
Method Detail |
---|
public void destroy()
destroy
in interface org.apache.struts.action.PlugIn
public void init(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config) throws javax.servlet.ServletException
Registers BLogicResources and BLogicMapper in servlet context.
NullPointerException occurs when the servlet that invokes this plugin and module configuration are null.
init
in interface org.apache.struts.action.PlugIn
servlet
- Servlet that invokes this pluginconfig
- Module configuration
javax.servlet.ServletException
- Exception at the time of initializationprivate void initResources() throws javax.servlet.ServletException
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.
javax.servlet.ServletException
- Exception which occurs at the time of initialization process of business logic I/O information
public java.lang.String getPublicIdentifier()
public java.lang.String getDtdUrl()
private void initMapper() throws javax.servlet.ServletException
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.
javax.servlet.ServletException
- Servlet exceptionpublic void setDigesterRules(java.lang.String digesterRules)
digesterRules
- blogic-io-rules.xmlpublic void setResources(java.lang.String resources)
resources
- blogic-io.xmlpublic void setMapperClass(java.lang.String mapperStr)
mapperStr
- Business logic I/O information mapping class namepublic void setPublicIdentifier(java.lang.String publicIdentifier)
publicIdentifier
- Public identifierpublic void setDtdUrl(java.lang.String dtdUrl)
dtdUrl
- DTD URL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |