Hi Mark,

On 2 Apr 2017, at 4:36 pm, Morris, Mark <mark.mor...@experian.com> wrote:

> I’m not sure if I’m missing the point of your question,

Sorry, it was a little bit unclear.

> but WOResourceManager will find files in frameworks just fine if they’re in 
> the Resources folder. Note that this is not under any 
> XXX.woa/Contents/Resources path as mentioned in your email, you just put the 
> files in the FrameworkName/Resources folder

I’m building with Maven, so I’ve put the resource in 
FrameworkName/src/main/resources...

> and they end up under FrameworkName.framework/Resources within the jar.

Yep, confirmed.

> You do have to supply the framework name in the call to WOResourceManager, 
> such as:
> 
> InputStream is = 
> WOApplication.application().resourceManager().inputStreamForResourceNamed( 
> “foo.txt", “FrameworkName", aLanguagesList );

This where I might have rushed the question a bit. What I am after is code that 
works both when the framework is open in Eclipse, and when it’s not and it’s 
instead referencing the built JAR under ~/.m2/repository (or wherever). So if I 
close FrameworkName.framework in Eclipse, your code above does work. If I open 
it again, the InputStream returned is null. But what _does_ then work is:

URL url = getClass().getClassLoader().getResource(“foo.txt")

To be completely clear this time:

1. If framework project is closed in Eclipse (and application is hence using 
framework under ~/.m2/repository), 
WOResourceManager.inputStreamForResourceNamed() works fine.

2. If framework project is open, 
WOResourceManager.inputStreamForResourceNamed() returns null, but 
getClass().getClassLoader().getResource(“foo.txt") does return a URL that can 
be used.

So, to load a resource from a framework, I’ve got to try both methods. Is this 
expected behaviour for a Maven build, or am I doing something wrong?


-- 
Paul Hoadley
http://logicsquad.net/
https://www.linkedin.com/company/logic-squad/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to