Tired of exporting your OSGI metatype to client manually?

Feel my pain

We use OSGi, but we don’t deploy our bundles further than testing environment. It is our client who deploys it to production. However, they rarely read the metatypes – as metatype files are hidden deep inside jars and their format is not very user-friendly (who wants to read XMLs?). This is why they don’t know how to configure the application.

Sharing metatypes

If you work with OSGi metatype files, you have to find some way of informing your client what configuration is necessary for your application. There are a few ways of sharing this information:

  • You can send configuration options by e-mail or Jira/Redmine/(paste your issue tracker here). However, this might cause a big mess, searching is horrible, and it becomes outdated faster than you can say I hate sending metatypes.
  • You can share your repository with the client so that they always have up-to-date XMLs. Nevertheless, XML files are difficult to read and are scattered across whole modules.
  • You can keep your configuration in some document (e.g. Markdown), providing easy access for the client, but you must remember to synchronize it every time you change metatype.

metatype-exporter-maven-plugin to the rescue!

Our new Maven plugin allows us to automatically generate Markdown file from metatype files. Just add the plugin and enjoy automatically generated configuration created without any effort. Sample configuration may look like below.

<project ...>

    ...

    <pluginRepositories>
        <pluginRepository>
            <id>touk</id>
            <url>https://philanthropist.touk.pl/nexus/content/repositories/releases</url>
            <!-- we are not on central, but we are going to be there soon -->
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>pl.touk.osgi</groupId>
                <artifactId>metatype-exporter-maven-plugin</artifactId>
                <version>@metatype-exporter-maven-plugin.version@</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>export</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <destination>${project.build.directory}/classes/documentation</destination>
                    <outputFileName>ConfigurationDescription.md</outputFileName>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

 

Markdown produced by this configuration may look like this:

# Properties name (theseAreProperties) for pid this.is.first.pid

Description goes here

| ID  | Name  | Required | Type    | Default value | Options                         | Description |
| --- | ----- | -------- | ------- | ------------- | ------------------------------- | ----------- |
| id1 | name1 | Yes      | String  |               |                                 | desc1       |
| id2 |       | No       | Long    | 123           |                                 | desc2       |
| id3 |       | Yes      | Integer |               | <ul><li>15</li><li>30</li></ul> |             |

# Properties name (secondProps) for pid this.is.second.pid

| ID  | Required | Type   |
| --- | -------- | ------ |
| id1 | Yes      | String |

Markdown files are great because many git repositories like Gitlab or Github render Markdown files nicely. You can view the above file here: https://gist.github.com/piotrekfus91/ba36404341664c48df19576350a2340f.

Definitely more readable, huh?

Change language if your client doesn’t speak English

If you want to change the language of generated files, just add a resource bundle named MarkdownBundle, change locale in plugin configuration and enjoy your custom language. English and Polish are available out of the box.

<project ...>

    ...

    <build>
        <plugins>
            <plugin>
                <groupId>pl.touk.osgi</groupId>
                <artifactId>metatype-exporter-maven-plugin</artifactId>
                <version>@metatype-exporter-maven-plugin.version@</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>export</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <language>de</language>
                    <country>DE</country>
                </configuration>
                <depenedencies>
                    <dependency>
                        <!-- maven coordinates of the jar with resource bundle -->
                    </dependency>
                <depenedencies>
            </plugin>
        </plugins>
    </build>
</project>

Resource bundle (for example MarkdownBundle_de.properties)

forPid=...
attributeHeaderId=...
attributeHeaderName=...
attributeHeaderDescription=...
attributeHeaderOptions=...
attributeHeaderType=...
attributeHeaderDefaultValue=...
attributeHeaderRequired=...
attributeRequiredTrue=...
attributeRequiredFalse=...

Summary

Our problem – client doesn’t know how to configure the application – was solved with our new Maven plugin. The sources may be found on https://github.com/TouK/metatype-exporter-maven-plugin.

What’s next?

We are planning to add other output formats or enable users to provide custom templates. If you have any suggestions for enhancements or found a bug, just let us know in a Github issue.

You May Also Like

Sample for lift-ng: Micro-burn 1.0.0 released

During a last few evenings in my free time I've worked on mini-application called micro-burn. The idea of it appear from work with Agile Jira in our commercial project. This is a great tool for agile projects management. It has inline tasks edition, drag & drop board, reports and many more, but it also have a few drawbacks that turn down our team motivation.

Motivation

From time to time our sprints scope is changing. It is not a big deal because we are trying to be agile :-) but Jira's burndowchart in this situation draw a peek. Because in fact that chart shows scope changes not a real burndown. It means, that chart cannot break down an x-axis if we really do more than we were planned – it always stop on at most zero.

Also for better progress monitoring we've started to split our user stories to technical tasks and estimating them. Original burndowchart doesn't show points from technical tasks. I can find motivation of this – user story almost finished isn't finished at all until user can use it. But in the other hand, if we know which tasks is problematic we can do some teamwork to move it on.

So I realize that it is a good opportunity to try some new approaches and tools.

Tools

I've started with lift framework. In the World of Single Page Applications, this framework has more than simple interface for serving REST services. It comes with awesome Comet support. Comet is a replacement for WebSockets that run on all browsers. It supports long polling and transparent fallback to short polling if limit of client connections exceed. In backend you can handle pushes in CometActor. For further reading take a look at Roundtrip promises

But lift framework is also a kind of framework of frameworks. You can handle own abstraction of CometActors and push to client javascript that shorten up your way from server to client. So it was the trigger for author of lift-ng to make a lift with Angular integration that is build on top of lift. It provides AngularActors from which you can emit/broadcast events to scope of controller. NgModelBinders that synchronize your backend model with client scope in a few lines! I've used them to send project state (all sprints and thier details) to client and notify him about scrum board changes. My actor doing all of this hard work looks pretty small:

Lift-ng also provides factories for creating of Angular services. Services could respond with futures that are transformed to Angular promises in-fly. This is all what was need to serve sprint history:

And on the client side - use of service:


In my opinion this two frameworks gives a huge boost in developing of web applications. You have the power of strongly typing with Scala, you can design your domain on Actors and all of this with simplicity of node.js – lack of json trasforming boilerplate and dynamic application reload.

DDD + Event Sourcing

I've also tried a few fresh approaches to DDD. I've organize domain objects in actors. There are SprintActors with encapsulate sprint aggregate root. Task changes are stored as events which are computed as a difference between two boards states. When it should be provided a history of sprint, next board states are computed from initial state and sequence of events. So I realize that the best way to keep this kind of event sourcing approach tested is to make random tests. This is a test doing random changes at board, calculating events and checking if initial state + events is equals to previously created state:



First look

Screenshot of first version:


If you want to look at this closer, check the source code or download ready to run fatjar on github.During a last few evenings in my free time I've worked on mini-application called micro-burn. The idea of it appear from work with Agile Jira in our commercial project. This is a great tool for agile projects management. It has inline tasks edition, drag & drop board, reports and many more, but it also have a few drawbacks that turn down our team motivation.

Scrum w Polsce – TouK

Nasi koledzy z Fluidcircle opublikowali właśnie studium przypadku opisujące doświadczenia TouK z wykorzystania metodyki Scrum. Wszystko w ramach programu “Scrum…