/** * This method can be used to ensure that no threaded created * by a reference manager will be active. This is useful if the Groovy * runtime itself is loaded through a class loader which should be disposed * off. Without calling this method and if a threaded reference manager is * active the class loader cannot be unloaded! * * Per default no threaded manager will be used. * * @since 1.6 */ public static void stopThreadedReferenceManager() { ReferenceBundle.getSoftBundle().getManager().stopThread(); ReferenceBundle.getWeakBundle().getManager().stopThread(); }
public ManagedReference(ReferenceBundle bundle, T value) { this(bundle.getType(),bundle.getManager(),value); }
public Object eval(String script, ScriptContext ctx) throws ScriptException { try { String val = (String) ctx.getAttribute("#jsr223.groovy.engine.keep.globals", ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase("soft")) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { Class<?> clazz = getScriptClass(script); if (clazz == null) throw new ScriptException("Script class is null"); return eval(clazz, ctx); } catch (Exception e) { if (debug) e.printStackTrace(); throw new ScriptException(e); } }
bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle();
/** * @deprecated use {@link ReferenceBundle#getWeakBundle()} */ @Deprecated public static ReferenceBundle getDefaultWeakBundle() { return ReferenceBundle.getWeakBundle(); } }
/** * @deprecated use {@link ReferenceBundle#getSoftBundle()} */ @Deprecated public static ReferenceBundle getDefaultSoftBundle() { return ReferenceBundle.getSoftBundle(); }
/** * {@inheritDoc} */ @Override public Object eval(final String script, final ScriptContext context) throws ScriptException { if (globalFunctionCacheEnabled) { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } } try { registerBindingTypes(context); final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (Exception e) { throw new ScriptException(e); } }
public void setPerInstanceMetaClass(Object obj, MetaClass metaClass) { version.incrementAndGet(); if (metaClass != null) { if (perInstanceMetaClassMap == null) perInstanceMetaClassMap = new ManagedConcurrentMap<Object, MetaClass>(ReferenceBundle.getWeakBundle()); perInstanceMetaClassMap.put(obj, metaClass); } else { if (perInstanceMetaClassMap != null) { perInstanceMetaClassMap.remove(obj); } } }
public GremlinGroovyClassLoader(final ClassLoader parent, final CompilerConfiguration conf) { super(parent, conf); classSoftCache = new ManagedConcurrentValueMap<>(ReferenceBundle.getSoftBundle()); }
/** * {@inheritDoc} */ @Override public Object eval(final String script, final ScriptContext context) throws ScriptException { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { registerBindingTypes(context); final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (Exception e) { throw new ScriptException(e); } }
/** * This method can be used to ensure that no threaded created * by a reference manager will be active. This is useful if the Groovy * runtime itself is loaded through a class loader which should be disposed * off. Without calling this method and if a threaded reference manager is * active the class loader cannot be unloaded! * * Per default no threaded manager will be used. * * @since 1.6 */ public static void stopThreadedReferenceManager() { ReferenceBundle.getSoftBundle().getManager().stopThread(); ReferenceBundle.getWeakBundle().getManager().stopThread(); }
public void setPerInstanceMetaClass(Object obj, MetaClass metaClass) { version++; if (metaClass != null) { if (perInstanceMetaClassMap == null) perInstanceMetaClassMap = new ManagedConcurrentMap(ReferenceBundle.getWeakBundle()); perInstanceMetaClassMap.put(obj, metaClass); } else { if (perInstanceMetaClassMap != null) { perInstanceMetaClassMap.remove(obj); } } }
public ManagedReference(ReferenceBundle bundle, T value) { this(bundle.getType(),bundle.getManager(),value); }
public GremlinGroovyClassLoader(final ClassLoader parent, final CompilerConfiguration conf) { super(parent, conf); classSoftCache = new ManagedConcurrentValueMap<>(ReferenceBundle.getSoftBundle()); }
public Object eval(String script, ScriptContext ctx) throws ScriptException { try { String val = (String) ctx.getAttribute("#jsr223.groovy.engine.keep.globals", ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val!=null && val.length()>0) { if (val.equalsIgnoreCase("soft")) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase("weak")) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase("phantom")) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { Class clazz = getScriptClass(script); if (clazz == null) throw new ScriptException("Script class is null"); return eval(clazz, ctx); } catch (SyntaxException e) { throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine()); } catch (Exception e) { if (debug) e.printStackTrace(); throw new ScriptException(e); } }
/** * This method can be used to ensure that no threaded created * by a reference manager will be active. This is useful if the Groovy * runtime itself is loaded through a class loader which should be disposed * off. Without calling this method and if a threaded reference manager is * active the class loader cannot be unloaded! * * Per default no threaded manager will be used. * * @since 1.6 */ public static void stopThreadedReferenceManager() { ReferenceBundle.getSoftBundle().getManager().stopThread(); ReferenceBundle.getWeakBundle().getManager().stopThread(); }
public void setPerInstanceMetaClass(Object obj, MetaClass metaClass) { version++; if (metaClass != null) { if (perInstanceMetaClassMap == null) perInstanceMetaClassMap = new ManagedConcurrentMap(ReferenceBundle.getWeakBundle()); perInstanceMetaClassMap.put(obj, metaClass); } else { if (perInstanceMetaClassMap != null) { perInstanceMetaClassMap.remove(obj); } } }
public ManagedReference(ReferenceBundle bundle, T value) { this(bundle.getType(),bundle.getManager(),value); }
@Override public Object eval(final String script, final ScriptContext context) throws ScriptException { try { final String val = (String) context.getAttribute(KEY_REFERENCE_TYPE, ScriptContext.ENGINE_SCOPE); ReferenceBundle bundle = ReferenceBundle.getHardBundle(); if (val != null && val.length() > 0) { if (val.equalsIgnoreCase(REFERENCE_TYPE_SOFT)) { bundle = ReferenceBundle.getSoftBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_WEAK)) { bundle = ReferenceBundle.getWeakBundle(); } else if (val.equalsIgnoreCase(REFERENCE_TYPE_PHANTOM)) { bundle = ReferenceBundle.getPhantomBundle(); } } globalClosures.setBundle(bundle); } catch (ClassCastException cce) { /*ignore.*/ } try { final Class clazz = getScriptClass(script); if (null == clazz) throw new ScriptException("Script class is null"); return eval(clazz, context); } catch (SyntaxException e) { throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine()); } catch (Exception e) { throw new ScriptException(e); } }
/** * This method can be used to ensure that no threaded created * by a reference manager will be active. This is useful if the Groovy * runtime itself is loaded through a class loader which should be disposed * off. Without calling this method and if a threaded reference manager is * active the class loader cannot be unloaded! * * Per default no threaded manager will be used. * * @since 1.6 */ public static void stopThreadedReferenceManager() { ReferenceBundle.getSoftBundle().getManager().stopThread(); ReferenceBundle.getWeakBundle().getManager().stopThread(); } }