org.apache.tiles.request.ApplicationContext Java Examples

The following examples show how to use org.apache.tiles.request.ApplicationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext,
		LocaleResolver resolver) {

	if (definitionsFactoryClass != null) {
		DefinitionsFactory factory = BeanUtils.instantiateClass(definitionsFactoryClass);
		if (factory instanceof ApplicationContextAware) {
			((ApplicationContextAware) factory).setApplicationContext(applicationContext);
		}
		BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory);
		if (bw.isWritableProperty("localeResolver")) {
			bw.setPropertyValue("localeResolver", resolver);
		}
		if (bw.isWritableProperty("definitionDAO")) {
			bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver));
		}
		return factory;
	}
	else {
		return super.createDefinitionsFactory(applicationContext, resolver);
	}
}
 
Example #2
Source File: TilesConfigurerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleBootstrap() {
	MockServletContext servletContext = new MockServletContext();

	TilesConfigurer tc = new TilesConfigurer();
	tc.setDefinitions("/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml");
	tc.setCheckRefresh(true);
	tc.setServletContext(servletContext);
	tc.afterPropertiesSet();

	ApplicationContext tilesContext = ServletUtil.getApplicationContext(servletContext);

	BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesContext);
	Request requestContext = new ServletRequest(container.getApplicationContext(),
			new MockHttpServletRequest(), new MockHttpServletResponse());
	assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));

	tc.destroy();
}
 
Example #3
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
	if (definitions != null) {
		List<ApplicationResource> result = new LinkedList<>();
		for (String definition : definitions) {
			Collection<ApplicationResource> resources = applicationContext.getResources(definition);
			if (resources != null) {
				result.addAll(resources);
			}
		}
		return result;
	}
	else {
		return super.getSources(applicationContext);
	}
}
 
Example #4
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext,
		LocaleResolver resolver) {

	if (definitionsFactoryClass != null) {
		DefinitionsFactory factory = BeanUtils.instantiate(definitionsFactoryClass);
		if (factory instanceof ApplicationContextAware) {
			((ApplicationContextAware) factory).setApplicationContext(applicationContext);
		}
		BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory);
		if (bw.isWritableProperty("localeResolver")) {
			bw.setPropertyValue("localeResolver", resolver);
		}
		if (bw.isWritableProperty("definitionDAO")) {
			bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver));
		}
		return factory;
	}
	else {
		return super.createDefinitionsFactory(applicationContext, resolver);
	}
}
 
Example #5
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
	if (definitions != null) {
		List<ApplicationResource> result = new LinkedList<>();
		for (String definition : definitions) {
			Collection<ApplicationResource> resources = applicationContext.getResources(definition);
			if (resources != null) {
				result.addAll(resources);
			}
		}
		return result;
	}
	else {
		return super.getSources(applicationContext);
	}
}
 
Example #6
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext,
		LocaleResolver resolver) {

	if (definitionsFactoryClass != null) {
		DefinitionsFactory factory = BeanUtils.instantiateClass(definitionsFactoryClass);
		if (factory instanceof ApplicationContextAware) {
			((ApplicationContextAware) factory).setApplicationContext(applicationContext);
		}
		BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory);
		if (bw.isWritableProperty("localeResolver")) {
			bw.setPropertyValue("localeResolver", resolver);
		}
		if (bw.isWritableProperty("definitionDAO")) {
			bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver));
		}
		return factory;
	}
	else {
		return super.createDefinitionsFactory(applicationContext, resolver);
	}
}
 
Example #7
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
	if (definitions != null) {
		List<ApplicationResource> result = new LinkedList<ApplicationResource>();
		for (String definition : definitions) {
			Collection<ApplicationResource> resources = applicationContext.getResources(definition);
			if (resources != null) {
				result.addAll(resources);
			}
		}
		return result;
	}
	else {
		return super.getSources(applicationContext);
	}
}
 
