Documentation Archive Developer
Search
[an error occurred while processing this directive] PATH  Documentation > WebObjects 4.5 > WebObjects Reference

Table of Contents

WOResourceManager


Inherits from: NSObject
Package: com.apple.yellow.webobjects


Class Description


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




Method Types


Retrieving resources
pathForResourceNamed
urlForResourceNamed
Retrieving localized strings
stringForKey
Managing the application-wide data cache
flushDataCache
removeDataForKey
setData
Controlling access
lock
unlock


Instance Methods



flushDataCache

public void flushDataCache()

Removes all data from the image data cache. Use this method if you are storing data in the application-wide cache that you no longer need.

Access to the WOResourceManager object is locked at the beginning of this method and unlocked at the end.

See Also: removeDataForKey, setData



lock

public void lock()

Locks access to the WOResourceManager object. When the WOResourceManager is locked, no other threads may access it.

Usually, you don't need to invoke this method in your own code. All messages that you send to a WOResourceManager object lock access to the object at the beginning of the method and unlock access at the end. You only need to use this method if you're subclassing WOResourceManager. In that case, you should lock access to the WOResourceManager object in methods that load resources.

See Also: unlock



pathForResourceNamed

public String pathForResourceNamed( String aResourceFile, String aFrameworkName, NSArray languagesList)

Returns the absolute path for the resource aResourceFile. Include the file's extension when specifying aResourceFile. If the file is in the application, specify null for the framework argument.

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



removeDataForKey

public void removeDataForKey( String key, WOSession aSession)

Removes the data stored in the data cache under the key key. The session argument is currently ignored; specify null to have WOResourceManager use the application-wide cache.

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



setData

public void setData( NSData someData, String key, String mimeType, WOSession aSession)

Adds the image or embbedded object someData of MIME type type to the data cache for the session specify by aSession. The data is stored under the key key. The session argument is currently ignored; specify null to have WOResourceManager use the application-wide cache.

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



stringForKey

public String stringForKey( String aKey, String aTableName, String aDefaultValue, String aFrameworkName, NSArray languagesList)

Returns a localized string from string table aTable.strings using aKey to look it up. If no string value for the key is found in the table, aDefaultValue (optional) is returned. The method first searches the aTable.strings file, if it exists, in each of the localized (.lproj) subdirectories of the application wrapper; searching proceeds in the order specified by the array languagesList. If no string value matching the key is found, the search then continues to the aTable.strings file (if it exists) directly under the Resources directory (inside the directory with the .woa extension).

unlock

public void unlock()

Removes the lock on the WOResourceManager object, allowing other threads to access it.

Usually, you don't need to invoke this method in your own code. All messages that you send to a WOResourceManager object lock access to the object at the beginning of the method and unlock access at the end. You only need to use this method if you're subclassing WOResourceManager. In that case, you should lock access to the WOResourceManager object in methods that load resources and unlock when the method is finished accessing the WOResourceManager object.

See Also: lock



urlForResourceNamed

public String urlForResourceNamed( String aResourceFile, String aFrameworkName, NSArray languagesList, WORequest aRequest)

Returns the URL associated with a resource named aResourceFile. The URL returned is of the following form:

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




Table of Contents