Friday, January 15, 2010

Developing OSGi bundles for WSO2 Carbon using Maven bundle plugin

Even though the title mentions about WSO2 Carbon, the steps that I've explained can be used to develop generic OSGi bundles which are compliant with OSGi R4 specification. WSO2 Carbon is the platform that I am using here to deploy the bundles. WSO2 Carbon is the industry's first SOA middleware platform based on OSGi.

If you read this post till the end, you will understand how to develop OSGi bundles using Maven bundle plugin and deploying them in WSO2 Carbon.

Obviously, the first step is to generate a Maven 2 project. One option is to create from the scratch and the second option is to use the Maven archetype plugin. Since the former is time-consuming, I am using the latter here.

Generate the Maven 2 project

mvn archetype:create -DarchtetypeGroupId=org.apache.maven.archetypes
-DgroupId=org.wso2.carbon -DartifactId=org.wso2.carbon.helloworld

Changes to generated Maven 2 project

  • Make another directory under "src/main/java/org/wso2/carbon/" with the name helloword.
  • Move the App.java file located inside the "src/main/java/org/wso2/carbon/" folder to "src/main/java/org/wso2/carbon/helloworld" folder
  • Replace source of the App.java file with the following.
package org.wso2.carbon.helloworld;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

/**
* Hello world!
*/
public class App implements BundleActivator {

public void start(BundleContext context) throws Exception {
System.out.println("Hello World!");
}

public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!");
}
}

You need to modify the generated pom.xml as well

Please note the changes done in the following pom.xml file. If you are interested in Maven bundle plugin, please refer this article on WSO2 Oxygen tank

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.helloworld</artifactId>
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>org.wso2.carbon.helloworld</name>
<url>http://maven.apache.org</url>

<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.5.0.v20090520</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Activator>org.wso2.carbon.helloworld.App</Bundle-Activator>
<Private-Package>org.wso2.carbon.helloworld</Private-Package>
<Import-Package>org.osgi.framework.*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>


<repositories>
<repository>
<id>wso2-maven2-repository</id>
<name>WSO2 Maven2 Repository</name>
<url>http://dist.wso2.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>
</repositories>

</project>

Building the OSGi bundle.

mvn install

Generated OSGi bundle(org.wso2.carbon.helloworld-1.0.0.jar) is placed in the target folder of the project. Observe the content of the bundle, specially the MANIFEST.MF file. It contains the OSGi manifest headers

Starting WSO2 Carbon

If you have correctly followed above steps, now we are in a position to deploy the generated bundle in WSO2 Carbon. Download the Carbon distribution from the project site. Then unzip the it to a preferred location. Go to the "bin" directory and execute the following command. Here "-DosgiConsole=19443" option is used to allow telnet access to the Equinox OSGi console.

Linux
sh wso2server.sh -DosgiConsole=19443
Windows
wso2server -DosgiConsole=19443

Now in a separate window, execute the following command to access the OSGi console

telnet localhost 19443

Deploying the generated OSGi bundle

Execute the following command to install the bundle into the Carbon instance

osgi> install file:/home/sameera/wso2/testing/maven/archtype/org.wso2.carbon.helloworld/target/org.wso2.carbon.helloworld-1.0.0.jar
Bundle id is 267

Using the given bundle id, now we can start and stop the helloworld bundle

osgi> start 267
Hello World!
osgi> stop 267
Goodbye World!

Are you still following this blog post? Great!!! now you know how to develop and deploy OSGi bundles into WSO2 Carbon.

Friday, November 27, 2009

Apache Asia Roadshow 2009 - Colombo

This will be an amazing opportunity for people who are interested in Open Source and Apache projects. You will also get a first hand experience to most of the popular Apache Projects. Event of this scale was organized in Sri Lanka four year back. But this time it will be bigger and better than before.

If you are not yet registered, better do it now!!

Wednesday, October 14, 2009

It is one of the only times in the history of modern warfare

Just wanted to highlight the following.