Example #8
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext,
		LocaleResolver resolver) {

	if (definitionsFactoryClass != null) {
		DefinitionsFactory factory = BeanUtils.instantiate(definitionsFactoryClass);
		if (factory instanceof ApplicationContextAware) {
			((ApplicationContextAware) factory).setApplicationContext(applicationContext);
		}
		BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory);
		if (bw.isWritableProperty("localeResolver")) {
			bw.setPropertyValue("localeResolver", resolver);
		}
		if (bw.isWritableProperty("definitionDAO")) {
			bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver));
		}
		return factory;
	}
	else {
		return super.createDefinitionsFactory(applicationContext, resolver);
	}
}
 
Example #9
Source File: TilesConfigurerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void simpleBootstrap() {
	MockServletContext servletContext = new MockServletContext();

	TilesConfigurer tc = new TilesConfigurer();
	tc.setDefinitions("/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml");
	tc.setCheckRefresh(true);
	tc.setServletContext(servletContext);
	tc.afterPropertiesSet();

	ApplicationContext tilesContext = ServletUtil.getApplicationContext(servletContext);

	BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesContext);
	Request requestContext = new ServletRequest(container.getApplicationContext(),
			new MockHttpServletRequest(), new MockHttpServletResponse());
	assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));

	tc.destroy();
}
 
Example #10
Source File: TilesConfigurerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void simpleBootstrap() {
	MockServletContext servletContext = new MockServletContext();

	TilesConfigurer tc = new TilesConfigurer();
	tc.setDefinitions("/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml");
	tc.setCheckRefresh(true);
	tc.setServletContext(servletContext);
	tc.afterPropertiesSet();

	ApplicationContext tilesContext = ServletUtil.getApplicationContext(servletContext);

	BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesContext);
	Request requestContext = new ServletRequest(container.getApplicationContext(),
			new MockHttpServletRequest(), new MockHttpServletResponse());
	assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));

	tc.destroy();
}
 
Example #11
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
	if (definitions != null) {
		List<ApplicationResource> result = new LinkedList<ApplicationResource>();
		for (String definition : definitions) {
			Collection<ApplicationResource> resources = applicationContext.getResources(definition);
			if (resources != null) {
				result.addAll(resources);
			}
		}
		return result;
	}
	else {
		return super.getSources(applicationContext);
	}
}
 
Example #12
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and exposes a TilesContainer for this web application,
 * delegating to the TilesInitializer.
 * @throws TilesException in case of setup failure
 */
@Override
public void afterPropertiesSet() throws TilesException {
	ApplicationContext preliminaryContext = new SpringWildcardServletTilesApplicationContext(this.servletContext);
	if (this.tilesInitializer == null) {
		this.tilesInitializer = new SpringTilesInitializer();
	}
	this.tilesInitializer.initialize(preliminaryContext);
}
 
Example #13
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected PreparerFactory createPreparerFactory(ApplicationContext context) {
	if (preparerFactoryClass != null) {
		return BeanUtils.instantiateClass(preparerFactoryClass);
	}
	else {
		return super.createPreparerFactory(context);
	}
}
 
Example #14
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates and exposes a TilesContainer for this web application,
 * delegating to the TilesInitializer.
 * @throws TilesException in case of setup failure
 */
@Override
public void afterPropertiesSet() throws TilesException {
	ApplicationContext preliminaryContext = new SpringWildcardServletTilesApplicationContext(this.servletContext);
	if (this.tilesInitializer == null) {
		this.tilesInitializer = new SpringTilesInitializer();
	}
	this.tilesInitializer.initialize(preliminaryContext);
}
 
Example #15
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(ApplicationContext applicationContext,
		LocaleResolver resolver) {
	BaseLocaleUrlDefinitionDAO dao = super.instantiateLocaleDefinitionDao(applicationContext, resolver);
	if (checkRefresh && dao instanceof CachingLocaleUrlDefinitionDAO) {
		((CachingLocaleUrlDefinitionDAO) dao).setCheckRefresh(true);
	}
	return dao;
}
 
Example #16
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(ApplicationContext applicationContext,
		LocaleResolver resolver) {
	BaseLocaleUrlDefinitionDAO dao = super.instantiateLocaleDefinitionDao(applicationContext, resolver);
	if (checkRefresh && dao instanceof CachingLocaleUrlDefinitionDAO) {
		((CachingLocaleUrlDefinitionDAO) dao).setCheckRefresh(true);
	}
	return dao;
}
 
