blob: 58eed845d5dcae2752eaca76a1607774c8541c41 [file] [log] [blame]
Felix Meschbergere7f513f2012-07-02 14:00:02 +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.cm.impl.helper;
20
21import java.util.Dictionary;
22
23import org.apache.felix.cm.impl.ConfigurationImpl;
24import org.apache.felix.cm.impl.ConfigurationManager;
25import org.osgi.framework.ServiceReference;
26import org.osgi.service.cm.ManagedServiceFactory;
27
28public class ManagedServiceFactoryTracker extends BaseTracker<ManagedServiceFactory>
29{
30
31 public ManagedServiceFactoryTracker( ConfigurationManager cm )
32 {
Felix Meschberger382a19b2012-07-03 09:45:14 +000033 super( cm, true );
Felix Meschbergere7f513f2012-07-02 14:00:02 +000034 }
35
36
37 @Override
Felix Meschbergeraccd9012012-07-02 15:18:08 +000038 public void provideConfiguration( ServiceReference<ManagedServiceFactory> reference, final ConfigurationImpl config, final Dictionary<String, ?> rawProps )
Felix Meschbergere7f513f2012-07-02 14:00:02 +000039 {
40 ManagedServiceFactory service = getRealService( reference );
41 if ( service != null )
42 {
43 try
44 {
45 Dictionary props = getProperties( rawProps, config.getFactoryPid(), reference );
46 service.updated( config.getPid(), props );
47 }
48 catch ( Throwable t )
49 {
Felix Meschberger382a19b2012-07-03 09:45:14 +000050 this.handleCallBackError( t, reference, config );
Felix Meschbergere7f513f2012-07-02 14:00:02 +000051 }
52 finally
53 {
54 this.ungetRealService( reference );
55 }
56 }
57 }
58
59
60 @Override
Felix Meschbergeraccd9012012-07-02 15:18:08 +000061 public void removeConfiguration( ServiceReference<ManagedServiceFactory> reference, final ConfigurationImpl config )
Felix Meschbergere7f513f2012-07-02 14:00:02 +000062 {
63 ManagedServiceFactory service = this.getRealService( reference );
64 if ( service != null )
65 {
66 try
67 {
68 service.deleted( config.getPid() );
69 }
70 catch ( Throwable t )
71 {
Felix Meschberger382a19b2012-07-03 09:45:14 +000072 this.handleCallBackError( t, reference, config );
Felix Meschbergere7f513f2012-07-02 14:00:02 +000073 }
74 finally
75 {
76 this.ungetRealService( reference );
77 }
78 }
79 }
80}