KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > components > util > infobuilder > CascadingBlockInfoReader


1 /*
2  * Copyright (C) The Loom Group. All rights reserved.
3  *
4  * This software is published under the terms of the Loom
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.components.util.infobuilder;
9
10 import org.codehaus.dna.Logger;
11 import org.codehaus.loom.components.util.info.ComponentInfo;
12
13 /**
14  * @author <a HREF="mailto:peter.royal@pobox.com">peter royal</a>
15  */

16 public class CascadingBlockInfoReader implements BlockInfoReader
17 {
18     private final LegacyBlockInfoReader m_legacyBlockInfoReader;
19     private final MetaClassBlockInfoReader m_metaClassBlockInfoReader = new MetaClassBlockInfoReader();
20
21     public CascadingBlockInfoReader( final ClassLoader JavaDoc classLoader, final Logger logger )
22     {
23         if( null == classLoader )
24         {
25             throw new NullPointerException JavaDoc( "classLoader" );
26         }
27         else if( null == logger )
28         {
29             throw new NullPointerException JavaDoc( "logger" );
30         }
31
32         m_legacyBlockInfoReader = new LegacyBlockInfoReader( classLoader, logger );
33     }
34
35     public ComponentInfo buildComponentInfo( final Class JavaDoc type ) throws Exception JavaDoc
36     {
37         final ComponentInfo legacyComponentInfo = m_legacyBlockInfoReader.buildComponentInfo( type );
38
39         if( null == legacyComponentInfo )
40         {
41             return m_metaClassBlockInfoReader.buildComponentInfo( type );
42         }
43         else
44         {
45             return legacyComponentInfo;
46         }
47     }
48 }
Popular Tags