Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

OpenEJB does not restrict you to just these data types or require you to use an ejb-jar.xml to declare them.

  • @Resource can be used on any

...

  • type for which there is java.beans.PropertyEditor
  • You may install your own PropertyEditors and package them with your app.
  • Java Generics are supported (e.g. List<URI> myURIs)
  • You may use a META-INF/env-entries.properties file as an alternative to an ejb-jar.xml

See Built-in Type Converters for a full list of supported env-entry types.

The source for this example is the "custom-injection" directory located in the openejb-examples.zip available on the download page.

The Code

Bean Class

...

The META-INF/env-entries.properties file

...

The Custom Type and Editor

Support for java.lang.Enum types is already built-in, but we've decided we'd like to allow abbreviated versions of the enum constants to be usable. We do this by creating a custom PropertyEditor for our Pickup enum like so:

...

We cleverly install this PropertyEditor in a static block in the Pickup class that will be executed should someone actually reference the Pickup type.

...

Test Case

...

Running it

Running the example is fairly simple. In the "custom-injection" directory of the examples zip, just run:

$ mvn clean install

Which should create output like the following.

...