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


Java WebApplicationContextUtils.getWebApplicationContext方法代码示例

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


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

示例1: getBeanFactory

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
/**
 * @return A found BeanFactory configuration
 */
private BeanFactory getBeanFactory()
{
    // If someone has set a resource name then we need to load that.
    if (configLocation != null && configLocation.length > 0)
    {
        log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations.");
        return new ClassPathXmlApplicationContext(configLocation);
    }

    ServletContext srvCtx = WebContextFactory.get().getServletContext();
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();

    if (request != null)
    {
        return RequestContextUtils.getWebApplicationContext(request, srvCtx);
    }
    else
    {
        return WebApplicationContextUtils.getWebApplicationContext(srvCtx);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:SpringCreator.java

示例2: getBean

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
protected Object getBean(String name) {
	WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	return applicationContext.getBean(name);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:5,代码来源:GwtDispatcherServlet.java

示例3: contextInitialized

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
@Override
public void contextInitialized(final ServletContextEvent event) {
    final ServletContext servletContext = event.getServletContext();
    final ApplicationContext ctx =
        WebApplicationContextUtils.getWebApplicationContext(servletContext);

    LOGGER.info("[{}] has loaded the CAS servlet application context: {}",
        servletContext.getServerInfo(), ctx);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:CasEnvironmentContextListener.java

示例4: execute

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
/**
    * Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and description. The
    * description will be in format "Lesson Name":"the lesson creator", or "The gate name":"The relatived lesson name".
    *
    * @param mapping
    *            The ActionMapping used to select this instance
    * @param actionForm
    *            The optional ActionForm bean for this request (if any)
    * @param request
    *            The HTTP request we are processing
    * @param response
    *            The HTTP response we are creating
    *
    * @exception IOException
    *                if an input/output error occurs
    * @exception ServletException
    *                if a servlet exception occurs
    *
    */
   @SuppressWarnings("unchecked")
   @Override
   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

WebApplicationContext ctx = WebApplicationContextUtils
	.getWebApplicationContext(this.getServlet().getServletContext());
Scheduler scheduler = (Scheduler) ctx.getBean("scheduler");
ArrayList<ScheduledJobDTO> jobList = new ArrayList<ScheduledJobDTO>();
try {
    Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(Scheduler.DEFAULT_GROUP));
    for (JobKey jobKey : jobKeys) {
	ScheduledJobDTO jobDto = new ScheduledJobDTO();
	JobDetail detail = scheduler.getJobDetail(jobKey);
	jobDto.setName(jobKey.getName());
	jobDto.setDescription(detail.getDescription());
	List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(jobKey);
	for (Trigger trigger : triggers) {
	    jobDto.setStartDate(trigger.getStartTime());
	    jobList.add(jobDto);
	}
    }
} catch (SchedulerException e) {
    ScheduledJobListAction.log.equals("Failed get job names:" + e.getMessage());
}

request.setAttribute("jobList", jobList);
return mapping.findForward("list");
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:ScheduledJobListAction.java

示例5: getAuditService

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
protected IAuditService getAuditService(ServletContext context) {
if (SsoHandler.auditService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
    SsoHandler.auditService = (IAuditService) ctx.getBean("auditService");
}
return SsoHandler.auditService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SsoHandler.java

示例6: contextInitialized

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent event) {
    springContext = WebApplicationContextUtils
            .getWebApplicationContext(event.getServletContext());
    initService = springContext.getBean(InitService.class);
    initService.start();
}
 
开发者ID:1991wangliang,项目名称:tx-lcn,代码行数:8,代码来源:ServerListener.java

示例7: sessionDestroyed

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
public void sessionDestroyed(HttpSessionEvent se) {
    ApplicationContext ctx = WebApplicationContextUtils
            .getWebApplicationContext(se.getSession().getServletContext());

    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    HttpSession session = se.getSession();
    UserAuthDTO userAuthDto = this.internalUserAuthConnector
            .findFromSession(session);

    String tenantId = null;

    if (userAuthDto != null) {
        tenantId = userAuthDto.getTenantId();
    }

    LogoutEvent logoutEvent = new LogoutEvent(session, null,
            session.getId(), tenantId);
    ctx.publishEvent(logoutEvent);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:LogoutHttpSessionListener.java

示例8: LDAPAuthenticator

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
public LDAPAuthenticator(IUserManagementService userManagementService) {
if (LDAPAuthenticator.userManagementService == null) {
    LDAPAuthenticator.userManagementService = userManagementService;
}
if (LDAPAuthenticator.ldapService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getWebApplicationContext(SessionManager.getServletContext());
    LDAPAuthenticator.ldapService = (ILdapService) ctx.getBean("ldapService");
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:LDAPAuthenticator.java

示例9: getTracker

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
protected Tracker getTracker(HttpSessionEvent event) {
	if (iTracker == null) {
		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getSession().getServletContext());
		iTracker = (Tracker)applicationContext.getBean("unitimeBusySessions");
	}
	return iTracker;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:BusySessions.java

示例10: init

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
@Override
public void init(FilterConfig fConfig) throws ServletException {
    ServletContext sc = fConfig.getServletContext();
    WebApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(sc);

    if (cxt != null) {
        cookieUtil = cxt.getBean(CookieUtil.class);
        sessionUtil = cxt.getBean(SessionUtil.class);
    }
    System.out.println("init finished");

}
 
开发者ID:haibodong,项目名称:JSiter,代码行数:13,代码来源:HTTPBasicAuthorizeAttribute.java

示例11: process

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
protected String process(String url, HttpServletRequest request) {
    Map<String, String> parameters = getParameters(url);

    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());

    CacheTemplate cacheTemplate = context.getBean(CacheTemplate.class);
    String name = parameters.get("name");
    String key = parameters.get("key");
    url = Strings.subString(url, null, ".json");
    if (url.equals("/get")) {
        if ((null != name && name.length() > 0) && (null != key && key.length() > 0)) {
            return returnJSONResultSuccess(RESULT_CODE_SUCCESS, cacheTemplate.get(name, key));
        }
    }
    //
    else if (url.equals("/del")) {
        if ((null != name && name.length() > 0) && (null != key && key.length() > 0)) {
            cacheTemplate.del(name, key);
            return returnJSONResultSuccess(RESULT_CODE_SUCCESS, null);
        }
    }
    //
    else if (url.equals("/rem")) {
        if (null != name && name.length() > 0) {
            cacheTemplate.rem(name);
            return returnJSONResultSuccess(RESULT_CODE_SUCCESS, null);
        }
    }
    //
    else if (url.equals("/names")) {
        return returnJSONResultSuccess(RESULT_CODE_SUCCESS, cacheTemplate.names());
    }
    //
    else if (url.equals("/keys")) {
        if (null != name && name.length() > 0) {
            return returnJSONResultSuccess(RESULT_CODE_SUCCESS, cacheTemplate.getKeysData(name));
        }
    }
    //
    else if (url.equals("/fetch")) {
        if ((null != name && name.length() > 0) && (null != key && key.length() > 0)) {
            return returnJSONResultSuccess(RESULT_CODE_SUCCESS, cacheTemplate.fetch(name, key));
        }
    }
    //
    else if (url.equals("/cls")) {
        cacheTemplate.cls();
        return returnJSONResultSuccess(RESULT_CODE_SUCCESS, null);
    }
    //
    return returnJSONResultFailure(RESULT_CODE_FALIURE, "Do not support this request, please contact with administrator.");

}
 
开发者ID:yrain,项目名称:smart-cache,代码行数:54,代码来源:CacheAdminServlet.java

示例12: init

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
/**
 * Initialize the servlet
 * 
 * @param config ServletConfig
 * @exception ServletException
 */
@SuppressWarnings("unchecked")
public void init(ServletConfig config) throws ServletException
{
    super.init(config);

    // Get service registry        
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    
    // If no context has been initialised, exit silently so config changes can be made
    if (context == null)
    {
        return;
    }
    
    // Get global configuration properties
    WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    initParams = (WebDAVInitParameters) wc.getBean(BEAN_INIT_PARAMS);
    
    // Render this servlet permanently unavailable if its enablement property is not set
    if (!initParams.getEnabled())
    {
        logger.info("Marking servlet WebDAV as unavailable!");
        return;
    }
    
    // Get root paths
    
    String storeValue = initParams.getStoreName();
    
    rootPath = initParams.getRootPath();
    
    // Get beans
    
    serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY);
    
    transactionService = serviceRegistry.getTransactionService();
    tenantService = (TenantService) context.getBean("tenantService");
    
    nodeService = (NodeService) context.getBean("NodeService");
    searchService = (SearchService) context.getBean("SearchService");
    namespaceService = (NamespaceService) context.getBean("NamespaceService");
    ActivityPoster poster = (ActivityPoster) context.getBean("activitiesPoster");
    singletonCache = (SimpleCache<String, NodeRef>)context.getBean("immutableSingletonCache");
    
    
    
    // Collaborator used by WebDAV methods to create activity posts.
    activityPoster = new ActivityPosterImpl("WebDAV", poster);
    
    // Create the WebDAV helper
    m_davHelper = (WebDAVHelper) context.getBean("webDAVHelper");
    
    // Initialize the root node
    initializeRootNode(storeValue, rootPath, context, nodeService, searchService, namespaceService, tenantService, transactionService);
    
    // Create the WebDAV methods table
    
    m_davMethods = new Hashtable<String, Class<? extends WebDAVMethod>>();
    
    m_davMethods.put(WebDAV.METHOD_PROPFIND, PropFindMethod.class);
    m_davMethods.put(WebDAV.METHOD_PROPPATCH, PropPatchMethod.class);
    m_davMethods.put(WebDAV.METHOD_COPY, CopyMethod.class);
    m_davMethods.put(WebDAV.METHOD_DELETE, DeleteMethod.class);
    m_davMethods.put(WebDAV.METHOD_GET, GetMethod.class);
    m_davMethods.put(WebDAV.METHOD_HEAD, HeadMethod.class);
    m_davMethods.put(WebDAV.METHOD_LOCK, LockMethod.class);
    m_davMethods.put(WebDAV.METHOD_MKCOL, MkcolMethod.class);
    m_davMethods.put(WebDAV.METHOD_MOVE, MoveMethod.class);
    m_davMethods.put(WebDAV.METHOD_OPTIONS, OptionsMethod.class);
    m_davMethods.put(WebDAV.METHOD_POST, PostMethod.class);
    m_davMethods.put(WebDAV.METHOD_PUT, PutMethod.class);
    m_davMethods.put(WebDAV.METHOD_UNLOCK, UnlockMethod.class);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:80,代码来源:WebDAVServlet.java

示例13: doGet

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
@Override
   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// even though response is empty, it is needed so Firefox does not show parsing error
response.setContentType("text/html;charset=utf-8");

Integer orgId = WebUtil.readIntParam(request, "orgId", false);
String ids = request.getParameter("ids");

WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
UserManagementService service = (UserManagementService) ctx.getBean("userManagementService");

if (orgId != null && ids != null) {
    Organisation org = (Organisation) service.findById(Organisation.class, orgId);

    if (org != null) {
	// make sure user has permission to sort org lessons
	boolean allowSorting = false;
	List<UserOrganisationRole> userOrganisationRoles = service.getUserOrganisationRoles(orgId,
		request.getRemoteUser());
	for (UserOrganisationRole userOrganisationRole : userOrganisationRoles) {
	    Integer roleId = userOrganisationRole.getRole().getRoleId();
	    if (roleId.equals(Role.ROLE_GROUP_MANAGER) || roleId.equals(Role.ROLE_MONITOR)) {
		allowSorting = true;
		break;
	    }
	}
	if (!allowSorting) {
	    log.warn("User " + request.getRemoteUser() + " tried to sort lessons in orgId " + orgId);
	    response.sendError(HttpServletResponse.SC_FORBIDDEN);
	    return;
	}

	// make sure we record lesson ids that belong to this org
	List<String> idList = Arrays.asList(ids.split(","));
	List lessons = service.findByProperty(Lesson.class, "organisation", org);
	for (String id : idList) {
	    try {
		Long l = new Long(Long.parseLong(id));
		if (!contains(lessons, l)) {
		    log.warn("Lesson with id " + l + " doesn't belong in org with id " + orgId);
		    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
		    return;
		}
	    } catch (NumberFormatException e) {
		continue;
	    }
	}

	String oldIds = org.getOrderedLessonIds();
	String updatedIds = mergeLessonIds((oldIds != null ? oldIds : ""), ids);
	org.setOrderedLessonIds(updatedIds);
	service.save(org);
    }
}

   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:57,代码来源:LessonOrderServlet.java

示例14: initBeansFromServletContext

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
private void initBeansFromServletContext(ServletConfig config) {
    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    timeService = (TimeService) context.getBean("timeService");
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:5,代码来源:TimerServlet.java

示例15: getClassAssignmentService

import org.springframework.web.context.support.WebApplicationContextUtils; //导入方法依赖的package包/类
private static AssignmentService<ClassAssignmentProxy> getClassAssignmentService(HttpSession session) {
	WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
	return (AssignmentService<ClassAssignmentProxy>)applicationContext.getBean("classAssignmentService");
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:5,代码来源:WebSolver.java


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