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); } }
/** Set an external class loader to be used as the base classloader for BeanShell. The base classloader is used for all classloading unless/until the addClasspath()/setClasspath()/reloadClasses() commands are called to modify the interpreter's classpath. At that time the new paths /updated paths are added on top of the base classloader. <p> 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. <p> @see BshClassManager#setClassLoader( ClassLoader ) */ public void setClassLoader( ClassLoader externalCL ) { getClassManager().setClassLoader( externalCL ); }
/** Set an external class loader to be used as the base classloader for BeanShell. The base classloader is used for all classloading unless/until the addClasspath()/setClasspath()/reloadClasses() commands are called to modify the interpreter's classpath. At that time the new paths /updated paths are added on top of the base classloader. <p> 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. <p> @see BshClassManager#setClassLoader( ClassLoader ) */ public void setClassLoader( ClassLoader externalCL ) { getClassManager().setClassLoader( externalCL ); }
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() {
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)