public Object getUnderlyingValue() { return value.getUnderlyingValue(); }
public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable { return value.getValue(info, cl); }
public String toShortString() { return value.toShortString(); } }
protected boolean isMetaDataComplete(PropertyMetaData pmd) { if (pmd == null) return false; ValueMetaData value = pmd.getValue(); Object underlyingValue = value.getUnderlyingValue(); return (underlyingValue instanceof AnnotationsMatcher == false); }
public Object dispatch() throws Throwable { return vmd.getValue(info, cl); }
public String toHumanReadableString() { return vmd.toShortString(); }
protected boolean isMetaDataComplete(PropertyMetaData pmd) { if (pmd == null) return false; ValueMetaData value = pmd.getValue(); Object underlyingValue = value.getUnderlyingValue(); return (underlyingValue instanceof AnnotationsMatcher == false); }
/** * Get the parameters * * @param trace whether trace is enabled * @param cl the classloader * @param pinfos the parameter infos * @param parameters the parameter metadata * @return an array of parameters * @throws Throwable for any error */ public static Object[] getParameters(boolean trace, ClassLoader cl, TypeInfo[] pinfos, List<ParameterMetaData> parameters) throws Throwable { if (parameters == null) return null; Object[] params = new Object[parameters.size()]; int x = 0; for (Iterator<ParameterMetaData> i = parameters.iterator(); i.hasNext();) { ParameterMetaData pdata = i.next(); ValueMetaData vmd = pdata.getValue(); params[x] = vmd.getValue(pinfos[x], cl); x++; } return params; }
public void toShortString(JBossStringBuilder buffer) { value.toShortString(buffer); }
public Object endElement(Object o, QName qName, ElementBinding element) { Holder holder = (Holder) o; ValueMetaData value = (ValueMetaData) holder.getValue(); if (value == null || value.getUnderlyingValue() == null) throw new IllegalArgumentException("Factory should have a bean attribute or nested element."); return value; } }
Object object = clVMD.getValue(null, tcl); if (object != null && object instanceof ClassLoader == false) throw new IllegalArgumentException("Configured object is not a classloader " + metaData);
/** * Set the factory * * @param factory the factory */ @XmlElement(name="factory", type=AbstractDependencyValueMetaData.class) public void setFactory(ValueMetaData factory) { // HACK to have wildcard factories if (factory != null && factory instanceof AbstractDependencyValueMetaData) { Object underlying = factory.getUnderlyingValue(); if (underlying != null && underlying instanceof ValueMetaData) factory = (ValueMetaData) underlying; } this.factory = factory; flushJBossObjectCache(); }
@SuppressWarnings("unchecked") public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable { Collection result = getTypeInstance(info, cl, Collection.class); TypeInfo elementTypeInfo = getElementClassInfo(cl, info); for (int i = 0; i < collection.size(); ++i) { ValueMetaData vmd = (ValueMetaData) collection.get(i); Object value = vmd.getValue(elementTypeInfo, cl); try { result.add(value); } catch (UnsupportedOperationException e) { if (i != 0) throw e; result = getTypeInstance(info, cl, Collection.class, false); result.add(value); } } return result; }
/** * Get a bean property * * @param name the name * @return the value metadata */ public ValueMetaData getBeanProperty(String name) { if (name == null) throw new IllegalArgumentException("Null name"); PropertyMetaData properties = getProperty("properties"); if (properties == null) return null; AbstractMapMetaData map = (AbstractMapMetaData) properties.getValue(); for (Iterator<Map.Entry<MetaDataVisitorNode, MetaDataVisitorNode>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<MetaDataVisitorNode, MetaDataVisitorNode> entry = i.next(); ValueMetaData key = (ValueMetaData) entry.getKey(); if (key.getUnderlyingValue().equals(name)) { ValueMetaData vmd = (ValueMetaData) entry.getValue(); return (ValueMetaData) vmd.getUnderlyingValue(); } } return null; }
/** * Configure a bean property * * @param trace whether trace is enabled * @param object the object to configure * @param info the property info * @param cl the classloader * @param metaData the property metadata * @throws Throwable for any error */ public static void configure(boolean trace, Object object, PropertyInfo info, ClassLoader cl, PropertyMetaData metaData) throws Throwable { if (trace) log.trace("Configuring info=" + info + " metaData=" + metaData); if (trace) log.trace("Setting property " + info); info.set(object, metaData.getValue().getValue(info.getType(), cl)); }
protected void buildDeployment(DeploymentUnit unit, BootstrapInfo info, BeanMetaDataBuilder builder) { WeldDiscoveryEnvironment env = unit.getAttachment(WeldDiscoveryEnvironment.class); builder.addConstructorParameter(WeldDiscoveryEnvironment.class.getName(), env); builder.addConstructorParameter(Collection.class.getName(), builder.createInject(info.getEjbServices().getUnderlyingValue(), "ejbs")); } }
/** * Get prototype class. * * @param cc the controller context * @return prototype's class */ protected Class<?> getPrototypeClass(ControllerContext cc) { if (cc instanceof KernelControllerContext == false) { return null; } KernelControllerContext kcc = (KernelControllerContext) cc; BeanMetaData bmd = kcc.getBeanMetaData(); Set<PropertyMetaData> properties = bmd.getProperties(); for (PropertyMetaData pmd : properties) { if ("bean".equals(pmd.getName())) { ValueMetaData value = pmd.getValue(); if (value != null && value.getUnderlyingValue() != null) { String className = value.getUnderlyingValue().toString(); return getBeanClass(className, kcc); } else { return null; } } } return null; }
ValueMetaData vmd = entry.getValue(); PropertyInfo pi = info.getProperty(property); pi.set(result, vmd.getValue(pi.getType(), loader));
@Override public void initialVisit(MetaDataVisitor visitor) { ValueMetaData factory = getFactory(); if (factory != null || getFactoryClass() != null) { if (getFactoryMethod() == null) throw new IllegalArgumentException("Constructor needs a factoryMethod attribute when there is a factoryClass attribute or factory element."); } if (factory != null) { if (factory.getUnderlyingValue() == null) throw new IllegalArgumentException("Factory should have a bean attribute or nested element."); } if (parameters != null) { for (int i = 0; i < parameters.size(); ++i) parameters.get(i).setIndex(i); } super.initialVisit(visitor); }