001    /*
002     * Copyright (c) OSGi Alliance (2004, 2008). All Rights Reserved.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.osgi.service.component;
018    
019    /**
020     * A ComponentInstance encapsulates a component instance of an activated
021     * component configuration. ComponentInstances are created whenever a component
022     * configuration is activated.
023     * 
024     * <p>
025     * ComponentInstances are never reused. A new ComponentInstance object will be
026     * created when the component configuration is activated again.
027     * 
028     * @ThreadSafe
029     * @version $Revision: 5654 $
030     */
031    public interface ComponentInstance {
032            /**
033             * Dispose of the component configuration for this component instance. The
034             * component configuration will be deactivated. If the component
035             * configuration has already been deactivated, this method does nothing.
036             */
037            public void dispose();
038    
039            /**
040             * Returns the component instance of the activated component configuration.
041             * 
042             * @return The component instance or <code>null</code> if the component
043             *         configuration has been deactivated.
044             */
045            public Object getInstance();
046    }