Giter VIP home page Giter VIP logo

clojure.osgi's Introduction

clojure.osgi

Clojure / OSGi integration Due to the fact that OSGI had seperate classloaders clojure will not work out of the box. The clojure.osgi bundle gives you the ability to run clojure code in osgi.

Works on Apache Karaf 3.0.0 simple example with no dependencies

Usage

Build the clojure.osgi module using maven

cd clojure.osgi
mvn clean install

This should give you a "clojureized" bundle for use in karaf exporting the main clojure. Deploy this in karaf.

Build the karaf-demo module.

cd karaf-demo
mvn clean install

This a very useless app that just prints out to System.out that the bundle has started. Deploy this in karaf. Start the clojure bundle and you should see system.out saying that main bundle has started.

The key point to this demo is specifying the namespace that contains your bundle activator function. As of now this is hardcoded as "bundle-start"

If you look in the pom in the karaf-demo you can see the instructions to the bnd plugin

<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
	                      <Import-Package>
                            <!--${project.artifactId}; version=$(Bundle-Version),-->
                            !sun.misc,
                            clojure.lang;version="1.6.0.RC1",
			    clojure.osgi;version="1.6.0.beta2-1",
			    org.osgi.framework
                        </Import-Package>
<Clojure-Require>demo.main</Clojure-Require>
<Clojure-ActivatorNamespace>demo.main</Clojure-ActivatorNamespace>

Notice Clojure-Require and Clojure-ActivatorNamespace custom entries to the manifest. This invokes a the BundleTracker in the clojure bundle which starts your bundle with the namespace specified. You can double check the Manifest it has

Clojure-Require: demo.main
Clojure-ActivatorNamespace: demo.main

Thats it have fun playing with clojure on karaf

Caveats

Beware of namespace issues like clojure.java as when you define your imports and exports your going to have a lot of split package issues.

Next

AOT (Ahead of Time) compiled classes demo.

OSGI Service.

There are examples from the main repos this was forked from all I am doing is using the maven bnd plugin to update the Manifest.

clojure.osgi's People

Contributors

aav avatar bot424f54 avatar charles-dyfis-net avatar laurentpetit avatar splix avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.