Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011 Project Funcito Contributors

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

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.funcito.internal.stub;
public abstract class ProxyFactory {
    private static ProxyFactory instance = null;
    private static ProxyUtils proxyUtils = new ProxyUtils();
    private Map<ClassObjectproxyCache = new HashMap<ClassObject>();
    public static ProxyFactory instance() {
        if ( == null) {
             = .getOverrideBySystemProperty();
            if ( == null) {
                 = .getExactlyOneFactoryFromClasspath();
        return ;

Exists for benchmarks suite, to try with different proxy providers
    public static void reset() {
         = null;
    public <T> T proxy(Class<T> clazzClass<?>... additionalInterfaces) {
        T proxy = clazz.cast(.get(clazz));
        if (proxy == null || (additionalInterfaces!=null && additionalInterfaces.length>0)) {
            proxy = proxyImpl(clazzadditionalInterfaces);
        return proxy;
    protected abstract <T> T proxyImpl(Class<T> clazzClass<?>... additionalInterfaces);
    public boolean canImposterise(Class<?> type) {
        return !type.isPrimitive() && !Modifier.isFinal(type.getModifiers()) && !type.isAnonymousClass();
New to GrepCode? Check out our FAQ X