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


Java WebApplicationContext类代码示例

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


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

示例1: onStartup

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	WebApplicationContext context = getContext();
	servletContext.addListener(new ContextLoaderListener(context));
	servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));

	DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
	dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

	ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
	dispatcher.setLoadOnStartup(1);
	dispatcher.addMapping("/*");

	CXFServlet cxf = new CXFServlet();
	BusFactory.setDefaultBus(cxf.getBus());
	ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
	cxfServlet.setLoadOnStartup(1);
	cxfServlet.addMapping("/services/*");

	servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
			"/*");

	servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:25,代码来源:AppInitializer.java

示例2: init

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
public void init(ServletConfig config) throws ServletException {
    try {
        WebApplicationContext springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
        final AutowireCapableBeanFactory beanFactory = springContext.getAutowireCapableBeanFactory();
        beanFactory.autowireBean(this);
    }
    catch (Exception e) {
        logger.error("Error initializing ShibbolethExtAuthnHandler", e);
    }
}
 
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:11,代码来源:ShibbolethExtAuthnHandler.java

示例3: processInjectionBasedOnCurrentContext

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
/**
 * Process {@code @Autowired} injection for the given target object,
 * based on the current web application context.
 * <p>Intended for use as a delegate.
 * @param target the target object to process
 * @see org.springframework.web.context.ContextLoader#getCurrentWebApplicationContext()
 */
