Monday, December 10, 2012

How to generate sub-categories for WSO2 features

We can generate sub-categories for WSO2 features by creating product-specific composite features to group existing features based on their functionality.
You can follow below steps to create a composite-feature and include it as a sub-category under a WSO2 product in P2. 

1. Identify the sub-categories for your product and create corresponding composite features. (eg: For AS, the identified sub-categories are listed in the previous post.)  Also, you can see the list of composite-features for AS category at: https://svn.wso2.org/repos/wso2/carbon/platform/branches/4.0.0/features/composite-features/as 
Similarly we can create composite-features for other products (eg: composite-features/esb, composite-features/greg)

2. In the new composite-feature, import the required features you want to group together. Use importFeatureDef to import required features instead of using includedFeatureDef. This is to avoid tight-coupling to it's dependency features. 

eg: In the "Application and Service Hosting" composite feature defined for AS we can import the set of features we need to group together as below.


        org.wso2.carbon.servicehosting:4.0.0
        org.wso2.carbon.service.mgt:4.0.5
        org.wso2.carbon.dataservices:4.0.5
        org.wso2.carbon.webapp.mgt:4.0.5
        org.wso2.carbon.jaxws.webapp.mgt:4.0.2
        org.wso2.appserver.mashup:4.0.5
        org.jaggeryjs:0.9.0.ALPHA2-wso2v2
        org.wso2.carbon.identity.xacml.filter:4.0.5

We should also make sure that these imported features are already published to the p2-repository under repo-gen goal. Otherwise during feature installations, P2 will not be able to resolve these dependencies as the required features are not in the repository.

So we should make sure the featureArtifacts of above imported features are in the list of published features in the p2-repository.

Note that in the above sample, I have imported org.wso2.appserver.mashup:4.0.5 feature, which is another composite feature introduced to group mashup related features set. Likewise we can nest composite-features in a parent composite-feature to gain a more fine-grained sub-categories.

3. Set the following properties for the composite feature in the p2-advice file (p2.inf)
 
org.eclipse.equinox.p2.type.category:true
org.wso2.carbon.p2.category.type:composite


This is how we are defining this feature is a composite-feature and a sub-category. Above properties are read by the feature manager to identify the feature as a composite type and list as a sub-category.

4. Following is the composite-feature pom created for "Application and Service Hosting" sub-category under AS. Note that the groupID is product specific: org.wso2.appserver, which is necessary to maintain composite-features based on products.


 
  org.wso2.carbon
  carbon-features
  4.0.0
  ../../../../pom.xml
 

 4.0.0
 org.wso2.appserver
 org.wso2.appserver.service.application.hosting.feature
 4.0.5
 pom
 WSO2 Carbon - Application and Service Hosting
 http://wso2.org
 This feature includes service and application hosting
  features

 
  
   
    org.wso2.maven
    carbon-p2-plugin
    ${carbon.p2.plugin.version}
    
     
      4-p2-feature-generation
      package
      
       p2-feature-gen
      
      
       org.wso2.appserver.service.application.hosting
       ../../../../etc/feature.properties
       
        
         org.eclipse.equinox.p2.type.category:true
         org.wso2.carbon.p2.category.type:composite
        
       
       
        org.wso2.carbon.servicehosting:4.0.0
        org.wso2.carbon.service.mgt:4.0.5
        org.wso2.carbon.dataservices:4.0.5
        org.wso2.carbon.webapp.mgt:4.0.5
        org.wso2.carbon.jaxws.webapp.mgt:4.0.2
        org.wso2.appserver.mashup:4.0.5
        org.jaggeryjs:0.9.0.ALPHA2-wso2v2
        org.wso2.carbon.identity.xacml.filter:4.0.5
       
      
     
    
   
  
 



5. Add the newly added composite-feature to the p2-repo pom.xml under <featureArtifacts>section, so the artifact is published to the repository at the repo-gen phase.

                             org.wso2.appserver:org.wso2.appserver.service.application.hosting.feature:${carbon.patch.version.405}

