tag:blogger.com,1999:blog-1094388580279212135.post413562878423839127..comments2017-07-08T01:22:33.946-04:00Comments on My Own Digressions: Platform scheme URIMarcelo Paternostrohttp://www.blogger.com/profile/05767041268062110476noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-1094388580279212135.post-57177165581865861562013-03-11T17:57:33.466-04:002013-03-11T17:57:33.466-04:00Just wanted to note that this information was inco...Just wanted to note that this information was incorporated into the platform documentation:<br /><br />http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/misc/platform-scheme-uri.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-77935076560278659442013-01-16T08:50:49.266-05:002013-01-16T08:50:49.266-05:00Hi,
AFAIK, the schemes I've described in this...Hi,<br /><br />AFAIK, the schemes I've described in this post do not allow specifying the version information. That said...<br /><br />- Say for example that the bundle A uses C1 and bundle B uses C2, where C is a bundle and 1 and 2 different versions of it. I'd assume that a URI of a C artifact in A would resolve to C1 while it would resolve to C2 in B. I haven't tested this though.<br /><br />- Eclipse 4 has introduced a new URI scheme: bundleclass. It may have support for versions (I have only used it to do the E4 tutorials so I can't say for sure).<br /><br />Cheers.Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-4906856069745107732013-01-15T05:09:40.334-05:002013-01-15T05:09:40.334-05:00Hi,
can you tell me how to access a resource in a ...Hi,<br />can you tell me how to access a resource in a plugin for a given plugin version ?<br />something like the platform:/plugin/my.plugin.v1.00/resource/foo.jpg<br />is this even possible ?SeBhttps://www.blogger.com/profile/14778585482454268074noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-57223522780705246102011-01-21T09:02:49.224-05:002011-01-21T09:02:49.224-05:00After some careful observation using the debugger,...After some careful observation using the debugger, the issue was really that the file layout of the plugin was different when it was jar'ed and deployed than when it was referenced during a launch from the IDE. The platform:/plugin resolution during the IDE launch resolved to a file URL that pointed to the file system location of the plugin project concatenated with the path portion of my platform URI. Since the resource I was trying to access was in a source directory, it had an additional path component during the ide launch that was removed during the packaging of the plugin into a jar. That's why it worked for the JAR, but not the IDE launch.<br /><br />I guess I encountered this problem because I wasn't following the convention of putting my .ecore files in the 'model' directory. Or perhaps there is some plugin configuration magic that would have resolved my situation and I simply am missing that piece. In any event, I resolved the problem by moving my resource files to a location, the more conventional 'model' directory, that was the same for both the packaged JAR and the IDE launch.<br /><br />Thanks for your help!rhudsonhttps://www.blogger.com/profile/02825290631372084880noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-64952838162450270092011-01-19T23:40:29.864-05:002011-01-19T23:40:29.864-05:00rhudson,
I definitely had a regular Eclipse execu...rhudson,<br /><br />I definitely had a regular Eclipse execution in mind when I wrote this post. That said, I just tried locating the real paths for the some URIs with a code running on a runtime workspace, and it worked. Remember that PDE does a lot of magic to make our lives easier so some bundles may not be where you'd expect them to be.<br /><br />I am pasting here the code I used. If you want to run it, add it to a bundle called 'Test' that depends on 'org.eclipse.core.runtime' and 'org.junit' (a 3.x version). Then right click the test and do 'Run As > JUnit Plug-in Test'. Oh, you will need to format it (I am sure it will look gross here ;-)<br /><br />Cheers.<br /><br />--------------<br /><br />import java.io.File;<br />import java.net.URI;<br />import java.net.URL;<br /><br />import junit.framework.TestCase;<br /><br />import org.eclipse.core.runtime.FileLocator;<br /><br />/**<br />* @author Marcelo Paternostro (mpaternostro@gmail.com)<br />*/<br />public class PlatformURITest extends TestCase {<br />public void testFileURL() throws Exception {<br />assertURI("platform:/plugin/org.eclipse.osgi", true);<br />assertURI("platform:/plugin/org.eclipse.core.runtime", true);<br /><br />assertURI("platform:/config/", false);<br /><br />// This bundle<br />assertURI("platform:/plugin/Test/build.properties", false);<br />}<br /><br />private void assertURI(String uriString, boolean isBundleDirOrJar) throws Exception {<br />URI uri = new URI(uriString);<br />URL url = FileLocator.toFileURL(uri.toURL());<br />System.out.println("\nURI: " + uri + "\nFile URL: " + url);<br /><br />File file = new File(url.toURI());<br />assertTrue(file.getAbsolutePath(), file.exists());<br /><br />if (isBundleDirOrJar) {<br />if (file.isDirectory()) {<br />File manifestFile = new File(file, "META-INF/MANIFEST.MF");<br />assertTrue(manifestFile.getAbsolutePath(), manifestFile.isFile());<br />} else {<br />assertTrue(file.getAbsolutePath(), file.getName().endsWith(".jar"));<br />}<br />}<br />}<br />}Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-81314198288479269552011-01-19T12:01:29.424-05:002011-01-19T12:01:29.424-05:00Is there a contextual difference between trying to...Is there a contextual difference between trying to resolve a platform URI when running in a deployed instance versus running from within Eclipse itself? I seem to be able to resolve a platform plugin URI when I deploy my RCP product, but not when I run my application (still as an RCP application) from an Eclipse "Run Configuration".<br /><br />In the working case, it gets nicely resolved to a jar URL in my exported product. In the failing case a FileNotFoundException gets thrown for the path portion of the URI.rhudsonhttps://www.blogger.com/profile/02825290631372084880noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-35678369943315431732010-07-13T23:23:38.282-04:002010-07-13T23:23:38.282-04:00Hi Mark,
If the URI is either a file URI ("f...Hi Mark,<br /><br />If the URI is either a file URI ("file://") or a URI that can be resolved into a file URI, you could use the java.io.File(URI) constructor to create a File object and use it normally.<br /><br />That said, URIs are not mere replacements for File objects. Typically when dealing with URIs, there is a service to which you pass the URI and from which you receive some information - think about a regular interaction with a HTTP server. What I am trying to say is that "grabbing" a file URI and converting it a File object (which typically only has visibility of the local file system) may not be of any good if that URI was not meant for this purpose.<br /><br />Moreover, it is up to this service to define what you can do with the URI. Apache, for example, can be configured to allow directory browsing, although that's enabled by default.Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-67302333105822814342010-07-06T13:45:26.808-04:002010-07-06T13:45:26.808-04:00Hello Marcelo, I'm really interested in this p...Hello Marcelo, I'm really interested in this post, and I want to ask you about can I iterate a URI in order to get all the files placed into a directory, for instance all the files placed into "platform:/plugin/org.eclipse.emf.ecore/model/". I only have the URI.<br /><br />In the same line, I want to know if it's easy to convert this URI to a java.io.File, it's so easy to iterate and read it finding the files...<br /><br />Thanks a lot Marcelo!<br />MarcMarchttps://www.blogger.com/profile/08088827266944291022noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-14445766376686124652008-05-08T13:55:00.000-04:002008-05-08T13:55:00.000-04:00Hi,Sorry for not paying attention to the comments ...Hi,<BR/><BR/>Sorry for not paying attention to the comments on this post. My daughter did arrive so things have been a bit erratic here ;-)<BR/><BR/>The platform scheme is defined in Eclipse. So if the code you are executing is running in an Eclipse shell, it should work.<BR/><BR/>Note that after the "resource" segment, you should enter the name of a registered project.<BR/><BR/>Finally, EMF has some tricks to allow the same application to run inside and outside Eclipse. Perhaps this could explain the difference you are seeing.Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-28924371813620596172008-04-28T14:00:00.000-04:002008-04-28T14:00:00.000-04:00Dear Marcelo,is "platform:/resource" an EMF specif...Dear Marcelo,<BR/><BR/>is "platform:/resource" an EMF specific thing?<BR/><BR/>The reason I ask is<BR/><BR/>FileLocator.resolve(new URL("platform:/resource/ValidDir/validFile"));<BR/><BR/>FileLocator.toFileURL(new URL("platform:/resource/ValidDir/validFile"));<BR/><BR/>do not work but <BR/><BR/>CommonPlugin.asLocalURI(URI.createURI("platform:/resource/ValidDir/validFile"));<BR/> CommonPlugin.resolve(URI.createURI("platform:/resource/ValidDir/validFile"));<BR/><BR/>do work.<BR/><BR/>If so, may be we should be requesting that "platform:/resource" to be made standard for Eclipse. I can see its usefulness although I am unlikely to use it myself<BR/><BR/>Congratulations on your second child if she arrived, if not, good luck.Unknownhttps://www.blogger.com/profile/00123986882271439033noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-39773347868797571842008-03-22T23:33:00.000-04:002008-03-22T23:33:00.000-04:00Good idea, Ed. I've just added an FAQ entry with ...Good idea, Ed. I've just added an FAQ entry with a link to the blog. It would take a bit of a time to remove the "funny and personal digressions" to make it a recipe :-P<BR/><BR/>Awesome point!!! I sure hope Alyssa inherits the qualities of my best half ;-)Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-37690860430586137662008-03-22T15:52:00.000-04:002008-03-22T15:52:00.000-04:00Marcelo, this is excellent information that is ext...Marcelo, this is excellent information that is extremely difficult to find, even via Google. Perhaps a link to your blog from the EMF FAQ or using it as an EMF recipe would make it easier for folks to find it in the future. Good stuff!<BR/><BR/>By the way, I hope Alyssa == "Little Helena #1" :-PEd Merkshttps://www.blogger.com/profile/08767888750692843294noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-71896819680366029552008-03-21T14:39:00.000-04:002008-03-21T14:39:00.000-04:00Thanks for the kind words guys ;-)Yeah... I am sur...Thanks for the kind words guys ;-)<BR/><BR/>Yeah... I am sure I will have lots of fun when Alyssa (== "Little Marcelo #2" :-) arrives. We are counting the days.Marcelo Paternostrohttps://www.blogger.com/profile/05767041268062110476noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-22012518663051212502008-03-20T21:55:00.000-04:002008-03-20T21:55:00.000-04:00Thanks Marcelo, this is the kind of stuff that I'm...Thanks Marcelo, this is the kind of stuff that I'm always trying to figure out, and I keep finding ugly work-arounds...<BR/><BR/>As for Little Marcelo #2, that is pretty exciting! I don't get to Toronto enough to see the EMF team anymore :-(.Ian Bullhttps://www.blogger.com/profile/02668098567506210626noreply@blogger.comtag:blogger.com,1999:blog-1094388580279212135.post-15903886362398193092008-03-20T13:26:00.000-04:002008-03-20T13:26:00.000-04:00Thanks Marcelo, this is a post to keep archived......Thanks Marcelo, this is a post to keep archived... as the documentation is a bit weak in this area traditionally.Chris Aniszczyk (zx)https://www.blogger.com/profile/14067673601779593093noreply@blogger.com