Donnerstag, 19. März 2015

In this post I will show how to install CloundFoundry on Windows and VirtualBox using Vagrant and bosh-lite.


  1. After you've installed Vagrant and VirtualBox you start by cloning

    git clone

  2. Now go into your bosh-lite directory and start Vagrant

    vagrant up --provider=virtualbox

  3. Since the bosh-cli doesn't run on Windows we will manage the bosh-lite instance inside the created vm. For that we login into the vm via ssh

    vagrant ssh

  4. Now we need to download a bosh stemcell with the bosh cli tool

    bosh download public stemcell bosh-stemcell-389-warden-boshlite-ubuntu-trusty-go_agent.tgz

  5. After it finished you need to upload the stemcell to your bosh instance

    bosh upload stemcell bosh-stemcell-389-warden-boshlite-ubuntu-trusty-go_agent.tgz

  6. Now we need to clone the CloudFoundry repository. Before we can do this we need to install git

    sudo apt-get install git

  7. Clone the CloudFoundry repository

    git clone

  8. We will use the 1.93 release of CloudFoundry.

    git checkout tags/v193
    ./update to fetch all references

  9. Upload the release to bosh

    bosh upload release releases/cf-193.yml

  10. To use the tool spiff for creating the bosh manifest file we need to install go

    tar -C /usr/local -xzf go1.4.2.linux-amd64.tar.gz
    export PATH=$PATH:/usr/local/go/bin
    export GO_PATH=$HOME/go
    mkdir $HOME/go

  11. Install spiff

    go get -v

  12. Build manifest

    Execute inside your bosh-lite folder sudo ./bin/make_manifest_spiff

  13. Choose the deployment

    bosh deployment manifests/cf-manifest.yml

  14. Start deployment of CloudFoundry inside bosh

    bosh deploy

  15. Install the CloudFoundry CLI for Windows on your Windows machine and access your installed CloudFoundry instance

Freitag, 13. März 2015

In the last project where I had to use EclipseLink as the JPA provider for a web-based application. One of the nice features of EclipseLink is the ability of creating dynamic entities. Dynamic entities are virtual entities which can be mapped to the database. That means that you can define a entity at runtime and persist this entity. In this post I will show you how to create dynamic entities and what is needed to use this functionality in a Java EE application. At first you need to create an EntityManager for the defined persistence unit in your persistence.xml. After that you have to create a ClassLoader specifically for the dynamic entity classes by getting the Session and doing a lookup with that Session which returns the DynamicClassLoader. For creating the classes and mapping to the database you have to instantiate the JPADynamicHelper with the created EntityManager.
public void prepare() {
    entityManagerFactory = Persistence.createEntityManagerFactory("DefaultPU");
    entityManager = entityManagerFactory.createEntityManager();
    Session session = JpaHelper.getEntityManager(entityManager).getServerSession();
    dynamicClassLoader = DynamicClassLoader.lookup(session);
    jpaDynamicHelper = new JPADynamicHelper(entityManager);
Now you can create dynamically at runtime your first class with createDynamicClass from the DynamicClassLoader. This will return a new Java Class which you have to wrapp into a JPADynamicTypeBuilder. This class allows you to set the different fields and types of your entity and build in the end your dynamic entity class. After you defined your entity class your call addTypes from the JPADynamicHelper which than creates the table.
Class<?> dynamicEntityClass = dynamicClassLoader.createDynamicClass("org.demo.entity.DemoDynamicEntity");
JPADynamicTypeBuilder newType = new JPADynamicTypeBuilder(dynamicEntityClass, null, "DEMO_DYNAMIC_ENTITY");
newType.addDirectMapping("name", String.class, "NAME");
newType.addDirectMapping("description", String.class, "DESCRIPTION");
jpaDynamicHelper.addTypes(true, true, newType.getType());
To instantiate and persist a dynamic entity you have to call newDynamicEntity from the JPADynamicHelper with the name of your defined class. This method will return you an object of type DynamicEntit which is a wrapper for your virtual classes. This class provides you setter and getter for the fields of your class. After you have finished setting the fields you can persist as usual by calling persist on the EntityManager.
DynamicEntity newDynamicEntity = jpaDynamicHelper.newDynamicEntity("org.demo.entity.DemoDynamicEntity");
newDynamicEntity.set("id", 1);
newDynamicEntity.set("name", "Demo");
newDynamicEntity.set("description", "Demo Entity");

Montag, 2. März 2015

OpenHAB Metro like Visualization

Currently I'am trying to make my home smarter. I'am a big fan of home automation and wanted a flexible gateway for using different protocols and sensors. Therefore I've started with the OpenHAB project which is a good choice if you want to connect many smarthome protocols. In my setup I'am using Z-Wave dongle and some of the Fibaro Dimmers and Shutter Modules. Furthermore I also have Philips HUE Bridge and a Bluetooth Dongle connected to the server where OpenHAB is running. The Bluetooth Dongle is used for receiving weather data from an Arduino running Bluetooth Low Energy, a temperature sensor and a wind sensor. Since I like the Metro style from Windows 8 or moreover the simple arrangement of tiles I wanted a visualization which was as simple as the Metro UI. And this visualization should of course be a website which I can access from my tablet as well. Fortunately there is a library/styling for Metro sites on After some playings I've implemented a simple visualization which uses the Metro stylings and the CometVISU on the OpenHAB server for writing and receiving item states.

Furthermore I've added the noUiSlider library for my dimming buttons.

For all of you intereseted in this Visualization I've created a Github repository under:

To start using this demonstration you can just clone this repository into your OpenHAB webapps folder and accessing it under http://OPENAHAB-IP:8080/smarthome_metro. But don't forget putting the CometVISU backend jar into your OpenHAB addons folder.