Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.dm.impl; |
| 20 | |
| 21 | import org.apache.felix.dm.DependencyManager; |
| 22 | import org.apache.felix.dm.resources.Resource; |
| 23 | |
| 24 | public class ResourceAdapterImpl { |
| 25 | private volatile DependencyManager m_manager; |
| 26 | private final Object m_impl; |
| 27 | private final Class m_iface; |
Marcel Offermans | d403a1d | 2009-12-10 09:57:06 +0000 | [diff] [blame^] | 28 | private final boolean m_propagate; |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 29 | |
Marcel Offermans | d403a1d | 2009-12-10 09:57:06 +0000 | [diff] [blame^] | 30 | public ResourceAdapterImpl(Object impl, Class iface, boolean propagate) { |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 31 | m_impl = impl; |
| 32 | m_iface = iface; |
Marcel Offermans | d403a1d | 2009-12-10 09:57:06 +0000 | [diff] [blame^] | 33 | m_propagate = propagate; |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | public void added(Resource resource) { |
| 37 | System.out.println("ADDED " + resource); |
| 38 | m_manager.add(m_manager.createService() |
| 39 | .setInterface(m_iface.getName(), null) |
| 40 | .setImplementation(m_impl) |
| 41 | .add(m_manager.createResourceDependency() |
| 42 | .setResource(resource) |
| 43 | .setRequired(true) |
Marcel Offermans | d403a1d | 2009-12-10 09:57:06 +0000 | [diff] [blame^] | 44 | .setPropagate(m_propagate) |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 45 | ) |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | public void removed(Resource resource) { |
| 50 | } |
| 51 | |
| 52 | } |