Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Loading a plugin programmatically
Loading a plugin programmatically [message #903884] Mon, 27 August 2012 02:31 Go to previous message
Chun Tat Chu is currently offline Chun Tat Chu
Messages: 10
Registered: August 2012
Junior Member
I have been searching the Internet and this forum on this. I read a bunch of articles and nothing appears to be helping. Please don't mind me if this question has already been asked.

What I am trying to do is to programmatically load a plugin within my RCP.

My scenario includes the following
- dc_buddypolicy_plugin1 is a headless plugin that provides a static class for logging to standard out
- dc_buddypolicy_plugin3 is my RCP and it tries to load plugin1 programmatically.

Below is a code snippet in dc_buddypolicy_plugin3::Activator::start() method.
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
		System.out.println(PLUGIN_ID + ":Activator::start invoked");
		

		try {
			System.out.println(PLUGIN_ID + ":Activator::start installing bundle");
			Bundle b = context.installBundle("file:///home/beyonddc/workspace/deployed_plugin/plugins/dc_buddypolicy_plugin1_1.0.0.jar");
			System.out.println(PLUGIN_ID + ":Activator::start installed bundle");
			
			b.start();
			System.out.println("Invoking Class.forName()");
			Class lc = Class.forName("dc_buddypolicy_plugin1.Logger");

		} catch (Throwable th) {
			th.printStackTrace();
		}

	}


My dc_buddypolicy_plugin1 appears to be loaded just fine according to the log in standard out except that I couldn't load my class via Class.forName().
dc_buddypolicy_plugin3:Activator::start invoked
dc_buddypolicy_plugin3:Activator::start installing bundle
dc_buddypolicy_plugin3:Activator::start installed bundle
dc_buddypolicy_plugin3:Activator::start dc_buddypolicy_plugin1 INSTALLED
dc_buddypolicy_plugin1:Activator - start - invoked [08272012]
dc_buddypolicy_plugin1::logger - dc_buddypolicy_plugin1:Activator::start invoked [08272012]
Invoking Class.forName()
java.lang.ClassNotFoundException: dc_buddypolicy_plugin1.Logger


I also setup buddy policy
dc_buddypolicy_plugin3 has Eclipse-BuddyPolicy: registered
dc_buddypolicy_plugin1 has Eclipse-RegisterBuddy: dc_buddypolicy_plugin3

Can someone please kindly explain what I did wrong? Thanks!


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:RCP - Debugging which plugin is missing from target platform
Next Topic:Export wizard failing
Goto Forum:
  


Current Time: Sat May 18 09:14:02 EDT 2013

Powered by FUDForum. Page generated in 0.01991 seconds