4.3. Retrieving Resources from within the Bundle

A bundle can carry not only code, but also data. Packaging classes and required resources together make the bundle a self-contained deployment unit.

In our dictionary bundle, it is apparent that inserting individual word definition entries into the data structure is awkward. Unless we add tens of thousands of put statements to our implementation code, our dictionary service won't be of much use.

Let's create a property file containing the dictionary entries, pack the file into the bundle, and write code to retrieve the entries in the dictionary service.

Here's a segment of the text file webster.properties:

 # The word definitions from Webster's Dictionary ... accuse=to charge with fault or offense ...

Get Programming Open Service Gateways with Java Embedded Server™ Technology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.