View Javadoc
1   package org.codehaus.plexus.personality.plexus.lifecycle.phase;
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 org.codehaus.plexus.PlexusContainer;
20  import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
21  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
22  
23  import java.util.List;
24  import java.util.Map;
25  
26  /**
27   * A ServiceLocator for PlexusContainer.
28   *
29   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
30   */
31  public class PlexusContainerLocator
32      implements ServiceLocator
33  {
34      private PlexusContainer container;
35  
36      public PlexusContainerLocator( PlexusContainer container )
37      {
38          this.container = container;
39      }
40  
41      public Object lookup( String role )
42          throws ComponentLookupException
43      {
44          return container.lookup( role );
45      }
46  
47      public Object lookup( String role,
48                            String roleHint )
49          throws ComponentLookupException
50      {
51          return container.lookup( role, roleHint );
52      }
53  
54      public Map lookupMap( String role )
55          throws ComponentLookupException
56      {
57          return container.lookupMap( role );
58      }
59  
60      public List lookupList( String role )
61          throws ComponentLookupException
62      {
63          return container.lookupList( role );
64      }
65  
66      public void release( Object component )
67          throws ComponentLifecycleException
68      {
69          container.release( component );
70      }
71  
72      public void releaseAll( Map components )
73          throws ComponentLifecycleException
74      {
75          container.releaseAll( components );
76      }
77  
78      public void releaseAll( List components )
79          throws ComponentLifecycleException
80      {
81          container.releaseAll( components );
82      }
83  
84      public boolean hasComponent( String componentKey )
85      {
86          return container.hasComponent( componentKey );
87      }
88  
89      public boolean hasComponent( String role,
90                                   String roleHint )
91      {
92          return container.hasComponent( role, roleHint );
93      }
94  }