Env-entries with OpenEJB ApplicationComposer?


A quick tip to customize env-entries when using the OpenEJB ApplicationComposer. Suppose you have a Bean “CustomBean” and you want to inject the env-entry “foo” with the value “bar”.

Since you can build the bean yourself with the ApplicationComposer, you can configure the env-entries yourself too very easily:

@Module
public EnterpriseBean bean() {
    final SingletonBean singletonBean = new SingletonBean(CustomBean.class);
    singletonBean.getEnvEntry().add(new EnvEntry("foo", String.class.getName(), "bar"));
    return singletonBean.localBean();
}

Leave a comment