• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading in a framework-level resource in a Maven-built app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading in a framework-level resource in a Maven-built app


  • Subject: Re: Reading in a framework-level resource in a Maven-built app
  • From: Paul Hoadley <email@hidden>
  • Date: Sun, 02 Apr 2017 17:28:00 +0930

Hi Mark,

On 2 Apr 2017, at 4:36 pm, Morris, Mark <email@hidden> 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 = "">

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reading in a framework-level resource in a Maven-built app
      • From: "Morris, Mark" <email@hidden>
References: 
 >Reading in a framework-level resource in a Maven-built app (From: Paul Hoadley <email@hidden>)
 >Re: Reading in a framework-level resource in a Maven-built app (From: "Morris, Mark" <email@hidden>)

  • Prev by Date: Re: wiki down??
  • Next by Date: Re: wiki down??
  • Previous by thread: Re: Reading in a framework-level resource in a Maven-built app
  • Next by thread: Re: Reading in a framework-level resource in a Maven-built app
  • Index(es):
    • Date
    • Thread