Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *              C E D A R
  *          S O L U T I O N S       "Software done right."
  *           S O F T W A R E
  *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  * Copyright (c) 2013 Kenneth J. Pronovici.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the Apache License, Version 2.0.
 * See LICENSE for more information about the licensing terms.
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 * Author   : Kenneth J. Pronovici <pronovic@ieee.org>
 * Language : Java 6
 * Project  : Common Java Functionality
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package com.cedarsolutions.junit.gwt.classloader;
Specialized class loader used for stubbed GWT client tests.

This works through the magic of Javassist. Basically, we create a new classloader that applies specific translations to certain classes.

This class was derived in part from source code in gwt-test-utils. See README.credits for more information.

Author(s):
Kenneth J. Pronovici <pronovic@ieee.org>
public class GwtClassLoader extends Loader {
    private static final GwtClassLoader INSTANCE = new GwtClassLoader(ClassPool.getDefault());
    private GwtClassLoader(ClassPool classPool) {
        super(classPool);
        handleDelegatedClasses();
        addTranslators(classPool);
    }
    public static synchronized GwtClassLoader get() {
        return ;
    }
    public static void reset() {
    }
    private void addTranslators(ClassPool classPool) {
        try {
            addTranslator(classPoolnew GwtCreateTranslator());
        } catch (Exception e) {
            throw new CedarRuntimeException("Error adding translator: " + e.getMessage(), e);
        }
    }
    private void handleDelegatedClasses() {
        // This list was originally derived from the gwt-test-utils.properties file.
        // It should eventually be made configurable, I think. For now, I'm just going
        // to leave it and see what problems I find.
        delegateLoadingOf("javassist.");
        delegateLoadingOf("org.aopalliance.");
        delegateLoadingOf("org.junit.");
        delegateLoadingOf("org.apache.");
        delegateLoadingOf("com.cedarsolutions.util.junit.gwt.classloader.GwtClassLoader");
        delegateLoadingOf("org.springframework.");
    }
New to GrepCode? Check out our FAQ X