Montag, 7. Dezember 2015

Multi-tenant cloud applications with Spring-Data-JPA and EclipseLink

We have been working on an application that requires a multi-tenancy architecture, tenants are created on the fly, potentially reaching a couple hundred. This mean, that multi-tenancy via database/schema separation is off the table, which leaves us with a single table approach and discriminator columns.

Usually Hibernate is our tool of choice for JPA persistence and Hibernate4 added multi-tenancy support - great! After fiddling around for a while and reading the documentation a second time, you will find a comment for the discriminator strategy: "This strategy is not yet implemented in Hibernate as of 4.0 and 4.1. Its support is planned for 5.0.".

Too bad, what now? Well since JPA 2.1 adds multi-tenancy support and EclipseLink is the reference implementation, maybe they support our need? Turns out they do since version 2.3.0 and they have a great documentation which has more than enough information to get you started.

The last piece of the puzzle is Spring-Data-JPA for the data-access-layer, one of our favorites - and it works with EclipseLink out of the box. Now we just have to make it behave nicely with multi-tenant entities.

Freitag, 25. Januar 2013

Befüllen dynamischer PDF-Formulare mit iText 2.1.7

Zur Bearbeitung von PDF bietet sich unter Java insbesondere die iText-Bibliothek an. Bis Version 2.1.7 konnte iText unter LGPL frei genutzt werden, anschließend wurde das Lizenzmodell geändert. Für die kommerzielle Nutzung späterer Versionen werden Gebühren fällig. Für kleine und mittlere Projekte wird Version 2.1.7 daher noch gern genutzt. Die Schwächen liegen hier vor allem in der Bearbeitung von dynamischen PDF nach XFA-Standard (XML Forms Architecture) ab PDF-Version 1.5.
Zumindest das Befüllen dynamischer Formulare ist jedoch auch mit der angestaubten Bibliothek ohne weiteres möglich. Im Beispiel wurde aus einem XML-Schema ein einfaches Formular generiert:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="modelData" type="modelDataDef"/>

  <xs:complexType name="modelDataDef">
    <xs:sequence>
      <xs:element name="author" type="xs:string"/>
      <xs:element name="cars" type="carsDef"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="carsDef">
    <xs:sequence>
      <xs:element name="car" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="manufacturer" type="xs:string"/>
            <xs:element name="type" type="xs:string"/>
            <xs:element name="color" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

Dienstag, 27. November 2012

Realizing async server architecture with GWTP and Atmosphere

We have been using the GWTP framework for several production applications so far. While the MVP module of GWTP allows for a maintainable and scalable client architecture, the GWTP-Dispatch module centralizes client-server communication around the command pattern with features like action handlers, caching and batching. 

Recently we have been working on integrating the Atmosphere framework and GWTP-Dispatch with the goal of allowing asynchronous execution of server code while maintaining the command pattern approach that GWTP-Dispatch uses. Specifically we had to work with some Camel endpoints and Akka actors that do some work and asynchronously provide a result which was to be displayed on the client.