public BeanShellTileSourceTemplate(String name, String urlToLoad, String ext, int maxZoom, int minZoom, int tileSize, int bitDensity, int avgSize) { super(name, urlToLoad, ext, maxZoom, minZoom, tileSize, bitDensity, avgSize); bshInterpreter = new Interpreter(); try { bshInterpreter.eval(urlToLoad); bshInterpreter.getClassManager().setClassLoader(new ClassLoader() { @Override public URL getResource(String resName) { return null; } @Override public InputStream getResourceAsStream(String resName) { return null; } @Override public Class<?> loadClass(String className) throws ClassNotFoundException { throw new ClassNotFoundException("Error requesting " + className); } }); } catch (bsh.EvalError e) { log.error("Error executing the map init script " + urlToLoad, e); } }
master = (BshClassManager) masterClassManagers.get(classLoader); if (master == null) { master = BshClassManager.createClassManager(); master.setClassLoader(classLoader); masterClassManagers.put(classLoader, master);
public void initService() { bsh = new Interpreter (); BshClassManager bcm = bsh.getClassManager(); try { bcm.setClassPath(getServer().getLoader().getURLs()); } catch (UtilEvalError e) { e.printStackTrace(); } bcm.setClassLoader(getServer().getLoader()); } public void startService() {
getClassManager().cacheClassInfo( fullname, clas ); return clas; if ( bcm.hasSuperImport() ) String s = bcm.getClassNameByUnqName( name ); if ( s != null ) return classForName( s );
public ClassBrowser() { this( BshClassManager.createClassManager( null/*interpreter*/ ) ); }
/** Set a new base classpath and create a new base classloader. This means all types change. */ public void setClassPath( URL [] cp ) throws UtilEvalError { throw cmUnavailable(); }
InputStream in = bcm.getResourceAsStream( scriptPath ); Class clas = bcm.classForName( className ); if ( clas != null ) return clas;
scriptPath = path + "/" + name + ".bsh"; Interpreter.debug("searching for script: " + scriptPath); URL url = bcm.getResource(scriptPath); if (null != url) try { return this.loadScriptedCommand((InputStream) url.getContent(), + name; Interpreter.debug("searching for class: " + className); final Class<?> clas = bcm.classForName(className); if (clas != null) return clas;
public boolean classExists( String name ) { return classForName( name ) != null ; }
public NameSpace( NameSpace parent, BshClassManager classManager, String name ) { // We might want to do this here rather than explicitly in Interpreter // for global (see also prune()) //if ( classManager == null && (parent == null ) ) // create our own class manager? setName(name); setParent(parent); setClassManager( classManager ); // Register for notification of classloader change if ( classManager != null ) classManager.addListener(this); }
/** Clear all loaders and start over. No class loading. */ public void reset() { clearCaches(); }
/** Set an external class loader. BeanShell will use this at the same point it would otherwise use the plain Class.forName(). i.e. if no explicit classpath management is done from the script (addClassPath(), setClassPath(), reloadClasses()) then BeanShell will only use the supplied classloader. If additional classpath management is done then BeanShell will perform that in addition to the supplied external classloader. However BeanShell is not currently able to reload classes supplied through the external classloader. */ public void setClassLoader( ClassLoader externalCL ) { externalClassLoader = externalCL; classLoaderChanged(); }
/** Perform a plain Class.forName() or call the externally provided classloader. If a BshClassManager implementation is loaded the call will be delegated to it, to allow for additional hooks. <p/> This simply wraps that bottom level class lookup call and provides a central point for monitoring and handling certain Java version dependent bugs, etc. @see #classForName( String ) @return the class */ public Class<?> plainClassForName( String name ) throws ClassNotFoundException { Class<?> c = null; if ( externalClassLoader != null ) c = externalClassLoader.loadClass( name ); else c = Class.forName( name ); cacheClassInfo( name, c ); return c; }
/** Create a new instance of the class manager. Class manager instnaces are now associated with the interpreter. @see bsh.Interpreter.getClassManager() @see bsh.Interpreter.setClassLoader( ClassLoader ) */ public static BshClassManager createClassManager( Interpreter interpreter ) { BshClassManager manager; // Do we have the optional package? if ( Capabilities.classExists("bsh.classpath.ClassManagerImpl") ) try { // Try to load the module // don't refer to it directly here or we're dependent upon it Class clazz = Class.forName( "bsh.classpath.ClassManagerImpl" ); manager = (BshClassManager) clazz.newInstance(); } catch ( Exception e ) { throw new InterpreterError("Error loading classmanager", e); } else manager = new BshClassManager(); if ( interpreter == null ) interpreter = new Interpreter(); manager.declaringInterpreter = interpreter; classManagers.put(manager,null); return manager; }
private Interpreter initBSH () throws UtilEvalError, EvalError { Interpreter bsh = new Interpreter (); BshClassManager bcm = bsh.getClassManager(); bcm.setClassPath(getServer().getLoader().getURLs()); bcm.setClassLoader(getServer().getLoader()); bsh.set ("qbean", this); bsh.set ("log", getLog()); bsh.eval (getPersist().getChildTextTrim ("init")); return bsh; } private ISOMsg applyRequestProps (ISOMsg m, Interpreter bsh)
this.getClassManager().cacheClassInfo(fullname, clas); return clas; if (bcm.hasSuperImport()) { final String s = bcm.getClassNameByUnqName(name); if (s != null) return this.classForName(s);
public BshClassManager getClassManager() { if ( classManager != null ) return classManager; if ( parent != null && parent != JAVACODE ) return parent.getClassManager(); classManager = BshClassManager.createClassManager( null/*interp*/ ); //Interpreter.debug("No class manager namespace:" +this); return classManager; }
/** Set a new base classpath and create a new base classloader. This means all types change. */ public void setClassPath( URL [] cp ) throws UtilEvalError { throw cmUnavailable(); }
public boolean classExists( String name ) { return ( classForName( name ) != null ); }
/** Instantiates a new name space. * @param parent the parent * @param classManager the class manager * @param name the name */ public NameSpace(final NameSpace parent, final BshClassManager classManager, final String name) { // We might want to do this here rather than explicitly in Interpreter // for global (see also prune()) // if (classManager == null && (parent == null)) // create our own class manager? this.setName(name); this.setParent(parent); this.setClassManager(classManager); // Register for notification of classloader change this.getClassManager().addListener(this); }