TomEE resource properties provider: one more step


I spoke recently ( https://rmannibucau.wordpress.com/2014/08/06/tomee-and-more-advanced-resource-configuration/ ) of the ability to read using a custom API properties for TomEE resources but for enterprise context where you want to control all resources it was surely not enough for big applications.

To make it smoother to use you can now:

  • set it globally using org.apache.openejb.api.resource.PropertiesResourceProvider system property
  • get injected the serviceId without reading it from all properties

This means your properties provider implementation can look like:

public class MyProvider {
    private serviceId;

    public Properties provides() {
        return myLoader.load(serviceId);
    }
}

myLoader being here just to abstract the fact you read in your enterprise configuration repository (MongoDB, a RDBMS, file system…).

To set it globally just add in conf/system.properties:

org.apache.openejb.api.resource.PropertiesResourceProvider = org.superbiz.MyProvider

Side note: it doesn’t prevent your resource to specify custom properties. However keep in mind the provider will override it if there is a conflict.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s