Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Platform URIs
Platform URIs [message #429344] Tue, 21 April 2009 03:05 Go to next message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
I'm writing an RCP plug-in and having problems with using platform URIs
with EMF. I'm working around it by resolving them to file URIs, but there
are a lot of code samples that successfully use platform URIs. What am I
doing wrong?

ResourceSet resourceSet = new ResourceSetImpl();
URI myURI = URI.createURI("platform:/plugin/com.abc/data/my.deck");
Resource myResource = resourceSet.getResource(myURI); // Fails
myResource = resourceSet.getResource(CommonPlugin.resolve(myURI)); //
Succeeds

Thanks,

Mike
Re: Platform URIs [message #429356 is a reply to message #429344] Tue, 21 April 2009 10:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Michael,

Comments below.


Michael Spertus wrote:
> I'm writing an RCP plug-in and having problems with using platform
> URIs with EMF.
RCP typically means there is no workspace so platform:/resource URIs
don't work in that case.
> I'm working around it by resolving them to file URIs, but there are a
> lot of code samples that successfully use platform URIs. What am I
> doing wrong?
>
> ResourceSet resourceSet = new ResourceSetImpl();
> URI myURI = URI.createURI("platform:/plugin/com.abc/data/my.deck");
> Resource myResource = resourceSet.getResource(myURI); // Fails
How does it fail? What's the exception?
> myResource = resourceSet.getResource(CommonPlugin.resolve(myURI)); //
> Succeeds
I'd be surprised that this works but the other fails since the fact it
resolve would seem to indicate that the platform:/plugin reference is
resolving correct, which would imply you should be able to use it
directly. If you create a URL from the original URI, does openStream
return a stream? I'd expect it to, if the file actually exists in the
plugin.
>
> Thanks,
>
> Mike
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Platform URIs [message #429364 is a reply to message #429356] Tue, 21 April 2009 12:25 Go to previous messageGo to next message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
Ed Merks wrote:

> Michael,

> Comments below.


> Michael Spertus wrote:
>> I'm writing an RCP plug-in and having problems with using platform
>> URIs with EMF.
> RCP typically means there is no workspace so platform:/resource URIs
> don't work in that case.
Understood, but that doesn't affect the platform:/plugin problem I'm
having.

>> I'm working around it by resolving them to file URIs, but there are a
>> lot of code samples that successfully use platform URIs. What am I
>> doing wrong?
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> URI myURI = URI.createURI("platform:/plugin/com.abc/data/my.deck");
>> Resource myResource = resourceSet.getResource(myURI, false); // Fails
> How does it fail? What's the exception?
No exception. It just returns null (I've edited the call slightly above).

>> myResource = resourceSet.getResource(CommonPlugin.resolve(myURI)); //
>> Succeeds
> I'd be surprised that this works but the other fails since the fact it
> resolve would seem to indicate that the platform:/plugin reference is
> resolving correct, which would imply you should be able to use it
> directly. If you create a URL from the original URI, does openStream
> return a stream? I'd expect it to, if the file actually exists in the
> plugin.
Yep. openStream works fine, just not getResource.

Am I supposed to something to setup the URIConverter?

Mike

>>
>> Thanks,
>>
>> Mike
>>
>>
>>
>>
Re: Platform URIs [message #429369 is a reply to message #429364] Tue, 21 April 2009 13:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Spertus wrote:
> Ed Merks wrote:
>
>> Michael,
>
>> Comments below.
>
>
>> Michael Spertus wrote:
>>> I'm writing an RCP plug-in and having problems with using platform
>>> URIs with EMF.
>> RCP typically means there is no workspace so platform:/resource URIs
>> don't work in that case.
> Understood, but that doesn't affect the platform:/plugin problem I'm
> having.
Indeed.
>
>>> I'm working around it by resolving them to file URIs, but there are
>>> a lot of code samples that successfully use platform URIs. What am I
>>> doing wrong?
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> URI myURI = URI.createURI("platform:/plugin/com.abc/data/my.deck");
>>> Resource myResource = resourceSet.getResource(myURI, false); // Fails
>> How does it fail? What's the exception?
> No exception. It just returns null (I've edited the call slightly above).
Returning null. Did you intend to pass in "true" given that you don't
seem to be expecting null.
>>> myResource = resourceSet.getResource(CommonPlugin.resolve(myURI));
>>> // Succeeds
Given there isn't a one argument version, did you perhaps leave out the
fact you used "true" in this case?
>> I'd be surprised that this works but the other fails since the fact
>> it resolve would seem to indicate that the platform:/plugin reference
>> is resolving correct, which would imply you should be able to use it
>> directly. If you create a URL from the original URI, does
>> openStream return a stream? I'd expect it to, if the file actually
>> exists in the plugin.
> Yep. openStream works fine, just not getResource.
>
> Am I supposed to something to setup the URIConverter?
It sounds like simply passing in true indicating you want to demand load
the resource if it's not already in the resource set would do the trick.
>
> Mike
>
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Platform URIs [message #429376 is a reply to message #429369] Tue, 21 April 2009 15:04 Go to previous messageGo to next message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
I'm an idiot. As you suspected, I'd somehow gotten a false in there. Never
mind.
Re: Platform URIs [message #429378 is a reply to message #429376] Tue, 21 April 2009 15:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Michael,

I've often found the smaller the mistake the harder it is to spot.
You'll note that I didn't spot it the first time either.


Michael Spertus wrote:
> I'm an idiot. As you suspected, I'd somehow gotten a false in there.
> Never mind.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] Switching from annotated XSD to annotated UML?
Next Topic:[Teneo] Problems with Eclipselink
Goto Forum:
  


Current Time: Sat Apr 27 04:25:47 GMT 2024

Powered by FUDForum. Page generated in 0.03160 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top