Showing posts with label Dev Knowledge. Show all posts
Showing posts with label Dev Knowledge. Show all posts

Thursday, July 25, 2013

REST API Design Rules

Found REST API Design Rulebook to be a useful guideline in designing REST APIs, and it's short n sweet with only 144 pages.



It has dished out a set of clear rules that are practical and easy to follow. Here is a summarized list of all the rules given in the book.

Identifier Design with URIs

URI Format
Rule: Forward slash separator (/) must be used to indicate a hierarchical relationship
Rule: A trailing forward slash (/) should not be included in URIs
Rule: Hyphens (-) should be used to improve the readability of URIs
Rule: Underscores (_) should not be used in URIs
Rule: Lowercase letters should be preferred in URI paths
Rule: File extensions should not be included in URIs

URI Authority Design
Rule: Consistent subdomain names should be used for your APIs
Rule: Consistent subdomain names should be used for your client developer portal

URI Path Design
Rule: A singular noun should be used for document names
Rule: A plural noun should be used for collection names
Rule: A plural noun should be used for store names
Rule: A verb or verb phrase should be used for controller names
Rule: Variable path segments may be substituted with identity-based values
Rule: CRUD function names should not be used in URIs

URI Query Design
Rule: The query component of a URI may be used to filter collections or stores
Rule: The query component of a URI should be used to paginate collection or store results

Interaction Design with HTTP

Request Methods
Rule: GET and POST must not be used to tunnel other request methods
Rule: GET must be used to retrieve a representation of a resource
Rule: HEAD should be used to retrieve response headers
Rule: PUT must be used to both insert and update a stored resource
Rule: PUT must be used to update mutable resources
Rule: POST must be used to create a new resource in a collection
Rule: POST must be used to execute controllers
Rule: DELETE must be used to remove a resource from its parent
Rule: OPTIONS should be used to retrieve metadata that describes a resource’s available interactions

Response Status Codes
Rule: 200 (“OK”) should be used to indicate nonspecific success
Rule: 200 (“OK”) must not be used to communicate errors in the response body
Rule: 201 (“Created”) must be used to indicate successful resource creation
Rule: 202 (“Accepted”) must be used to indicate successful start of an asynchronous action
Rule: 204 (“No Content”) should be used when the response body is intentionally empty
Rule: 301 (“Moved Permanently”) should be used to relocate resources
Rule: 302 (“Found”) should not be used
Rule: 303 (“See Other”) should be used to refer the client to a different URI
Rule: 304 (“Not Modified”) should be used to preserve bandwidth
Rule: 307 (“Temporary Redirect”) should be used to tell clients to resubmit the request to another URI
Rule: 400 (“Bad Request”) may be used to indicate nonspecific failure
Rule: 401 (“Unauthorized”) must be used when there is a problem with the client’s credentials
Rule: 403 (“Forbidden”) should be used to forbid access regardless of authorization state
Rule: 404 (“Not Found”) must be used when a client’s URI cannot be mapped to a resource
Rule: 405 (“Method Not Allowed”) must be used when the HTTP method is not supported
Rule: 406 (“Not Acceptable”) must be used when the requested media type cannot be served
Rule: 409 (“Conflict”) should be used to indicate a violation of resource state
Rule: 412 (“Precondition Failed”) should be used to support conditional operations
Rule: 415 (“Unsupported Media Type”) must be used when the media type of a request’s payload cannot be processed
Rule: 500 (“Internal Server Error”) should be used to indicate API malfunction

Metadata Design

HTTP Headers
Rule: Content-Type must be used
Rule: Content-Length should be used
Rule: Last-Modified should be used in responses
Rule: ETag should be used in responses
Rule: Stores must support conditional PUT requests
Rule: Location must be used to specify the URI of a newly created resource
Rule: Cache-Control, Expires, and Date response headers should be used to encourage caching
Rule: Cache-Control, Expires, and Pragma response headers may be used to discourage caching
Rule: Caching should be encouraged
Rule: Expiration caching headers should be used with 200 (“OK”) responses
Rule: Expiration caching headers may optionally be used with 3xx and 4xx responses
Rule: Custom HTTP headers must not be used to change the behavior of HTTP methods

