blob: 89e9c3b540261047ca5937332caf9237a24cdda6 [file] [log] [blame]
Marcel Offermans001db052009-12-08 08:58:40 +00001/*
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 */
19package org.apache.felix.dm.impl;
20
21import org.apache.felix.dm.DependencyManager;
22import org.apache.felix.dm.resources.Resource;
23
24public class ResourceAdapterImpl {
25 private volatile DependencyManager m_manager;
26 private final Object m_impl;
27 private final Class m_iface;
Marcel Offermansd403a1d2009-12-10 09:57:06 +000028 private final boolean m_propagate;
Marcel Offermans001db052009-12-08 08:58:40 +000029
Marcel Offermansd403a1d2009-12-10 09:57:06 +000030 public ResourceAdapterImpl(Object impl, Class iface, boolean propagate) {
Marcel Offermans001db052009-12-08 08:58:40 +000031 m_impl = impl;
32 m_iface = iface;
Marcel Offermansd403a1d2009-12-10 09:57:06 +000033 m_propagate = propagate;
Marcel Offermans001db052009-12-08 08:58:40 +000034 }
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 Offermansd403a1d2009-12-10 09:57:06 +000044 .setPropagate(m_propagate)
Marcel Offermans001db052009-12-08 08:58:40 +000045 )
46 );
47 }
48
49 public void removed(Resource resource) {
50 }
51
52}