How to Create a Custom Proxy Services Template using WSO2 Carbon Studio

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By Chathuri Wimalasena
  • 23 May, 2011

Content

  1. Pre-requisites
  2. Introduction
  3. Tutorial Scenario
  4. Getting Started
    1. Create a plugin project
    2. Add extension point exposed by org.wso2.carbonstudio.eclipse.capp.artifact.proxyservice bundle
    3. Export project as a bundle
  5. Test final outcome
  6. Summary

1. Pre-requsites

This tutorial is for WSO2 Carbon Studio 1.0.5 or higher. We assume you have already installed WSO2 Carbon Studio in your Eclipse instance.

2. Introduction

WSO2 Carbon Studio is a set of tools developed for middleware users to help writing applications or configurations for WSO2 Carbon Products.  It contains set of tools for products like Enterprise Service Bus, Application servers, Business Process Server, CarbonGadget Server, Governance Registry, Data Services Server, etc.  WSO2 Carbon Studio is available as a set of plugins for the famous Open-source IDE, Eclipse.  which containing diverse set of tools to support many of our arbon products and it is easy to install and practically needs no configuring at all. You can find more information on WSO2 Carbon Studio from here.

3. Tutorial Scenario

In this tutorial, I'm explaining how to create a custom proxy services template with the help of WSO2 Carbon Studio. This feature is really helpful if your system has a frequently used proxy services template type. With this you can create your own WSO2 Carbon Studio version to match your requirement.

4. Getting Started

4.1 Create a plugin project

To create your own template proxy service, first you have to create a standard Eclipse plugin project. Open your Eclipse instance. You do not need to have WSO2 Carbon Studio installed Eclipse instance for this. To create a plugin project, select File -> New -> Project. 


Then select Plug-in Project from Plug-in Development section and click Next.  


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Give a name for your project and click Next.

In the next page remove "qualifier" term from Version and click Finish.

4.2 Add an extension point exposed by org.wso2.carbonstudio.eclipse.capp.artifact.proxyservice bundle

Double click on the MANIFEST.MF and you will see there are several tabs such as Extensions, plugin.xml, build.properties etc. plugin.xml may not visible by default. If you can not find plugin.xml, click on the Extension tab click on Add and you will see MANIFEST.MF goes to the unsaved state. Now save MANIFEST.MF and you will see, plugin.xml is automatically added.


 Open plugin.xml and add

<extension
        point="org.wso2.carbonstudio.proxy.templates">
     <template
           file="templates/MyProxyTemplate.xml"
           id="org.wso2.carbonstudio.eclipse.capp.artifact.proxyservice.template.MyProxyTemplate"
           name="My Template Proxy Service">
     </template>
</extension> 

 

Change the name, id and file according to your preference. Make sure you add the template proxy file to the defined location in the plugin.xml.  In this case, we need to add MyProxyTemplate.xml in to templates folder. To add a folder right click on the project, New -> Folder


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Name the folder as “templates” and click Finish


Now we will add MyProxyTemplate.xml in to the created template folder like we added the folder. To do that right click on the templates folder and select New -> File

Add the mediators you want to be included in the template proxy service. Here I’m adding following template. You can modify according to your requirement.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="{1}"
    name="{0}" statistics="disable" trace="disable" transports="http,https">
   <target>
       <inSequence>
           <log category="INFO" level="full" separator=",">
               <property name="MESSAGE" value="Sending Request"/>
           </log>
       </inSequence>
   </target>
</proxy>

In this template, namespace and name of the proxy service is given as parameters. Name parameter is filled according to data entered by user. Namespace parameter is a predefined value.

Then we need to update the build.properties file, the file we state that we want to include templates folder when creating the bundle. To specify that information, double click on the build.properties file and tick templates folder.

Click on the MANIFEST.MF tab and make sure your MANIFEST.MF include following two entries.

Bundle-SymbolicName: org.wso2.carbonstudio.sample;singleton:=true
Bundle-ClassPath: .

4.3 Export project as a bundle

Now we are ready to create the bundle which we should add to <eclipse-home>/plugins folder. Save all the changes in the project. To create the bundle, right click on the project and select Export.

Then select Deployable plug-ins and Fragments from Plug-in Development category.


Point the location to create the bundle.


If you go to the given location, you will see a folder called “plugins” has been created and you will find the bundle we just created inside that folder.

5. Test final outcome

Copy the bundle we just created, in to <eclipce-home>/plugins folder and restart eclipse with -clean option. Now you will see “My Template Proxy Service” template is available in proxy service templates drop-down box.


6. Summary

In this tutorial we have explained how you can create a custom proxy services template using WSO2 Carbon Studio. As you can see, it is as simple as copying your template proxy services configuration and implementing the extension point exposed by WSO2 Carbon Studio. There are lot of other extension points, which you can try out as well.

Author

Chathuri Wimalasena

Senior Software Engineer, WSO2 Inc.