Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Access project resources from ODA driver Plug-in
Access project resources from ODA driver Plug-in [message #540348] Tue, 15 June 2010 18:48 Go to next message
Brad Johnson is currently offline Brad JohnsonFriend
Messages: 2
Registered: June 2010
Junior Member
I've written a ODA designer and oda driver using the BIRT plugin generators.

From the code I'd like to access a (configurable) class that is defined in the user's reporting project that uses my DataSource.

I get ClassNotFoundException when trying to load the class from its name using Class.forName("mypackage.MyClass");

What is the trick for a plugin to access resources in the user's project? Is there anything special about BIRT DataSource projects in this regard?
Re: Access project resources from ODA driver Plug-in [message #540517 is a reply to message #540348] Wed, 16 June 2010 12:47 Go to previous messageGo to next message
Steve Schafer is currently offline Steve SchaferFriend
Messages: 23
Registered: December 2009
Junior Member
I don't think there's anything special about BIRT datasources in this respect. It's just the nature of OSGI bundles (AKA eclipse plugins). Each bundle has its own tightly controled class loader, which you configure in the plugin dependencies tab. The plugin won't be able to access anything outside of that, even with reflection.

However the users project can access classes in your plugin, so maybe you could accomplish this another way. Define an interface in your plugin that the user must implement and then a method where the user can pass their implementation to you. Just a thought.
Re: Access project resources from ODA driver Plug-in [message #540599 is a reply to message #540517] Wed, 16 June 2010 15:51 Go to previous messageGo to next message
Brad Johnson is currently offline Brad JohnsonFriend
Messages: 2
Registered: June 2010
Junior Member
I'm able to get at a classloader that works somewhat for a report preview. It will load my classes in my src folder, but not ones from jars in the build path of the project. Also context is null in setAppContext() when setting up the datasource in the wizard, so I can't access the class there where I need to. Sad

In my Connection.setAppContext( Object context ):

Map m = (Map)context;
classloader = (ClassLoader) m.get("PARENT_CLASSLOADER");


I really think it must be possible to access the classes in the build path/classpath of a project from a plugin. For example the java editor must be able to access that info just to provide the text completion of methods.

Any ideas how this is done?

-Brad
Re: Access project resources from ODA driver Plug-in [message #540669 is a reply to message #540348] Wed, 16 June 2010 22:47 Go to previous message
Steve Schafer is currently offline Steve SchaferFriend
Messages: 23
Registered: December 2009
Junior Member
I've written plugins where I get the workspace root from org.eclipse.birt.report.designer.ui.ReportPlugin.getDefault( ).getStateLocation() (which actually gives you a location within .metadata, but you can work up from there). Then I go about finding projects in subdirectories below that. But that makes the big assumption that the projects are actually located in the workspace, which the don't need to be. There's probably a way to find projects no matter where they are located, but I have never explored that area.

Anyway if you knew where the jars were you could build a new URL class loader for them. Seems like this solution would only work in the eclipse environment though. If you deploy your application to run as a webapp or a stand-alone java app, you won't have a workspace.

Perhaps a better idea is to configure the classpath in your ODA plugin runtime tab. You can only specify jar files that live in your project, so you may need to move the jar files you need into your project.
Previous Topic:Gantt chart height
Next Topic:redirect: how?
Goto Forum:
  


Current Time: Fri Apr 26 08:53:41 GMT 2024

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

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

Back to the top