View Javadoc
1   package org.apache.maven.doxia.module.site.manager;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collection;
23  import java.util.LinkedHashMap;
24  import java.util.Map;
25  
26  import org.apache.maven.doxia.module.site.SiteModule;
27  import org.codehaus.plexus.component.annotations.Component;
28  import org.codehaus.plexus.component.annotations.Requirement;
29  
30  /**
31   * Simple implementation of the SiteModuleManager interface.
32   *
33   * @author Jason van Zyl
34   * @version $Id: DefaultSiteModuleManager.java 1546011 2013-11-27 12:18:20Z hboutemy $
35   * @since 1.0
36   * @deprecated replaced by DefaultParserModuleManager
37   */
38  @Component( role = SiteModuleManager.class )
39  public class DefaultSiteModuleManager
40      implements SiteModuleManager
41  {
42      @Requirement( role = SiteModule.class )
43      private Map<String, SiteModule> siteModules;
44  
45      private Collection<SiteModule> siteModulesValues;
46  
47      /** {@inheritDoc} */
48      public Collection<SiteModule> getSiteModules()
49      {
50          if ( siteModulesValues == null )
51          {
52              Map<Class<?>, SiteModule> siteModulesTmp = new LinkedHashMap<Class<?>, SiteModule>();
53              for ( SiteModule module : siteModules.values() )
54              {
55                  siteModulesTmp.put( module.getClass(), module );
56              }
57              siteModulesValues = siteModulesTmp.values();
58          }
59  
60          return siteModulesValues;
61      }
62  
63      /** {@inheritDoc} */
64      public SiteModule getSiteModule( String id )
65          throws SiteModuleNotFoundException
66      {
67          SiteModule siteModule = siteModules.get( id );
68  
69          if ( siteModule == null )
70          {
71              throw new SiteModuleNotFoundException( "Cannot find site module id = " + id );
72          }
73  
74          return siteModule;
75      }
76  }