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 "Create notification producer and consumer using tooling"

(New page: <h1>Create notification producer and consumer using tooling</h1> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="100">Author:</td> <td>Krishna C Shastry, Saurab...)
 
Line 29: Line 29:
 
<li>
 
<li>
 
Create a new '''Manageability Endpoint Project''' by the name of ProducerModel. All our Notification producer related artifacts will be stored in this project.<br><br>
 
Create a new '''Manageability Endpoint Project''' by the name of ProducerModel. All our Notification producer related artifacts will be stored in this project.<br><br>
[[Image:wsdl_complex_type_new_mep_wizard.png]]<br><br>
+
[[Image:producer_new_mep_wizard.png]]<br><br>
 
</li>
 
</li>
  
 
<li>For this resource we create a capability which publishes the file system space change events to the consumer. Create a new capability by specifying following user inputs defined in following screenshot. Click Finish.<br><br>
 
<li>For this resource we create a capability which publishes the file system space change events to the consumer. Create a new capability by specifying following user inputs defined in following screenshot. Click Finish.<br><br>
[[Image:wsdl_complex_type_new_cap_wizard_1.png]]<br><br>
+
[[Image:file_system_new_cap_wizard_1.png]]<br><br>
 
</li>
 
</li>
  
 
<li>
 
<li>
 
Tooling will open this newly created capability with Capability Editor. Move to the Topics tab in the editor and add a new Root Topic by providing the Topic namespace as "http://www.eclipse.org/FileSpaceChangeEvent/capability/Topics" and Root topic name as "FileSpaceChange".<br><br>
 
Tooling will open this newly created capability with Capability Editor. Move to the Topics tab in the editor and add a new Root Topic by providing the Topic namespace as "http://www.eclipse.org/FileSpaceChangeEvent/capability/Topics" and Root topic name as "FileSpaceChange".<br><br>
   [[Image:wsdl_complex_type_new_cap_wizard_1.png]]<br><br>
+
   [[Image:file_space_change_topic.png]]<br><br>
 
</li>
 
</li>
  
 
<li>
 
<li>
 
     Create a new Manageable resource type (WSDM resource type) and add the "NotificationProducer" and "FileSpaceChangeEvent" capability to it.<br><br>
 
     Create a new Manageable resource type (WSDM resource type) and add the "NotificationProducer" and "FileSpaceChangeEvent" capability to it.<br><br>
     [[Image:wsdl_complex_type_new_mrt_wizard_1.png]]<br><br>
+
     [[Image:producer_new_mrt_wizard_1.png]]<br><br>
     [[Image:wsdl_complex_type_new_mrt_wizard_2.png]]<br><br>
+
     [[Image:producer_new_mrt_wizard_2.png]]<br><br>
 
</li>
 
</li>
  
 
<li>
 
<li>
 
Right click the "FileSystem.mrt" file and select the option '''Generate Java Code'''. This will bring a new wizard to do the code generation for defined managed resource type. Provide the Output project name as "FileSystem".<br><br>
 
Right click the "FileSystem.mrt" file and select the option '''Generate Java Code'''. This will bring a new wizard to do the code generation for defined managed resource type. Provide the Output project name as "FileSystem".<br><br>
     [[Image:wsdl_complex_type_codegen_wizard.png]]<br><br>
+
     [[Image:file_system_codegen_wizard.png]]<br><br>
 
</li>
 
</li>
  

Revision as of 11:27, 10 July 2007

Create notification producer and consumer using tooling

Author: Krishna C Shastry, Saurabh Dravid
email: krishna.shastry@in.ibm.com sadravid@in.ibm.com
Last updated:

Create a notification producer resource

  • We will take a file system as a notification producer resource, which will notify the consumer at some specific time interval about the file space change event.
  • Create a new Manageability Endpoint Project by the name of ProducerModel. All our Notification producer related artifacts will be stored in this project.

    Producer new mep wizard.png

  • For this resource we create a capability which publishes the file system space change events to the consumer. Create a new capability by specifying following user inputs defined in following screenshot. Click Finish.

    File system new cap wizard 1.png

  • Tooling will open this newly created capability with Capability Editor. Move to the Topics tab in the editor and add a new Root Topic by providing the Topic namespace as "http://www.eclipse.org/FileSpaceChangeEvent/capability/Topics" and Root topic name as "FileSpaceChange".

    File space change topic.png

  • Create a new Manageable resource type (WSDM resource type) and add the "NotificationProducer" and "FileSpaceChangeEvent" capability to it.

    Producer new mrt wizard 1.png

    Producer new mrt wizard 2.png

  • Right click the "FileSystem.mrt" file and select the option Generate Java Code. This will bring a new wizard to do the code generation for defined managed resource type. Provide the Output project name as "FileSystem".

    File system codegen wizard.png

  • After doing the code generation remove the java package "org.eclipse.tptp.wsdm.runtime.capability" from "FileSystem" web project. The classes available in this package are already available in tools.jar.

  • Open Java class in /FileSystem/JavaSource by the name of org.eclipse.www.FileSpaceChangeEvent.capability.MyCapability and put the following code in this class. This class will publish the file system space change notification messages at specific time interval.

    package org.eclipse.www.FileSpaceChangeEvent.capability;
    
    import javax.xml.namespace.QName;
    
    import org.apache.muse.core.AbstractCapability;
    import org.apache.muse.util.xml.XmlUtils;
    import org.apache.muse.ws.addressing.soap.SoapFault;
    import org.apache.muse.ws.notification.NotificationProducer;
    import org.apache.muse.ws.notification.WsnConstants;
    import org.w3c.dom.Element;
    
    public class MyCapability extends AbstractCapability
    {
        public QName TOPIC_QNAME = new QName("http://www.eclipse.org/FileSpaceChangeEvent/capability/Topics","FileSpaceChange","tns");
        private final int TIME_INTERVAL_SECONDS = 3;
    	
    	public void initialize() throws SoapFault 
        {
            //
            //The following call is necessary to property initialize the resource
            //
            super.initialize();
    
            //
            //TODO Perform any needed initialization for this empty capability
            //
        }
        
        public void initializeCompleted() throws SoapFault
        {
        	super.initializeCompleted();
        	
        	
        	
        	Thread thread = new Thread(){
        		
        		public void run()
        		{
        			String message = "File space changed";
    				QName messageName = new QName("http://org.eclipse/FileSystem",
    						"FileSpaceChangeMessage", "tns");
    				Element payload = XmlUtils.createElement(messageName,
    						message);
    				NotificationProducer producer = (NotificationProducer) getResource()
    						.getCapability(WsnConstants.PRODUCER_URI);
        			while (true) {
        				try {
    						Thread.currentThread().sleep(TIME_INTERVAL_SECONDS * 1000);
    					} catch (InterruptedException e1) {
    						e1.printStackTrace();
    					}
    					try {
    						producer.publish(TOPIC_QNAME, payload);
    					} catch (SoapFault e) {
    						e.printStackTrace();
    					}
    				}
        		}
        	};
        	
        	thread.start();
        }
    
    }


Comments

Back to the top