background preloader

Apache Karaf

Facebook Twitter

Labelled content - Liquid Reality - Apache Karaf Tutorial Part 8 - Distributed OSGi - Liquid Reality - By default OSGi services are only visible and accessible in the OSGi container where they are published.

Apache Karaf Tutorial Part 8 - Distributed OSGi - Liquid Reality -

Distributed OSGi allows to define services in one container and use them in some other (even over machine boundaries). For this tutorial we use the DOSGi sub project of CXF which is the reference implementation of the OSGi Remote Service Admin specification, chapter 122 in the OSGi 4.2 Enterprise Specification). Example on github Introducing the example Following the hands on nature of these tutorial we start with an example that can be tried in some minutes and explain the details later. Our example is again the tasklist example from Part 1 of this tutorial. As DOSGi should not be active for all services on a system the spec defines that the service property "osgi.remote.interfaces" triggers if DOSGi should process the service. Apache Karaf Tutorial Part 7 - Camel JPA and JTA transactions - Liquid Reality -

Practical Camel example that polls from a database table and sends the contents as XML to a jms queue.

Apache Karaf Tutorial Part 7 - Camel JPA and JTA transactions - Liquid Reality -

The route uses a JTA transaction to synchronize the DB and JMS transactions. An error case shows how you can handle problems. Route and Overview The route starts with a jpa endpoint. It is configured with the fully qualified name of a JPA @Entity. The onException clause makes the route do up to 3 retries with backoff time increasing by factor 2 each time. The next step transacted() marks the route as transactional it requires that a TransactedPolicy is setup in the camel context. The marshal(df) step converts the Person object to xml using JAXB. The ExceptionDecidet bean allows to trigger an exception if the name of the person is error. The last step to("jms:person") sends the xml representation of person to a jms queue. Apache Karaf Tutorial Part 6 - Database Access - Liquid Reality - Shows how to access databases from OSGi applications running in Karaf and how to abstract from the DB product by installing DataSources as OSGi services.

Apache Karaf Tutorial Part 6 - Database Access - Liquid Reality -

Some new Karaf shell commands can be used to work with the database from the command line. Finally JDBC and JPA examples show how to use such a DataSource from user code. Installing the driver The first step is to install the driver jar(s) for your database system into Karaf. Most drivers are already valid bundles and available in the maven repo. For derby the following command will work See the db/datasource folder on github for installation instructions for (db2, derby, h2, mysql and oracle).

Installing the datasource In Java EE servers and servlet containters you typically use JNDI to install a DataSource on the server level so the application can just refer to it and so does not have to know the specific driver or database url. As we can deploy simple blueprint xml files in Karaf this is really easy. Db:select <name> Example: db:tables. Karaf Tutorial Part 5 - Running Apache Camel integrations in OSGi - Liquid Reality - Shows how to run your camel routes in the OSGi server Apache Karaf.

Karaf Tutorial Part 5 - Running Apache Camel integrations in OSGi - Liquid Reality -

Like for CXF blueprint is used to boot up camel. The tutorial shows three examples - a simple blueprint route, a jms2rest adapter and an order processing example. Installing Karaf and making Camel features available. Karaf Tutorial Part 4 - CXF Services in OSGi - Liquid Reality - Shows how to publish and use a simple REST and SOAP service in karaf using cxf and blueprint.

Karaf Tutorial Part 4 - CXF Services in OSGi - Liquid Reality -

To run the example you need to install the http feature of karaf. The default http port is 8080 and can be configured using the config admin pid "org.ops4j.pax.web". You also need to install the cxf feature. The base url of the cxf servlet is by default "/cxf". It can be configured in the config pid "org.apache.cxf.osgi". Differences in Talend ESB Icon If you use Talend ESB instead of plain karaf then the default http port is 8044 and the default cxf servlet name is "/services". PersonService Example The "business case" is to manage a list of persons. The example consists of four projects. Karaf Tutorial Part 3 - Improving configuration editing using the OSGI Metatype Service and the Felix Webconsole - Liquid Reality -

Karaf Tutorial Part 2 - Using the Configuration Admin Service - Liquid Reality - In the first part of the Karaf Tutorial we learned how to use maven and blueprint to offer and use pojo services and how to use the http service to publish a servlet.

Karaf Tutorial Part 2 - Using the Configuration Admin Service - Liquid Reality -

In this second part we concentrate on configuration for our OSGi bundles. Unlike servlet containers OSGi contains a very good specification for configuration: The Config Admin Service from the OSGi enterprise spec. In this tutorial we will cover ussing the Config Admin Service with pure OSGi and blueprint and how to automatically deploy config files with your bundles. The practical parts of this tutorial can be found on github in The Configuration Admin Service spec We will first get a fast overview of the Configuration Admin Service spec. ConfigurationAdmin - Allows to retrieve and change configurations. So basically a configuration in the Config Admin Service is a Dictionary that contains attributes and their values. How to work with configuration? Karaf Tutorial Part 1 - Installation and First application - Liquid Reality -

With this post I am beginning a series of posts about Apache Karaf.

Karaf Tutorial Part 1 - Installation and First application - Liquid Reality -

So what is Karaf and why should you be interested in it? Karaf is an OSGi container based on Equinox or Felix. The main difference to these fine containers is that it brings excellent management features with it. Outstanding features of Karaf: Extensible Console with Bash like completion features ssh console deployment of bundles and features from maven repositories easy creation of new instances from command line All together these features make developing server based OSGi applications almost as easy as regular java applications.