001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020package org.apache.felix.ipojo.dependency.interceptors;
021
022import org.apache.felix.ipojo.util.DependencyModel;
023
024/**
025 * Dependency interceptor are collaborating with the service dependency during the service resolution.
026 *
027 * Interceptors publishes a service property (target) to select the dependencies they handle.
028 *
029 * Notice that interceptor can invalidate the set of service used by a dependency by calling
030 * {@link org.apache.felix.ipojo.util.DependencyModel#invalidateMatchingServices()} and
031 * {@link org.apache.felix.ipojo.util.DependencyModel#invalidateSelectedServices()}.
032 */
033public interface DependencyInterceptor {
034
035    /**
036     * A mandatory property published by provider of this service.
037     * The value must be a LDAP filter (Filter or String). This filter will be confronted to the dependency property.
038     *
039     * @see org.osgi.framework.Filter
040     */
041    public static String TARGET_PROPERTY = "target";
042
043
044    /**
045     * The interceptor is plugged to the given dependency.
046     * @param dependency the dependency starting using the interceptor.
047     */
048    public void open(DependencyModel dependency);
049
050    /**
051     * The interceptor won't be use anymore by the given dependency.
052     * This method is called either when the interceptor is replace or when the instance's dependency is stopping.
053     * @param dependency the dependency stopping its use of the interceptor
054     */
055    public void close(DependencyModel dependency);
056}