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

Connecting to OSGi Endpoint using WSDM Tooling

Connecting to OSGi endpoint using WSDM Tooling

Author: Krishna C Shastry
email: krishna.shastry@in.ibm.com
Last updated:

Creating a New WSDM Manageable Endpoint Type

  • Create a new Manageability endpoint project by the name Model.
  • Select File >> New >> Project... >> Tooling for Web Services Distributed Management >> Manageability Endpoint Project.
  • CreateProject1.png

  • Press Next.
  • Give the project name as Model
  • CreateProject2.png

  • Click on Finish
  • Now create a MRT file in the above project.
  • Right click on project and select New >> other… >> Tooling for Web Services Distributed Management >> New WSDM Manageable Endpoint Type.
  • CreateMRT1.png

  • Select Next..
  • Give the MRT name as “System Model” and select “Add WSDM Resource Capability” check box.
  • CreateMRT2.png

  • Click on “Finish”.

Running OSGi Project

  • Code Generation

    • Right click on the “SystemModel.mrt” file and select “Generate Java Code”.
    •   CodeGeneration.PNG

    • Following code generation wizard page will come up. Give a name for the output project.
    • Select “OSGi” in the “Platform” combo box and “Axis2” in the “Container” combo box.
    •    Codegen2.png

    • Click on “Finish” to create an OSGi end point project.
  • Resolving Compilation Errors

    • Open the “Manifest.MF” file in the osgi project. Open the “Dependency” tab in it.
    •    Removeservlet.png

    • Remove “org.eclipse.equinox.servlet.api” plug in from the dependencies.
    • Save the Manifest.MF file
    • Select File >> Import… >> Plug-in Development >> Plug-ins and Fragments.
    •   Importplugiin0.png

    • Click on “Next”.
    •   Importplugin2.png 

    • Do not change anything in this page and click on “Next”.
    • This page will list all the plug-ins. Select “org.apache.muse.osgi.core” form the left pane and click on “Add”.
    •   ImportPlugin.PNG

    • Click on “Finish”.
    • Right click on the “org.apache.muse.osgi.core” plug-in.
    • Select “Properties” as shown.

      Addingtobuildpath.PNG

    • Select “Java Build Path”, “Libraries” tab.
    •     File:Addclassfolder.png

    • Click on the “Add class Folders…”.
    • Select “org.apache.muse.osgi.core”
    •    Addingtobuildpath3.png

    • Click “OK”.
    • Now, open the “Order and Export” tab and select “org.apache.muse.osgi.core” check box. File:Addingtobuildpath2.png

    • Click on “OK”.

Running an OSGi endpoint

  • Right click on the “osgi” project
  • Select “Run As >> Open Run Dialog” as shown.
  •   Rundialog.PNG

  • Right click on the “OSGi Framework” and select New.
  • Give the name as “OSGI”. Go to the “Bundles” tab and click on “Deselect All”.
  • Now select the following plug-ins.
    • osgi project (i.e.: Project created by you using mrt)
    • javax.saaj.api
    • org.apache.muse.osgi.wrapper.mini
  • After selecting the above plug-ins click on “Add required Bundles”.
  • Addrequired.png

  • Click on “Apply” and select “Run”.

Connecting to OSGi endpoint using MAX

  • Right click on the “osgi” project and select “Profile As >> Open Profile Dialog…” as shown.
  •   Openprofiledialog.PNG

  • Right click on “Managed Resource” select “New”.
  • Select the “WSDM Resource” and click on “Edit Options” button.
  • Profiledialog.png.PNG

  • Type the URL in the “Specify the URI” text field.
  •    Wsdmendpoint.png

  • Click “Finish”.
  • Click on "Profile"
  • This will open the “Managed Agent Explorer”. You can see the resource in the “Resource Topology” section.

Connecting to OSGi endpoint using Proxy

  • Proxy Generation

    • Right click on the “SystemModel.mrt” file and select “Generate Java Code”.
    • Following code generation wizard page will come up. Give a name for the output project.
    • Select “Proxy” in the “Platform” combo box
    •    Proxy.png

    • Click on “Finish” to create a proxy end point project.
    • Create a new class called TestClient in the package org.eclipse.www.SystemModel.
    • Copy the following code into it.
    • package org.eclipse.www.SystemModel;
      
      import java.net.URI;
      
      import org.apache.muse.ws.addressing.EndpointReference;
      import org.apache.muse.ws.addressing.soap.SoapFault;
      
      public class TestClient 
      {
      	public static void main(String[] args) throws SoapFault 
      	{
      		URI uri = URI.create("http://localhost:81/osgi/services/MyService");
      		EndpointReference epr = new EndpointReference(uri);
      		MyServiceProxy  proxy = new MyServiceProxy(epr);
      		System.out.println(proxy.getResourceId());
      	}
      }
         
         
  • Now run the class TestClient.
  • You will see the resource id printed on the console.

Comments

Back to the top