Media Type Design
Rule: Application-specific media types should be used
Rule: Media type negotiation should be supported when multiple representations are available
Rule: Media type selection using a query parameter may be supported

Representation Design

Message Body Format
Rule: JSON should be supported for resource representation
Rule: JSON must be well-formed
Rule: XML and other formats may optionally be used for resource representation
Rule: Additional envelopes must not be created

Hypermedia Representation
Rule: A consistent form should be used to represent links
Rule: A consistent form should be used to represent link relations
Rule: A consistent form should be used to advertise links
Rule: A self link should be included in response message body representations
Rule: Minimize the number of advertised “entry point” API URIs
Rule: Links should be used to advertise a resource’s available actions in a state-sensitive manner

Media Type Representation
Rule: A consistent form should be used to represent media type formats
Rule: A consistent form should be used to represent media type schemas

Error Representation
Rule: A consistent form should be used to represent errors
Rule: A consistent form should be used to represent error responses
Rule: Consistent error types should be used for common error conditions

Client Concerns

Versioning
Rule: New URIs should be used to introduce new concepts
Rule: Schemas should be used to manage representational form versions
Rule: Entity tags should be used to manage representational state versions

Security
Rule: OAuth may be used to protect resources
Rule: API management solutions may be used to protect resources

Response Representation Composition
Rule: The query component of a URI should be used to support partial responses
Rule: The query component of a URI should be used to embed linked resources

JavaScript Clients
Rule: JSONP should be supported to provide multi-origin read access from JavaScript
Rule: CORS should be supported to provide multi-origin read/write access from JavaScript

Tuesday, July 16, 2013

Fuse ESB Demo Code

Fuse ESB Enterprise documentation is making use of demonstration code to illustrate the capabilities of the system. Explanations are not very clear to follow without the code, but unfortunately the code is for subscribers only.

Downloading the demonstration package

The source code for the demonstrations is packaged as a Zip file, cxf-webinars-assembly-1.1.1-src.zip, and is available from the following location:
http://repo.fusesource.com/nexus/content/repositories/subscriber/org/fusesource/sparks/fuse-
webinars/cxf-webinars-assembly/1.1.1

When you try to navigate to this location with your browser, you will be prompted for a username and password. Enter your subscription login credentials to gain access to this directory and click on cxf-webinars-assembly-1.1.1-src.zip to start downloading.

Did a little Googling to see if any generous developer has shared the code, and look what we found!

The actual git repository they use for storing these projects is not restricted.

http://fusesource.com/forge/git/sparks.git/?p=sparks.git;a=tree

It's not possible to clone it, since it requires authentication. But can click on the snapshot  (http://fusesource.com/forge/git/sparks.git/?p=sparks.git;a=snapshot;h=HEAD;sf=tgz) and the entire lot is downloaded.

Wednesday, July 10, 2013

Frequently Used Linux Commands

For my easy reference,

find . -name *.jar | xargs grep -i 'ABC.class'
# Find a jar file which has ABC.class in it

printenv
# Environment variables

printenv | grep proxy
# Environment variables with proxy in name

export https_proxy=http://x.x.x.x:3128
# Set environment variable

sudo su
# Login as super user

rm -rf folderToDelete
# Delete the folder and the contents

netstat -anp|grep :7001
# Find a process binding a port

kill -9 21286
# Kill process

telnet hostA 1521
# Telnet a port

nslookup hostA
# 

uname -a
# kernel-name, nodename, processor, OS etc

lsb_release -a
# OS version

