Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.nanocontainer.script
Class ScriptBuilderResolver

    java.lang.Object
      org.nanocontainer.script.ScriptBuilderResolver

    public class ScriptBuilderResolver

extends Object

ScriptBuilderResolver handles the task of resolving a file name to a builder name. Typical default resolution is for Groovy, BeanShell, JavaScript, Jython, and XML script names. However, you can register/replace your own builder implementations by using the registerBuilder() function.

Author:
  Michael Rimov

Field Summary
`static String` | `BEANSHELL`
`static String` | `DEFAULT_BEANSHELL_BUILDER`
`static String` | `DEFAULT_GROOVY_BUILDER`
`static String` | `DEFAULT_JAVASCRIPT_BUILDER`
`static String` | `DEFAULT_JYTHON_BUILDER`
`static String` | `DEFAULT_XML_BUILDER`
`static String` | `GROOVY`
`static String` | `JAVASCRIPT`
`static String` | `JYTHON`
`static String` | `XML`

Constructor Summary
`ScriptBuilderResolver()`

Method Summary
`String[]` | `getAllSupportedExtensions()` Retrieve a list of all supported extensions.
`String` | `getBuilderClassName(File compositionFile)` Retrieve the classname of the appropriate ScriptedContainerBuilder given the file.
`String` | `getBuilderClassName(String extension)` Retrieve the classname of the builder to use given the provided extension.
`String` | `getBuilderClassName(URL compositionURL)` Retrieve the classname of the appropriate ScriptedContainerBuilder given the file.
`void` | `registerBuilder(String extension, String className)` Registers/replaces a new handler for a given extension.
`void` | `resetBuilders()` Function to allow the resetting of the builder map to defaults.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### GROOVY

    public static final String GROOVY

See Also:
  Constant Field Values

### BEANSHELL

    public static final String BEANSHELL

See Also:
  Constant Field Values

### JAVASCRIPT

    public static final String JAVASCRIPT

See Also:
  Constant Field Values

### JYTHON

    public static final String JYTHON

See Also:
  Constant Field Values

### XML

    public static final String XML

See Also:
  Constant Field Values

### DEFAULT_GROOVY_BUILDER

    public static final String DEFAULT_GROOVY_BUILDER

See Also:
  Constant Field Values

### DEFAULT_BEANSHELL_BUILDER

    public static final String DEFAULT_BEANSHELL_BUILDER

See Also:
  Constant Field Values

### DEFAULT_JAVASCRIPT_BUILDER

    public static final String DEFAULT_JAVASCRIPT_BUILDER

See Also:
  Constant Field Values

### DEFAULT_XML_BUILDER

    public static final String DEFAULT_XML_BUILDER

See Also:
  Constant Field Values

### DEFAULT_JYTHON_BUILDER

    public static final String DEFAULT_JYTHON_BUILDER

See Also:
  Constant Field Values

Constructor Detail

### ScriptBuilderResolver

    public ScriptBuilderResolver()

Method Detail

### getBuilderClassName

    public String getBuilderClassName(File compositionFile)

  Retrieve the classname of the appropriate ScriptedContainerBuilder given the file.

  Parameters:
    `compositionFile` - File
  Returns:
    String

### getBuilderClassName

    public String getBuilderClassName(URL compositionURL)

  Retrieve the classname of the appropriate ScriptedContainerBuilder given the file.

  Parameters:
    `compositionFile` - File
  Returns:
    String

### getBuilderClassName

    public String getBuilderClassName(String extension)
                               throws UnsupportedScriptTypeException

  Retrieve the classname of the builder to use given the provided extension. Example: `

       ScriptedContainerBuilderFactory factory = new ScriptedContainerBuilderFactory(.....);
       String groovyBuilderName = factory.getBuilderClassName(".groovy");
       assert "org.nanocontainer.script.groovy.GroovyContainerBuilder".equals(groovyBuilderName);

  `

  Parameters:
    `extension` - String
  Returns:
    String
  Throws:
    `UnsupportedScriptTypeException`

### resetBuilders

    public void resetBuilders()

  Function to allow the resetting of the builder map to defaults. Allows testing of the static resource a bit better.

### registerBuilder

    public void registerBuilder(String extension,
                                String className)

  Registers/replaces a new handler for a given extension. Allows for customizable behavior in the various builders or the possibility to dynamically add handlers for new file types. Example: `

       ScriptedContainerBuilderFactory factory = new ScriptedContainerBuilderFactory(...)
       factory.registerBuilder(".groovy", "org.nanocontainer.script.groovy.GroovyContainerBuilder");
       ScriptedContainerBuilder builder = factory.getContainerBuilder();
       assertNotNull(builder);

  `

  The internal code now requires synchronization of the builder extension map since who knows what is using it when a new builder is registered.

  Parameters:
    `extension` - String the extension to register under.
    `className` - String the classname to use for the given extension.

### getAllSupportedExtensions

    public String[] getAllSupportedExtensions()

  Retrieve a list of all supported extensions.

  Returns:
    String[] of extensions including the period in the name.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Codehaus. All Rights Reserved.