Upload
wso2
View
1.284
Download
3
Embed Size (px)
DESCRIPTION
Citation preview
How to build a custom stack with WSO2 Carbon
Shameera RatnayakaSoftware Engineer
Manoj KumaraSoftware Engineer
Topics● The feature/component concept in the WSO2 Carbon
platform.
● Installing features using the Feature Manager.
● How to create your custom products for cluster wide
deployment.
● Scripting feature installations for automation.
● Configuring logs/adding configs/etc.
What is Carbon
Carbon is a modular server runtime based on OSGi Built on top of Carbon are a set of middleware servers (App Server, ESB, Identity, API Manager, etc)
Re-configurable» Install new features, uninstall, revert
Carbon includes a set of re-usable core components● Clustering, User Management, Logging, JMX, ...
WSO2 Carbon based Products
Features• Service Management Feature• Proxy Services Features• Transport Management Feature, etc..
What is a Feature
In Eclipse world– Feature is a grouping of set of logically related plug-ins/ OSGi bundles– Feature can be installed into Eclipse platform using its Update Manager
In Carbon world– Feature can be thought of as an installable form of one or more logically related Carbon component• Service Management Component– What you develop
• Service Management Feature– What you install
– Feature is a grouping of one or more logically related Carbon components– Features can be installed into Carbon based product using Feature Manager
Features
Allows you to specify pre-requisites of your Carbon component.– Other dependent features, bundles.– Dependency Management.• Are installable Units which can be installed into any Carbon based product.• Can be installed using the WSO2 Carbon Feature Manager or by using a script• Can be shared with others by packaging features as a Repository (Update Site in eclipse terms).
What is a Carbon Component● A set of OSGi Bundles.
● Lives in the Carbon Framework. Hence should conform to rules define in the Carbon Framework.
● Uses Core Carbon Services○ Via OSGI service registry
e.g. Registry Service, UserManager Service, etc
● Two aspects/ BE-FE Separation○ Every component has a core runtime, a clean SOA management interface, a
well-defined front-end console component○ Back-end Runtime○ Front-end Console
Equinox P2
● A provision platform for OSGi based systems.● p2 stands for “Provisioning Platform”● Provides a well defined model for provisioning OSGi
bundles ● p2 allows us to manage components in a controlled
manner● Install, Uninstall, Revert● Based on a web or file based repository
○ Can be hosted internally for an organization
● Three approaches:○ Command line ○ Web console○ Secure remote API
Carbon Component: Development Process
1. Develop the Carbon component○ Back-end component (BE OSGi bundles)○ Front-end component (FE OSGi bundles)○ Common bundles, if any
2. Develop the corresponding feature○ BE/Server Feature○ FE/UI Feature○ Composite Feature
3. Install into a Carbon based product○ By integrating with the product build system○ By developing a feature repository and installing using Feature
Manage
Eclipse p2
● Manages the packaging of OSGi bundles into features
● Supports deploying, undeploying, checkpoints
● Advanced features include shared repositories
Student Manager Component
Lets develop a sample Carbon component to understand the development process as well as the build process.• Student Manager component
○ Consists of a BE runtime which exposes a Web services to • Add new students• Get the list of students
○ Consist of a FE console which displays the available student information on the Carbon management console.
• Student Manager Feature○ org.wso2.carbon.student.mgt.server.feature○ org.wso2.carbon.student.mgt.ui.feature○ org.wso2.carbon.student.mgt.feature
Developing the BE Component
● Some actual server logic plus an admin service to manage it
● Add some special sauce into the services.xml to let us know it’s an admin service
● component.xml configures permissions
We use Maven as our build tool.• Building Carbon components/OSGi bundles– Use Maven Bundle plugin to build OSGi bundles
https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.1.0/core/org.wso2.carbon.core/4.1.0/pom.xml
• Building Features– Use Maven P2 Feature plugin (Developed at WSO2)– Use p2-feature-gen goal
https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.1.0/features/org.wso2.carbon.core.feature/4.1.0/pom.xml
• Building a Repository– Use Maven P2 plugin– P2-repo-generator goal
https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.1.0/features/pom.xml
Carbon Component: Build Process
Acquiring a OSGi service declaratively /** * @scr.component name="org.wso2.carbon.student.mgt" immediate="true" * @scr.reference name="registry.service" interface="org.wso2.carbon.registry.core.service.RegistryService" * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" */public class StudentRegistryService {
public static RegistryService registryService;
protected void setRegistryService(RegistryService registryService) { StudentRegistryService.registryService = registryService;
}protected void unsetRegistryService(RegistryService registryService) {
StudentRegistryService.registryService = null;}
}
Install features in build time
- Why? - can we do this with feature manager UI?- Then how we do that?- Carbon-p2 maven plugin
- Generate p2 repository- Install feature
Configuration files
- axis2.xml- carbon.xml- master-datasources.xml- authenticators.xml- registry.xml- cache.xml- user-mgt.xml- log4j.properties- .......
Add and Edit Configurationsconf├── axis2│ ├── axis2_client.xml│ ├── axis2.xml│ └── tenant-axis2.xml├── carbon.xml├── datasources│ └── master-datasources.xml├── etc│ ├── cache.xml├── log4j.properties├── registry.xml├── security│ ├── authenticators.xml├── tomcat│ ├── carbon│ │ ├── META-INF│ │ │ └── context.xml│ │ └── web.xml│ ├── catalina-server.xml│ ├── tomcat-users.xml│ └── web.xml└── user-mgt.xml