|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.endeca.infront.assembler.spring.SpringAssemblerFactory
public class SpringAssemblerFactory
An assembler factory implementation that uses a Spring Framework bean factory to resolve cartridge handlers and other services.
FILE: browse.jsp
<%
// See the assembler-context.xml
Spring configuration file in the
// WEB-INF directory of the Discover reference application.
//
// Get the Spring Web Application Context
ServletContext servletCtx = this.getServletContext();
WebApplicationContext webappCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletCtx);
// Get an assembler factory and create an assembler
AssemblerFactory assemblerFactory = (AssemblerFactory)webappCtx.getBean("assemblerFactory", AssemblerFactory.class);
Assembler assembler = assemblerFactory.createAssembler();
// Assemble the results for the mobile browse page.
ContentItem assemblerResults = assembler.assemble(new RedirectAwareContentInclude("/pages/mobile/browse"));
// Serialize the results to JSON
response.setCharacterEncoding("UTF-8");
JsonSerializer serializer = new JsonSerializer(response.getWriter());
serializer.write(assemblerResults);
%>
This class is thread-safe, but Assembler
objects returned by its
createAssembler()
method are not.
Constructor arguments passed into this class should not subsequently be
modified by other threads as this may result in concurrency errors.
Constructor Summary | |
---|---|
SpringAssemblerFactory(AssemblerSettings pSettings)
Constructor to use when configuring and instantiating instances of this assembler from Spring. |
|
SpringAssemblerFactory(AssemblerSettings pSettings,
List<AssemblerEventListener> pListeners)
Constructor to use when configuring and instantiating instances of this assembler from Spring. |
|
SpringAssemblerFactory(AssemblerSettings pSettings,
List<AssemblerEventListener> pListeners,
ApplicationContext pApplicationContext)
Convenience constructor to use when instantiating a Spring-based assembler programmatically. |
Method Summary | |
---|---|
Assembler |
createAssembler()
Creates and returns a new assembler. |
void |
setApplicationContext(ApplicationContext pApplicationContext)
Sets the Spring Framework bean factory used by this assembler for resolving cartridge handlers and other services within an assembler request context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpringAssemblerFactory(AssemblerSettings pSettings)
SpringAssemblerFactory(AssemblerSettings, List)
with an empty list of AssemblerEventListener
s.
pSettings
- Contains settings to be applied to Assembler
s
produced by this factorypublic SpringAssemblerFactory(AssemblerSettings pSettings, List<AssemblerEventListener> pListeners)
pSettings
- Contains settings to be applied to Assembler
s
produced by this factorypListeners
- A list of listeners to be added to Assembler
s
created by this factory. Because Assemblers
may be
created and invoked concurrently, these listeners MUST
be thread safe.public SpringAssemblerFactory(AssemblerSettings pSettings, List<AssemblerEventListener> pListeners, ApplicationContext pApplicationContext)
pSettings
- Contains settings to be applied to Assembler
s
produced by this factorypListeners
- A list of listeners to be added to Assembler
s
created by this factory. Because Assemblers
may be
created and invoked concurrently, these listeners MUST
be thread safe.pApplicationContext
- A Spring application context to use for
looking up CartridgeHandler
s.Method Detail |
---|
public Assembler createAssembler() throws AssemblerException
AssemblerFactory
createAssembler
in interface AssemblerFactory
AssemblerException
- if the assembler cannot be created. For
example, this exception may be thrown if the factory is misconfigured.public void setApplicationContext(ApplicationContext pApplicationContext) throws BeansException
If the assembler and cartridge handlers are managed within the same Spring bean factory, then
you don't need to call this method explicitly. Since the assembler is
ApplicationContextAware
, the Spring Framework will implicitly set the bean
factory just after the assembler is constructed. However, if you instantiate an assembler
outside of the Spring Framework, then you must explicitly set the bean factory on this
assembler.
setApplicationContext
in interface ApplicationContextAware
BeansException
CartridgeHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |