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 simple object"

Line 1: Line 1:
Enabling a Java class for management is a relatively easy process. Consider the following class, which contains a property <code>prop</code> and an operation <code>doOperation()</code>, which comprise the management interface for the class <code>SimpleJavaObject</code>.
+
Enabling a Java class for management is a relatively easy process. Consider the following class, which contains a property <code>prop</code> and an operation <code>doOperation()</code>, which comprise the management interface for the class <code>SimpleJavaObject</code>.  
  
 
<code><pre>
 
<code><pre>

Revision as of 10:10, 30 April 2007

Enabling a Java class for management is a relatively easy process. Consider the following class, which contains a property prop and an operation doOperation(), which comprise the management interface for the class SimpleJavaObject.

package org.eclipse.corona.wsdm.example;

public class SimpleJavaObject {

	private String prop;

	public void doOperation() {
		System.out.println("invoked operation");
	}

	public String getProp() {
		return "Property";
	}

	//Other non-management oprations and properties

}

Instances of the class can be made manageable by adding the following annotations:

package org.eclipse.corona.wsdm.example;

import org.eclipse.corona.management.annotations.ManagedOperation;
import org.eclipse.corona.management.annotations.ManagedProperty;
import org.eclipse.corona.management.annotations.ManagedResource;

@ManagedResource(namespace="http://org.eclipse.corona.wsdm.example")
public class SimpleJavaObject {

	@ManagedProperty
	private String prop;

	@ManagedOperation
	public void doOperation() {
		System.out.println("invoked operation");
	}

	public String getProp() {
		return "Property";
	}

	//Other non-management oprations and properties

}

Instances of the class are then registered with the Management Runtime using the ContributionManager<Link to Obtaining the Management Enabling environment> as follows:


	SimpleJavaObject objInstance = new SimpleJavaObject();
	manager.manage(objInstance );

Back to the top