The only nation that fits the bill is Sri Lanka. And the reason for that is a ruthless military campaign waged by President Mahinda Rajapaksa against a militarized Tamil death cult known as the Tamil Tigers. This conflict has taken nearly 100,000 lives since it began three decades ago. But Mr. Rajapaksa ended it definitively at one stroke, killing or capturing virtually the entire Tiger leadership. It is one of the only times in the history of modern warfare that a guerrilla/ terrorist movement has been utterly destroyed in such a fashion. Overnight, war became a stranger to Sri Lanka.

Sounds like a pretty good candidate for a "peace" prize, don't you think?

Read more: http://www.nationalpost.com/opinion/story.html?id=2088558&p=1

Sunday, October 11, 2009

WSO2 Carbon 2.0.1 family of products released!!!

WSO2 Carbon team is pleased to announce the release of WSO2 Carbon 2.0.1 and its family of products.
WSO2 Carbon is the base platform for all the above products. Based on OSGi, WSO2 Carbon gives unprecedented flexibility for users to develop customized SOA platforms.

WSO2 Web Services Application Server

WSO2 WSAS is an enterprise ready Web services engine powered by Apache Axis2. It is a lightweight, high performing platform for Service Oriented Architectures, enabling business logic and applications. Bringing together a number of Apache Web services projects, WSO2 WSAS provides a secure, transactional and reliable runtime for deploying and managing Web services.

New Features
  • Various bug fixes & enhancements to Apache Axis2, Apache Rampart, Apache Sandesha2 , WSO2 Carbon & other projects.
  • Equinox P2 based provisioning support to extend your WSAS instance by installin new P2 features. See https://wso2.org/wiki/display/carbon/p2-based-provisioning-support
  • Better integration with application servers such as WebLogic & WebSphere

WSO2 Enterprise Services Bus

WSO2 ESB is a lightweight and easy-to-use Open Source Enterprise Service Bus (ESB) available under the Apache Software License v2.0. WSO2 ESB allows administrators to simply and easily configure message routing, intermediation, transformation, logging, task scheduling, load balancing, failover routing, event brokering, etc.. The runtime has been designed to be completely asynchronous, non-blocking and streaming based on the Apache Synapse core.

