public interface ServletIntegration
Provides hooks for integrating JRebel with custom Servlet containers.
To use it acquire an instance from ServletIntegrationFactory
A typical (Servlet context) integration will look like this:
class MyServletContext implements ServletContext, RebelServletContext {
ServletIntegration integration;
public MyServletContext() {
...
integration = ServletIntegrationFactory.getInstance();
integration.registerServletContext(this);
}
...
public String getRealPath(String path) {
if (integration.isResourceReplaced(this, path))
return integration.getRealPath(this, path);
...
}
public URL getResource(String path) throws MalformedURLException {
if (integration.isResourceReplaced(this, path))
return integration.getResource(this, path);
...
}
public InputStream getResourceAsStream(String path) {
if (integration.isResourceReplaced(this, path))
return integration.getResourceAsStream(this, path);
...
}
public Set getResourcePaths(String path) {
if (integration.isResourceReplaced(this, path))
return integration.getResourcePaths(this, path);
...
}
}
ServletIntegrationFactory,
RebelServletContext,
Integration,
Reloader,
Logger,
Plugin| Modifier and Type | Method and Description |
|---|---|
void |
disableResourcePathsAssumption()
Assert that ServletContext#getResourcePaths is not able to find all resources
that can be found by ServletContext#getResource
|
String |
getRealPath(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a String containing the managed real path for a given virtual path.
|
RebelSource[] |
getRebelSources(org.zeroturnaround.javarebel.RebelServletContext sc)
Returns the additional root paths of the given
ServletContext
managed by JRebel. |
URL[] |
getRebelURLs(org.zeroturnaround.javarebel.RebelServletContext sc)
Returns the additional root paths of the given
ServletContext
managed by JRebel. |
URL |
getResource(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a URL to the managed resource that is mapped to a specified path.
|
InputStream |
getResourceAsStream(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns the managed resource located at the named path as an InputStream object.
|
Set<String> |
getResourcePaths(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a directory-like listing of all the paths to managed resources within the
web application whose longest sub-path matches the supplied path argument.
|
String |
getTransparentRealPath(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a String containing the original real path for a given virtual path.
|
URL |
getTransparentResource(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a URL to the original resource that is mapped to a specified path.
|
InputStream |
getTransparentResourceAsStream(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns the original resource located at the named path as an InputStream object.
|
Set<String> |
getTransparentResourcePaths(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns a directory-like listing of all the paths to resources within the
web application whose longest sub-path matches the supplied path argument.
|
boolean |
hasReplacedResources(org.zeroturnaround.javarebel.RebelServletContext sc)
Returns
true if all resources of the given Servlet Context are managed by JRebel. |
boolean |
isResourceReplaced(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
Returns
true if the given resource is managed by JRebel. |
void |
registerAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc,
String filter)
Registers additional
ServletContext-s rebel web resources with target ServletContext After adding some reinitialisation of some plugins may be required to get the new
rebel sources |
void |
registerAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
URL url)
Register additional resources with target
ServletContext. |
void |
registerAdditionalWebResourcesWithPrefix(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc,
String prefix)
Registers additional
ServletContext-s rebel web resources with target ServletContext After adding some reinitialisation of some plugins may be required to get the new
rebel sources |
void |
registerServletContext(org.zeroturnaround.javarebel.RebelServletContext sc)
Registers a
ServletContext with JRebel. |
void |
unregisterAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc)
Unregisters additional
ServletContext-s rebel web resources from target ServletContext
After removing some reinitialisation of some plugins may be required to change rebel sources |
void |
unregisterServletContext(org.zeroturnaround.javarebel.RebelServletContext sc)
Unregisters a
ServletContext from JRebel. |
void registerServletContext(org.zeroturnaround.javarebel.RebelServletContext sc)
ServletContext with JRebel.
It is necessary to do this before any calls to the rest of the methods of ServletIntegration,
the best place is usually the constructor.
The custom ServletContext must implement the RebelServletContext,
The latter can be easily added by the corresponding ClassBytecodeProcessor.sc - The custom Servlet context being integrated.void unregisterServletContext(org.zeroturnaround.javarebel.RebelServletContext sc)
ServletContext from JRebel.
It is recommended to do this in case the corresponding ServletContext is destroyed
(e.g. the web application is undeployed).sc - The custom Servlet context being integrated.void registerAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc,
String filter)
ServletContext-s rebel web resources with target ServletContext After adding some reinitialisation of some plugins may be required to get the new
rebel sourcessc - The target Servlet context where new resources are being addedadditionalWebSc - The source Servlet context which rebel.xml web tags source is also used for resourcesfilter - Adds only paths that match the filter. Can be null.void registerAdditionalWebResourcesWithPrefix(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc,
String prefix)
ServletContext-s rebel web resources with target ServletContext After adding some reinitialisation of some plugins may be required to get the new
rebel sourcessc - The target Servlet context where new resources are being addedadditionalWebSc - The source Servlet context which rebel.xml web tags source is also used for resourcesprefix - Attach prefix before every patchvoid registerAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
URL url)
ServletContext.sc - The custom Servlet context being integrated.url - URL to a jar with additional web resources.void unregisterAdditionalWebResources(org.zeroturnaround.javarebel.RebelServletContext sc,
org.zeroturnaround.javarebel.RebelServletContext additionalWebSc)
ServletContext-s rebel web resources from target ServletContext
After removing some reinitialisation of some plugins may be required to change rebel sourcessc - The target Servlet context where new resources are being addedadditionalWebSc - The source Servlet context which rebel.xml web tags source is also used for resourcesURL[] getRebelURLs(org.zeroturnaround.javarebel.RebelServletContext sc)
ServletContext
managed by JRebel.sc - The custom Servlet context being integrated.ServletContext
or null if nothing found.RebelSource[] getRebelSources(org.zeroturnaround.javarebel.RebelServletContext sc)
ServletContext
managed by JRebel.sc - The custom Servlet context being integrated.ServletContext
or null if nothing found.boolean hasReplacedResources(org.zeroturnaround.javarebel.RebelServletContext sc)
true if all resources of the given Servlet Context are managed by JRebel.
All Servlet Context resources are managed by JRebel if the Servlet Context has been registered
and a valid rebel.xml has been found which defines the new resource locations.
sc - The custom Servlet context being integrated.true if all resources of the given Servlet Context are managed by JRebel.boolean isResourceReplaced(org.zeroturnaround.javarebel.RebelServletContext sc,
String path)
true if the given resource is managed by JRebel.
In that case resources can be resolved using the corresponding methods of the ServletIntegration.
If any of these methods returns a null it must be returned by the ServletContext as well.
sc - The custom Servlet context being integrated.path - path of the resource.true if the given resource is managed by JRebel.InputStream getResourceAsStream(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
A typical usage will look like this:
class MyServletContext implements ServletContext, RebelServletContext {
...
public InputStream getResourceAsStream(String path) throws MalformedURLException {
ServletIntegration integration = ServletIntegrationFactory.getInstance();
if (integration.isResourceReplaced(this, path))
return integration.getResourceAsStream(this, path);
...
}
...
}
The Servlet context instance must be first registered with JRebel.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if there is no resource at that pathregisterServletContext(RebelServletContext)URL getResource(org.zeroturnaround.javarebel.RebelServletContext sc, String path) throws MalformedURLException
A typical usage will look like this:
class MyServletContext implements ServletContext, RebelServletContext {
...
public URL getResource(String path) throws MalformedURLException {
ServletIntegration integration = ServletIntegrationFactory.getInstance();
if (integration.isResourceReplaced(this, path))
return integration.getResource(this, path);
...
}
...
}
The Servlet context instance must be first registered with JRebel.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if there is no resource at that pathMalformedURLException - if the pathname is not given in the correct formregisterServletContext(RebelServletContext)String getRealPath(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
A typical usage will look like this:
class MyServletContext implements ServletContext, RebelServletContext {
...
public String getRealPath(String path) throws MalformedURLException {
ServletIntegration integration = ServletIntegrationFactory.getInstance();
if (integration.isResourceReplaced(this, path))
return integration.getRealPath(this, path);
...
}
...
}
The Servlet context instance must be first registered with JRebel.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if the translation cannot be performedregisterServletContext(RebelServletContext)Set<String> getResourcePaths(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
class MyServletContext implements ServletContext, RebelServletContext {
...
public Set getResourcePaths(String path) throws MalformedURLException {
ServletIntegration integration = ServletIntegrationFactory.getInstance();
if (integration.isResourceReplaced(this, path))
return integration.getResourcePaths(this, path);
...
}
...
}
The Servlet context instance must be first registered with JRebel.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if there are no resources in the web application
whose path begins with the supplied path.registerServletContext(RebelServletContext)InputStream getTransparentResourceAsStream(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
This is used to get the original result unaltered by JRebel.
The corresponding Servlet context method will be invoked such that
isResourceReplaced(RebelServletContext, String) returns false.
path - a String specifying the path to the resourcenull if there is no resource at that pathURL getTransparentResource(org.zeroturnaround.javarebel.RebelServletContext sc, String path) throws MalformedURLException
This is used to get the original result unaltered by JRebel.
The corresponding Servlet context method will be invoked such that
isResourceReplaced(RebelServletContext, String) returns false.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if there is no resource at that pathMalformedURLException - if the pathname is not given in the correct formString getTransparentRealPath(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
This is used to get the original result unaltered by JRebel.
The corresponding Servlet context method will be invoked such that
isResourceReplaced(RebelServletContext, String) returns false.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if the translation cannot be performedSet<String> getTransparentResourcePaths(org.zeroturnaround.javarebel.RebelServletContext sc, String path)
This is used to get the original result unaltered by JRebel.
The corresponding Servlet context method will be invoked such that
isResourceReplaced(RebelServletContext, String) returns false.
sc - The custom Servlet context being integrated.path - a String specifying the path to the resourcenull if there are no
resources in the web application whose path begins with the supplied path.void disableResourcePathsAssumption()
Copyright © 2019. All rights reserved.