public Object getContextAttribute(String key) { Map context = getContext(); if (context != null) { return context.get(key); } return null; }
public Object invokeMethod(String methodName, Object args) { Object name = getProxyBuilder().getName(methodName); Object result; Object previousContext = getProxyBuilder().getContext(); try { result = getProxyBuilder().doInvokeMethod(methodName, name, args); } catch (RuntimeException e) { // remove contexts created after we started if (getContexts().contains(previousContext)) { Map<String, Object> context = getProxyBuilder().getContext(); while (context != null && context != previousContext) { getProxyBuilder().popContext(); context = getProxyBuilder().getContext(); } } throw e; } return result; }
public void setParent(FactoryBuilderSupport builder, Object parent, Object child) { Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF); if (!lazy.booleanValue()) super.setParent(builder, parent, child); } }
Object previousContext = getProxyBuilder().getContext(); FactoryBuilderSupport previousProxyBuilder = localProxyBuilder.get(); try { Map<String, Object> context = getProxyBuilder().getContext(); while (context != null && context != previousContext) { getProxyBuilder().popContext(); context = getProxyBuilder().getContext();
public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF); if (!lazy.booleanValue()) super.setChild(builder, parent, child); }
Map parentContext = getProxyBuilder().getContext(); getProxyBuilder().newContext(); try { getProxyBuilder().getContext().put(OWNER, closure.getOwner()); getProxyBuilder().getContext().put(CURRENT_NODE, node); getProxyBuilder().getContext().put(PARENT_FACTORY, parentFactory); getProxyBuilder().getContext().put(PARENT_NODE, current); getProxyBuilder().getContext().put(PARENT_CONTEXT, parentContext); getProxyBuilder().getContext().put(PARENT_NAME, parentName); getProxyBuilder().getContext().put(PARENT_BUILDER, parentContext.get(CURRENT_BUILDER)); getProxyBuilder().getContext().put(CURRENT_BUILDER, parentContext.get(CHILD_BUILDER));
/** * Overloaded to make variables appear as bean properties or via the subscript operator */ public Object getProperty(String property) { try { return getProxyBuilder().doGetProperty(property); } catch (MissingPropertyException mpe) { if ((getContext() != null) && (getContext().containsKey(property))) { return getContext().get(property); } else { try { return getMetaClass().getProperty(this, property); } catch(MissingPropertyException mpe2) { if(mpe2.getProperty().equals(property) && propertyMissingDelegate != null) { return propertyMissingDelegate.call(new Object[]{property}); } throw mpe2; } } } }
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map properties) throws InstantiationException, IllegalAccessException { ObjectGraphBuilder ogbuilder = (ObjectGraphBuilder) builder; String classname = ogbuilder.classNameResolver.resolveClassname((String) name); Class klass = resolveClass(builder, classname, name, value, properties); Map context = builder.getContext(); context.put(ObjectGraphBuilder.NODE_NAME, name); context.put(ObjectGraphBuilder.NODE_CLASS, klass); return resolveInstance(builder, name, value, klass, properties); }
Map context = builder.getContext(); if(value instanceof String || value instanceof GString) {
/** * This is a hook for subclasses to plugin a custom strategy for mapping * names to factories. * * @param name the name of the factory * @param attributes the attributes from the node * @param value value arguments from te node * @return the Factory associated with name.<br> */ protected Factory resolveFactory(Object name, Map attributes, Object value) { getProxyBuilder().getContext().put(CHILD_BUILDER, getProxyBuilder()); return getProxyBuilder().getFactories().get(name); }
getProxyBuilder().getContext().put(CURRENT_FACTORY, factory); getProxyBuilder().getContext().put(CURRENT_NAME, String.valueOf(name)); getProxyBuilder().preInstantiate(name, attributes, value); try {
@Override public void onNodeCompleted(FactoryBuilderSupport builder, Object parent, Object node) { builder.getContext().remove(Reporting.class.getName()); } }
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attrs) throws InstantiationException, IllegalAccessException { builder.getContext().put(Reporting.class.getName(), true); return new Reporting(); }
public Object getContextAttribute(String key) { Map context = getContext(); if (context != null) { return context.get(key); } return null; }
@Override public void onNodeCompleted(FactoryBuilderSupport builder, Object parent, Object node) { builder.getContext().remove(Reporting.class.getName()); } }
public void setParent(FactoryBuilderSupport builder, Object parent, Object child) { Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF); if (!lazy.booleanValue()) super.setParent(builder, parent, child); } }
public void setParent(FactoryBuilderSupport builder, Object parent, Object child) { Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF); if (!lazy.booleanValue()) super.setParent(builder, parent, child); } }
public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF); if (!lazy.booleanValue()) super.setChild(builder, parent, child); }
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map properties) throws InstantiationException, IllegalAccessException { ObjectGraphBuilder ogbuilder = (ObjectGraphBuilder) builder; String classname = ogbuilder.classNameResolver.resolveClassname((String) name); Class klass = resolveClass(builder, classname, name, value, properties); Map context = builder.getContext(); context.put(ObjectGraphBuilder.NODE_NAME, name); context.put(ObjectGraphBuilder.NODE_CLASS, klass); return resolveInstance(builder, name, value, klass, properties); }
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map properties) throws InstantiationException, IllegalAccessException { ObjectGraphBuilder ogbuilder = (ObjectGraphBuilder) builder; String classname = ogbuilder.classNameResolver.resolveClassname((String) name); Class klass = resolveClass(builder, classname, name, value, properties); Map context = builder.getContext(); context.put(ObjectGraphBuilder.NODE_NAME, name); context.put(ObjectGraphBuilder.NODE_CLASS, klass); return resolveInstance(builder, name, value, klass, properties); }