View Javadoc
1   package org.codehaus.plexus.component.manager;
2   
3   /*
4    * Copyright 2001-2006 Codehaus Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * 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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.util.concurrent.atomic.AtomicLong;
20  
21  import org.codehaus.plexus.MutablePlexusContainer;
22  import org.codehaus.plexus.classworlds.realm.ClassRealm;
23  import org.codehaus.plexus.component.factory.ComponentInstantiationException;
24  import org.codehaus.plexus.component.repository.ComponentDescriptor;
25  import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
26  import org.codehaus.plexus.lifecycle.LifecycleHandler;
27  import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException;
28  
29  /**
30   * Manages a component manager.
31   * Determines when a component is shutdown, and when it's started up. Each
32   * manager deals with only one component class, though may handle multiple
33   * instances of this class.
34   *
35   * @author Jason van Zyl
36   *
37   */
38  public interface ComponentManager<T> {
39      String ROLE = ComponentManager.class.getName();
40  
41      /**
42       * @deprecated for internal use only.. will be removed
43       */
44      AtomicLong NEXT_START_ID = new AtomicLong(1);
45  
46      int getConnections();
47  
48      /**
49       * @return {@link LifecycleHandler}.
50       * @deprecated use start instead
51       */
52      LifecycleHandler getLifecycleHandler();
53  
54      void dispose() throws ComponentLifecycleException;
55  
56      void release(Object component) throws ComponentLifecycleException;
57  
58      T getComponent() throws ComponentInstantiationException, ComponentLifecycleException;
59  
60      ComponentDescriptor<T> getComponentDescriptor();
61  
62      Class<? extends T> getType();
63  
64      String getRole();
65  
66      String getRoleHint();
67  
68      MutablePlexusContainer getContainer();
69  
70      void dissociateComponentRealm(ClassRealm realm) throws ComponentLifecycleException;
71  
72      ClassRealm getRealm();
73  
74      void start(Object component) throws PhaseExecutionException;
75  
76      /**
77       * @return The start id.
78       * @deprecated for internal use only.. will be removed
79       */
80      long getStartId();
81  }