Example #17
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected PreparerFactory createPreparerFactory(ApplicationContext context) {
	if (preparerFactoryClass != null) {
		return BeanUtils.instantiate(preparerFactoryClass);
	}
	else {
		return super.createPreparerFactory(context);
	}
}
 
Example #18
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(ApplicationContext applicationContext,
		LocaleResolver resolver) {
	BaseLocaleUrlDefinitionDAO dao = super.instantiateLocaleDefinitionDao(applicationContext, resolver);
	if (checkRefresh && dao instanceof CachingLocaleUrlDefinitionDAO) {
		((CachingLocaleUrlDefinitionDAO) dao).setCheckRefresh(true);
	}
	return dao;
}
 
Example #19
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Creates and exposes a TilesContainer for this web application,
 * delegating to the TilesInitializer.
 * @throws TilesException in case of setup failure
 */
@Override
public void afterPropertiesSet() throws TilesException {
	Assert.state(this.servletContext != null, "No ServletContext available");
	ApplicationContext preliminaryContext = new SpringWildcardServletTilesApplicationContext(this.servletContext);
	if (this.tilesInitializer == null) {
		this.tilesInitializer = new SpringTilesInitializer();
	}
	this.tilesInitializer.initialize(preliminaryContext);
}
 
Example #20
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected PreparerFactory createPreparerFactory(ApplicationContext context) {
	if (preparerFactoryClass != null) {
		return BeanUtils.instantiate(preparerFactoryClass);
	}
	else {
		return super.createPreparerFactory(context);
	}
}
 
Example #21
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected PreparerFactory createPreparerFactory(ApplicationContext context) {
	if (preparerFactoryClass != null) {
		return BeanUtils.instantiateClass(preparerFactoryClass);
	}
	else {
		return super.createPreparerFactory(context);
	}
}
 
Example #22
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(ApplicationContext applicationContext,
		LocaleResolver resolver) {
	BaseLocaleUrlDefinitionDAO dao = super.instantiateLocaleDefinitionDao(applicationContext, resolver);
	if (checkRefresh && dao instanceof CachingLocaleUrlDefinitionDAO) {
		((CachingLocaleUrlDefinitionDAO) dao).setCheckRefresh(true);
	}
	return dao;
}
 
Example #23
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Creates and exposes a TilesContainer for this web application,
 * delegating to the TilesInitializer.
 * @throws TilesException in case of setup failure
 */
@Override
public void afterPropertiesSet() throws TilesException {
	Assert.state(this.servletContext != null, "No ServletContext available");
	ApplicationContext preliminaryContext = new SpringWildcardServletTilesApplicationContext(this.servletContext);
	if (this.tilesInitializer == null) {
		this.tilesInitializer = new SpringTilesInitializer();
	}
	this.tilesInitializer.initialize(preliminaryContext);
}
 
Example #24
Source File: EntandoStrutsTilesInitializer.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
    LOG.trace("Creating dedicated Struts factory to create Tiles container");
    return new EntandoStrutsTilesContainerFactory(this.getServletContext());
}
 
Example #25
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected DefinitionsReader createDefinitionsReader(ApplicationContext context) {
	DigesterDefinitionsReader reader = (DigesterDefinitionsReader) super.createDefinitionsReader(context);
	reader.setValidating(validateDefinitions);
	return reader;
}
 
Example #26
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public TilesContainer createContainer(ApplicationContext context) {
	TilesContainer container = super.createContainer(context);
	return (useMutableTilesContainer ? new CachingTilesContainer(container) : container);
}
 
Example #27
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
	return new SpringTilesContainerFactory();
}
 
Example #28
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected LocaleResolver createLocaleResolver(ApplicationContext context) {
	return new SpringLocaleResolver();
}
 
Example #29
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
	return new SpringCompleteAutoloadTilesContainerFactory();
}
 
Example #30
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected LocaleResolver createLocaleResolver(ApplicationContext applicationContext) {
	return new SpringLocaleResolver();
}