public class WebAppUtil extends Object
| 构造器和说明 |
|---|
WebAppUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
callService(String serviceName,
String methodName,
Object[] methodParams,
javax.servlet.http.HttpServletRequest request)
Command pattern for service invoke sample: browser url:
/aaa.do?
|
static Object |
getComponentInstance(String name,
javax.servlet.http.HttpServletRequest request)
get a component that registered in container. the component is not
different from the service. the component instance is single instance Any
intercepter will be disable
|
static Object |
getComponentInstance(String name,
javax.servlet.ServletContext sc)
get a component that registered in container. the component is not
different from the service. the component instance is single instance Any
intercepter will be disable
|
static ContainerWrapper |
getContainer(javax.servlet.http.HttpServletRequest request)
get this Web application's container
|
static ContainerWrapper |
getContainer(javax.servlet.ServletContext sc) |
static String |
getContainerKey()
get the key for the application container user can directly get his
container from servletcontext by the key.
|
static String |
getInterceptorKey()
get the key for the interceptor, by the key, use can add his interceptor
to the container
|
static Object |
getService(String name,
javax.servlet.http.HttpServletRequest request)
get a service from jdonframework.xml's service configure. the service
maybe is a service .
|
static Object |
getService(String name,
javax.servlet.ServletContext sc)
Difference with getComponentInstance method: 1. this method return new
service instance each times.
2. call methods of the return service instance, will active interceptors.
|
static Object |
getService(TargetMetaDef targetMetaDef,
javax.servlet.http.HttpServletRequest request) |
public static Object getService(String name, javax.servlet.http.HttpServletRequest request)
if user has a business interface, so the interface can has two implemention:pojo or ejb, if is ejb, the ejb's local/remote interface must inherit the business interface. so the application's MVC will completely seperate from his business lay
usage: in jdonframework.xml:
UserDao ud = (UserDao)WebAppUtil.getService(“userJdbcDao”, request); UserDao is a interface.
name - Stringrequest - HttpServletRequestExceptionpublic static Object getService(String name, javax.servlet.ServletContext sc)
name - sc - public static Object getService(TargetMetaDef targetMetaDef, javax.servlet.http.HttpServletRequest request)
public static Object getComponentInstance(String name, javax.servlet.http.HttpServletRequest request)
public static Object getComponentInstance(String name, javax.servlet.ServletContext sc)
sc - public static Object callService(String serviceName, String methodName, Object[] methodParams, javax.servlet.http.HttpServletRequest request) throws Exception
serviceName - the service name in jdonframework.xmlmethodName - the method namerequest - model - the method parameter must be packed in a ModelIF object. if no
method parameter, set it to null;Exceptioncom.jdon.strutsutil.ServiceMethodActionpublic static String getContainerKey()
public static String getInterceptorKey()
public static ContainerWrapper getContainer(javax.servlet.http.HttpServletRequest request) throws Exception
request - HttpServletRequestExceptionpublic static ContainerWrapper getContainer(javax.servlet.ServletContext sc) throws Exception
ExceptionCopyright © 2018. All rights reserved.