OpenNaaS uses a pile of technologies and frameworks in order to make easier developing, maintaining and extending source code of the project. In this chapter these technologies are briefly summarized to explain how them are used.

OSGi

According to OSGi Alliance, OSGi technology "is a set of specifications that defines a dynamic component system for Java. These specifications reduce software complexity by providing a modular architecture for large-scale distributed systems as well as small, embedded applications".

Basically, OSGi framework is a module system and service platform for the Java programming language that implements a complete and dynamic component model. Those characteristics are not provided by Java Virtual Machine itself. OSGi provides a collection of benefits: Reduced Complexity, Reusability, Easy Deployment, Dynamic Updates, etc. and it is widely used.

The reasons for the adoption of this technology are multiple. For more information there are some slides to reinforce the basic concepts and motivation of using OSGi: Why OSGi?.

OSGi itself is only an specification. There are different versions of OSGi specification:

An implementation is needed to use this technology.

Architecture

OSGi has a layered model as it is shown in the next figure:

There are 4 stacked layers and a cross one:

More information can be found here.

Bundles

OSGi specification defines a new concept called bundle. A bundle is a plain old JAR file. The difference resides in the visibility of the packages inside the bundle: OSGi hides everything in that JAR unless explicitly exported. A bundle that wants to use another JAR must explicitly import the parts it needs. By default, there is no sharing. This information is added in the JAR manifest (/META-INF/MANIFEST.MF).

The manifest has some headers that can be used. Some of them are standard, and another ones are implementation-specific. A complete list can be found here. Basically, these headers define the exported and imported packages and other information about the bundle. An Apache Maven plugin is used to build bundles from source code (Apache Felix Bundle Plugin for Maven).

Life-cycle

Bundles have a life cycle inside OSGi. It is defined by a set of states and a rules to change between them. A bundle can be in one of the following states:

This state diagram shows how the states can change between them:

Services

This layer allows registering services. A service is a Java interface and a bundle can implement this interface to provide the service. There exist a Service Registry that allows any bundle to register services, search for them or receive notifications when their registration state changes. This notifications are built using a register-event system. OSGi specification defines some standard services.

Implementations

OSGi is only an specification, an implementation is necessary to use this technology. There are different implementations, some of them open sourced. Apache Felix and Eclipse Equinox are the more commonly used. OpenNaaS uses Apache Felix.

Apache Felix

Apache Felix is an implementation of OSGi Service Platform Release 4. It is divided in a set of more than 30 subprojects as it is shown here. There are some tutorial examples in Apache Felix official documentation that show how to develop OSGi bundles using Apache Felix.

OpenNaaS uses Apache Felix as OSGi framework, it is configured in the Apache Karaf properties file using this guidelines.

Apache Karaf

Apache Karaf is an OSGi runtime which provides a container plus some other complementary tools. It is possible to choose the OSGi framework to use between Apache Felix or Eclipse Equinox; OpenNaaS uses Felix.

This figure shows Karaf's architecture: 

Karaf has lots of features that improve the experience developing on an OSGi container. Some of these features are:

Console

One of the most powerful tools of Apache Karaf is the console. It provides an entry point to add, remove and configure bundles for instance. There are a bunch of available commands to interact with Karaf instance. Besides, the console functionalities can be extended.

In fact, OpenNaaS extends Karaf console to interact with their capabilities. Each OpenNaaS capability exports Karaf commands to be accessed through Karaf console. Some examples can be found in OpenNaaS source code, a good point to start is GenericKarafCommand, an abstract class that must be extended to create new OpenNaaS Karaf commands. An example of an OpenNaaS capability that uses this functionality is the Router Capability called IP and his SetIPv4 Command implemented in the Java class SetIPv4Command.

Moreover, this console can be accessed through SSH allowing a remote user to control an Apache Karaf instance.

Apache CXF

Apache CXF is a Web Services framework. It supports multiple Web Services standards, development tools. different transport layers, etc. OpenNaaS exports his API using this technology. By now, it is exported using RESTful WS. Besides, OpenNaaS has some SOAP clients developed to connect to some external services like GÉANT AutoBAHN.

There are documentation about how to develop RESTful Services in the Apache CXF official documentation. Furthermore there are documents to develop client in the same web page.

On one hand, OpenNaaS SOAP client example can be found in the Java class called AutobahnProtocolSession that interacts with GÉANT AutoBAHN service. On the other hand, an example of RESTful Web Service in OpenNaaS can be found in Router Capability called IP and his IPCapability interface IIPCapability.

Apache Aries

Apache Aries "consists of a set of pluggable Java components enabling an enterprise OSGi application programming model". It provides components  like Blueprint container and tools to integrate enterprise technologies like JTA, JNDI and JPA into an OSGi environment. In conclusion, it provides OSGi bundles to use these technologies inside an OSGI framework.

The persistence layer of OpenNaaS uses Apache Aries. Concretely OpenNaaS uses Apache OpenJPA as persistence provider. There are more information about it here.

Apache OpenJPA

Apache OpenJPA is a POJO persistence layer that can wrok standalone or integrated into any Java EE compliant container. Used inside Apache Aries, it is the persistence provider of OpenNaaS. More information about this technology an his usage can be found in the chapter Persistence.

Apache ServiceMix

Apache ServiceMix is an integration container that unifies the features and functionality of Apache ActiveMQ, Camel, CXF, ODE and Karaf into a runtime platform. It provides an ESB exclusively powered by OSGi."

Apache ServiceMix provides an easy way to develop and to integrate this set of technologies and OpenNaaS uses it.Some of these technologies are not used in OpenNaaS (Apache ActiveMQ, Camel and ODE), but Apache ServiceMix is flexible and allow not to use all of them.

Fuse ESB

Fuse ESB "is a flexible, standards-based enterprise service bus based on Apache ServiceMix". OpenNaaS uses Fuse ESB as a distribution of Apache ServiceMix. In practice, OpenNaaS uses a version of Apache ServiceMix that is released by FuseSource called Fuse ESB. They guarantee stability,  Quality Assurance, packaging, verification and incremental patches of their Apache ServiceMix distribution. Moreover FuseSource offers training, support and other value-added services. More information can be found here.

FuseSource has a great documentation, not only related with their products like Fuse ESB. It can be found here.

Apache Maven

According to official documentation, Apache Maven "is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information".

The use of Maven gives a development team and users many advantages to develop, build, extend, manage a project or a bunch of them. Furthermore, it can be configured to use plugins allowing extensions to the basic functionalities of the tool.

Basically, a POM file defines the project, its internal or external dependencies, manage the repositories to obtain these dependencies and defines goals to build the project. Also its allows to perform other tasks like generating documentation, deploying project builds into different servers or places or generating project skeletons based on archetypes.

Maven requires Java to work. This quickly guide shows how to get started using Maven.