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.



No comments:

Post a Comment