com.sun.hk2.component
Class InhabitantsParser

java.lang.Object
  extended by com.sun.hk2.component.InhabitantsParser

public class InhabitantsParser
extends java.lang.Object

Parses /META-INF/inhabitants and populate Habitat.

This class can be subclasses to customize the parsing behavior, which is useful for ignoring some components.

Author:
Kohsuke Kawaguchi

Field Summary
 Habitat habitat
           
 
Constructor Summary
InhabitantsParser(Habitat habitat)
           
 
Method Summary
protected  void add(Inhabitant i, KeyValuePairParser kvpp)
          Adds the given inhabitant to the habitat, with all its indices.
static MultiMap<java.lang.String,java.lang.String> buildMetadata(KeyValuePairParser kvpp)
           
 void drop(java.lang.Class component)
          Tells InhabitantsParser that if it encounters the specified component while parsing inhabitants file, simply drop it and pretend that such an inhabitant had never existed.
 void drop(java.lang.String fullyQualifiedClassName)
           
 void parse(InhabitantsScanner scanner, Holder<java.lang.ClassLoader> classLoader)
          Parses the inhabitants file (which is represented by InhabitantsScanner.
 void replace(java.lang.Class oldComponent, java.lang.Class newComponent)
          Tells InhabitantsParser that if it encounters the specified component while parsing inhabitants file, ignore the one in the inhabitants file and instead insert the specified 'new' component.
 void replace(java.lang.String oldComponentFullyQualifiedClassName, java.lang.Class newComponent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

habitat

public final Habitat habitat
Constructor Detail

InhabitantsParser

public InhabitantsParser(Habitat habitat)
Method Detail

drop

public void drop(java.lang.Class component)
Tells InhabitantsParser that if it encounters the specified component while parsing inhabitants file, simply drop it and pretend that such an inhabitant had never existed.

This is useful when the application that's hosting an HK2 environment wants to tweak the inhabitant population at sub-module level.


drop

public void drop(java.lang.String fullyQualifiedClassName)

replace

public void replace(java.lang.Class oldComponent,
                    java.lang.Class newComponent)
Tells InhabitantsParser that if it encounters the specified component while parsing inhabitants file, ignore the one in the inhabitants file and instead insert the specified 'new' component.

This is useful when the application that's hosting an HK2 environment wants to tweak the inhabitant population at sub-module level.


replace

public void replace(java.lang.String oldComponentFullyQualifiedClassName,
                    java.lang.Class newComponent)

parse

public void parse(InhabitantsScanner scanner,
                  Holder<java.lang.ClassLoader> classLoader)
           throws java.io.IOException
Parses the inhabitants file (which is represented by InhabitantsScanner.

All the earlier drop/replace commands will be honored during this process.

Throws:
java.io.IOException

add

protected void add(Inhabitant i,
                   KeyValuePairParser kvpp)
Adds the given inhabitant to the habitat, with all its indices.


buildMetadata

public static MultiMap<java.lang.String,java.lang.String> buildMetadata(KeyValuePairParser kvpp)


Copyright © 2009 Sun Microsystems, Inc.. All Rights Reserved.