blob: afd53adfdda86dcb337a04c3e028d72a25a5eb01 [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. 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.api.bndrun" descriptor, then run it, and type under gogo shell:
g! log warn
You will then see:
2016.02.08 23:04:46 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.api - DeviceAccessConsumer: Handling device access: id=2
device=Device #2
device parameter=DeviceParameter #2
device access properties={service.bundleid=12, service.id=28, service.scope=singleton, objectClass=[Ljava.lang.String;@679b62af, device.access.id=2, device.id=2}
2016.02.08 23:04:46 WARNING - Bundle: org.apache.felix.dependencymanager.samples.device.api - DeviceAccessConsumer: Handling device access: id=1
device=Device #1
device parameter=DeviceParameter #1
device access properties={service.bundleid=12, service.id=29, service.scope=singleton, objectClass=[Ljava.lang.String;@679b62af, device.id=1, device.access.id=1}