Methods Summary |
---|
void | addAdHocPathAndSubtree(java.lang.String path, java.lang.String subtree, AdHocServletInfo servletInfo)
if (path == null && subtree == null) {
return;
}
Wrapper adHocWrapper = (Wrapper)
findChild(servletInfo.getServletName());
if (adHocWrapper == null) {
adHocWrapper = createAdHocWrapper(servletInfo);
addChild(adHocWrapper);
}
if (path != null) {
adHocPaths.put(path, servletInfo);
hasAdHocPaths = true;
}
if (subtree != null) {
adHocSubtrees.put(subtree, servletInfo);
hasAdHocSubtrees = true;
}
|
void | addAdHocPaths(java.util.HashMap newPaths)
if (newPaths == null || newPaths.isEmpty()) {
return;
}
Iterator<String> iter = newPaths.keySet().iterator();
while (iter.hasNext()) {
String adHocPath = iter.next();
AdHocServletInfo servletInfo = (AdHocServletInfo)
newPaths.get(adHocPath);
Wrapper adHocWrapper = (Wrapper)
findChild(servletInfo.getServletName());
if (adHocWrapper == null) {
adHocWrapper = createAdHocWrapper(servletInfo);
addChild(adHocWrapper);
}
adHocPaths.put(adHocPath, servletInfo);
}
hasAdHocPaths = true;
|
void | addAdHocSubtrees(java.util.HashMap newSubtrees)
if (newSubtrees == null || newSubtrees.isEmpty()) {
return;
}
Iterator<String> iter = newSubtrees.keySet().iterator();
while (iter.hasNext()) {
String adHocSubtree = iter.next();
AdHocServletInfo servletInfo = (AdHocServletInfo)
newSubtrees.get(adHocSubtree);
Wrapper adHocWrapper = (Wrapper)
findChild(servletInfo.getServletName());
if (adHocWrapper == null) {
adHocWrapper = createAdHocWrapper(servletInfo);
addChild(adHocWrapper);
}
adHocSubtrees.put(adHocSubtree, servletInfo);
}
hasAdHocSubtrees = true;
|
public void | addAdHocValve(org.apache.catalina.Valve valve)Adds the given valve to this web module's ad-hoc pipeline.
adHocPipeline.addValve(valve);
|
void | addFilterMap(com.sun.enterprise.deployment.web.ServletFilterMapping sfm)Configures this web module with the filter mappings specified in the
deployment descriptor.
FilterMaps filterMaps = new FilterMaps();
filterMaps.setFilterName(sfm.getName());
Set dispatchers = sfm.getDispatchers();
if (dispatchers != null) {
Iterator<String> iter = dispatchers.iterator();
while (iter.hasNext()){
filterMaps.setDispatcher(iter.next());
}
}
List servletNames = sfm.getServletNames();
if (servletNames != null) {
Iterator<String> iter = servletNames.iterator();
while (iter.hasNext()) {
filterMaps.addServletName(iter.next());
}
}
List urlPatterns = sfm.getURLPatterns();
if (urlPatterns != null) {
Iterator<String> iter = urlPatterns.iterator();
while (iter.hasNext()) {
filterMaps.addURLPattern(iter.next());
}
}
addFilterMaps(filterMaps);
|
protected void | addListener(java.lang.String listenerName)Add a Catalina listener to a Container
Object listener = loadInstance(listenerName);
if ( listener == null ) return;
if (listener instanceof ContainerListener) {
addContainerListener((ContainerListener)listener);
} else if (listener instanceof LifecycleListener ){
addLifecycleListener((LifecycleListener)listener);
} else if (listener instanceof InstanceListener){
addInstanceListener(listenerName);
} else {
logger.log(Level.SEVERE,"webcontainer.invalidListener"
+ listenerName);
}
|
protected void | addValve(java.lang.String valveName)Add a Valve to a VirtualServer pipeline.
Valve valve = (Valve)loadInstance(valveName);
if (valve == null) return;
super.addValve(valve);
|
protected void | configureCatalinaProperties()Configure the WebModule
String propName = null;
String propValue = null;
if (bean != null) {
ElementProperty[] props = bean.getElementProperty();
if (props != null) {
for (int i=0; i< props.length; i++) {
propName = props[i].getName();
propValue = props[i].getValue();
configureCatalinaProperties(propName,propValue);
}
}
}
if (iasBean != null && iasBean.sizeWebProperty() > 0) {
WebProperty[] wprops = iasBean.getWebProperty();
for (int i = 0; i < wprops.length; i++) {
propName = wprops[i].getAttributeValue("name");
propValue = wprops[i].getAttributeValue("value");
configureCatalinaProperties(propName,propValue);
}
}
|
protected void | configureCatalinaProperties(java.lang.String propName, java.lang.String propValue)Configure the WebModule
if (propName == null || propValue == null) {
logger.log(Level.WARNING,
"webcontainer.nullWebModuleProperty",
getName());
return;
}
if (propName.startsWith("valve_")) {
addValve(propValue);
} else if (propName.startsWith("listener_")) {
addListener(propValue);
}
|
private org.apache.catalina.Wrapper | createAdHocWrapper(AdHocServletInfo servletInfo)Creates an ad-hoc servlet wrapper from the given ad-hoc servlet info.
Wrapper adHocWrapper = new StandardWrapper();
adHocWrapper.setServletClass(servletInfo.getServletClass().getName());
adHocWrapper.setName(servletInfo.getServletName());
Map<String,String> initParams = servletInfo.getServletInitParams();
if (initParams != null && !initParams.isEmpty()) {
Iterator<String> iter = initParams.keySet().iterator();
while (iter.hasNext()) {
String paramName = iter.next();
adHocWrapper.addInitParameter(
paramName,
initParams.get(paramName));
}
}
return adHocWrapper;
|
java.util.HashMap | getAdHocPaths()
return adHocPaths;
|
public org.apache.catalina.Pipeline | getAdHocPipeline()Gets this web module's ad-hoc pipeline.
return adHocPipeline;
|
public java.lang.String | getAdHocServletName(java.lang.String path)Returns the name of the ad-hoc servlet responsible for servicing the
given path.
if (!hasAdHocPaths() && !hasAdHocSubtrees()) {
return null;
}
AdHocServletInfo servletInfo = null;
// Check if given path matches any of the ad-hoc paths (exact match)
if (path == null) {
servletInfo = adHocPaths.get("");
} else {
servletInfo = adHocPaths.get(path);
}
// Check if given path starts with any of the ad-hoc subtree paths
if (servletInfo == null && path != null && hasAdHocSubtrees()) {
Iterator<String> iter = adHocSubtrees.keySet().iterator();
while (iter.hasNext()) {
String adHocSubtree = iter.next();
if (path.startsWith(adHocSubtree)) {
servletInfo = adHocSubtrees.get(adHocSubtree);
break;
}
}
}
if (servletInfo != null) {
return servletInfo.getServletName();
} else {
return null;
}
|
java.util.HashMap | getAdHocSubtrees()
return adHocSubtrees;
|
public com.sun.enterprise.config.serverbeans.WebModule | getBean()
return bean;
|
public java.lang.Object[] | getCachedFindOperation()Return the cached result of doing findXX on this object
NOTE: this method MUST be used only when loading/using
the content of default-web.xml
return cachedFinds;
|
public java.lang.String | getFileEncoding()Gets the file encoding of all static resources of this web module.
return fileEncoding;
|
public com.sun.enterprise.deployment.runtime.web.SunWebApp | getIasWebAppConfigBean()gets the sun-web.xml config bean
return iasBean;
|
public com.sun.enterprise.deployment.runtime.web.LocaleCharsetMap[] | getLocaleCharsetMap()return locale-charset-map
return _lcMap;
|
public boolean | hasAdHocPaths()Indicates whether this web module contains any ad-hoc paths.
An ad-hoc path is a servlet path that is mapped to a servlet
not declared in the web module's deployment descriptor.
A web module all of whose mappings are for ad-hoc paths is called an
ad-hoc web module.
return this.hasAdHocPaths;
|
public boolean | hasAdHocSubtrees()Indicates whether this web module contains any ad-hoc subtrees.
return this.hasAdHocSubtrees;
|
public boolean | hasBeenXmlConfigured()Return true if the default=web.xml has been read for
this module.
return hasBeenXmlConfigured;
|
public boolean | hasLocaleToCharsetMapping()Returns true if this web module specifies a locale-charset-map in its
sun-web.xml, false otherwise.
LocaleCharsetMap[] locCharsetMap = getLocaleCharsetMap();
return (locCharsetMap != null && locCharsetMap.length > 0);
|
private java.lang.Object | loadInstance(java.lang.String className)
try{
WebappClassLoader loader = (WebappClassLoader)
getLoader().getClassLoader();
Class clazz = loader.loadClass(className);
return clazz.newInstance();
} catch (Throwable ex){
String msg = _rb.getString("webcontainer.unableToLoadExtension");
msg = MessageFormat.format(msg, new Object[] { className,
getName() });
logger.log(Level.SEVERE, msg, ex);
}
return null;
|
public java.lang.String | mapLocalesToCharset(java.util.Enumeration locales)Matches the given request locales against the charsets specified in
the locale-charset-map of this web module's sun-web.xml, and returns
the first matching charset.
String encoding = null;
LocaleCharsetMap[] locCharsetMap = getLocaleCharsetMap();
if (locCharsetMap != null && locCharsetMap.length > 0) {
/*
* Check to see if there is a match between the request
* locales (in preference order) and the locales in the
* locale-charset-map.
*/
boolean matchFound = false;
while (locales.hasMoreElements() && !matchFound) {
Locale reqLoc = (Locale) locales.nextElement();
for (int i=0; i<locCharsetMap.length && !matchFound; i++) {
String language = locCharsetMap[i].getAttributeValue(
LocaleCharsetMap.LOCALE);
if (language == null || language.equals("")) {
continue;
}
String country = null;
int index = language.indexOf('_");
if (index != -1) {
country = language.substring(index+1);
language = language.substring(0, index);
}
Locale mapLoc = null;
if (country != null) {
mapLoc = new Locale(language, country);
} else {
mapLoc = new Locale(language);
}
if (mapLoc.equals(reqLoc)) {
/*
* Match found. Get the charset to which the
* matched locale maps.
*/
encoding = locCharsetMap[i].getAttributeValue(
LocaleCharsetMap.CHARSET);
matchFound = true;
}
}
}
}
return encoding;
|
void | parseAlternateDocBase(java.lang.String propName, java.lang.String propValue)
if (propName == null || propValue == null) {
logger.log(Level.WARNING, "Null property name or value");
return;
}
if (!propName.startsWith("alternatedocroot_")) {
return;
}
/*
* Validate the prop value
*/
String urlPattern = null;
String docBase = null;
int fromIndex = propValue.indexOf(ALTERNATE_FROM);
int dirIndex = propValue.indexOf(ALTERNATE_DOCBASE);
if (fromIndex < 0 || dirIndex < 0) {
logger.log(
Level.WARNING,
"webmodule.alternateDocBase.missingPathOrUrlPattern",
propValue);
return;
}
if (fromIndex > dirIndex) {
urlPattern = propValue.substring(
fromIndex + ALTERNATE_FROM.length());
docBase = propValue.substring(
dirIndex + ALTERNATE_DOCBASE.length(),
fromIndex);
} else {
urlPattern = propValue.substring(
fromIndex + ALTERNATE_FROM.length(),
dirIndex);
docBase = propValue.substring(
dirIndex + ALTERNATE_DOCBASE.length());
}
urlPattern = urlPattern.trim();
if (!validateURLPattern(urlPattern)) {
logger.log(Level.WARNING,
"webmodule.alternateDocBase.illegalUrlPattern",
urlPattern);
return;
}
docBase = docBase.trim();
addAlternateDocBase(urlPattern, docBase);
|
void | removeAdHocPath(java.lang.String path)
if (path == null) {
return;
}
adHocPaths.remove(path);
if (adHocPaths.isEmpty()) {
this.hasAdHocPaths = false;
}
|
void | removeAdHocSubtree(java.lang.String subtree)
if (subtree == null) {
return;
}
adHocSubtrees.remove(subtree);
if (adHocSubtrees.isEmpty()) {
this.hasAdHocSubtrees = false;
}
|
public void | removeAdHocValve(org.apache.catalina.Valve valve)Removes the given valve from this web module's ad-hoc pipeline.
adHocPipeline.removeValve(valve);
|
void | setAlternateDocBases(com.sun.enterprise.config.serverbeans.ElementProperty[] props)Sets the alternate docroots of this web module from the given
"alternatedocroot_" properties.
if (props == null) {
return;
}
for (int i=0; i<props.length; i++) {
parseAlternateDocBase(props[i].getName(), props[i].getValue());
}
|
public void | setAttribute(java.lang.String name, java.lang.Object value)Sets the context attribute with the given name and value.
context.setAttribute(name, value);
|
public void | setBean(com.sun.enterprise.config.serverbeans.WebModule bean)
this.bean = bean;
|
public void | setCachedFindOperation(java.lang.Object[] cachedFinds)Cache the result of doing findXX on this object
NOTE: this method MUST be used only when loading/using
the content of default-web.xml
this.cachedFinds = cachedFinds;
|
public void | setFileEncoding(java.lang.String enc)Sets the file encoding of all static resources of this web module.
this.fileEncoding = enc;
|
public void | setI18nInfo()Sets the parameter encoding (i18n) info from sun-web.xml.
if (iasBean == null) {
return;
}
if (iasBean.isParameterEncoding()) {
formHintField = (String) iasBean.getAttributeValue(
SunWebApp.PARAMETER_ENCODING,
SunWebApp.FORM_HINT_FIELD);
defaultCharset = (String) iasBean.getAttributeValue(
SunWebApp.PARAMETER_ENCODING,
SunWebApp.DEFAULT_CHARSET);
}
LocaleCharsetInfo lcinfo = iasBean.getLocaleCharsetInfo();
if (lcinfo != null) {
if (lcinfo.getAttributeValue(
LocaleCharsetInfo.DEFAULT_LOCALE) != null) {
logger.warning("webmodule.default_locale_deprecated");
}
/*
* <parameter-encoding> subelem of <sun-web-app> takes precedence
* over that of <locale-charset-info>
*/
if (lcinfo.isParameterEncoding()
&& !iasBean.isParameterEncoding()) {
formHintField = (String) lcinfo.getAttributeValue(
LocaleCharsetInfo.PARAMETER_ENCODING,
LocaleCharsetInfo.FORM_HINT_FIELD);
defaultCharset = (String) lcinfo.getAttributeValue(
LocaleCharsetInfo.PARAMETER_ENCODING,
LocaleCharsetInfo.DEFAULT_CHARSET);
}
_lcMap = lcinfo.getLocaleCharsetMap();
}
|
public void | setIasWebAppConfigBean(com.sun.enterprise.deployment.runtime.web.SunWebApp iasBean)set the sun-web.xml config bean
this.iasBean = iasBean;
|
public void | setParent(org.apache.catalina.Container container)Sets the virtual server parent of this web module, and passes it on to
this web module's realm adapter..
super.setParent(container);
// The following assumes that the realm has been set on this WebModule
// before the WebModule is added as a child to the virtual server on
// which it is being deployed.
RealmAdapter ra = (RealmAdapter) getRealm();
if (ra != null) {
ra.setVirtualServer(container);
}
|
void | setWebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor wbd)Sets the WebBundleDescriptor (web.xml) for this WebModule.
this.webBundleDescriptor = wbd;
|
public void | setXmlConfigured(boolean hasBeenXmlConfigured)Set to true when the default-web.xml has been read for
this module.
this.hasBeenXmlConfigured = hasBeenXmlConfigured;
|
public synchronized void | start()Starts this web module.
// Start and register Tomcat mbeans
super.start();
configureCatalinaProperties();
started = true;
// Register monitoring mbeans, which delegate to the Tomcat mbeans
webContainer.enableMonitoring(this,
((VirtualServer) getParent()).getID());
|
public void | stop()Stops this web module.
// Unregister monitoring mbeans only if this web module was
// successfully started, because if stop() is called during an
// aborted start(), no monitoring mbeans will have been registered
if (started) {
webContainer.disableMonitoring(
this, ((VirtualServer) getParent()).getID());
started = false;
}
if (webBundleDescriptor != null && webBundleDescriptor.getServiceReferenceDescriptors() != null) {
for (Object obj: webBundleDescriptor.getServiceReferenceDescriptors()) {
ClientPipeCloser.getInstance().cleanupClientPipe((ServiceReferenceDescriptor)obj);
}
}
// Stop and unregister Tomcat mbeans
super.stop();
|
private boolean | validateURLPattern(java.lang.String urlPattern)
if (urlPattern == null) {
return (false);
}
if (urlPattern.indexOf('\n") >= 0 || urlPattern.indexOf('\r") >= 0) {
logger.log(Level.WARNING,
"webmodule.alternateDocBase.crlfInUrlPattern",
urlPattern);
return false;
}
if (urlPattern.startsWith("*.")) {
if (urlPattern.indexOf('/") < 0) {
return (true);
} else {
return (false);
}
}
if ( (urlPattern.startsWith("/")) &&
(urlPattern.indexOf("*.") < 0)) {
return (true);
} else {
return (false);
}
|