blob: ec3612d4ccfc8c4823e580f9214ea0031db2de78 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
This is an example showing a Dependency Manager "Adapter" in action, using DM annotations. Two kinds
of services are registered in the registry: some Device, and some DeviceParameter services. For each
Device (having a given id), there is also a corresponding "DeviceParameter" service, having the same
id.
Then a "DeviceAccessImpl" adapter service is defined: it is used to "adapt" the "Device" service to
a "DeviceAccess" service, which provides the union of each pair of Device/DeviceParameter having the
same device.id . The adapter also dynamically propagate the service properties of the adapted Device
service.
Start the test by clicking on the "device.annot.bndrun" descriptor, then run it, and type under gogo shell:
g! log warn
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - Handling device access: id=1
device=Device #1
device parameter=DeviceParameter #1
device access properties={service.bundleid=12, service.id=31, service.scope=singleton, objectClass=[Ljava.lang.String;@6e38921c, device.id=1, device.access.id=1}
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - DeviceAccessImpl.start
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - DeviceAccessImpl.init: device id=1
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - Handling device access: id=0
device=Device #0
device parameter=DeviceParameter #0
device access properties={service.bundleid=12, service.id=28, service.scope=singleton, device.id=0, objectClass=[Ljava.lang.String;@6e38921c, device.access.id=0}
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - DeviceAccessImpl.start
2016.02.08 22:05:45 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.annot - DeviceAccessImpl.init: device id=0