be used from inside an OSG i framework. What does this enterprise OSG i programming
model look like?
Dependency injection , sometimes called inversion of control , defines both an enterprise
technology and an architectural model. Dependency injection has only recently
become part of the official Java EE standard, but it has been a de facto part of enter-
prise programming for many years through the use of frameworks like Spring. Depen-
dency injection is, if anything, even more valuable in an OSG i environment. Because
the OSG i Service Registry is such a dynamic environment, it's difficult to correctly
write a bundle that makes use of a service in a safe way, monitoring its lifecycle, and
finding an appropriate replacement.
Using and providing services becomes even more difficult when an implementa-
tion depends upon more than one service, with a user having to write some complex
thread-safe code. Using dependency injection eliminates this complexity by managing
the lifecycle of both the services exposed, and consumed, by a bundle.
Because of its ability to dramatically simplify programming in OSG i, dependency
injection is at the heart of the enterprise OSG i programming model. Without it, busi-
ness logic is difficult to separate from dependency management logic, and develop-
ment is slow. The other key advantage of dependency injection is that it allows
application code to avoid dependencies on core OSG i API s, dramatically reducing the
amount that developers need to learn before they can start making use of OSG i and
making applications easier to unit test.
Java EE integration
As we mentioned previously, enterprise OSG i wouldn't be useful if it didn't provide at
least some of the functions available in Java EE . Furthermore, Java EE already has a lot
of experienced developers, and it wouldn't be helpful if the OSG i way of doing things
was completely different from the Java EE way. These two requirements are fundamen-
tal drivers of the OSG i Enterprise Specification, which aims to provide core enterprise
services, reusing Java EE idioms and structure where possible.
The OSG i Enterprise Specification is large, and covers many of the Java EE services
that developers know and love. For example, it includes an OSG i-friendly version of a
Web Archive ( WAR ), declarative Java Persistence API ( JPA ) database access, and access
to Java Transaction API ( JTA ) transactions. It also includes, not one, but two dependency
injection systems, Java Management Extensions ( JMX ) management, and a way of dis-
tributing work across multiple JVM s. The OSG i Enterprise Specification Releases 5 even
includes support for dynamically exposing META-INF services as OSG i services. If you're
not familiar with JPA , JTA , and the other Java EE technologies we've mentioned, don't
worry—we'll introduce them in later chapters with worked examples.
Search WWH ::