6. Finally, add the new composite-feature as a <catFeature> under the relevant product category.

 org.wso2.appserver.service.application.hosting
 ${carbon.patch.version.405}



Here are the list of new AS-specific composite features published to the p2-repo.


 org.wso2.appserver:org.wso2.appserver.miscellaneous.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.mashup.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.monitoring.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.module.mgt.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.tools.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.registry.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.data.publisher.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.transports.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.service.application.hosting.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.service.application.security.feature:${carbon.patch.version.405}


 org.wso2.appserver:org.wso2.appserver.mandatory.feature:${carbon.patch.version.405}




Now the AS category looks like this with the newly added composite-features to mimic sub-categories

 org.wso2.carbon.appserver.category
 
 This category contains features required for WSO2
  Application Server
 
 
  
   org.wso2.appserver.monitoring
   ${carbon.patch.version.405}
  
  
   org.wso2.appserver.tools
   ${carbon.patch.version.405}
  
  
   org.wso2.appserver.transports
   ${carbon.patch.version.405}
  
  
   org.wso2.appserver.service.application.hosting
   ${carbon.patch.version.405}
  
  
   org.wso2.appserver.mandatory
   ${carbon.patch.version.405}
  
  
   org.wso2.appserver.miscellaneous
   ${carbon.patch.version.405}
  
 

Here is how AS category is now displayed in Feature manager UI.



WSO2 Carbon Feature Sub-Categories

Equinox P2 provides a concept called P2 category to group related installable units (IUs) in a P2 repository.  In WSO2 Carbon we use the same concept to implement Carbon feature categories in our P2 repo. In our maven based build platform we use carbon-p2-plugin tool, to generate features, feature-repository, product profiles and feature-categories. To generate P2-categories using the Carbon p2-plugin we use P2 CategoryPublisher tool under-the-hood. I have explained how we can create P2-categories for Carbon features to represent a WSO2 product in one of my previous posts.

Following is how 'Application Server' category is shown as a P2-category in the repository. All required features to install Application Server is listed under the AS category as shown below.

 
However there's a limitation in P2 category concept which restricts us from achieving fine-grained feature sub-categorization. Sub-categorization of features under a Product can be really useful from a user's point-of-view to identify the set of minimally required features to gain  functionality of a certain WSO2 product. Using P2 category concept and CategoryPublisher tool we can only categorize features in a single level (Product level) as shown above. We cannot achieve a hierarchical sub-categorization which can map features to user-level feature groups based on their functionality. So to achieve sub-categorization of features we must find an alternate approach.

As a solution for this, and to implement sub-categories for WSO2 Carbon features, we can follow a process to create new set of composite features to group required features as sub-categories. A newly created composite feature will correspond to a sub-category in a certain Product. They can be specific to a product, because each product can have different grouping of the same platform features based on the expected functionality.

For an example if we take Application Server, we can group the list of features under AS category into sub-categories by defining new set of composite features as below.
  1. Application and Service Hosting
  2. Application Server - Core (contains the core set of features that must be installed with AS)
  3. Application Server -Transports (jms, mail transport features)
  4. Miscellaneous (dep.sync, event, tasks, ws-discovery features)
  5. Monitoring
  6. Tools
Please note that it's also possible to define more composite-features to group related carbon features and have them under other composites as imported-features.
For example under Application Server we can create a composite-feature as 'Mashup' and have it as an imported-feature under 'Application and Service Hosting' sub-category.
 
With above sub-categories defined and required features grouped into sub-categories, the AS category is now shown in the P2 repository like below.


In the next post, I will explain a step-by-step approach to create feature sub-categories under Products.

Thursday, December 6, 2012

My Presentation at the OSGi Community Event 2012

 OSGi Community Event 2012 on "Reducing Complexity with OSGi" was held in Ludwigsburg, Germany between Oct 23-25, 2012. The event was co-located with EclipseCon Europe and it was a great opportunity for me to represent WSO2 and give a technical talk on how we have reduced complexity in building a server platform using OSGi. Here is the slide-deck I used for my talk.