Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse, Plugins, Statics and Classpaths
Eclipse, Plugins, Statics and Classpaths [message #149359] Thu, 20 April 2006 17:52
Eclipse UserFriend
Originally posted by: SSalewski.Gmx.net

Hello,
I am relative new in plugin-programming under eclipse, and there's a
problem I am not able to solve: I want to let two Plugins use a class
ProjectProxy.

(note: the code is extremly shortened; assume that the way the factories
and its implementations are bound together cannot be modified - and I am
sorry for my not-so-good-english ;)

Plugin A has a plugin class AB like this:

class AB {
public void start() {
String pp = ProjectProxy.class.getName();
String io = "my.package.java1_4impl.ProjectProxyObject";

...

Factory factory = (Factory) Class.forName(factoryClass).newInstance();
FactoryObjectImplementation implementation
= (FactoryObjectImplementation) Class.forName(implClass).newInstance();

factory.bind(implementation);

...
}
}

Plugin B has the class ProjectProxy and the plugin class BB:

class ProjectProxy {
private static ProjectFactoryObject pfo = null;
...
public boolean bind(Object implementation) {
if (implementation instanceof ProjectFactoryObject) {
return ProjectFactory.bind((ProjectFactoryObject)
implementation);
}
return false;
}
...
public static boolean bind(ProjectFactoryObject implementation) {
pfo = (ProjectFactoryObject) implementation;
return true;
}
...
public static Project newProject(String projectName) {
if (pfo == null)
return null;
return pfo.newProject(projectName);
}
}

class BB {
public void start(BundleContext context) throws Exception {
...
this.project
= new ProjectProxy(ProjectFactory.newProject("New Project", true));
...
}
}

First, plugin AB will be called at startup. The start() method in BB will
be called (implicit) after the binding was made.

Problem: When the Plugin AB calls the bind-method, the static variable fop
in ProxyFactory is set correctly. But if the plugin BB tries to call the
newProject(...) method of ProxyFactory, fop is always null.

I know this is because of the classloader-concept of eclipse (there is an
interessting article from Martin Lippert on the web). But I was not able
to solve this problem. Has anyone an idea for this?
Previous Topic:Moving a Project help...
Next Topic:Looking for good getting started help
Goto Forum:
  


Current Time: Thu Apr 25 12:53:47 GMT 2024

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

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

Back to the top