MAP | PageMixer Documents > Tutorial > Mixing with Servlet > Get 'InputStream' | << | >> |
This section explains
how to customize getting InputStream
,
to create Producer
,
with PageServlet
.
Class diagram in this section is shown below:
Classes which you must define are colored, and other are already defined.
In this tutorial, abbreviated class names are used. Complete names are shown below.
Notation | Full name |
---|---|
ClassLoaderLocator | jp.ne.dti.lares.foozy.pagemixer.page.ClassLoaderLocator |
LocalFSLocator | jp.ne.dti.lares.foozy.pagemixer.page.LocalFSLocator |
Locator | jp.ne.dti.lares.foozy.pagemixer.page.Locator |
LocatorFactory | jp.ne.dti.lares.foozy.pagemixer.servlet.LocatorFactory |
PageServlet | jp.ne.dti.lares.foozy.pagemixer.servlet.PageServlet |
Producer | jp.ne.dti.lares.foozy.pagemixer.mixer.Producer |
ServletContextLocator | jp.ne.dti.lares.foozy.pagemixer.servlet.ServletContextLocator |
WebAppLocator | jp.ne.dti.lares.foozy.pagemixer.servlet.WebAppLocator |
No tutorial specific class is explained in this section.
Please see "Render locale sensitively" section
for detail about getting InputStream
as 'resource' management.
Locator
implementationPageMixer provides
"LocatorFactory
" for
customization of getting InputStream
of 'resource'.
LocatorFactory
is used to create Locator
.
In addition to ClassLoaderLocator
and
LocalFSLocator
explained in
"Render locale sensitively",
PageMixer provides ServletContextLocator
and
WebAppLocator
for Servlet environment.
And LocatorFactory
default implementation
chooses one of them by configuration(as explained later).
ServletContextLocator
is derived from
ClassLoaderLocator
.
This tries to get InputStream
by getResourceAsStream
of ServletContext
at first.
Then this invokes getInputStream(String)
of base class.
WebAppLocator
is derived from
LocalFSLocator
.
This passes getRealPath("")
result
of ServletContext
as base directory to constructor of LocalFSLocator
.
So, this tries to get InputStream
of resoures
under own web application directory.
ServletContextLocator
can not examine
whether resource base of InputStream
is modified or not
since last access,
so can not allow you to "reload" resource.
In other hand,
Servlet container, which does not make extracted WAR image on runtime,
may not allow you to use WebAppLocator
.
But I do not know such implementation.
Please see API document and source code of them
about detail to define custom LocatorFactory
,
even though you may satisfy your needs by pre-defined classes
in almost all cases.
LocatorFactory
accepts
Servet initialize parameter(s) shown below:
name | description |
---|---|
locator.reloadable |
whether Servlet wants to reload resource when modified.
in other words,
this causes choice of
WebAppLocator if this is "true",
or ServletContextLocator otherwise.
default value of this is "true". |
To use your custom LocatorFactory
,
you should specify "servlet.locatorFactory
"
Servlet init-param in deployment descriptor
as shown below.
<init-param>
<param-name>
servlet.locatorFactory
</param-name>
<param-value>
name of your custom LocatorFactory
</param-value>
</init-param>
MAP | PageMixer Documents > Tutorial > Mixing with Servlet > Get 'InputStream' | << | >> |