cat /etc/*release 
# OS version

df -h
# file system sizes & free space

du -s folderloc
# folder size

du --si -s file 
# File size shown in G,M

ssh root@serverA
# Connect to serverA as root

scp root@serverA.abc.com:/path/a.log b.log
# Copy a file from serverA

scp -r /path/folderA  userB@serverB:/path/folderB
# Copy a folder to serverB

tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.

tar -xf archive.tar
# Extract all files from archive.tar.

vpnc-connect
# VPN connect

date
# Current date

date +%T -s "15:22:13"
# Update time

split --bytes=50m largeFile.log splitFile_
# Split a file to files with 50m


Common Options

-f, --force
-r, -R, --recursive
-a, --all
-v, --verbose
--help
--version

SOAP vs REST


SOAP REST
Simple Object Access Protocol REpresentational State Transfer
XML based messaging protocol Architectural style
JAX-WS JAX-RS
XML JSON, XML, plain text etc
RPC URL path
Binary data that is sent must be encoded Binary data can simply be delivered
Standard specification No standard specification
Exposes operations that represent logic Exposes resources that represent data

Tuesday, July 9, 2013

Camel Route: Quering Oracle DB


camel-context.xml





 
  
   
   
    Select * from ACCOUNT
   
   
   
  
 

 
  
  
  
  
 

 



pom.xml



  
  
   org.apache.camel
   camel-core
   2.10.0.redhat-60024
  

  
   org.apache.camel
   camel-spring
   2.10.0.redhat-60024
  

  
   org.apache.camel
   camel-jdbc
   2.10.0.redhat-60024
  

  
    org.springframework
    spring-jdbc
    3.1.0.RELEASE
   

   
    com.oracle
    ojdbc6
   11.2.0
   

  


Following dependency issued were encountered when implementing the above.

java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSource 

Adding spring-jdbc jar was the solution, but the question was which version.


org.springframework
spring-jdbc
x.x.x


Tried 1.2.9, 2.0.1, 2.5.6. All gave the following error.

[ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:2.10.0.redhat-60024:run (default-cli) on project poc-database: null: MojoExecutionException: org/springframework/core/env/EnvironmentCapable: org.springframework.core.env.EnvironmentCapable -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

Running with -e switch revealed the following error.


Caused by: java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable

This class was found in 3.x versions of spring-jdbc. Tried with 3.1.0.RELEASE, and it gave the following error.

[ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:2.10.0.redhat-60024:run (default-cli) on project poc-database: null: MojoExecutionException: InvocationTargetException: Error creating bean with name 'dataSource' defined in URL [file:/home/kl40306/SAM6/Fuse_POC/workspace/poc-database/src/main/resources/META-INF/spring/DatabaseSample.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClass' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'driverClass' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? -> [Help 1]
[ERROR]

The reason is the attribute which was "driverClass" is now "driverClassName" in DriverManagerDataSource.

After fixing the above, following error came up.

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

Needed to add Oracle maven dependency.


   com.oracle
   ojdbc6
   11.2.0
  

This is not downloaded automatically from maven repositories. Need to install manually.

Download the jar and run

mvn install:install-file -Dfile=/path_to_jar/ojdbc.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar


Friday, June 28, 2013

SVN Commands

For my own reference :)
  • svn co svnLocation
  • svn add  dirLocation
  • svn commit dirLocation
  • svn status
  • svn info
  • svn log
  • svn log --stop-on-copy
  • svn diff -r 125:HEAD --summarize
  • svn mkdir -m "Create Dir"  svnLocation
  • svn delete svnLocation
  • svn revert -R dirLocation
  • svn copy svnLocationTrunk svnLocationBranch -m "Creating a new branch."
  • svn merge -r 5:10 svnLocationTrunk --non-interactive

Thursday, June 20, 2013

Fuse ESB 123


Download Fuse ESB from http://www.jboss.org/products/fuse 

Create a Web Services (WS) Project
mkdir get-started
cd get-started
mvn archetype:generate -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-cxf-code-first-osgi-bundle -DgroupId=org.fusesource.example -DartifactId=cxf-basic -Dversion=1.0-SNAPSHOT
Create project
cd cxf-basic/
mvn install
Build project
cd ESBInstallDir/bin
./fuse
Start Fuse ESB
karaf@root> install mvn:org.fusesource.example/cxf-basic/1.0-SNAPSHOT Install the WS as an OSGi bundle
karaf@root> start 229 Start the WS with bundle id returned from previous step.
karaf@root> list Check if the bundle has started
cd get-started/cxf-basic
mvn -Pclient
Run the WS client

Monday, May 20, 2013

BPMN 2.0 : Business Process Model and Notation

The BPMN 2.0 standard specification was formally released in January 2011. This specification is the result of collaboration between companies such as Oracle, IBM, Red Hat, Intalio, and many others within the Object Management Group, to conform  a unified language to model and execute business processes.

The specification aims to reduce/eliminate the gap between technical business process representations and the fact that a lot of business analysts use flow chart representations to define how a company works. This gap can be eliminated using a standardized mapping between the visual notation of the business process and the execution semantic of the model. A business processes modeled using the BPMN notation defines the flow of data and the association of the data artifacts to business activities.

BPMN2 covers more than just the notation that needs to be used to draw our business processes, and the complete specification is divided into four sections that allow different vendors to be compliant with one or more of these four conformance types:
  • Process Modeling
  • Process Execution
  • Collaboration Modeling
  • Choreography Modeling 
e.g: A diagram that conforms to process modeling notation is shown below.

Friday, May 10, 2013

Error: type doesn't support the "osfamily" attribute

Above error can come when executing an ant target. This happens because ant versions older than 1.7 do not support osfamily.

Solve it by,
1. If you're using a older ant version, replace 'osfamily' attribute in exec tasks with 'os' in your build file.
or
2. If you're using ant 1.7, see if an older version of jar is getting picked up. If you have a certain jar earlier in the classpath which has ant dependencies, it might load an older version. Move such jars to the bottom of the classpath.

Thursday, May 9, 2013

MongoDB



If you're interested in learning MongoDB check this out.

It's a free on-line course hosted by the MongoDB company itself.

https://education.10gen.com

Quoting their about us page;

10gen Education is an online learning platform run by 10gen (the MongoDB company) available to anyone in the world with an internet connection. Our free courses will teach you how to develop for and administer MongoDB quickly and efficiently.

Frequent assessments help you verify your understanding, and at the end of a course, you'll receive a certificate of completion from 10gen. You'll also become a member of 10gen's community of cutting-edge NoSQL technologists. Over time, we'll be adding classes on schema design, advanced scaling and replication, and other topics, so check back often!

10gen's education platform was developed under a collaboration with edX, the not-for-profit consortium between MIT, Harvard and Berkeley.

I18n = Internationalization

I18n stands for "Internationalization"


The story goes as follows (as sited in Internet):
A DEC employee named Jan Scherpenhuizen was given an email account of S12n by a system administrator, since his name was too long to be an account name. This approach to abbreviating long names was intended to be humorous and became generalized at DEC. The convention was applied to "internationalization" at DEC which was using the numeronym by 1985.

Drools

Rule engines provide us a declarative language to express our rules, in contrast to the imperative nature of languages. Java, C, PHP, Python, and Cobol are imperative languages, meaning that they follow the instructions that we give them, one after the other.

Using Drools Rule Language(DRL) we specify situations that are evaluated by the rule engine. Each rule defines a situation. A rule has two sections,

conditional section => Starts when 'when' keyword
consequence section => Starts when 'then' keyword

A rule that is activated is said to be eligible to be fired.

In the rule consequence, you can write any Java code you want. This code will be executed as regular Java code.

Rule engine doesn't care about the order of the rules that we provide; it will analyze them by their conditional sections

rule "enabled to drive must have a car"
When
$p: Person( enabledToDrive == true )
not(Car(person == $p))
then
insert(new Car($p));
end

rule "person with new car must be happy"
when
$p: Person()
$c: Car(person == $p)
then
$p.setHappy(true);
end

Wednesday, May 8, 2013

Technical/IT Product Evaluation Criteria

We've been doing a couple of technology/product evaluations recently. Following is a list of useful evaluation criteria that can be considered generally for any kind of product evaluation.
  • Adherence to standards
  • Latest version
  • Resource monitoring
  • Optimization tools and capabilities
  • Testing/Debug capabilities
  • Integration with external systems
  • Integration with frameworks
  • Server/OS compatibility
  • Performance
  • Community (developer and user)
  • Product Support
  • Pricing\Product Model
  • License (tricky restrictions?)
  • Clients
  • Maturity
  • Ratings by independent product evaluators (Forrester, Gartner etc)
  • Road-map
  • Stability
  • Documentation
  • Usage of proprietary technology (Risk of vendor lock-in)
  • Expert Availability
  • Security Criteria
  • Deployment Methods
  • Light weight vs feature rich

Competition for Best Open Source ESB!!

A long story in a nutshell...


We were asked to find out the best open source ESB to be used for a new product our company is designing.

Step 1
Found the key players we need to evaluate. We looked at industry standard ESB evaluations, latest Forrester and Gartner reports.

 


The Forrester ESB Evaluation -2011

 
Gartner Magic Quadrant for SOA Infrastructure Projects - 2012

 Short listed candidates,
  • Fuse ESB
  • Mule ESB
  • WSO2 ESB (A Sri Lankan company made it! wow)
  
Step 2
Decided on evaluation criteria based on the product requirement.


1
Support multiple protocols
2
Dynamic configuration
3
Dynamic Integration of multiple components
4
Hot deployment
5
Retry mechanism
6
Service pooling
7
Dynamic content based routing
8
Flexible service coordination
9
Expose multiple services as a  single service
10
Web based UI components
11
Message transformation
12
Embedding the ESB runtime in a Java application


Step 3
Evaluated the short listed products against the criteria.

Evaluation details are bit too lengthy and techi for a simple blog post.

WSO2 ESB which claimed to be great in performance, which was even selected by eBay for their platform (case study available on net), had to be rejected because they did not recommend hot deployment which we really wanted.

FuseESB which scored great against all the evaluation criteria was chosen without much debate. Being based on Apache Camel was a big plus point.

Friday, April 19, 2013

What is hot?

There is an ocean of programming languages out there that can drown any software engineer. Having worked only in java and OOP, I honestly don't think I'm even qualified to call myself a software developer! Have touched upon several languages time to time, (read a little and coded a little) but that's not at all sufficient to say I have several baskets to put my eggs in.

As a first step in finding more baskets (other than the Java n OOP basket), I thought why not find out the most popular programming languages these days. Who knows, I might even step on a gold mine.

Wikipedia listed several indices I can use to find out what's hot.
  • TIOBE Programming Community Index 
  • Language Popularity Index
  • PYPL PopularitY of Programming Language
  • RedMonk Programming Language Rankings
-----------------------------------------------------------------------------------------------------------------------------------

TIOBE Programming Community Index for April 2013
The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. The popular search engines Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings.

Language Popularity Index
The Language Popularity Index tool is a fully automatic, transparent, open-source and free tool to measure the popularity of programming languages on the Internet.


PYPL PopularitY of Programming Language index
The PYPL PopularitY of Programming Language index  is created by analyzing how often language tutorials are searched on Google : the more a specific language tutorial is searched, the more popular the language is assumed to be.


The RedMonk Programming Language Rankings: January 2013
Derived from a correlation of programming traction on GitHub (usage) and Stack Overflow 

Thursday, March 21, 2013

Birth of Ruby on Rails

37 Signals began as a Web design consulting firm and branched out into software development at first simply to meet its own needs. It built some internal tools to manage projects. Then it needed a way to communicate with clients, so it opened up parts of its system to them. Before they knew it, they had the makings of a Web-based application.

With four months more work, they turned their software into a service called Basecamp. Launched in February 2004, it quickly became a leader in the parade of new, rich, Web-based applications like Google's Gmail and Flickr.

37 Signals had only one developer, a young whiz named David Heinemeyer Hanssonk. He was keen on working with Ruby, a dynamic object-oriented programming language.

37 Signals set out to create some small programs, not to build an ambitious new platform or application framework. But in the course of building Basecamp, Hansson had written some useful and innovative code that streamlined and simplified the basic chores that all Web applications had to perform in the course of storing and retrieving data. After Basecamp's launch, he and 37 Signals decided to take that work and release it as an open source platform called Ruby on Rails.

Rails, as it came to be called,made writing Web applications easier, in part by limiting the programmer's options. "Flexibility is overrated. Constraints are liberating," Hansson says.

Rails was ready-made for the AJAX-style interface enhancements that were making those Web-based programs credible competition to their desktop equivalents.

- Summarized from 
Dreaming in code : two dozen programmers, three years, 4,732 bugs, and one quest for transcendent software by Scott Rosenberg.

Friday, March 8, 2013

Maven on Ubuntu

Install:   sudo apt-get install maven
Verify:    mvn -version

The command apt-get, install the Maven in /usr/share/maven.

maven2/conf/settings.xml

Configure a proxy in settings.xml
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>_internal proxy address_</host>
      <port>_proxy port_</port>
      <username>{your_proxyuser}</username>
      <password>{your_proxypassword}</password>
    </proxy>
  </proxies>


Install a jar manually
mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging= -DgeneratePom=true

Example
mvn install:install-file -Dfile=/home/kl40306/Desktop/jars/camel-http-2.10.0.fuse-71-047.jar -DgroupId=org.apache.camel -DartifactId=camel-http -Dversion=2.10.0.fuse-71-047 -Dpackaging=jar -DgeneratePom=true

Monday, March 4, 2013

Differentiating between ESB implementations

Most ESB implementations provide all of the services that are used to define an ESB, so it is hard to differentiate ESB implementations based on features. A better way to differentiate between them is to use the following four measures.

Supported deployment / runtime environments
Many ESB solutions are designed to be deployed into application servers, other heavy weight containers, or proprietary runtime environments. These types of ESB solution is ideal for distributed computing. They also contribute to vendor lock-in.
Ideally, an ESB solution should have flexible deployment requirements so that it can be distributed through out an enterprise.

Container/component model
Does the ESB solution use a standardized container model, such as J2EE, JBI, or OSGi, for managing deployed services? Or does it use a proprietary model?
Ideally, an ESB solution should use a standardized container model. Standard models ensure maximum compatibility and lessen the learning curve needed for adoption.

Coupling to other infrastructure components
ESB solutions often leave out infrastructure components like orchestration engines and advanced transports like CORBA. Instead they rely on plug-ins or other components to provided the functionality. Many ESB solutions require a tight coupling between the ESB and the added components. This means that you are limited to only using the added components supplied by the ESB vendor or must learn complex APIs to extend the ESB yourself.
Ideally, an ESB solution would provide a loose coupling or provide a standardized interface between the ESB and any added components. This allows the ESB to be extended easily and in a flexible manner.

Dependencies

ESB solutions have a lot of moving parts and complex dependencies. Some ESB solutions handle these dependencies by locking themselves into using proprietary solutions for things like security or JMS implementations. Others rely on standardized implementations as much as possible.
Ideally, an ESB solution would only depend on widely available standardized libraries to make dependencies easy to manage.

-Fuse ESB Getting Started with Fuse ESB Version 4.3.1

Sunday, March 3, 2013

What is OSGi?

It’s a modularity layer for the Java platform. Modularity refers to the logical decomposition of a large system into smaller collaborating pieces.

Nearly all but the simplest of applications can benefit from the modularity features OSGi provides.

Common scenarios where OSGi can be helpful
  • ClassNotFoundExceptions when starting your application because the class path wasn’t correct. OSGi can help by ensuring that code dependencies are satisfied before allowing the code to execute.
  • Execution-time errors from your application due to the wrong version of a dependent library on the class path. OSGi verifies that the set of dependencies are consistent with respect to required versions and other constraints.
  • Type inconsistencies when sharing classes among modules: put more concretely, the dreaded appearance of foo instanceof Foo == false. With OSGi, you don’t have to worry about the constraints implied by hierarchical class-loading schemes.
  • Packaging an application as logically independent JAR files and deploying only those pieces you need for a given installation. This pretty much describes the purpose of OSGi.
  • Packaging an application as logically independent JAR files, declaring which code is accessible from each JAR file, and having this visibility enforced. OSGi enables a new level of code visibility for JAR files that allows you to specify what is and what isn’t visible externally.
  • Defining an extensibility mechanism for an application, like a plugin mechanism. OSGi modularity is particularly suited to providing a powerful extensibility mechanism, including support for execution-time dynamism.

The OSGi Service Platform is composed of two parts:
  • OSGi framework
  • OSGi standard services

The framework is the runtime that implements and provides OSGi functionality. The standard services define reusable APIs for
common tasks, such as Logging and Preferences.

If you use an IDE to do your Java development, it’s possible you already have experience with OSGi.

OSGi layered architecture
  • Module layer—Concerned with packaging and sharing code.
  • Lifecycle layer—Concerned with providing execution-time module management and access to the underlying OSGi framework
  • Service layer—Concerned with interaction and communication among modules, specifically the components contained in them

General approach when creating an OSGi-based application
  1. Design your application by breaking it down into service interfaces (normal interface-based programming) and clients of those interfaces.
  2. Implement your service provider and client components using your preferred tools and practices.
  3. Package your service provider and client components into (usually) separate JAR files, augmenting each JAR file with the appropriate OSGi metadata.
  4. Start the OSGi framework.
  5. Install and start all your component JAR files from step 3.
-OSGi in Action

Saturday, March 2, 2013

Fuse ESB

FuseSource was formed when Progress Software spun off this open source effort into a separate organization in mid-2010. It was acquired by RedHat in mid-2012 to enhance Red Hat's JBoss middleware portfolio.

Fuse ESB is the core product of FuseSource.

Fuse ESB is an open source integration platform. It is a flexible, standards-based enterprise service bus based on Apache ServiceMix. It combines features from the Apache ServiceMix ESB, the Apache Camel integration framework, the Apache ActiveMQ message broker, and the Apache CXF web services framework.

You can download it now from RedHat downloads page, but I wonder  if the 90 day evaluation  story here is a mistake or not! Isn't it open source any more???



Fuse ESB has a pluggable architecture that allows organizations to use their preferred service solutions in their SOA. Any standard JBI or OSGi-compliant service engine or binding component – including BPEL, XSLT or JMX engines – may be deployed to a Fuse ESB container, and Fuse ESB components may be deployed to other ESBs.

It differentiates itself in the following ways:
  • Fuse ESB kernel is lightweight and can run on most platforms.
  • Fuse ESB kernel uses the OSGi framework to simplify componentization of applications.
    • The OSGi framework is a standard for managing the dependencies between application components. It also provides a standard mechanism for controlling the life-cycle of components.
  • Fuse ESB supports the Java Business Integration (JBI) specification.
    • JBI is a well defined standard for packaging, deploying, and managing components deployed to the ESB.
  • Fuse ESB can be coupled to other infrastructure services over a variety of transport protocols and message formats.
    • Out of the box, the Fuse ESB supports JMS, HTTP HTTPS, FTP XMPP, Web services, and a number of other bindings. In addition, you can easily extend its connectivity options using other components that conform to either the OSGi or JBI specification.
  • Fuse ESB employs standards as much as possible to limit dependencies.

In addition, Fuse ESB supports event driven architectures. Services deployed into the Fuse ESB container can be fully decoupled and will simply listen on the bus until an appropriate service request arrives. Fuse ESB also supports events that occur outside of the bus. For example, a JMS service can listen on a topic that is hosted outside of the bus and only act when an appropriate message arrives.

Architecture Overview


Fuse ESB employs a layered architecture comprised of the following:
  • Kernel: A lightweight runtime that extends OSGi with powerful features for handling and managing OSGi bundles.
  • Technology layer: A layer of component technologies that sits on top of the kernel.

Fuse ESB kernel is based on Apache Karaf, an OSGi-based runtime that provides a lightweight container into which you can deploy various components and applications.

The kernel provides the following features:
  • Console: Karaf can be administered via an extensible console shell that supports secure, remote access.
  • Dynamic logging: A dynamic logging backend provided by Log4J supports different APIs (JDK 1.4, JCL, SLF4J, Avalon, Tomcat, OSGi).
  • Hot deployment: When a JAR file is added to the InstallDir/deploy folder, it is automatically installed inside the runtime.
  • Provisioning: Application provisioning through file-drop, Maven repository and remote download.
  • Dynamic configuration: Changes to the properties files contained in the InstallDir/etc directory are monitored and propagated to the relevant services.
  • Security: Security framework based on Java Authentication and Authorization Service (JAAS).