concept datum in category osgi

appears as: data, data
Enterprise OSGi in Action

This is an excerpt from Manning's book Enterprise OSGi in Action.

Although they’re database-independent, these interfaces are thin wrappers for the raw database access. Developers assume complete responsibility for converting the result set into Java objects. Developers must also code all of the SQL statements for inserting and retrieving data. Developers need a fairly solid grasp of SQL and database administration to achieve much with JDBC. Because SQL support tends to vary between database vendors, developers also need to know a good deal about the intended deployment environment for their applications.

The datasource groundwork allows you to move on to the real meat of the Fancy Foods persistence. You set your datasources up to use in-memory databases, so you don’t need to worry about creating physical databases or writing lots of SQL to set them up. It’s still worth thinking, though, about what you’re trying to model with the database and what kind of data you want to store.

OSGi in Depth

This is an excerpt from Manning's book OSGi in Depth.

For example, consider a Log service interface and a log event. The Log service interface is likely to define methods, such as logError(String message) and logWarning(String message). You’re indicating that a consumer of this interface may either log an error or a warning message. In the case of a log event, which contains a severity and a message field, you only give the data to the consumer, and you don’t tell the consumer what can be done with the data. The consumer could log the message or could just print it to the console. Coupling between a consumer and a producer of an event is solely on the data of the event and not on any interfaces.

As you’ve learned, OSGi applications are part of a larger ecosystem and constantly need to engage with other applications and deal with external components. In the previous chapter, you learned how to interact with diverse components by publishing and subscribing to application and business events. In this chapter, we’ll investigate other means of collaboration, specifically how to access external (business) data by reading and writing data to and from persistent storage.

The persistence of data is a common theme for most enterprise-grade applications because they must not lose data, particularly enterprise data, which may contain their client’s transactions. For example, recall from section 6.4.1 that one of the issues of the Event Admin service is that it may lose events. One way to avoid this would be for the Event Admin implementation to store the events into some durable media as the events arrive.

In OSGi, there are different ways you can achieve the persistence of data. You’ll first learn that the OSGi framework provides each bundle with its own bundle storage area, which can be used as persistent storage. Next, you’ll learn how to use JDBC within OSGi by registering and retrieving JDBC data source factories. Finally, we’ll take an abstraction leap, and you’ll learn how to use object-relational approaches to automatically persist a bundle’s Java objects. This is done using JPA, and, as you’ll see, it has an interesting and somewhat involved setup within OSGi.

Listing 7.1. Storing data using the bundle’s storage area