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, Jerome Dochez

Field Summary
 Habitat habitat
           
 
Constructor Summary
InhabitantsParser(Habitat habitat)
           
 
Method Summary
protected  void add(Inhabitant<?> i, InhabitantParser parser)
          Adds the given inhabitant to the habitat, with all its indices.
 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(java.lang.Iterable<InhabitantParser> 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(java.lang.Iterable<InhabitantParser> 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,
                   InhabitantParser parser)
Adds the given inhabitant to the habitat, with all its indices.



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