Java Reference
In-Depth Information
What happens when multiple providers of the service have been registered? Service
consumers have a choice between getting one, or a list containing all of them. If the
service is something like a credit card processing service, it's only necessary to take a
payment once. In this situation one service provider is sufficient, and it probably
doesn't matter too much which provider is chosen. In the case of a logging service, on
the other hand, logged messages should probably be sent to all the available loggers,
rather than one of them. Fortunately, OSG i also allows you to find all of the services
that match a particular request:
ServiceReference[] refs = ctx.getServiceReferences(Logger.class
.getName());
if (refs != null) {
for (ServiceReference ref : refs) {
Logger logger = (Logger) ctx.getService(ref);
logger.doSomeLogging();
}
}
As you can see, in addition to its modular, versioned runtime and flexible lifecycle
management, OSG i provides an elegant services infrastructure and a lightweight
dynamic framework. All of these encourage good engineering practice, but, as with
most things, using OSG i doesn't guarantee that your application will be well struc-
tured. What OSG i does is give developers the tools they need to be able to define a
proper application structure. It also makes it easier to identify when application struc-
tures have slid in the direction of highly coupled soupishness. Given its obvious advan-
tages, why isn't everyone using OSG i already?
1.2.3
Why isn't everyone using OSGi?
As we've mentioned previously, OSG i isn't a new technology; the ideas have been
around for more than a decade now. But OSG i adoption within the Java community
isn't as ubiquitous as you would expect, given its obvious advantages. There are several
reasons for this.
THE ORIGINS OF OSGI
The OSG i Alliance's original mission was to allow Java to be used in embedded and
networked devices. In addition to Sun, IBM , and Oracle, its original members were,
for the most part, mobile phone manufacturers like Motorola and Ericsson, and net-
working companies like Lucent and Nortel. There were also energy companies
involved, such as Électricité de France and the late Enron Communications. Within a
few years, OSG i was being used inside set-top boxes, Siemens medical devices, Bombar-
dier locomotives, and the entertainment system of the BMW 5 Series. The main reason
for this is that the advantages of OSG i are particularly useful in constrained devices, or
in applications where the system must remain running for long periods, including
through maintenance updates.
The next wave of OSG i adoption happened in large-scale software projects, partic-
ularly IDE s, application servers, and other middleware. It's initially surprising that a
Search WWH ::




Custom Search