public static void processInjectionBasedOnCurrentContext(Object target) {
	Assert.notNull(target, "Target object must not be null");
	WebApplicationContext cc = ContextLoader.getCurrentWebApplicationContext();
	if (cc != null) {
		AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
		bpp.setBeanFactory(cc.getAutowireCapableBeanFactory());
		bpp.processInjection(target);
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug("Current WebApplicationContext is not available for processing of " +
					ClassUtils.getShortName(target.getClass()) + ": " +
					"Make sure this class gets constructed in a Spring web application. Proceeding without injection.");
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SpringBeanAutowiringSupport.java

示例4: trigger

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
/**
    * See {@link IEventNotificationService#trigger(String, String, Long, String, String)
    */
   private void trigger(Event event, String subject, String message) {
final String subjectToSend = subject == null ? event.getSubject() : subject;
final String messageToSend = message == null ? event.getMessage() : message;

// create a new thread to send the messages as it can take some time
new Thread(() -> {
    try {
	HibernateSessionManager.openSession();
	// use proxy bean instead of concrete implementation of service
	// otherwise there is no transaction for the new session
	WebApplicationContext ctx = WebApplicationContextUtils
		.getWebApplicationContext(SessionManager.getServletContext());
	IEventNotificationService eventNotificationService = (IEventNotificationService) ctx
		.getBean("eventNotificationService");
	eventNotificationService.triggerInternal(event, subjectToSend, messageToSend);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:EventNotificationService.java

示例5: doFilter

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
		throws ServletException, IOException {

	// Lazily initialize the delegate if necessary.
	Filter delegateToUse = this.delegate;
	if (delegateToUse == null) {
		synchronized (this.delegateMonitor) {
			if (this.delegate == null) {
				WebApplicationContext wac = findWebApplicationContext();
				if (wac == null) {
					throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
				}
				this.delegate = initDelegate(wac);
			}
			delegateToUse = this.delegate;
		}
	}

	// Let the delegate perform the actual doFilter operation.
	invokeDelegate(delegateToUse, request, response, filterChain);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:DelegatingFilterProxy.java

示例6: before

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
@Override
protected void before() throws Throwable {

	final SpringApplicationBuilder builder = new SpringApplicationBuilder(LocalTestSkipperServer.class);

	if (this.configLocations  != null && this.configLocations.length > 0) {
		builder.properties(
			String.format("spring.config.location:%s", StringUtils.arrayToCommaDelimitedString(this.configLocations))
		);
	}

	if (this.configNames  != null && this.configNames.length > 0) {
		builder.properties(
			String.format("spring.config.name:%s", StringUtils.arrayToCommaDelimitedString(this.configNames))
		);
	}

	this.app = builder.build();



	configurableApplicationContext = app.run(
		new String[] { "--server.port=0" });

	Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values();
	mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) configurableApplicationContext)
			.addFilters(filters.toArray(new Filter[filters.size()])).build();
	skipperPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:30,代码来源:LocalSkipperResource.java

示例7: getForumManager

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
private IForumService getForumManager() {
if (forumService == null) {
    WebApplicationContext wac = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    forumService = (IForumService) wac.getBean(ForumConstants.FORUM_SERVICE);
}
return forumService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AuthoringAction.java

示例8: getLessonService

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
private ILessonService getLessonService() {
if (OrganisationGroupAction.lessonService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    OrganisationGroupAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return OrganisationGroupAction.lessonService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:OrganisationGroupAction.java

示例9: unspecified

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
@Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);

WebApplicationContext wac = WebApplicationContextUtils
	.getRequiredWebApplicationContext(getServlet().getServletContext());
ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService");
String finishURL = learnerService.completeToolSession(toolSessionId, user.getUserID().longValue());
return new RedirectingActionForward(finishURL);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:LearningAction.java

示例10: getUserManagementService

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
private IUserManagementService getUserManagementService() {
if (HomeAction.userManagementService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return HomeAction.userManagementService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HomeAction.java

示例11: getLearningDesignService

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
private ILearningDesignService getLearningDesignService() {
if (HomeAction.learningDesignService == null) {
    WebApplicationContext ctx = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return HomeAction.learningDesignService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HomeAction.java

示例12: getUserManagementService

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
private IUserManagementService getUserManagementService() {
if (AuthoringAction.userManagementService == null) {
    WebApplicationContext wac = WebApplicationContextUtils
	    .getRequiredWebApplicationContext(getServlet().getServletContext());
    AuthoringAction.userManagementService = (IUserManagementService) wac
	    .getBean(CentralConstants.USER_MANAGEMENT_SERVICE_BEAN_NAME);
}
return AuthoringAction.userManagementService;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AuthoringAction.java

示例13: main

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
/**
 * Sets up and runs server.
 * @param args
 */
public static void main(String[] args)
{
    final Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.addConnector(connector);

    Context htmlContext = new Context(server, "/", Context.SESSIONS);

    ResourceHandler htmlHandler = new ResourceHandler();
    htmlHandler.setResourceBase("web");
    htmlContext.setHandler(htmlHandler);

    Context servletContext = new Context(server, "/", Context.SESSIONS);

    GenericWebApplicationContext springContext = new GenericWebApplicationContext();
    springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);

    ServletHolder holder = new ServletHolder(new DwrSpringServlet());
    holder.setInitParameter("pollAndCometEnabled", "true");
    holder.setInitParameter("debug", "true");
    servletContext.addServlet(holder, "/dwr/*");

    try
    {
        JettyShutdown.addShutdownHook(server);
        server.start();
        server.join();
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:JettySpringLauncher.java

示例14: putActivityPositionInRequestByToolSessionId

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
/**
    * Finds activity position within Learning Design and stores it as request attribute.
    */
   public static ActivityPositionDTO putActivityPositionInRequestByToolSessionId(Long toolSessionId,
    HttpServletRequest request, ServletContext context) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService");
if (learnerService == null) {
    LearningWebUtil.log.warn("Can not set activity position, no Learner service in servlet context.");
    return null;
}
ActivityPositionDTO positionDTO = learnerService.getActivityPositionByToolSessionId(toolSessionId);
if (positionDTO != null) {
    request.setAttribute(AttributeNames.ATTR_ACTIVITY_POSITION, positionDTO);
}
return positionDTO;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:LearningWebUtil.java

示例15: lookupSessionFactory

import org.springframework.web.context.WebApplicationContext; //导入依赖的package包/类
/**
 * Look up the SessionFactory that this filter should use.
 * <p>The default implementation looks for a bean with the specified name
 * in Spring's root application context.
 * @return the SessionFactory to use
 * @see #getSessionFactoryBeanName
 */
protected SessionFactory lookupSessionFactory() {
	if (logger.isDebugEnabled()) {
		logger.debug("Using SessionFactory '" + getSessionFactoryBeanName() + "' for OpenSessionInViewFilter");
	}
	WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
	return wac.getBean(getSessionFactoryBeanName(), SessionFactory.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:OpenSessionInViewFilter.java


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