Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Corona management framework access"

Line 4: Line 4:
  
 
<code><pre>
 
<code><pre>
<component name="your.sample.Component" immediate="true" >
+
<component name="SimpleJavaObject" immediate="true" >
<implementation class="your.sample.ComponentImpl" />
+
<implementation class="org.eclipse.corona.wsdm.example.SimpleJavaObject" />
 
<reference name="ContributionManager" interface="org.eclipse.corona.management.common.ContributionManager" cardinality="1..1" policy="static" />
 
<reference name="ContributionManager" interface="org.eclipse.corona.management.common.ContributionManager" cardinality="1..1" policy="static" />
 
<reference name="WSDM" interface="org.eclipse.corona.management.binding.Binding" cardinality="1..1" policy="static" target="(provider=WSDM)"/>
 
<reference name="WSDM" interface="org.eclipse.corona.management.binding.Binding" cardinality="1..1" policy="static" target="(provider=WSDM)"/>
Line 11: Line 11:
 
</pre></code>
 
</pre></code>
  
The following code would then be place in <code>your.sample.ComponentImpl</code>:
+
The following code would then be place in <code>org.eclipse.corona.wsdm.example.SimpleJavaObject</code>:
  
 
<code><pre>
 
<code><pre>
private ContributionManager manager;
+
package org.eclipse.corona.wsdm.example;
 +
 
 +
 
 +
import org.osgi.framework.ServiceReference;
 +
import org.osgi.service.component.ComponentContext;
 +
import org.eclipse.corona.management.common.ContributionManager;
 +
 
 +
public class SimpleJavaObject {
 +
 
 +
        ContributionManager manager;
 
 
 +
//Declarative Services methods
 
protected void activate(ComponentContext ctx)
 
protected void activate(ComponentContext ctx)
 
{
 
{
 
ServiceReference ref = ctx.getBundleContext().getServiceReference(ContributionManager.class.getName());
 
ServiceReference ref = ctx.getBundleContext().getServiceReference(ContributionManager.class.getName());
 
manager = (ContributionManager)ctx.getBundleContext().getService(ref);
 
manager = (ContributionManager)ctx.getBundleContext().getService(ref);
+
 
 +
manager.manage(this);
 
}
 
}
 
 
Line 27: Line 38:
 
manager.remove(this);
 
manager.remove(this);
 
}
 
}
 +
 +
 +
//The rest of the class properties and operations
 +
}
 
</pre></code>
 
</pre></code>
 
The <code>ContributionManager</code> instance defined by <code>manager</code> provides the entry point into the Management runtime.
 
The <code>ContributionManager</code> instance defined by <code>manager</code> provides the entry point into the Management runtime.
  
 
[[Corona_HowTo_Management_Annotations|Return to Tutorial]]
 
[[Corona_HowTo_Management_Annotations|Return to Tutorial]]

Revision as of 10:16, 30 April 2007

!!Obtaining the Management Enabling environment!!

The Management runtime is exposed as a service in the OSGi environment. The easiest way to obtain a reference to the Management service is to use declarative services. A sample declartive service description that specifies a dependency on the Management environment and a WSDM management binding is given below:

<component name="SimpleJavaObject" immediate="true" >
	<implementation class="org.eclipse.corona.wsdm.example.SimpleJavaObject" />
	<reference name="ContributionManager" interface="org.eclipse.corona.management.common.ContributionManager" cardinality="1..1" policy="static" />
	<reference name="WSDM" interface="org.eclipse.corona.management.binding.Binding" cardinality="1..1" policy="static" target="(provider=WSDM)"/>
</component>

The following code would then be place in org.eclipse.corona.wsdm.example.SimpleJavaObject:

package org.eclipse.corona.wsdm.example;


import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.eclipse.corona.management.common.ContributionManager;

public class SimpleJavaObject {

        ContributionManager manager;
	
	//Declarative Services methods
	protected void activate(ComponentContext ctx)
	{
		ServiceReference ref = ctx.getBundleContext().getServiceReference(ContributionManager.class.getName());
		manager = (ContributionManager)ctx.getBundleContext().getService(ref);

		manager.manage(this);
	}
	
	protected void deactivate(ComponentContext ctxt)
	{
		manager.remove(this);
	}
	

	//The rest of the class properties and operations
}

The ContributionManager instance defined by manager provides the entry point into the Management runtime.

Return to Tutorial

Back to the top