/** * Returns a helper for the given class, either from the cache * or by creating a new instance. * * @param c The class for which a helper is required. * Must not be <code>null</code>. * * @return a helper for the specified class */ public static synchronized IntrospectionHelper getHelper(final Class<?> c) { return getHelper(null, c); }
/** * Stores a configured child element within its parent object. * * @param project Project containing the objects. * May be <code>null</code>. * @param parent Parent object to add child to. * Must not be <code>null</code>. * @param child Child object to store in parent. * Should not be <code>null</code>. * @param tag Name of element which generated the child. * May be <code>null</code>, in which case * the child is not stored. */ public static void storeChild(Project project, Object parent, Object child, String tag) { IntrospectionHelper ih = IntrospectionHelper.getHelper(project, parent.getClass()); ih.storeElement(project, parent, child, tag); }
/** * Adds the content of #PCDATA sections to an element. * * @param project The project containing the target. * Must not be <code>null</code>. * @param target The target object to be configured. * Must not be <code>null</code>. * @param text Text to add to the target. * May be <code>null</code>, in which case this * method call is a no-op. * * @exception BuildException if the target object doesn't accept text */ public static void addText(Project project, Object target, String text) throws BuildException { if (text == null) { return; } if (target instanceof TypeAdapter) { target = ((TypeAdapter) target).getProxy(); } IntrospectionHelper.getHelper(project, target.getClass()).addText(project, target, text); }
ih = IntrospectionHelper.getHelper(p, element); } catch (final Throwable t) {
/** * Try to set a value on an object using reflection. * Helper method for easier access to IntrospectionHelper.setAttribute(). * @param obj the object on which the attribute should be set * @param name the attributename * @param value the new value */ protected void tryToSetAParameter(Object obj, String name, String value) { Project prj = (getProject() != null) ? getProject() : new Project(); IntrospectionHelper iHelper = IntrospectionHelper.getHelper(prj, obj.getClass()); try { iHelper.setAttribute(prj, obj, name, value); } catch (BuildException e) { // no-op } }
target = ((TypeAdapter) target).getProxy(); IntrospectionHelper ih = IntrospectionHelper.getHelper(project, target.getClass());
IntrospectionHelper ih = IntrospectionHelper.getHelper(helperImpl.project, parentClass);
IntrospectionHelper.getHelper(p, target.getClass()); ComponentHelper componentHelper = ComponentHelper.getComponentHelper(p); if (attributeMap != null) {
.getComponentHelper(owner.getProject()); IntrospectionHelper ih = IntrospectionHelper.getHelper(owner.getProject(), EnableAttributeConsumer.class); for (Map.Entry<String, Object> entry : attributeMap.entrySet()) {
IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass);
public SingleModuleIntrospection(IModule module, String taskClassName) throws ClassNotFoundException { _taskClass = loadClass(taskClassName); _helperInstance = IntrospectionHelper.getHelper(_taskClass); }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }
private IntrospectionHelper getIntrospectionHelper(AntTypeDefinition taskClass) { Project p = antModel.getProjectNode().getProject(); Class<?> clazz = taskClass.getExposedClass(p); if (clazz != null) { IntrospectionHelper helper = null; try { helper = IntrospectionHelper.getHelper(antModel.getProjectNode().getProject(), clazz); } catch (NoClassDefFoundError e) { // ignore as a task may require additional classpath components } return helper; } return null; }
@Override public Object handleCall(Object ctx, Object... args) { try { // see ComponentHelper.createComponent(UnknownElement, String, String) IntrospectionHelper helper = IntrospectionHelper.getHelper(_taskClass); Task taskInstance = (Task) _taskClass.newInstance(); taskInstance.setProject(Aardvark.getProject()); taskInstance.setTaskName(_taskName); taskInstance.init(); for (int i = 0; i < args.length; i++) { if (args[i] != null) { _taskMethods[i].invoke(taskInstance, args[i], helper); } } taskInstance.execute(); return taskInstance; } catch (IllegalAccessException e) { // should never happen throw GosuExceptionUtil.forceThrow(e); } catch (InstantiationException e) { // should not happen - we know we can instantiate the task throw GosuExceptionUtil.forceThrow(e); } } }