|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.servlets.resolver.internal.SlingServletResolver
public class SlingServletResolver
The SlingServletResolver
has two functions: It resolves scripts
by implementing the SlingScriptResolver
interface and it resolves a
servlet for a request by implementing the ServletResolver
interface.
The resolver uses an own session to find the scripts.
Field Summary | |
---|---|
static Integer |
DEFAULT_CACHE_SIZE
The default cache size for the script resolution. |
static String |
DEFAULT_SERVLET_ROOT
The default servlet root is the first search path (which is usally /apps) |
static String |
PROP_CACHE_SIZE
|
static String |
PROP_DEFAULT_SCRIPT_WORKSPACE
|
static String |
PROP_PATHS
|
static String |
PROP_SCRIPT_USER
|
static String |
PROP_SERVLET_ROOT
|
static String |
PROP_USE_DEFAULT_WORKSPACE
|
static String |
PROP_USE_REQUEST_WORKSPACE
|
Constructor Summary | |
---|---|
SlingServletResolver()
|
Method Summary | |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context)
Activate this component. |
protected void |
bindServlet(org.osgi.framework.ServiceReference reference)
|
protected void |
deactivate(org.osgi.service.component.ComponentContext context)
Deactivate this component. |
SlingScript |
findScript(ResourceResolver resourceResolver,
String name)
Finds the SlingScript for the given name. |
void |
handleError(int status,
String message,
SlingHttpServletRequest request,
SlingHttpServletResponse response)
Called to render a response for a HTTP status code. |
void |
handleError(Throwable throwable,
SlingHttpServletRequest request,
SlingHttpServletResponse response)
Called to render a response for an uncaught Throwable . |
void |
handleEvent(org.osgi.service.event.Event event)
|
javax.servlet.Servlet |
resolveServlet(ResourceResolver resolver,
String scriptName)
Resolves a javax.servlet.Servlet whose
service method may be used to handle a request. |
javax.servlet.Servlet |
resolveServlet(Resource resource,
String scriptName)
Resolves a javax.servlet.Servlet whose
service method may be used to handle a request. |
javax.servlet.Servlet |
resolveServlet(SlingHttpServletRequest request)
Resolves a javax.servlet.Servlet whose
service method may be used to handle the given
request . |
protected void |
unbindServlet(org.osgi.framework.ServiceReference reference)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROP_SERVLET_ROOT
public static final String PROP_SCRIPT_USER
public static final String PROP_CACHE_SIZE
public static final String PROP_DEFAULT_SCRIPT_WORKSPACE
public static final String PROP_USE_REQUEST_WORKSPACE
public static final String PROP_USE_DEFAULT_WORKSPACE
public static final String DEFAULT_SERVLET_ROOT
public static final Integer DEFAULT_CACHE_SIZE
public static final String PROP_PATHS
Constructor Detail |
---|
public SlingServletResolver()
Method Detail |
---|
public javax.servlet.Servlet resolveServlet(SlingHttpServletRequest request)
ServletResolver
javax.servlet.Servlet
whose
service
method may be used to handle the given
request
.
The returned servlet must be assumed to be initialized and ready to run.
That is, the init
nor the destroy
methods
must NOT be called on the returned servlet.
This method must not return a Servlet
instance
implementing the OptingServlet
interface and returning
false
when the
OptingServlet.accepts(SlingHttpServletRequest)
method is called.
resolveServlet
in interface ServletResolver
request
- The SlingHttpServletRequest
object used to drive
selection of the servlet.
service
method may be called to
handle the request.ServletResolver.resolveServlet(org.apache.sling.api.SlingHttpServletRequest)
public javax.servlet.Servlet resolveServlet(Resource resource, String scriptName)
ServletResolver
javax.servlet.Servlet
whose
service
method may be used to handle a request.
The returned servlet must be assumed to be initialized and ready to run.
That is, the init
nor the destroy
methods
must NOT be called on the returned servlet.
This method skips all OptingServlet
s as there is no
request object available.
Basically this method searches a script with the scriptName
for the resource type defined by the resource
resolveServlet
in interface ServletResolver
resource
- The Resource
object used to drive
selection of the servlet.scriptName
- The name of the script - the script might have an
extension. In this case only a script with the
matching extension is used.
service
method may be called to
handle the request.ServletResolver.resolveServlet(org.apache.sling.api.resource.Resource, java.lang.String)
public javax.servlet.Servlet resolveServlet(ResourceResolver resolver, String scriptName)
ServletResolver
javax.servlet.Servlet
whose
service
method may be used to handle a request.
The returned servlet must be assumed to be initialized and ready to run.
That is, the init
nor the destroy
methods
must NOT be called on the returned servlet.
This method skips all OptingServlet
s as there is no
request object available.
Basically this method searches a script with the scriptName
resolveServlet
in interface ServletResolver
resolver
- The ResourceResolver
object used to drive
selection of the servlet.scriptName
- The name of the script - the script might have an
extension. In this case only a script with the
matching extension is used.
service
method may be called to
handle the request.ServletResolver.resolveServlet(org.apache.sling.api.resource.ResourceResolver, java.lang.String)
public SlingScript findScript(ResourceResolver resourceResolver, String name) throws SlingException
SlingScriptResolver
SlingScript
for the given name.
The semantic meaning of the name is implementation specific: It may be an
absolute path to a Resource
providing the script source or
it may be a relative path resolved according to some path settings.
Finally, the name may also just be used as an identifier to find the
script in some registry.
findScript
in interface SlingScriptResolver
resourceResolver
- The ResourceResolver
used to
access the script.name
- The script name. Must not be null
.
SlingScript
to which the name resolved or
null
otherwise.
SlingException
- If an error occurrs trying to resolve the name.SlingScriptResolver.findScript(org.apache.sling.api.resource.ResourceResolver, java.lang.String)
public void handleError(int status, String message, SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException
ErrorHandler
If the response has already been committed, an error message should be logged but no further processing should take place.
handleError
in interface ErrorHandler
status
- The HTTP status code to setmessage
- An optional message to write to the response. This message
may be null
.request
- The request object providing more information on the
request.response
- The response object used to send the status and message.
IOException
- May be thrown if an error occurrs sending the
response.ErrorHandler.handleError(int,
String, SlingHttpServletRequest, SlingHttpServletResponse)
public void handleError(Throwable throwable, SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException
ErrorHandler
Throwable
.
If the response has already been committed, an error message should be logged but no further processing should take place.
handleError
in interface ErrorHandler
throwable
- The Throwable
causing this method to be
called.request
- The request object providing more information on the
request.response
- The response object used to send the status and message.
IOException
- May be thrown if an error occurrs sending the
response.protected void activate(org.osgi.service.component.ComponentContext context) throws LoginException
LoginException
protected void deactivate(org.osgi.service.component.ComponentContext context)
protected void bindServlet(org.osgi.framework.ServiceReference reference)
protected void unbindServlet(org.osgi.framework.ServiceReference reference)
public void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
EventHandler.handleEvent(org.osgi.service.event.Event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |