|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.p13n.management.ApplicationHelper
public final class ApplicationHelper
Utility methods for applications.
Method Summary | |
---|---|
static String |
getApplicationName()
Deprecated The methods getNonVersionedAppName and getVersionedAppName should be used instead of this method. This method is not descriptive enough for use with side by side deployment. This method will be removed at a future date. This method now returns the same thing as getNonVersionedAppName(); |
static String |
getContextRoot(String versionedapplicationName,
String webAppName)
Retrieve the context root for a webapp. |
static String |
getNonVersionedAppName()
Get name of the current application. |
static InputStream |
getResourceAsStream(String uri)
Read a resource (file) from the current application. |
static String |
getVersionedAppName()
Get name of the current application. |
static String |
getWebAppName(javax.servlet.http.HttpServletRequest theRequest)
Get name of the current WebApp module running the given HTTP Request. |
static String |
getWebAppName(javax.servlet.ServletContext theContext)
Get name of the current WebApp module for the given context. |
static String |
getWebAppUri(javax.servlet.ServletContext theContext)
Retrieve the URI where the webapp is deployed. |
static String |
getWebAppUri(String versionedapplicationName,
String webAppName)
Retrieve the URI where the webapp is deployed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
@Deprecated public static String getApplicationName() throws IllegalStateException
IllegalStateException
public static String getNonVersionedAppName() throws IllegalStateException
This method must be called from an application context. That is, some component (EJB, Servlet, etc.) deployed as part of an application (ear), or code called from such a component. The result will be specific to the application containing that component.
The Application Name is the deployed name of the application, and is often the name of the EAR jar file or directory, although this is not always the case.
This method differs from getVersionedApplicaitonName in that the name will be stay the same between versioned deployments.
IllegalStateException
- If not called from an application context.public static String getVersionedAppName() throws IllegalStateException
This method must be called from an application context. That is, some component (EJB, Servlet, etc.) deployed as part of an application (ear), or code called from such a component. The result will be specific to the application containing that component.
The Application Name is the deployed name of the application, and is often the name of the EAR jar file or directory, although this is not always the case.
This method differs from get NoVersionedApplicaitonName in that the name change from versioned deployment to versioned deployment. This name would most often be used in the case where you need to key some data by the applicaiton but do not want the data to collide between two applicaitons running in side by side mode. An example where this might be used is in a caching framework or versioned security provider.
IllegalStateException
- If not called from an application context.public static String getWebAppName(javax.servlet.ServletContext theContext)
This method is intended to be called from a WebApp component (Servlet) that wants to know its own deployed name. The name is a unique name for the webapp, and is often the webapp's context root, although this is not guaranteed to be the case. This name is unique among webapps in the application, and thus can be useful for naming resources to be scoped to the webapp. Note, however, that the name might not be unique within a server or domain, so it is safest to qualify this name with the application name, if server-wide uniqueness is needed.
theContext
- The Servlet context for which the name is to be returned.
IllegalStateException
- If not called with a WebLogic ServletContext.getApplicationName()
,
getWebAppName(HttpServletRequest)
,
getContextRoot(String, String)
,
getWebAppUri(String, String)
public static String getWebAppName(javax.servlet.http.HttpServletRequest theRequest)
This method is intended to be called from a WebApp component (Servlet) that wants to know its own deployed name. The name is a unique name for the webapp, and is often the webapp's context root, although this is not guaranteed to be the case. This name is unique among webapps in the application, and thus can be useful for naming resources to be scoped to the webapp. Note, however, that the name might not be unique within a server or domain, so it is safest to qualify this name with the application name, if server-wide uniqueness is needed.
theRequest
- The Request for which the name is to be returned.
IllegalStateException
- If not called with a WebLogic Request.getApplicationName()
,
getWebAppName(ServletContext)
,
getContextRoot(String, String)
,
getWebAppUri(String, String)
public static String getWebAppUri(String versionedapplicationName, String webAppName) throws InstanceNotFoundException
This uri can be used with getResourceAsStream to retrieve files from a
webapp, for example, when ServletContext.getResourceAsStream()
will not work. Usually this will be in the case of one webapp "managing"
another webapp.
versionedapplicationName
- the name of the application containing the webappwebAppName
- the name of the webapp (context-root)
InstanceNotFoundException
- if the named application or webapp does not existgetApplicationName()
,
getWebAppName(ServletContext)
,
getWebAppName(HttpServletRequest)
,
getContextRoot(String, String)
public static String getWebAppUri(javax.servlet.ServletContext theContext) throws IllegalStateException
This uri can be used with getResourceAsStream to retrieve files from a
webapp, for example, when ServletContext.getResourceAsStream()
will not work. Usually this will be in the case of one webapp "managing"
another webapp.
theContext
- The Servlet context for which the URI is to be returned.
IllegalStateException
- If not called with a WebLogic ServletContext.getApplicationName()
,
getWebAppName(ServletContext)
,
getWebAppName(HttpServletRequest)
,
getContextRoot(String, String)
public static String getContextRoot(String versionedapplicationName, String webAppName) throws InstanceNotFoundException
This can be used when a webapp needs to build an absolute URL to itself, or a URL to some other webapp.
versionedapplicationName
- the name of the application containing the webappwebAppName
- the name of the webapp
InstanceNotFoundException
- if the named application or webapp does not existgetApplicationName()
,
getWebAppName(ServletContext)
,
getWebAppName(HttpServletRequest)
,
getWebAppUri(String, String)
public static InputStream getResourceAsStream(String uri) throws IOException
This method must be called from an application context. That is, some component (EJB, Servlet, etc.) deployed as part of an application (ear), or code called from such a component. The result will be specific to the application containing that component.
This will fail (log and throw an IOException) if the file does
not exist. Use resourceExists()
to test existence and prevent
the exception being logged.
uri
- the location of the resource (file) in the application.
Path must be relative to the application (ear) and not null.
The uri may optionally be of the form moduleUri#resourceUri,
(for example myWebApp.war#WEB-INF/web.xml) to retrieve resources
from modules within the application.
FileNotFoundException
- if the file or module doesn't exist
IOException
- if there is trouble reading the file or problem
with deployment or app or something
NullPointerException
- if uri is nullresourceExists(String)
|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |