當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。