Dienstag, 15. Oktober 2013

How do you get the Bundle Class Loader?

The class loader of a bundle can be obtained through the BundleWiring interface. The BundleWiring interface has replaced the OSGi PackageAdmin service. The new interface can be used to get any information of the actual (dependencies) wiring of a bundle. And the new API also provides a method to get the class loader instance of a bundle.



Freitag, 5. Juli 2013

Spring Security Java Configuration

Spring Security now has new module called spring-security-javaconfig. It provides a fluent builder API to configure spring security in Java code instead of XML. I used the CI build in a simple demo blog application and I really like it to have no XML file in the whole web project. The code snippet belows shows the security configuration from this demo appliction.
To get spring security support up and running the "DelegatingFilterProxy" must be added to your web application filter chain. This can also be done without any XML by using the Servlet API 3.0 features by using the Spring "AbstractAnnotationConfigDispatcherServletInitializer" base class to configure the web-app. The web-app configuration is shown in the code listing below.
More details on spring security java config see the github project.

Dienstag, 18. Juni 2013

Gradle and Continuous Delivery

Here my slides from the SEITENBAU Developer Convention 2013. The slides provide an introduction to Gradle Basics and cover how to use Gradle for Continuous Delivery.

Mittwoch, 24. April 2013

Simple Table DSL in Groovy

Sometimes the best way to model data is as a table. A good example where you could use tables is the spock framework. Spock is a great testing framework for Java and Groovy. In spock the test parameters can be defined as a table. The spock framework use Groovy AST transformations to implement the DSL for the tables. I think about if there is a simpler way to parse an embedded table DSL in groovy. Not with the same features then the spock table DSL. My requirements for the DSL are to define a table and to have support for variables in the table.

Here a short example of such a table:

To implement the DSL parser in groovy I use two groovy languages feature:
  1. The category feature to define the OR operators, for the different types of the table values 
  2. The dynamic of groovy for the variable support, the getProperty is overwritten and creates a object of type Var for a undefined groovy variable
The code below contains a simple groovy implementation of a table DSL parser. The simple parser now can be used to parse the table DSL from the example above. How the DSL can be use in JUnit is show in the parameterized test in the listing below. Not a perfect example, because for testing you should use Spock instead.