当前位置: 首页>>代码示例>>Java>>正文


Java ActionServlet.getServletContext方法代码示例

本文整理汇总了Java中org.apache.struts.action.ActionServlet.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java ActionServlet.getServletContext方法的具体用法?Java ActionServlet.getServletContext怎么用?Java ActionServlet.getServletContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.struts.action.ActionServlet的用法示例。


在下文中一共展示了ActionServlet.getServletContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retrieveTempDir

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
 * Retrieves the temporary directory from either ActionServlet, a context
 * property, or a system property, in that order.
 */
protected void retrieveTempDir(ModuleConfig moduleConfig) {

    //attempt to retrieve the servlet container's temporary directory
    ActionServlet servlet = getServlet();
    if (servlet != null) {
        //attempt to retrieve the servlet container's temporary directory
        ServletContext context = servlet.getServletContext();

        try {
            tempDir =
                    (String) context.getAttribute("javax.servlet.context.tempdir");
        } catch(ClassCastException cce) {
            tempDir = ((File) context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
        }
    }

    if (tempDir == null) {
        //attempt to retrieve the temporary directory from the controller
        tempDir = moduleConfig.getControllerConfig().getTempDir();

        if (tempDir == null) {
            //default to system-wide tempdir
            tempDir = System.getProperty("java.io.tmpdir");

            log.debug(
                "DiskMultipartRequestHandler.handleRequest(): "
                    + "defaulting to java.io.tmpdir directory \""
                    + tempDir);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:DiskMultipartRequestHandler.java

示例2: setServlet

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
public void setServlet(ActionServlet actionServlet) {
	super.setServlet(actionServlet);
	if (actionServlet != null) {
		ServletContext servletContext = actionServlet.getServletContext();
		WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
		this.petStore = (PetStoreFacade) wac.getBean("petStore");
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:BaseAction.java

示例3: setServlet

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
public void setServlet(ActionServlet actionServlet) {
	super.setServlet(actionServlet);
	ServletContext servletContext = actionServlet.getServletContext();
	WebApplicationContext wac =
		WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);


}
 
开发者ID:NCIP,项目名称:cadsr-uml-model-browser,代码行数:9,代码来源:BaseDispatchAction.java

示例4: setServlet

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
public void setServlet(ActionServlet actionServlet) {
	super.setServlet(actionServlet);
	ServletContext servletContext = actionServlet.getServletContext();
	WebApplicationContext wac =
		WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

}
 
开发者ID:NCIP,项目名称:cadsr-uml-model-browser,代码行数:8,代码来源:BaseAction.java

示例5: init

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
 * Intializer. Instantiates a new object and adds it to the application context by key
 *
 * @param servlet The ActionServlet for our application
 * @param config  The ModuleConfig for our owning module
 * @throws ServletException if we cannot configure ourselves correctly
 */
public void init(ActionServlet servlet, ModuleConfig config)
        throws ServletException {

    this.servlet = servlet;
    try {
      ServletContext servletContext = servlet.getServletContext();
      SpringObjectLocatorImpl.applicationContext=WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

    } catch (Exception e) {

        throw new ServletException("Could not initalize SpringObjectLocatorImpl.applicationContext",e);
    }

}
 
开发者ID:NCIP,项目名称:cadsr-uml-model-browser,代码行数:22,代码来源:SpringWebContextPlugIn.java

示例6: init

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
 * The init method is called when this plugin is initialized
 * <P>
 * @param actionServlet The struts ActionServlet
 * @param moduleConfig The struts ModuleConfig
 */
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
		throws ServletException
{
	 // Retrieve the ServletContext
	  ServletContext ctx = actionServlet.getServletContext();
	  
	  // The Quartz Scheduler
	  Scheduler scheduler = null;

	  // Retrieve the factory from the ServletContext.
	  // It will be put there by the Quartz Servlet
	  StdSchedulerFactory factory = (StdSchedulerFactory) 
	      ctx.getAttribute(QuartzInitializerServlet.QUARTZ_FACTORY_KEY);
	    
	  try
	  {
	        // Retrieve the scheduler from the factory
	        scheduler = factory.getScheduler();

	        // Start the scheduler in case, it isn't started yet
	        if (startOnLoad != null && 
	            startOnLoad.equals(Boolean.TRUE.toString()))
	        {
	            scheduler.start();
	        }
	  }
	  catch (Exception e)
	  {
	     logger.error("Error setting up scheduler", e);
	  }
	  
	  sm_scheduler = scheduler;
}
 
开发者ID:NCIP,项目名称:rembrandt,代码行数:40,代码来源:SchedulerPlugIn.java

示例7: init

import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
 * The init method is called when this plugin is initialized
 * <P>
 * @param actionServlet The struts ActionServlet
 * @param moduleConfig The struts ModuleConfig
 */
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
		throws ServletException
{
	 // Retrieve the ServletContext
	  ServletContext ctx = actionServlet.getServletContext();
	  
	  // The Quartz Scheduler
	  Scheduler scheduler = null;

	  // Retrieve the factory from the ServletContext.
	  // It will be put there by the Quartz Servlet
	  StdSchedulerFactory factory = (StdSchedulerFactory) 
	      ctx.getAttribute(QuartzInitializerServlet.QUARTZ_FACTORY_KEY);
	    
	  try
	  {
	        // Retrieve the scheduler from the factory
	        scheduler = factory.getScheduler();
	        // Start the scheduler in case, it isn't started yet
	        if (startOnLoad != null && 
	            startOnLoad.equals(Boolean.TRUE.toString()))
	        {
	            scheduler.start();
	        }
	  }
	  catch (Exception e)
	  {
	     logger.error("Error setting up scheduler", e);
	  }
	  
	  sm_scheduler = scheduler;
}
 
开发者ID:NCIP,项目名称:rembrandt,代码行数:39,代码来源:StatisticsInfoPlugIn.java


注:本文中的org.apache.struts.action.ActionServlet.getServletContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。