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)
          Adds the given inhabitant to the habitat
protected  void add(Inhabitant<?> i, InhabitantParser parser)
          Adds the given inhabitant to the habitat, with all its indices.
protected  void addIndex(Inhabitant<?> i, java.lang.String typeName, java.lang.String name)
          Adds the given inhabitant index to the habitat
 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)
           
protected  boolean isFilteredInhabitant(InhabitantParser inhabitantParser)
          Returns true if this inhabitant should be ignored.
protected  boolean isFilteredInhabitant(java.lang.String typeName)
          Returns true if this inhabitant should be ignored.
 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

isFilteredInhabitant

protected boolean isFilteredInhabitant(InhabitantParser inhabitantParser)
Returns true if this inhabitant should be ignored.

Parameters:
inhabitantParser -
Returns:

isFilteredInhabitant

protected boolean isFilteredInhabitant(java.lang.String typeName)
Returns true if this inhabitant should be ignored.

Parameters:
typeName -
Returns:

add

protected void add(Inhabitant<?> i,
                   InhabitantParser parser)
Adds the given inhabitant to the habitat, with all its indices.


add

protected void add(Inhabitant<?> i)
Adds the given inhabitant to the habitat

Parameters:
i -

addIndex

protected void addIndex(Inhabitant<?> i,
                        java.lang.String typeName,
                        java.lang.String name)
Adds the given inhabitant index to the habitat



Copyright © 2011 Oracle Corporation. All Rights Reserved.