org.zeroturnaround.javarebel
Interface Configuration


public interface Configuration

This class manages JavaRebel configuration.

To manage the classes that will be instrumented use the filter methods addExcludeManagedFilter(ClassFilter) and addIncludeManagedFilter(ClassFilter). If you need to override the default behavior (e.g. you don't need class files to be managed) use clearManagedFilters() to disable the default filters. If you want to filter classes by packages you can use PackageClassFilter.

The filter methods work as follows:

  • If at least one exclude filter matches a class it will not be instrumented.
  • If none of the exclude filters match a class and at least one of the include filters matches a class it will be instrumented.
  • For example, if you want all classes in a particular JAR to be instrumented you can use a following filter:

       ConfigurationFactory.getInstance()
         .addIncludeManagedFilter(new ClassFilter() {
         public boolean matches(ClassLoader cl, String className,
             ClassResource classResource) {        
           return classResource.toURL().getPath().contains("mylibrary.jar");
         }
       });
     

    To manage monitored directories use the method addMonitoredDir(File)

    Author:
    Jevgeni Kabanov (ekabanov@zeroturnaround.com)
    See Also:
    ConfigurationFactory, Integration, Reloader, Logger, Plugin

    Field Summary
    static java.lang.String SYSPROP_MANAGED_PACKAGES
              This system property should be set to a comma-separated list of Java packages.
    static java.lang.String SYSPROP_MANAGED_PACKAGES_EXCLUDE
              This system property should be set to a comma-separated list of Java packages.
    static java.lang.String SYSPROP_MANAGED_PACKAGES_INCLUDE
              This system property should be set to a comma-separated list of Java packages.
    static java.lang.String SYSPROP_MONITORED_DIRS
              This system property should be set to a comma-separated list of directories.
     
    Method Summary
     void addExcludeManagedFilter(ClassFilter classFilter)
              Adds an exclude filter for managed classes.
     void addIncludeManagedFilter(ClassFilter classFilter)
              Adds an include filter for managed classes.
     void addMonitoredDir(java.io.File dir)
              Adds a monitored directory.
     void clearManagedFilters()
              Clears all currently used filters including the default ones.
     java.io.File[] getMonitoredDirs()
              Returns all currently monitored directories.
     boolean isManagedClass(java.lang.ClassLoader cl, java.lang.String classname, ClassResource cr)
              Returns whether the filters will allow the given class to be managed.
     

    Field Detail

    SYSPROP_MANAGED_PACKAGES

    static final java.lang.String SYSPROP_MANAGED_PACKAGES
    This system property should be set to a comma-separated list of Java packages. JavaRebel will then only manage classes in those packages and their subpackages. This is mainly used to restrict instrumenting to only a limited subset of classes, e.g. to improve performance.
    For example -Drebel.packages=com.mycompany.mypackage,com.thirdparty.theirpackage.

    See Also:
    Constant Field Values

    SYSPROP_MANAGED_PACKAGES_EXCLUDE

    static final java.lang.String SYSPROP_MANAGED_PACKAGES_EXCLUDE
    This system property should be set to a comma-separated list of Java packages. JavaRebel will not manage classes in those packages and their subpackages. This is mainly used to exclude classes that produce errors with JavaRebel from being instrumented.
    For example -Drebel.packages_exclude=com.mycompany.mypackage,com.thirdparty.theirpackage.

    See Also:
    Constant Field Values

    SYSPROP_MANAGED_PACKAGES_INCLUDE

    static final java.lang.String SYSPROP_MANAGED_PACKAGES_INCLUDE
    This system property should be set to a comma-separated list of Java packages. JavaRebel will also manage classes in those packages and their subpackages. This is mainly used to enable JAR file reloading.
    For example -Drebel.packages_include=com.mycompany.mypackage,com.thirdparty.theirpackage.

    See Also:
    Constant Field Values

    SYSPROP_MONITORED_DIRS

    static final java.lang.String SYSPROP_MONITORED_DIRS
    This system property should be set to a comma-separated list of directories. Those directories should have the same layout as if they were in the classpath. The classes in those directories will be monitored for class changes. This is mainly meant to use with unexploded development by setting this property to the IDE class output directories.
    For example -Drebel.dirs=c:/workspace/myproject/bin;c:/workspace/mylibrary/bin.

    See Also:
    Constant Field Values
    Method Detail

    clearManagedFilters

    void clearManagedFilters()
    Clears all currently used filters including the default ones. Use it if you need to override the default behavior (e.g. you don't need class files to be managed).


    addIncludeManagedFilter

    void addIncludeManagedFilter(ClassFilter classFilter)
    Adds an include filter for managed classes. If none of the exclude filters match a class and at least one of the include filters matches a class it will be instrumented by JavaRebel.


    addExcludeManagedFilter

    void addExcludeManagedFilter(ClassFilter classFilter)
    Adds an exclude filter for managed classes. If at least one exclude filter matches a class it will not be instrumented by JavaRebel.


    isManagedClass

    boolean isManagedClass(java.lang.ClassLoader cl,
                           java.lang.String classname,
                           ClassResource cr)
    Returns whether the filters will allow the given class to be managed.


    addMonitoredDir

    void addMonitoredDir(java.io.File dir)
    Adds a monitored directory. These directories should have the same layout as if they were in the classpath. The classes in those directories will be monitored for class changes. This is mainly meant to use with unexploded development by setting this property to the IDE class output directories.


    getMonitoredDirs

    java.io.File[] getMonitoredDirs()
    Returns all currently monitored directories.