Refine search
if (stapler != null) { try { WebApp webapp = WebApp.getCurrent(); MetaClass meta = webapp.getMetaClass(this); Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail"); if (s == null) { return "";
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }
@Override protected Script resolveDefinition(JellyContext context) throws JellyTagException { Object it = expr.evaluate(context); if (it==null) throw new JellyTagException("'"+ expr.getExpressionText() +"' evaluated to null"); try { WebApp webApp = WebApp.getCurrent(); MetaClass c = webApp.getMetaClass(it instanceof Class ? Klass.java((Class)it): webApp.getKlass(it)); // prefer 'foo.jellytag' to avoid tags from showing up as views, // but for backward compatibility, support the plain .jelly extension as well. Script tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jellytag"); if (tag==null) tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jelly"); if (tag ==null) throw new JellyTagException("No such tag file "+tagName+".jellytag in "+c); return tag; } catch (JellyException e) { throw new JellyTagException("Failed to load "+tagName+".jellytag from "+it,e); } } };
public void buildViewDispatchers(final MetaClass owner, List<Dispatcher> dispatchers) { dispatchers.add(new Dispatcher() { final GroovyClassTearOff tearOff = owner.loadTearOff(GroovyClassTearOff.class); final GroovyServerPageTearOff gsp = owner.loadTearOff(GroovyServerPageTearOff.class);
private void _include(Object it, Klass clazz, String view) throws IOException, JellyException { JellyClassTearOff t = request.getWebApp().getMetaClass(clazz).loadTearOff(JellyClassTearOff.class); Script s = t.findScript(view); if(s==null) throw new IllegalArgumentException("No such view: "+view+" for "+clazz); JellyContext context = new JellyContext(getContext()); if(it!=null) context.setVariable("it",it); context.setVariable("from", it); ClassLoader old = Thread.currentThread().getContextClassLoader(); if (clazz.clazz instanceof Class) Thread.currentThread().setContextClassLoader(((Class)clazz.clazz).getClassLoader()); try { s.run(context,output); } finally { Thread.currentThread().setContextClassLoader(old); } }
/*package*/ MetaClass(WebApp webApp, Class clazz) { this.clazz = clazz; this.webApp = webApp; this.baseClass = webApp.getMetaClass(clazz.getSuperclass()); this.classLoader = MetaClassLoader.get(clazz.getClassLoader()); buildDispatchers( new ClassDescriptor(clazz,null/*support wrappers*/)); }
registerDoToken(node); String name = camelize(f.getName().substring(2)); // jsXyz -> xyz f = f.contextualize(new JavaScriptMethodContext(name)); dispatchers.add(new JavaScriptProxyMethodDispatcher(name, f)); List<Function> excludedByNew = minus(getMethods, filteredGetMethods); String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); final boolean isAccepted = filteredGetMethods.contains(f); if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); final boolean isAccepted = filteredGetMethods.contains(f); if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); final boolean isAccepted = filteredGetMethods.contains(f); if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); final boolean isAccepted = filteredGetMethods.contains(f);
private void registerDoToken(KlassDescriptor<?> node){ final FunctionList filteredFunctions; FunctionList functions; if(LEGACY_WEB_METHOD_MODE || webApp.getFilterForDoActions() == null){ functions = node.methods.webMethodsLegacy(); filteredFunctions = functions; } else { functions = node.methods.webMethodsLegacy(); filteredFunctions = functions.filter(webApp.getFilterForDoActions()); if(LOGGER.isLoggable(Level.FINER)){ List<Function> excludedByNew = minus(functions, filteredFunctions); else names=new String[]{camelize(f.getName().substring(2))}; // 'doFoo' -> 'foo'
/** * Convenience maintenance method to clear all the cached scripts for the given tearoff type. * * <p> * This is useful when you want to have the scripts reloaded into the live system without * the performance penalty of {@link MetaClass#NO_CACHE}. * * @see MetaClass#NO_CACHE */ public void clearScripts(Class<? extends AbstractTearOff> clazz) { synchronized (classMap) { for (MetaClass v : classMap.values()) { AbstractTearOff t = v.getTearOff(clazz); if (t!=null) t.clearScripts(); } } }
public void onClassEvent(int eventType, Class klass) { synchronized (metaClasses) { for (Entry<Class, MetaClass> e : metaClasses.entrySet()) { if (klass.isAssignableFrom(e.getKey())) { LOGGER.fine("Reloaded Stapler MetaClass for "+e.getKey()); e.getValue().buildDispatchers(); } } } // purge the model builder cache ResponseImpl.MODEL_BUILDER = new ModelBuilder(); }
public MetaClass getMetaClass(Klass<?> c) { if(c==null) return null; synchronized(classMap) { MetaClass mc = classMap.get(c); if(mc==null) { mc = new MetaClass(this,c); classMap.put(c,mc); } return mc; } }
else names=new String[]{camelize(f.getName().substring(2))}; // 'doFoo' -> 'foo' String name = camelize(f.getName().substring(2)); // jsXyz -> xyz else names=new String[]{camelize(f.getName().substring(3))}; // 'getFoo' -> 'foo' if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' dispatchers.add(new NameBasedDispatcher(name) { public boolean doDispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException, IllegalAccessException, InvocationTargetException { if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' dispatchers.add(new NameBasedDispatcher(name,1) { public boolean doDispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException, IllegalAccessException, InvocationTargetException { if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' dispatchers.add(new NameBasedDispatcher(name,1) { public boolean doDispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException, IllegalAccessException, InvocationTargetException {
public void buildViewDispatchers(final MetaClass owner, List<Dispatcher> dispatchers) { dispatchers.add(new Dispatcher() { final JellyClassTearOff tearOff = owner.loadTearOff(JellyClassTearOff.class);
/*package*/ MetaClass(WebApp webApp, Klass<?> klass) { this.clazz = klass.toJavaClass(); this.klass = klass; this.webApp = webApp; this.baseClass = webApp.getMetaClass(klass.getSuperClass()); this.classLoader = MetaClassLoader.get(clazz.getClassLoader()); buildDispatchers(); }
/** * Convenience maintenance method to clear all the cached scripts for the given tearoff type. * * <p> * This is useful when you want to have the scripts reloaded into the live system without * the performance penalty of {@link MetaClass#NO_CACHE}. * * @see MetaClass#NO_CACHE */ public void clearScripts(Class<? extends AbstractTearOff> clazz) { synchronized (classMap) { for (MetaClass v : classMap.values()) { AbstractTearOff t = v.getTearOff(clazz); if (t!=null) t.clearScripts(); } } }
public void onClassEvent(int eventType, Class klass) { synchronized (metaClasses) { for (Entry<Class, MetaClass> e : metaClasses.entrySet()) { if (klass.isAssignableFrom(e.getKey())) { LOGGER.fine("Reloaded Stapler MetaClass for "+e.getKey()); e.getValue().buildDispatchers(); } } } // purge the model builder cache ResponseImpl.MODEL_BUILDER = new ModelBuilder(); }
public MetaClass getMetaClass(Klass<?> c) { if(c==null) return null; synchronized(classMap) { MetaClass mc = classMap.get(c); if(mc==null) { mc = new MetaClass(this,c); classMap.put(c,mc); } return mc; } }
else names=new String[]{camelize(f.getName().substring(2))}; // 'doFoo' -> 'foo' String name = camelize(f.getName().substring(2)); // jsXyz -> xyz f = f.contextualize(new JavaScriptMethodContext(name)); dispatchers.add(new JavaScriptProxyMethodDispatcher(name, f)); String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); dispatchers.add(new NameBasedDispatcher(name) { if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); dispatchers.add(new NameBasedDispatcher(name,1) { if(f.getName().length()<=3) continue; String name = camelize(f.getName().substring(3)); // 'getFoo' -> 'foo' final Function ff = f.contextualize(new TraversalMethodContext(name)); dispatchers.add(new NameBasedDispatcher(name,1) { if(f.getName().length()<=3) continue;
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }