com.jdon.controller
类 WebAppUtil

java.lang.Object
  继承者 com.jdon.controller.WebAppUtil

public class WebAppUtil
extends Object

Used in Web application. Using WebAppUtil, framework's user can get his businesss service object that defined in jdonframework.xml this is main and important client class for framework's user. ForumService forumService = (ForumService) WebAppUtil.getService("forumService", request); forumService.getForums(start);

作者:
banq

构造方法摘要
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)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

WebAppUtil

public WebAppUtil()
方法详细信息

getService

public 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 . this method will find HttpSession , if not exist then create a HttpSession, save the proxy object into the httpSesion. if you use the service with session support, must use this method, or use getService(String name, ServletContext sc) ;

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 - String
request - HttpServletRequest
返回:
Object
抛出:
Exception

getService

public 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. execept some interceptors about session, such as Stateful disable. 3. not support session ,if you need your jsp page not create cookie with JSESSIONID, use this method.

参数:
name -
sc -
返回:

getService

public static Object getService(TargetMetaDef targetMetaDef,
                                javax.servlet.http.HttpServletRequest request)

getComponentInstance

public 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


getComponentInstance

public 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

参数:
sc -
返回:

callService

public static Object callService(String serviceName,
                                 String methodName,
                                 Object[] methodParams,
                                 javax.servlet.http.HttpServletRequest request)
                          throws Exception
Command pattern for service invoke sample: browser url: /aaa.do?method=xxxxx xxxxx is the service's method, such as: public interface TestService{ void xxxxx(EventModel em); }

参数:
serviceName - the service name in jdonframework.xml
methodName - the method name
request -
model - the method parameter must be packed in a ModelIF object. if no method parameter, set it to null;
返回:
return the service dealing result
抛出:
Exception
另请参见:
com.jdon.strutsutil.ServiceMethodAction

getContainerKey

public static String getContainerKey()
get the key for the application container user can directly get his container from servletcontext by the key.

返回:
String

getInterceptorKey

public static String getInterceptorKey()
get the key for the interceptor, by the key, use can add his interceptor to the container

返回:
String

getContainer

public static ContainerWrapper getContainer(javax.servlet.http.HttpServletRequest request)
                                     throws Exception
get this Web application's container

参数:
request - HttpServletRequest
返回:
ContainerWrapper
抛出:
Exception

getContainer

public static ContainerWrapper getContainer(javax.servlet.ServletContext sc)
                                     throws Exception
抛出:
Exception


Copyright © 2013. All Rights Reserved.