WSO2 ESB 2.1.1 is developed on top of the revolutionary Carbon platform (Middleware a' la carte), and is based on the OSGi framework to achieve the better modularity for your SOA architecture. This also contains a lots of new features and many other optional components to customize the behavior of the server. Further, if you do not want any of the built in features, you can uninstall those features without any trouble. In other words, this ESB can be customized to your SOA needs.

New Features
  • This ESB release is based on the award winning WSO2 Carbon "Middleware a' la carte", an OSGi based SOA platform, version 2.0.1 by WSO2 Inc.
  • Rule based mediation via Drools
  • Fine grained autherization for services via the Entitlement mediator
  • Reliable-Messaging specification 1.1 support
  • Enhanced WS-Eventing support and Event Sources making it an even broker
  • Enhanced AJAX based sequence, endpoint and proxy service editors
  • Enhanced transport configuration management through the graphical console
  • Enhanced integrated registry and search functionalities with versionning, notifications, rating of resources, and commenting
  • Enhanced remote registry support
  • Default persistence to the registry for the configuration elements
  • Enhanced permission model with the user management
  • Enhanced REST/GET and other HTTP method support
  • P2 based OSGi feature support, for optional features like service management, runtime governance and so on..
Key Features
  • Proxy services - facilitating synchronous/asynchronous transport, interface (WSDL/Schema/Policy), message format (SOAP 1.1/1.2, POX/REST, Text, Binary), QoS (WS-Addressing/WS-Security/WS-RM) and optimization switching (MTOM/SwA).
  • Non-blocking HTTP/S transports based on Apache HttpCore for ultrafast execution and support for thousands of connections at high concurreny with constant memory usage.
  • Built in Registry/Repository, facilitating dynamic updating and reloading of the configuration and associated resources (e.g. XSLTs, XSD, WSDL, Policies, JS, Configurations ..)
  • Easily extendable via custom Java class (mediator and command)/Spring mediators, or BSF Scripting languages (Javascript, Ruby, Groovy, etc.)
  • Built in support for scheduling tasks using the Quartz scheduler.
  • Load-balancing (with or without sticky sessions)/Fail-over, and clustered Throttling and Caching support
  • WS-Security, WS-Reliable Messaging, Caching & Throttling configurable via (message/operation/service level) WS-Policies
  • Lightweight, XML and Web services centric messaging model
  • Support for industrial standards (Hessian binary web service protocol/ Financial Information eXchange protocol and optional Helth Level-7 protocol)
  • Enhanced support for the VFS(File/FTP/SFTP)/JMS/Mail transports with optional TCP/UDP transports and transport switching for any of the above transports
  • Support for message splitting & aggregation using the EIP and service callouts
  • Database lookup & store support with DBMediators with reusable database connection pools
  • WS-Eventing support with event sources and event brokering
  • Rule based mediation of the messages using the Drools rule engine
  • Transactions support via the JMS transport and Transaction mediator for database mediators
  • Internationalized GUI management console with user/permission management for configuration development and monitoring support with statistics, configurable logging and tracing
  • JMX monitoring support and JMX management capabilities like, Gracefull/Forcefull shutdown/restart

Bug Fixes and Enhancements
  • Endpoint management issues in clustered environments have been fixed (CARBON-5108)
  • Defects in DBReport, DBLookup mediator UIs have been corrected (CARBON-5084)
  • Script mediator UI has been improved to handle some exceptional scenarios (CARBON-5080)
  • XQuery mediator UI has been enhanced to handle some exceptional scenarios (CARBON-5078)
  • ESB management console has been enhanced to work properly on WebLogic application server
  • UI enhancements to support WebSphere application server
  • Sequence management UI has undergone some minor enhancements
  • Enhancements to support front end - back end separation of the server
  • Reported issues related to transaction mediator have been fixed (CARBON-4225)
  • Issues releated to task creation and management have been rectified
  • Many documentation updates and enhancements
WSO2 Governance Registry

WSO2 Governance Registry is a user-friendly, but comprehensive enterprise governance, registry and repository solution available underthe Apache Software License v2.0. It is pre-loaded with best practices to help users with governance adoption.

With the 3.0.1 release, WSO2 Governance Registry is fully integrated to the WSO2 Carbon platform. This allows WSO2 Governance Registry users to benefit from the flexibility and extensibility provided by the Carbon platform.

WSO2 Governance Registry can be either used as a complete product or used in combination with components of other WSO2 products. User specific components, extensions or UIs to the WSO2 Governance Registry can be easily added as Carbon components. We are striving for a simple and happy first time user experience as well as a satisfying experienced user experience with this release.

New Features
  • Improved transaction support.
  • Improved Support for deploying on top of WebSphere, WebLogic, and JBoss.
  • P2 based provisioning for WSO2 Carbon family of products.
  • Support for clustering.
  • Numerous bug fixes.
Key Features
  • Intuitive User Interface with an Ajax-based Web 2.0 interface
  • Dependency management - maintain relationships between dependent resources for impact analysis
  • Managing users and roles
  • Authentication and authorization on all resources and actions
  • Activity log and monitoring with filtering support for the activity logs
  • Subscribe to resources, collections, comments, tags, etc. with any standard feed reader (Bloglines, Google Reader, etc)
  • Storing and managing arbitrary resources and collections
  • Tagging, commenting and rating
  • Resource / collection versioning and rollback
  • Advanced search capabilities - tags, users, etc.
  • Built in media type support for common types (WSDL, XSD)
  • Pluggable media type handlers for handling custom media types
  • Atom Publishing Protocol (APP) support for reading/writing the data store remotely
  • Java client for remote access via APP
  • Based on the OSGi based WSO2 Carbon architecture. This is a unification of all Java based products from WSO2.
  • Advanced service governance through, discovery, impact analysis, versioning and automatically extraction of service meta data
  • Dashboard support with gadgets with design-time and run-time governance information
  • Advanced Life cycle management with checklists.
  • Validation policies. e.g. WSDL Validation, WS-I Validation and Schema Validation
  • Eventing and notifications
  • Supports remote links, symbolic links for resources
  • Attach remote WSO2 Governance Registry instances, providing oneinterface for many WSO2 Governance Registry instances
  • Support for processing custom URL patterns via pluggable URL handlers
  • Support for custom query languages via pluggable query processors
  • Import/export resources and collections
  • Enhanced admin UI
WSO2 Identity Server

WSO2 Identity Server is an open source identity and entitlement management server having Information Cards, OpenID and XACML support.

New Features
  • SAML 2.0 Token Profile support
  • Passive STS
  • Equinox P2 based provisioning support
  • Improved Support for deploying on top of WebSphere, WebLogic, and JBoss.
  • Various bug fixes and enhancements including architectural improvements to Apache Axis2, Apache Rampart, Apache Sandesha2, WSO2 Carbon and other projects
Key Features
  • Entitlement Engine with XACML 2.0 support.
  • Claim based Security Token Service.
  • Extension points for SAML assertion handling.
  • OpenID Provider
  • Information Card Provider
WSO2 Mashup Server

"Create, deploy, and consume Web services Mashups in the simplest fashion."

The WSO2 Mashup Server is a powerful yet simple and quick way to tailor Web-based information to the personal needs of individuals and organizations. It is a platform for acquiring data from a variety of sources including Web Services, HTML pages, feeds and data sources, and process and combine it with other data using JavaScript with E4X XML extensions. The result is then exposed as a new Web service with rich metadata and artifacts to simplify the creation of rich user interfaces.

Key Features
  • Hosting of mashup services written using JavaScript with E4X XML extension
  • - Simple file based deployment model
  • JavaScript annotations to configure the deployed services
  • Auto generation of metadata and runtime resources for the deployed mashups
  • - JavaScript stubs that simplify client access to the mashup service
  • - Code templates for developing rich HTML or Google Gadget interfaces
  • - TryIt functionality to invoke the mashup service through a web browser
  • - WSDL 1.1/WSDL 2.0/XSD documents to describe the mashup service
  • - API documentation
  • Ability to bundle a custom user interface for the mashups
  • Many useful Javascript Host objects that can be used when writing mashups
  • - WSRequest: invoke Web services from mashup services
  • - File: File storage/manipulation functionality
  • - System: Set of system specific utility functions
  • - Session: Ability to share objects across different service invocations
  • - Scraper: Extract data from HTML pages and present in XML format
  • - APPClient: Atom Publishing Protocol client to retrieve/publish Atom
  • feeds with APP servers
  • - Feed: A generic set of host objects to transparently read and create
  • Atom and RSS feeds
  • - Request: Ability get information regarding a request received
  • Support for recurring and longer-running tasks
  • Support for service lifecycles
  • Ability to secure hosted mashups using a set of commonly used security scenarios
  • Management console to easily manage the mashups
New Features
  • The 2.0 version of the Mashup Server is built on top of the Award Winning WSO2 Carbon Platform. All the major features have been developed as pluggable Carbon components.

How to run WSO2 Carbon family of products

  1. Extract the downloaded zip
  2. Go to the bin directory in the extracted folder
  3. Run the wso2server.sh or wso2server.bat as appropriate
  4. Point your browser to the URL https://localhost:9443/carbon
  5. Use "admin", "admin" as the username and password to login as an admin
  6. If you need to start the OSGi console with the server use the property -DosgiConsole when starting the server. The INSTALL.txt file found on the installation directory will give you a comprehensive set of options and properties that can be passed into the startup script
Mailing Lists

Join our mailing lists and correspond with the developers directly.

http://wso2.org/mail

Reporting Issues

WSO2 encourages you to report issues and your enhancement requests for the WSO2 Carbon family of products using the public Carbon JIRA. You can also watch how they are resolved, and comment on the progress..

http://wso2.org/jira/browse/CARBON

Training

WSO2 Inc. offers a variety of professional Training Programs, including training on general Web services as well as WSO2 Carbon family of Products, Apache Synapse, Apache Axis2 and number of other products.

For additional support information please refer to http://wso2.com/training

Support

WSO2 Inc. offers a variety of development and production support programs, ranging from Web-based support up through normal business hours, to premium 24x7 phone support.

For additional support information please refer to http://wso2.com/support/

For more information, visit the WSO2 Oxygen Tank (http://wso2.org)

We welcome your feedback on this implementation. Thank you for your interest in WSO2 Carbon.




Thursday, September 24, 2009

How to make/create OSGi bundles using Maven Bundle Plugin

I wrote a tutorial explaining how to make OSGi bundles using Maven Bundle plugin. The flow of the tutorial is organized as follows.

First section describes how to develop a simple bundle which just print "Hello World!" and "Goodbye World!" When starting and stopping the bundle. Rest of the tutorial focuses on sharing and hiding packages. Those sections covers the Export-package, Import-Package, Private-Package and DynamicImport-Package instructions with enough examples.

You can read the tutorial here.

How to start Carbon based products with the OSGi console enabled

WSO2 Carbon is the heart of all WSO2 Java products. Based on OSGi technology, WSO2 Carbon provides a fully componentized service oriented architecture(SOA) platform. WSO2 WSAS, WSO2 ESB, WSO2 IS and WSO2 G-REG are some of the Carbon based products. Lets look at how you can start a Carbon based product with the OSGi console enabled.

You might wonder, why you ever need the OSGi console. Carbon is developed on top of OSGi technology, hence all you can find in a Carbon based product is a set of bundles plus some configuration files. Here are some advantages of having access to the OSGi console.
  1. List, install, uninstall, update, start and stop bundles.
  2. List OSGi services.
  3. Get the details of bundles such as exported or imported packages
  4. Troubleshoot the Carbon based products.
  5. Administrate the Carbon based products such as restart, shutdown and switch the server to the maintenance mode, etc..
  6. Provision Carbon based products. i.e, install, update and uninstall features using Equinox P2.
Carbon based products can be used in two different modes. One is the standalone mode. It can also be used as a webapp in an application server such as Apache Tomcat.

If you haven't downloaded any of the carbon based products, now it is time for it. Please visit here and download the product of your interest. I am using the WSAS distribution for demonstration purposes. $CARBON_HOME refers to the folder you get, when you unzip the download distribution. For an example, $CARBON_HOME=/home/userX/wso2wsas-3.3.1/

1) How to enable OSGi console when Carbon runs as a webapp in an application server

Step 01:
First you need to deploy Carbon webapp in the application server. You can refer documents available in the WSO2 OxygenTank for this purpose.

Step 02:
Uncomment the following lines in the web.xml of the Carbon webapp.

<init-param>
<param-name>osgiConsole</param-name>
<param-value>-console 19444</param-value>
</init-param>

Step 03:
Now start your application server.

Step 04:
Access the OSGi console, by executing the following command. You will be able to see the OSGi console.

telnet localhost 19444

2) How to enable OSGi console when Carbon runs in the standalone mode.

Step 01:
Go to the bin/ directory in the unzipped Carbon distribution.

Step 02:
Start the Carbon server with the "-DosgiConsole" option. If you specify "-DosgiConsole=19443" you will be able access the console using telnet.

For linux users : sh wso2server.sh -DosgiConsole
For Windows users : wso2server.bat -DosgiConsole

Sunday, September 6, 2009

SOA Workshop on Colombo, Sri Lanka

Are you ready to get beyond the hype surrounding Service Oriented Architecture, and learn how to actually implement a real SOA solution?

Then this workshop is the right solution for you. For more information please visit here.