Re: WOResourceManager pathForResourceNamed deprecated method
Re: WOResourceManager pathForResourceNamed deprecated method
- Subject: Re: WOResourceManager pathForResourceNamed deprecated method
- From: Art Isbell <email@hidden>
- Date: Mon, 13 Oct 2003 10:55:50 -1000
On Sunday, October 12, 2003, at 09:47 PM, Hsu wrote:
In 5.2.1, there should be a pathURLForResourcePath, documented in the
release notes for 5.2.1
Thanks for the tip!
Actually, I couldn't find this documented in the "WebObjects 5.2
Release Notes" (at Apple's Web site or on my WO 5.2.1 partition),
"What's New in WebObjects 5.2", or "WebObjects API Reference". I found
a reference to NSBundle.pathURLForResourcePath() and also to
WOResourceManager.pathURLForResourceNamed() in the KBase article,
"WebObjects 5: WebObjects 5.2.1: Update Overview"
(http://docs.info.apple.com/article.html?artnum=75433):
bytesForResourceNamed did not support nested resources
Apple Reference 3152708
ISSUE:
The WOResourceManager method bytesForResourceNamed took a resource name
rather than a path to the resource, which did not allow access to
nested resources.
RESOLUTION:
To discourage using String path, Apple did not enhance the method
bytesForResourceNamed to accept a path to the resource. Instead 2 new
methods were introduced.
In WOResourceManager, pathURLForResourceNamed() was introduced and its
usage is as follows:
public java.net.URL pathURLForResourceNamed(String aResourceName,
String aFrameworkName, NSArray aLanguagesList)
Returns the URL to the specified resource.
Include the file's extension when specifying aResourceName. If the file
is in the application, specify null for aFrameworkName.
This method always returns a URL like
file:/Local/Library/WebObjects/Applications/MyApp.woa/Contents/
Resources/MyResource. It does not return a URL relative to the HTTP
server's document root unless the entire application is located in the
document root.
The URL returned by this method is intended to be used for accessing
the resource programmatically. If you want a URL to display the
resource on a webpage (WOComponent), use urlForResourceNamed instead.
Access to the WOResourceManager object is locked at the beginning of
this method and unlocked at the end.
Important: This method is called very often internally by WebObjects.
If you reimplement it, make sure it stays very fast!
If you use Project Builder (rather than ProjectBuilderWO) and you add a
folder of resources, they must be added as Folder References. This
allows WOResourceManager to find them in rapid turnaround mode.
Further, WOComponents (files in directories that have a wo extension)
are treated as opaque objects, so resources located in the .wo cannot
be found by this method.
@param aResourceName name of the resource
@param aFrameworkName name of the framework in which the resource
resides
@param aLanguagesList list of languages in specific order
@return the URL to the resource aResourceName
@see #urlForResourceNamed
In NSBundle, pathURLForResourcePath() was introduced and its usage is
as follows:
public java.net.URL pathURLForResourcePath(String aResourcePath)
Returns an URL representing the resource specified by aResourcePath.
The resource path must be specified relative to the top level of the
resources hierarchy, that is, the directory containing the language
subdirectories. It is usually returned from resourcePathsForResources
or resourcePathsForLocalizedResources.
Note: The resource path for a resource is not the same as its file
system path.
See "Determining Available Resources" in the class description for more
information about resource paths.
@param aResourcePath the path of the resource, according to the
resources hierarchy
@return the URL, or null if not found.
@see #resourcePathsForResources(String, String)
@see #resourcePathsForLocalizedResources(String, String)
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.