SPECIAL OFFERS
Keep up with new releases and promotions. Sign up to hear from us.
Register your product to gain access to bonus material or receive a coupon.
The Java Embedded Server from Sun Microsystems, Inc., is a solution for linking consumer devices with services over the Internet. It is based on the Open Services Gateway Initiative (OSGi) Service Gateway Specification 1.0. Written by authors who are intimately involved with the development and implementation of the specification, Programming Open Service Gateways with Java Embedded Server Technology reveals the concepts and inner workings of the Java Embedded Server framework and explains how to program and develop services for open gateways using the Java programming language.
With an emphasis on actual coding, this definitive guide begins by explaining the backdrop in which the residential gateway market emerged. Next, the book discusses the history and mission of the Java Embedded Server product and the OSGi consortium. Throughout the book, the Java Embedded Server technical architecture and the OSGi Service Gateway API are presented with examples and detailed implementations. The book's practical, how-to format shows you how to write code for residential gateway applications that is correct, robust, and efficient while avoiding common traps and pitfalls.
Highlights include:
Programming Open Service Gateways with Java Embedded Server Technology gives you an insider's perspective on the development process of new applications and services for the residential gateway environment.
Click below for Sample Chapter related to this title:
chench01.pdf
Preface.
Acknowledgments.
1. Introduction.
The Internet and the Networked Home.
The Service Gateway.
Challenges.
A Multitude of Competing Solutions.
A New Application Environment.
Java Embedded Server Technology.
The Open Services Gateway Initiative.
Operational Model.
Setting Up the Java Embedded Server Software.
The "Home, Sweet Home" Bundle.
Create the Directory.
Define the Manifest.
Write an Activator.
Compile the Activator Class.
Pack Up.
Running the Bundle.
Getting Help.
The Cache Directory.
The Bundle Base URL.
Brief Summary of the Major Commands.
Motivation.
Architecture.
Service.
Bundle.
A Bundle Is a Packaging Vehicle.
A Bundle Is a Functional Module.
The "Hooks" to the Framework.
The Framework.
Cooperation among Bundles and Services.
Exporting and Importing Packages.
Registering and Obtaining Services.
Package versus Service Dependency.
Life within the Framework.
Installing a Bundle.
Starting the Bundle.
Importing Packages and Getting Services.
Handling the Dynamic Service Dependency.
Updating a Bundle.
Stopping and Uninstalling a Bundle.
The Component-based Model.
Forget CLASSPATH.
Writing Service Bundles.
Design the Service Interface.
Implement the Service.
Register the Service in the Activator.
Define the Manifest Headers.
Create the Bundle.
Same Service Interface, Different Implementations.
Retrieving Resources from within the Bundle.
Obtaining and Calling Registered Services.
Interbundle Dependency and Class Loading Issues.
Service Use Count.
Compiling Client Bundles.
Service Factory.
Producing a Customized Service for Each Client Bundle.
Service Cache.
Customization for Getting and Releasing Service.
Relevant org.osgi.framework APIs.
BundleContext Interface.
ServiceReference Interface.
ServiceRegistration Interface.
Library Bundles.
Advanced Examples.
A Mailer.
A Line Printer Daemon Print Service.
Writing Bundles That Contain Native Code.
Common Mistakes.
Activator.
Manifest.
Creating a JAR File.
Event Handling.
Bundle State and Service Registration.
Synchronous and Asynchronous Events.
Dealing with Service Unregistration.
Don't Start without the Service.
Discovering Stale Service.
Carrying On without the Service.
Picking an Alternative.
Cascading Service Registration.
Refusing Service.
Cooperation with Asynchronous Events.
Designing the Service.
Separating Service Interface and Implementation.
Challenges in Designing a Service Interface.
Approaching an Interface Design.
The Social Aspect.
Designing Library Bundles.
Delegation and Callback.
Leveraging the Service Registry.
Threading.
Preventing Runaway Threads.
Writing a Multithread Server Bundle.
Using a Thread Pool.
Managing Object Allocation.
Nullify References After Use.
Managing References among Bundles.
The Log Service.
Using LogService to Write Logs.
Using LogReaderService to Get Logs.
Performing Persistent Logging.
The HTTP Service.
The Standard HttpService API.
Performing Basic Authentication.
The Extended HTTP Service.
Introduction.
The Software Stack in Device Access.
What Device Access Is Not.
Motivation.
Cast of Characters.
Device Service.
Driver Services.
Driver Locator.
Device Manager.
Writing DA Services.
The Base Driver.
Device Detection.
Device Refinement.
The Reconfiguration Process.
Putting It Together.
Permission-based Security inside the Java 2 Platform.
Code Source.
Permission.
Policy.
Granting Permissions to Classes.
Security Manager.
OSGi Permissions.
AdminPermission.
ServicePermission.
PackagePermission.
Permission Required by the Framework APIs.
Enabling Security.
Setting Up a Policy.
Running with Security Enabled.
Using Permissions in Your Service.
Checking Permissions.
Performing Privileged Actions.
Creating Your Own Permission Types.
Administration.
Resolving Bundles Dynamically.
Relevant APIs.
Removing Phantom Bundles.
Dynamic Permissions.
Preferences.
User Administration.
Configuration Management.
What's Next.
Chapter 4--Developing Bundles.
The LPD Print Service.
Chapter 8--Device Access.
Serial Service and Driver Locator.
Driver Service and Modem Service.
Web Interface to the Serial Ports.
Chapter 9--Permission-based Security and Administration.
Parameter Services.
Parameter Configuration Servlet.
Facilitator.
org.osgi.framework.
AdminPermission.
Bundle.
BundleActivator.
BundleContext.
BundleEvent.
BundleException.
BundleListener.
Configurable.
FrameworkEvent.
FrameworkListener.
InvalidSyntaxException.
PackagePermission.
ServiceEvent.
ServiceFactory.
ServiceListener.
ServicePermission.
ServiceReference.
ServiceRegistration.
org.osgi.service.device.
Device.
Driver.
DriverLocator.
org.osgi.service.http.
HttpContext.
HttpService.
NamespaceException.
org.osgi.service.log.
LogEntry.
LogListener.
LogReaderService.
LogService.
Technology is invented and advanced by, well, technical people. However, a truly successful technology is marked by its adoption by people in their daily lives. Few ponder radio frequency modulation when they turn on the TV, or the internal combustion engine when they drive around. The technology has disappeared behind the utility.
The last decade saw two new technologies begin to blend into our lives: the computer and the Internet. We only need to launch a browser and the resources of the World Wide Web are at our fingertips, and we are hard pressed to tell the difference between a computer and a game console, a personal digital assistant (such as PalmPilot), or a cell phone. It is now entirely feasible to bring services to smart consumer devices at home and to small businesses through the Internet. Utility providers and network, computer, wireless, consumer electronics, and home appliance companies recognize the tremendous potential and have started to tap into this market. As a result, new horizons are open for application developers.
The Open Services Gateway Initiative (OSGi) was formed to explore these exciting opportunities, and its membership includes such diverse companies as Bell South, Echelon, Electricite de France, IBM, Sun, Ericsson, Nokia, Sony, Maytag, and Whirlpool, to name just a few from a roster of more than 80 organizations. With these combined resources, OSGi stands a good chance to turn this vision into reality.
The OSGi Service Gateway Specification 1.0 defines a Java™ technology-based software architecture for developing and deploying services, which is the topic of this book.
What compels us to write this book, in addition to our enthusiasm for the emerging new applications, is the unique software model involved. We stumbled through a lot of unfamiliar territory ourselves when we worked on the Java Embedded Server™ product, the predecessor to the OSGi Service Gateway Specification, only to find our fellow developers encountering and struggling with the same class of problems. It is our hope to be able to elucidate the model and capture the hard-won solutions in one place.
This book is primarily for programmers interested in writing services for residential gateways in the Java programming language. It should also be useful to anyone who wants to learn about residential gateway technology and the efforts made by the OSGi consortium.
This book may be of interest to those who are involved with component-based software construction in general. Interestingly, nothing in the underlying programming model limits the kinds of applications that can be written. It aims at residential gateway applications at the "small" end of the spectrum in terms of code size and resource consumption, but it is just as viable for developing applications for desktop and enterprise environments. Indeed, the task will be made easier and the end result will be more powerful when fewer constraints on computing resources are imposed.We assume the readers are well versed in the Java programming language and experienced in software development on the Java platform. However, no experience is needed in embedded systems at the hardware and operating system levels.
Many trade-offs on the contents of the book had to be considered, and these were not easy decisions to make. We wrote this book with the following goals in mind:
You can read this book from cover to cover, or you can select the chapters that address your particular needs. For the impatient, it is possible to jump to Chapter 4 and try out the code in action, because clear step-by-step instructions are given. However, you are strongly encouraged to read Chapter 3, which puts things into context.
Chapter 1 describes the backdrop from which the residential gateway market emerged, and its propellants and challenges, then explains the history of the Java Embedded Server product and the OSGi consortium, and introduces our view of what OSGi is trying to achieve.
Chapter 2 outlines steps to develop your first bundle and familiarizes you with the Java Embedded Server execution environment.
Chapter 3 explains the OSGi architecture and basic concepts, including the interaction of various entities during interbundle class sharing, service registration and retrieval, and bundle life cycle operations.
Chapter 4 teaches you how to develop services, how to write library bundles, and how to include native code in your bundles. Two advanced examples are given in this chapter.
Chapter 5 analyzes the dynamic nature of cooperation with services, and proposes strategies to cope with the situation. Events are also discussed at the beginning of this chapter.
Chapter 6 describes design patterns and pitfalls.
Chapter 7 explains how to use the OSGi standard services: HTTP and Log services.
Chapter 8 explains the OSGi Device Access (DA) and how to develop services to communicate with devices using the DA.
Chapter 9 discusses permission-based security and administration.
Chapter 10 summarizes the issues being worked and our view of the future directions that the OSGi consortium could take.
Appendix A contains the complete source code of the examples in this book.
Appendix B is a copy of the OSGi specification. A list of references is included at the end of the book.
A copy of the Java Embedded Server product can be downloaded from Sun Microsystems' Web site at
http://www.sun.com/software/embeddedserverFor updated information about the book, visit the following URL:
http://java.sun.com/docs/books/jesFull details of the OSGi consortium can be found at http://www.osgi.org
Symbols& (AND), 76, 77
* (asterisk), 77, 78
: (colon), 106
, (comma), 252
. (dot), 84, 88
! (NOT), 76,77
/ (forward slash), 169
| (OR), 76, 77
Numbers 3Com, 25
10BaseT Ethernet, 4Aaccept method, 148, 150
AccessController class, 229
Actions, performing privileged, 238-245
Activator.java, 277-278, 283-284, 287, 296-297, 304, 309, 315-318
Activator(s). See also Bundle-Activator: header; BundleActivator interface
basic description of, 31-32
classes, 17-18, 109
common mistakes related to, 105
device access and, 201, 207-209
nullifying references and, 156-157
registering services in, 54-55
service unregistration and, 120
writing, 17
ACTIVE field, 337
ACTIVE state, 40, 262
addBundleListener method, 354
addFrameworkListener method, 355
addLogListener method, 432
addServiceListener method, 119, 355-356
Administration, permission-based. See also Administration, user
APIs for, 261-264
basic description of, 250-263
code for, 297-319
dynamic bundle resolution and, 251-252
Administration, user, 269. See also Administration, permission-based
admin.jar, 251, 253, 257
AdminPermission class, 227, 229, 237, 239, 331, 332-334
AdminPermission constructor, 333
AdminServlet.java, 305-309
ADSL (Asynchronous Digital Subscriber Line), 3
Algorithm(s)
device management and, 404-405
resolution, 258
security and, 229, 241, 258
sorting, 140
Alias(es)
mapping, 169
namespaces, 169-170
parameters, 184
registering, 171, 185
syntax, 184-185
Allied Business Intelligence, 2-3
AllPermission class, 234
American Standard Code for Information Interchange (ASCII). See also
ASCII (American Standard Code for Information Interchange)
America Online (AOL), 25
ampersand (&), 77
APIs (application program interfaces). See also Interfaces
Java Communications API, 187, 198-201, 205
JavaMail API, 86-89, 137
Java Servlet API, 170-171
permissions required by, 230-231
Apple Computer, 195
Application(s)
environment, new, 8-9
logic, 120, 146
ASCII (American Standard Code for Information Interchange), 91
Assembly language, 189
Asterisk (*), 77, 78
Asynchronous Digital Subscriber Line (ADSL). See also ADSL (Asynchronous
Digital Subscriber Line)
AT command, 213
attach method, 208, 212, 408-409
Auditing, 165
Authentication. See also Security
basic, 178-184
HTTP, 178-184
performing, 181-184
user administration and, 269
Authorization, 269. See also Authentication; SecurityBBase
drivers, 193-194, 198-200
URLs, 22
BasicPermission class, 229-231, 248
BasicSchemeHandler service, 178, 182-184
Bierce, Ambrose, 53
BlueTooth, 6, 7, 189
Browser(s)
device access and, 218-220
preferences, storing/retrieving, 268-269
registering images and, 172-176
security and, 238-245
Buffer size, 167
Bundle(s)
basic description of, 16-18, 28-32, 325-326
calling, 37, 61, 73
commands for, 20-21, 22-23
common mistakes related to, 105-106
configuring, 269
that contain native code, 96-105
context, 33, 73
cooperation among, 33-39, 107-129
developing, 51-106, 271-278
framework for, 32-33, 39-45
help for, 20-21
IDs, 19, 39, 262
installing, 19-20, 39, 363-365
JavaMail API and, 86-89
life cycles of, 29-30, 32, 47, 146
locations, 22, 44, 262
the line printer daemon print service and, 89-95
managing references among, 157-160
multithread, 148-152
permission-based administration and, 251-252
phantom, 265-267
removing, 265-267
resolution of, 34, 251-252
retrieving resources from within, 60-61
running, 19-23
service-providing, 37, 61, 66
starting/stopping, 40, 45, 326, 343-345, 351
state, 111
transitive closure of, 251
uninstalling, 45, 155, 158
updating, 42-45
writing, 51-56, 96-105
Bundle activator(s). See also Bundle-Activator: header; BundleActivator interface
basic description of, 31-32
classes, 17-18, 109
common mistakes related to, 105
device access and, 201, 207-209
nullifying references and, 156-157
registering services in, 54-55
service unregistration and, 120
writing, 17
Bundle-Activator: header, 105, 148, 326
BundleActivator interface, 17, 41
basic description of, 330, 350-351
starting/stopping bundles and, 326
bundleChanged method, 375
Bundle-ClassPath: header, 84, 85, 88, 327
Bundle-ContactAddress: header, 261, 327
BundleContext interface, 40, 55, 62-63, 70, 73-80, 145, 218, 231, 263-264
basic description of, 330, 352-358
methods, 354-358
service registry and, 143
Bundle-Description: header, 261, 327
Bundle-DocURL: header, 261, 327
BundleEvent event, 107, 128-129
BundleEvent class, 331, 369-372
BundleEvent constructor, 371
BundleException constructor, 374
BundleException interface, 373-374
BundleException exception, 331
Bundle interface, 231, 252, 261-263, 330, 335-349
BundleListener interface, 128-129, 330, 375
Bundle-Name: header, 261, 326
Bundle-NativeCode: header, 96, 97, 99, 329
bundles command, 20, 23, 56
Bundle-UpdatedLocation: header, 43, 327
Bundle-Vendor: header, 261, 326
Bundle-Version: header, 261, 326CC programming (high-level language), 10, 102, 105, 189
Cable modems. See also Modems
data rates for, 6
transforming, into residential gateways, 9
usage statistics for, 2
Cable Television Laboratories, 6
cache directory, 21
Caching, 21, 69, 158
Cahners In-Stat, 2-3
Callback, 140-143, 159, 244
Cascading service registration, 123-125
CEBus, 2, 6, 7
Certificate(s). See also Security
authorities, 226
public keys in, 226
self-signed, 243
CGI (Common Gateway Interface), 168
changeConfiguration method, 218
checkPermission method, 245, 246
Class(s). See also Classes (listed by name)
compiling, 17-18
encapsulation of, 228
granting permissions to, 228
inheritance, 228
instantiation, 229
loading issues, 64-65
names, fully qualified, 64
origin of, 226