Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Running a RCP plugin dynamically from another project(How to Add and run a RCP hello world plugin from another project dynamically)
Running a RCP plugin dynamically from another project [message #651664] Tue, 01 February 2011 07:59 Go to next message
Prithviraj Patil is currently offline Prithviraj PatilFriend
Messages: 10
Registered: February 2011
Junior Member
I am trying to dynamically add a simple hello world RCP plugin to a RCP application with a view . I am able to load the hello world plugin but am unable to actually get the plugin to run (i.e i am unable to call the activator of the hello world plugin).
Re: Running a RCP plugin dynamically from another project [message #651736 is a reply to message #651664] Tue, 01 February 2011 13:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 02/01/2011 02:59 AM, Prithviraj Patil wrote:
> I am trying to dynamically add a simple hello world RCP plugin to a RCP
> application with a view . I am able to load the hello world plugin but
> am unable to actually get the plugin to run (i.e i am unable to call the
> activator of the hello world plugin).

What code are you using to load/start the plugin?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Running a RCP plugin dynamically from another project [message #651755 is a reply to message #651736] Tue, 01 February 2011 13:43 Go to previous messageGo to next message
Prithviraj Patil is currently offline Prithviraj PatilFriend
Messages: 10
Registered: February 2011
Junior Member
In my RCP project :: Application.java .. start() function i have loaded the plugin jar using the following code ::

public Object start(IApplicationContext context) {
Display display = PlatformUI.createDisplay();

BundleContext bundleContext = InternalPlatform.getDefault()
.getBundleContext();
String location = "reference:file:/C:/Users/Prithviraj P/Desktop/plugins/plug_1.0.0.201101311851.jar";
Bundle b = null;
try {
b = bundleContext.installBundle(location);
} catch (BundleException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

try {

b.start(Bundle.START_TRANSIENT);
try {
b.loadClass("plug.activator").getDeclaredMethod("getDefault ");
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("-I- Started bundle myplugin" + b.getState());
} catch (BundleException e) {
e.printStackTrace();
System.out.println("-E- Error load bundle myplugin");
}

try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}



This loads the plugin and i am able to access all its classes and methods.. however i want to run the loaded plugin dynamically i.e i want to run it as an application as a whole.
Re: Running a RCP plugin dynamically from another project [message #651853 is a reply to message #651755] Tue, 01 February 2011 19:06 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 02/01/2011 08:43 AM, Prithviraj Patil wrote:

> b.start(Bundle.START_TRANSIENT);

This is enough to call your bundle activator start(BundleContext)
method, if you have your activator set:

Bundle-Activator: com.example.your.plugin.Activator


>
>
> This loads the plugin and i am able to access all its classes and
> methods.. however i want to run the loaded plugin dynamically i.e i want
> to run it as an application as a whole.

It's not clear what you are trying to do here. Your code starts your
bundle, and then calls createAndRunWorkbench(*) which will launch
configured by your ApplicationWorkbenchAdvisor.

You control the IApplication, what would you like it to do?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Running a RCP plugin dynamically from another project [message #651930 is a reply to message #651853] Wed, 02 February 2011 06:10 Go to previous messageGo to next message
Prithviraj Patil is currently offline Prithviraj PatilFriend
Messages: 10
Registered: February 2011
Junior Member
The activator start(BundleContext) method does get called .. however it does not call the application start (IApplicationContext context) method , applicationworkbenchadvisor , perspective classes.

My main aim is to make an extensible rcp project into which i can import other rcp plugins at run time and then when i select one of these plugins i should be able to launch the workbench of this plugin (i.e say if i have my rcp application running and then i import a rcp hello world plugin at run time then i want to know how i can to load the hello world workbench and perspective ; and make the hello workbench appear)

Thanks for the help .
Re: Running a RCP plugin dynamically from another project [message #652017 is a reply to message #651930] Wed, 02 February 2011 13:03 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

2 things come to mind:

1) you could try and read the Extensions from the registry for that
plugin, find the IApplication class, instantiate it, and call
start(IApplicationContext), but ...

2) you can't run 2 workbenches in the same JVM ... it's a singleton that
manages all the workbench windows.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Running a RCP plugin dynamically from another project [message #652028 is a reply to message #652017] Wed, 02 February 2011 13:45 Go to previous message
Prithviraj Patil is currently offline Prithviraj PatilFriend
Messages: 10
Registered: February 2011
Junior Member
Oh..thanks.Could you please explain. how the adding of plugins to eclipse IDE works?? or could you suggest a round about method or tool to achieve something of this sort ??
Re: Running a RCP plugin dynamically from another project [message #652036 is a reply to message #651930] Wed, 02 February 2011 13:43 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

I will mention that Equinox/OSGi does support loading and running more
than one application (in some circumstances). You'll have to
investigate the mechanism to do that ... but the eclipse IDE application
itself takes a default cardinality, which it says is singleton-global

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:How to load custom perspective from XML Memento
Next Topic:p2.inf file is ignored
Goto Forum:
  


Current Time: Fri Mar 29 00:53:42 GMT 2024

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

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

Back to the top