Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » GetPlugin from TargetPlatform
GetPlugin from TargetPlatform [message #912924] Fri, 14 September 2012 12:11 Go to next message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
Hello!

I'm looking for a solution to get a plugin from the TargetPlaform. The usecase is as follows:

I've got an Eclipse-Workspace, where I develop a Code-Generator. The Code-Generator reads out XML-files, which provides information to generate the code.

So I start the Generator as Eclipse-Plugin and get another Eclipse, where the generator is executable. The XMLs are now placed into the Target-Platform (not in the workspace). The Generator should load out the XML-Files out of the Target-Platform and generate Code into the Workspace.

My problem is that I don't know how to get the files out of the target platform. Platform.getExtensionRegistry() provides the possibility to get the extensions of the startet Eclipse, where the Generator gets developed. But I don't receive the extensions of the target-platform, where the XMLs are situated.

If my problem is not clear, I will try to explain it more clearly.

I hope somebody has an idea.
Re: GetPlugin from TargetPlatform [message #913049 is a reply to message #912924] Fri, 14 September 2012 17:02 Go to previous messageGo to next message
Curtis Windatt is currently offline Curtis WindattFriend
Messages: 166
Registered: July 2009
Senior Member
If you explain what your code generator does in more detail I can probably give a better answer, but I will take a guess at what you are trying to do.

You have a code generating tool that runs from an action in Eclipse. When the tool is run, it looks at the bundles PDE knows about (the workspace and the target platform). The tool looks up a specific bundle and finds an xml file inside (maybe plugin.xml). The information is then used to write out code in a workspace project.

I have assumed that you are building a tool for use inside of Eclipse since you are asking about the target bundles. The fact that you are launching a second Eclipse instance doesn't matter because in the ned your tool will be installed into the host Eclipse (PDE provides a shortcut to test this, File > Export > Deplyoable Plug-ins and Fragments > Install into host).

Anyways, to access the bundles PDE knows about, use org.eclipse.pde.core.plugin.PluginRegistry. From there you can find the bundles you care about, get their installed location and extract whatever file you need from the jars.

I don't think this is part of your use case, but you can interact with the target platform from the preferences page or through the org.eclipse.pde.core.target.ITargetPlatformService API.

Good luck.

Re: GetPlugin from TargetPlatform [message #922989 is a reply to message #913049] Tue, 25 September 2012 14:16 Go to previous messageGo to next message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
Thx for that help!

I've found the Plugins of the TargetPlatform by using
PluginRegistry.getExternalModels();


I've seen the possibility to handle plugins via the org.osgi.framework.Bundle, but I don't find any object, which delivers a Bundle-Object of the given Target-Platform. Using
Platform.getBundle(String symbolicName)

doesn't deliver bundles of the TargetPlatform. And using
PluginRegistry.getExternalModels()[i].getBundleDescription().getBundle()

doesn't deliver anything, only Null.

Is it the only way to call the file by creating an InputStream and creating a temporary java.io.File?

[Updated on: Tue, 25 September 2012 14:24]

Report message to a moderator

Re: GetPlugin from TargetPlatform [message #923050 is a reply to message #922989] Tue, 25 September 2012 15:06 Go to previous messageGo to next message
Curtis Windatt is currently offline Curtis WindattFriend
Messages: 166
Registered: July 2009
Senior Member
Platform.getBundle is asking the current OSGi runtime for the bundle. The target platform is a PDE concept. While PDE does have an OSGi state underlying its models, the bundles are not installed/started like they are in the runtime, hence why you can't get the actual bundle object.

To access files from within the bundle you will have to use java.util.zip or java file IO to explore the bundle yourself.
Re: GetPlugin from TargetPlatform [message #923720 is a reply to message #923050] Wed, 26 September 2012 06:14 Go to previous message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 55
Registered: February 2012
Member
Thx for that information. Now I know what to do.
Previous Topic:Creating a feature patch for org.eclipse.core.filesystem
Next Topic:Why no main method
Goto Forum:
  


Current Time: Wed Apr 24 14:20:25 GMT 2024

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

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

Back to the top