Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/ide/extension/spi/FeatureRegistry.java


1   package javax.ide.extension.spi;
2   
3   import java.util.Map;
4   
5   import javax.ide.Service;
6   import javax.ide.spi.ProviderNotFoundException;
7   import javax.ide.extension.Extension;
8   import javax.ide.extension.ExtensionRegistry;
9   /**
10   * The feature registry provides access to information about extensions which
11   * are declared as features in their extension manifest. It is only intended to
12   * be used by integrators writing IDE support for JSR198.
13   */
14  public class FeatureRegistry extends Service
15  {
16  
17    private Map _features;
18    
19    /**
20     * Gets the feature corresponding to the specified extension.
21     * 
22     * @param extension the extension to get the feature for.
23     * @return The feature for the specified extension, or <tt>null</tt> if
24     *    no feature exists for that extension.
25     */
26    public Feature getFeature( Extension extension )
27    {  
28      if ( _features == null )
29      {
30        return null;
31      }
32      return (Feature) _features.get( extension.getID() );
33    }
34    
35    protected void initialize()
36    {
37      FeatureHook featureHook = (FeatureHook) 
38        ExtensionRegistry.getExtensionRegistry().getHook( FeatureHook.ELEMENT );
39        
40      _features = featureHook.getFeatures();
41    }
42    
43    public static FeatureRegistry getFeatureRegistry()
44    {
45      try
46      {
47        return (FeatureRegistry) getService( FeatureRegistry.class );
48      }
49      catch ( ProviderNotFoundException nse )
50      {
51        nse.printStackTrace();
52        throw new IllegalStateException( "No feature registry" );
53      }
54    }
55  }