Saturday, January 29, 2011

Create Business Processes, Human Tasks, with many other features


Suppose you need to write a business process/human task with some quality of service features like security, throttling caching etc. Or suppose you need inject ESB characteristics like service mediation, routing, load balancing, message enrichment etc. to incoming and outgoing message sequences.
Now what if you can do all these stuff with one server instance without using different products for different requirements, isn't it great?
WSO2 Carbon is capable on this due to its component architecture. Not only that you can do these stuff using Carbon UI very easily.
Due to WSO2 Carbon's OSGi based component architecture, you can customize WSO2 products based on your requirements.

Here I'm writing about how those stuff can be done in a very high level.

1. Security, Caching, Throttling to Business processes/Human tasks.
WSO2 BPS is inherently support this, and you can use the BPS Web UI to configure, monitor and maintain business processes with these features. The more interesting thing is; the whole set of WSO2 carbon products, have this unique interface. So once you get familiar with one product, you can use other products very easily. As an example, to enable throttling to service mashup, data service or SOAP service etc, user sees an unique interface.

Here are some screen-shots of the service dashboard.

Main service dashboard

Security configuration

Throttling configuration

Caching configuration

Try-it configuration


2. How to embed ESB like features
How to install ESB features - To use WSO2 ESB features what you need to do is install ESB related features to BPS. But I would prefer install BPS features into ESB as the number of BPS features are less than ESB features. As any WSO2 product is a set of OSGi components; there is no any difference in installing BPS features to ESB product and installing ESB features to BPS product.

Here is a screen-shot of feature management page


Now if you are already familiar with WSO2 ESB; using ESB features on business processes/ human tasks is no different from using ESB features on any other service.
eg - writing a proxy service for a business process and use message mediation in in-sequence and out-sequence. etc

Friday, January 28, 2011

How to reuse Eclipse EMF.edit to write GEF editors


If you are into Eclipse Plugin development you’ve definitely heard of Eclipse Modeling Framework (EMF).
EMF provides a framework to define, code-generate, extend etc, for user-defined structured data models.
There are various ways to define the data model. One example would be using a define data model in XSD and use EMF to code generation.
EMF handles the code-generation of the model as well it also generate a general GEF based editor to manipulate the model instances using a tree-view, list-view, table-view etc.
Apart from it EMF provides many features to seamlessly extend the model.

This blog-post talks about the basic initial steps to implement a eclipse editor using EMF.edit package. If you are not that much familiar with EMF.edit refer this documentation.

Few features provided by EMF.edit is
  1. Content provider and Label provider
  2. Property Source
  3. Command framework
  4. Change notifier
1. Content provider and Label provider
These classes are used to represent data to the end-user. Here I’m not going much deeper. I’ll show you a code snippet that can be used on top of EMF.edit code and reuse the content and label providers used by the EMF framework.

adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new NamespaceItemProviderAdapterFactory());

TableViewer notificationsTableViewer;
notificationsTableViewer = new TableViewer(parent, SWT.SINGLE);
notificationsTableViewer.setContentProvider(new AdapterFactoryContentProvider(adaptorFactory));
notificationsTableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adaptorFactory));
notificationsTableViewer.setInput(notifications);

2. Property Source
Property source provider is used to represent the properties involved with a particular model object. In EMF.edit the item provider classes implements org.eclipse.emf.edit.provider.IItemPropertySource.
Here is a code snippet that can be used to integrate property source providers generated from EMF framework.

propertySheetPage =new PropertySheetPage ();
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));

If you go into provider classes generated from EMF.edit, you’ll see those classes have three methods, that implement the interface IItemPropertySource.

List getPropertyDescriptors(Object object);
IItemPropertyDescriptor getPropertyDescriptor(Object object, Object propertyID);
Object getEditableValue(Object object);

So you can reuse/study the above three method implementations to represent properties for each element.

3. Command Framework
If you have heard of Eclipse Command Framework, you’ve already realized how it is easy and cool to use eclipse commands to edit the EMF model objects.
Here’s a sample code to add a new element to the parent. This code is not general for all commands. So you may need to refer some documentations on this.

Group group = _200803Factory.eINSTANCE.createGroup();
group.setName(“Group Name”);
List<group> list = new BasicEList<group>();
list.add(group);
 
Command addGroup= AddCommand.create(domain, group, _200803Package.eINSTANCE.getGroups_Group(), list);
if(addGroup.canExecute()){
  domain.getCommandStack().execute(addGroup);
}else {
  System.out.println("Cannot execute");
}

4. Change notifier
In EMF.edit framework item provider adapters extends ItemProviderAdapter class which extends AdapterImpl. The method NotifyChange() is implemented in order to notify the viewers related to changes occurred to a model.

public void notifyChanged(Notification notification) {
  updateChildren(notification);
  switch (notification.getFeatureID(TExtensibleElements.class)) {
    case _200803Package.TEXTENSIBLE_ELEMENTS__DOCUMENTATION:
    case _200803Package.TEXTENSIBLE_ELEMENTS__ANY:
    case _200803Package.TEXTENSIBLE_ELEMENTS__ANY_ATTRIBUTE:
    fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
  return;
  }
  super.notifyChanged(notification);
}

Take a look at the code of this method, you will find, fireNotifyChange() method is called with a parameter ViewerNotification, this method is defined in ItemProviderAdapter which implements the interface “IChangeNotifier”, both the viewers and property sheets are the listener of the IChangeNotifier (using addListener and removeListener method provided by ItemProviderAdapter to register as a listener of the item provider), and in the changeNotifier.fireNotifyChanged(notification) method will called all the listener’s notifyChange() method.

public void fireNotifyChanged(Notification notification) {
  if (changeNotifier != null) {
    changeNotifier.fireNotifyChanged(notification);
  }

  if (adapterFactory instanceof IChangeNotifier) {
    IChangeNotifier changeNotifier = (IChangeNotifier)adapterFactory;
    changeNotifier.fireNotifyChanged(notification);
  }
}

Saturday, January 15, 2011

WSO2 Annual Award Ceremony 2010


WSO2 Annual Award Ceremony 2010; was held at Kings Court, Cinnamon Lakeside, Colombo on 14th January 2011. The most tremendous contributors in WSO2 were honored. I personally congratulate all of them for a better future. You can Google them if you wanna know more about them :).
  • Afkham Azeez
  • Supun Kamburugamuwa
  • Thilina Mahesh Buddhika
  • Milinda Pathirage
  • Saminda Wijerathne
  • Chathuri Wimalasena
  • Hiranya Jayathilaka
  • Prabath Siriwardena
  • Kasun Indrasiri
  • Asanka Abeysinghe
  • Sumedha Rubasinghe
  • Selvaratnam Uthaiyashankar
  • Samisa Abeysinghe
  • Senaka Fernando
  • Charitha Kankanamge
  • Evanthika Amarasiri
  • Krishantha Samaraweera
  • Chamith Kumarage
  • Nirosh Perera
  • Janath Sivayoganathan
  • Hasmin AbdulCader
  • Udeshika Ratnavira
  • Devaka Randeniya
  • Padmika Dissanaike
As well I congratulate all the WSO2 team members who are very supportive to each other.