| /* |
| * 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. |
| */ |
| package org.apache.felix.cm.impl.helper; |
| |
| import java.util.Dictionary; |
| |
| import org.apache.felix.cm.impl.ConfigurationImpl; |
| import org.apache.felix.cm.impl.ConfigurationManager; |
| import org.osgi.framework.ServiceReference; |
| import org.osgi.service.cm.ManagedServiceFactory; |
| |
| public class ManagedServiceFactoryTracker extends BaseTracker<ManagedServiceFactory> |
| { |
| |
| public ManagedServiceFactoryTracker( ConfigurationManager cm ) |
| { |
| super( cm, ManagedServiceFactory.class ); |
| } |
| |
| |
| @Override |
| protected boolean isFactory() |
| { |
| return true; |
| } |
| |
| |
| @Override |
| public void provide( ServiceReference<ManagedServiceFactory> reference, final ConfigurationImpl config, final Dictionary<String, ?> rawProps ) |
| { |
| ManagedServiceFactory service = getRealService( reference ); |
| if ( service != null ) |
| { |
| try |
| { |
| Dictionary props = getProperties( rawProps, config.getFactoryPid(), reference ); |
| service.updated( config.getPid(), props ); |
| } |
| catch ( Throwable t ) |
| { |
| this.cm.handleCallBackError( t, reference, config ); |
| } |
| finally |
| { |
| this.ungetRealService( reference ); |
| } |
| } |
| } |
| |
| |
| @Override |
| public void remove( ServiceReference<ManagedServiceFactory> reference, final ConfigurationImpl config ) |
| { |
| ManagedServiceFactory service = this.getRealService( reference ); |
| if ( service != null ) |
| { |
| try |
| { |
| service.deleted( config.getPid() ); |
| } |
| catch ( Throwable t ) |
| { |
| this.cm.handleCallBackError( t, reference, config ); |
| } |
| finally |
| { |
| this.ungetRealService( reference ); |
| } |
| } |
| } |
| } |