PATH |
Inherits from: Object
Package: com.webobjects.appserver
WOResourceManager manages an application's resources. It defines methods that retrieve resources from standard directories. Each WebObjects application contains a resource manager object, which you can access by sending resourceManager to the WOApplication class
Retrieving resources bytesForResourceNamed contentTypeForResourceNamed errorMessageUrlForResourceNamed inputStreamForResourceNamed pathForResourceNamed urlForResourceNamed Retrieving localized strings stringForKey Managing the application-wide data cache flushDataCache removeDataForKey setData Other toString
protected WOResourceManager()
public byte[] bytesForResourceNamed( String aResourceName, String aFrameworkName, NSArray aLanguagesList)
null
if the resource resides within the application) specified by aFrameworkName, and an NSArray of String objects identifying the order in which the language-specific resources should be searched (supply null
for this third argument specified by aLanguageList if the default order is sufficient).
public String contentTypeForResourceNamed(String aResourcePath)
public String errorMessageUrlForResourceNamed( String aResourceName, String aFrameworkName)
null
is passed as the first parameter), the error message will contain "null" in place of the resource name. If a framework name is passed as the second parameter, the error message will have the following form: /ERROR/NOT_FOUND/framework=frameworkName/filename=resourceName
. If null
is passed as the second parameter, the error message will include the application name instead of a framework name and will have the following form: /ERROR/NOT_FOUND/app=applicationName/filename=resourceName
.
public void flushDataCache()
Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.
See Also: removeDataForKey, setData
public java.io.InputStream inputStreamForResourceNamed( String aResourceName, String aFrameworkName, NSArray aLanguagesList)
java.io.InputStream
which you can use to read the contents of the specified resource. When calling this method you must provide the name of the resource (including the filename extension) specified by aResourceName, the name of the framework in which the resource resides (or null
if the resource resides within the application) specified by aFrameworkName, and an NSArray of String objects identifying the order in which the language-specific resources should be searched (supply null
for this third argument if the default order is sufficient) specified by aLanguageList.
public String pathForResourceNamed( String aResourceFile, String aFrameworkName, NSArray languagesList)
This method always returns a path like /Local/Library/WebObjects/Applications/MyApp.woa/WebServerResources/MyResource. It does not return the path relative to the HTTP server's document root unless the entire application is located in the document root.
Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.
See Also: urlForResourceNamed
public void removeDataForKey( String key, WOSession aSession)
This method is used by default when a dynamic element requests an image or embedded object from a database and the key attribute is not set for that dynamic element. If the key attribute isn't set, the data retrieved from the database is stored in the cache using setData, sent to the dynamic element, and then removed from the cache using removeDataForKey. If the key attribute is set, removeDataForKey is not invoked.
You rarely need to invoke this method yourself. Use it only if you need to limit the amount of memory your application uses, if your application has data stored in the cache, and you know that the data is no longer needed.
Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.
See Also: flushDataCache
public void setData( NSData someData, String key, String mimeType, WOSession aSession)
This method is invoked any time a dynamic element requests an image or embedded object from a database. You rarely need to invoke it yourself.
By default when a dynamic element requests an image from the database, WOResourceManager fetches the image, stores it in the cache using setData, sends it to the dynamic element, and then removes it from the cache using removeDataForKey. However, if the dynamic element has a key attribute defined, then the image is stored in the database under that key, and it is not removed from the database.
Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.
See Also: flushDataCache
public String stringForKey( String aKey, String aTableName, String aDefaultValue, String aFrameworkName, NSArray languagesList)
public String toString()
public String urlForResourceNamed( String aResourceFile, String aFrameworkName, NSArray languagesList, WORequest aRequest)
WebObjects/MyApp.woa/WebServerResources/English.lproj/aResourceFile
Include the file's extension when specifying aResourceFile. If the file is in the application, specify null for the framework argument.
This method locates resources under the application or framework. The URL returned is computed by concatenating the application's base URL (returned by WOApplication's baseURL method and settable using the WOApplicationBaseURL user default) and the relative path of the resource. This method does not check to see if the file is actually under the document root. For example, if your application is installed in /Local/Library/WebObjects/Applications, and the method finds aResourceFile in the Resources directory, it returns:
/WebObjects/MyApp.woa/Resources/aResourceFile
even though the Resources directory is not under the document root.
Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.
See Also: pathForResourceNamed
© 2001 Apple Computer, Inc. (Last Published April 15, 2001)