Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2010-2012 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.callbackparams.internal;
import  org.apache.bcel.Constants;
Used by CallbackTestClassReloader to make sure that no classes bcel- classes, JUnit-classes or classes from the combine-packages are reloaded! It also allows test-runner implementations to specify special additional filtering by passing a special CallbackTestClassReloader.ReloadFilter instance to the constructor.

Author(s):
Henrik Kaipe
public final class GeneralReloadFilter
    private static final String combinePackagePrefix =
            CombineStrategy.class.getName().substring(0,
            CombineStrategy.class.getName().lastIndexOf('.') + 1);
    
The annotation-classes org.callbackparams.ParameterizedCallback and org.callbackparams.ParameterizedValue should not be reloaded, because they are used by the combine-package. Well, at least org.callbackparams.ParameterizedValue is!

See also:
org.callbackparams.combine.annotation.AnnotationAwareCallbackRecordsFactory
    private static final String coreApiAnnotationsPrefix =
            CallbackFactory.class.getName().substring(0,
            CallbackFactory.class.getName().lastIndexOf('.'))
            + ".Parameterized";
    private static final String bcelPackagePrefix =
            Constants.class.getName().substring(0,
            Constants.class.getName().lastIndexOf('.') + 1);

    
The JUnit-dependencies are optional so their package prefixes must be hardcoded in case there are no JUnit-jars on classpath.
    private static final String
            junit3PackagePrefix = "junit.",
            junit4PackagePrefix = "org.junit.",
            hamcrestInternal = "org.hamcrest.internal.",
            hamcrestCore = "org.hamcrest.core.";
    private static final String[] filteredClassNamePrefixes = {
    };
    public GeneralReloadFilter(
            CallbackTestClassReloader.ReloadFilter specialReloadFilter) {
        this. = specialReloadFilter;
    }
    public boolean needsToBeReloaded(String classNameToReload) {
        for (int i = 0 ; i < . ; ++i) {
            if (classNameToReload.startsWith([i])) {
                return false;
            }
        }
        return isPackageHamcrestBase(classNameToReload) ? false
                : null == 
                || .needsToBeReloaded(classNameToReload);
    }
    private boolean isPackageHamcrestBase(String className) {
        String hamcrestBasePackage = "org.hamcrest";
        return className.lastIndexOf('.') == hamcrestBasePackage.length()
                && className.startsWith(hamcrestBasePackage);
    }
New to GrepCode? Check out our FAQ X