/* (non-Javadoc)
@see nz.co.senanque.rules.RuleSession#bind(nz.co.senanque.validationengine.ValidationObject)
324643
public void unbind(ValidationObject validationObject)
    {
        Integer id = System.identityHashCode(validationObject);
    	m_unbinding.add(id);
        List<ProposedValue> proposedValues = new ArrayList<ProposedValue>();
    	ProxyObject proxyObject = getSession().getProxyObject(validationObject);
    	for (ProxyField proxyField: proxyObject.getFieldMap().values())
    	{
    		if (!proxyField.isDerived())
    		{
    			// Figure out if this property contains a list or a known object type
    			// we want to ignore those and only reset primitive objects (long, String etc)
    			Class<?> clazz = proxyField.getPropertyMetadata().getGetMethod().getReturnType();
       			if (clazz.isAssignableFrom(List.class))
    			{
    				continue;
    			}
       			if (getSession().getValidationEngine().getClassMetadata(clazz) != null)
    			{
    				continue;
    			}
    			RuleProxyField ruleProxyField = getRuleProxyField(proxyField);
    			if (ruleProxyField.isDifferent(proxyField.getInitialValue()))
    			{
    				ProposedValue pv = new ProposedValue(ruleProxyField,proxyField.getInitialValue());
    				proposedValues.add(pv);
    			}
    		}    		
    	}
        setValues(proposedValues);
        m_boundObjects.remove(id);
    	m_unbinding.remove(id);
        List<String> kill = new ArrayList<String>();
        for (Map.Entry<String, RuleContext> entry: m_ruleContextsMap.entrySet())
        {
        	if (entry.getValue().getValidationObject() == validationObject)
        	{
        		kill.add(entry.getKey());
        	}
        }

        for (String key: kill)
        {
        	RuleContext rc = m_ruleContextsMap.remove(key);
        	rc.reset();
        }
    }
579237
protected final <T> GinAnnotatedBindingBuilder<T> bind(Class<T> clazz) {
    return binder.bind(clazz);
  }
394
@SuppressWarnings("unchecked")
    public void postValidate(Object object) throws DataValidationException {
        if (_values != null || _ranges != null) {
            if (_values != null) for (Object value: _values) {
                if (value.equals(object)) return;
            }

            if (_ranges != null) for (@SuppressWarnings("rawtypes") Range r: _ranges) {
                @SuppressWarnings("rawtypes")
                Comparable o = (Comparable)object;
                if (r.inclusive) {
                    if ((r.min == null || r.min.compareTo(o) <= 0) && (r.max == null || o.compareTo(r.max) <= 0)) {
                        return;
                    }
                } else {
                    if ((r.min == null || r.min.compareTo(o) < 0) && (r.max == null || o.compareTo(r.max) < 0)) {
                        return;
                    }
                }
            }

            throw new DataValidationException("VALUES/RANGES", _name, object);
        }
    }
1035227
public DataBinder put(Object object) throws Exception {
        for (Field field: Beans.getKnownInstanceFields(object.getClass())) {
            Object value = field.get(object);
            if (value != null) {
                put(field.getName(), value.toString());
            }
        }
        return this;
    }
859975
@Override
    public void bindJavaGlobal(String name, EJBBinding bindingObject) {
        String bindingName = buildJavaGlobalName(name);
        ejbJavaColonHelper.addGlobalBinding(bindingName, bindingObject);
    }
873366
public void validate(FacesContext context,
                         UIComponent  component,
                         Object       value) throws ValidatorException {
	if (null == context || null == component) {
	    throw new NullPointerException();
	}
        try {
            methodBinding.invoke(context, new Object[] {context, component, 
							value});
        } 
	catch (EvaluationException ee) {
	    Throwable cause = this.getExpectedCause(ValidatorException.class,
						    ee);
	    if (cause instanceof ValidatorException) {
		throw ((ValidatorException) cause);
	    }
	    if (cause instanceof RuntimeException) {
		throw ((RuntimeException) cause);
	    }
	    throw new IllegalStateException(ee);
        }
	
	
    }
368227
public void clean(final ValidationObject object)
    {
        if (m_enabled)
        {
            m_validationEngine.clean(object);
            for (ProxyField proxyField:m_history) {
            	proxyField.expire();
            }
        }
    }
452994
@Override
    public void setProducerBind(String bind) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setProducerBind", bind);

        // Make sure null and empty are treated equally.
        if ((bind == null) || ("".equals(bind.trim())))
            bind = null;

        if ((bind == null) ||
            (ApiJmsConstants.PRODUCER_BIND_OFF.equals(bind) ||
            (ApiJmsConstants.PRODUCER_BIND_ON.equals(bind)))) {

            updateProperty(PRODUCER_BIND, bind);
        }
        else {
            // bad value, throw exception
            String key = "INVALID_VALUE_CWSIA0281";
            Object[] inserts = new Object[] { PRODUCER_BIND, bind };
            throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class, key, inserts, tc);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setProducerBind");
    }
221019
void bindInjectedObject() throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "bindInjectedObject: " + toSimpleString(), bindingObjectToString(ivBindingObject));

        // d660700 - resolveJndiName will set a scope if the JNDI name starts
        // with "java:", including "java:comp/".  However, JNDI names starting
        // with "java:comp/env/" will not have a scope because that prefix is
        // removed by setJndiName.
        InternalInjectionEngine ie = InjectionEngineAccessor.getInternalInstance();
        ie.bindJavaNameSpaceObject(ivNameSpaceConfig, ivInjectionScope, ivJavaNameSpaceName, this, ivBindingObject);

        // Store this binding object in the caller's map, if provided.  d473811
        if (ivJavaColonCompEnvMap != null &&
            ivInjectionScope == null)
        {
            ivJavaColonCompEnvMap.put(ivJndiName, this);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "bindInjectedObject");
    }
290764
public void setBindValues(Collection<BindAttribute> bindValues) throws CpoException {

    if (bindValues != null) {
      int index = getStartingIndex();

      //runs through the bind attributes and binds them to the prepared statement
      // They must be in correct order.
      for (BindAttribute bindAttr : bindValues) {
        Object bindObject = bindAttr.getBindObject();
        CpoAttribute cpoAttribute = bindAttr.getCpoAttribute();

        // check to see if we are getting a cpo value object or an object that
        // can be put directly in the statement (String, BigDecimal, etc)
        MethodMapEntry<?, ?> jsm = ((MethodMapper<?>)getMethodMapper()).getDataMethodMapEntry(bindObject.getClass());

        if (jsm != null) {
          try {
            if (cpoAttribute == null) {
              localLogger.debug(bindAttr.getName() + "=" + bindObject);
            } else {
              localLogger.debug(cpoAttribute.getDataName() + "=" + bindObject);
            }
            jsm.getBsSetter().invoke(this.getBindableStatement(), index++, bindObject);
          } catch (IllegalAccessException iae) {
            localLogger.error("Error Accessing Prepared Statement Setter: " + ExceptionHelper.getLocalizedMessage(iae));
            throw new CpoException(iae);
          } catch (InvocationTargetException ite) {
            localLogger.error("Error Invoking Prepared Statement Setter: " + ExceptionHelper.getLocalizedMessage(ite));
            throw new CpoException(ite.getCause());
          }
        } else {
          CpoData cpoData = getCpoData(cpoAttribute, index++);
          cpoData.invokeSetter(bindObject);
        }
      }
    }
  }
341447
@Override
	public void bind(RestExpress server)
	{
		this.activeRequestsCounter = metrics.counter("active-requests");
	    this.allExceptionsCounter = metrics.counter("all-exceptions");
	    this.allTimesTimer = metrics.timer("all-times");
	}
501924
@Override
	public void rebind(Name name, Object obj) throws NamingException
    {
        if (name.isEmpty())
            throw new InvalidNameException("Cannot bind empty name");

        // Extract components that belong to this namespace
        String nm = name.toString();

        // Add object to internal hash table
        bindings.put(nm, obj);
    }
514005
@Override
	public void bind(String name, Object obj) throws NamingException
    {
        bind(new CompositeName(name), obj);
    }
765763
public static BindingResult bindObjectToInstance(Object object, Object source) {
        return bindObjectToInstance(object, source, getBindingIncludeList(object), Collections.emptyList(), null);
    }
146369
@NonNull @UiThread
  public static Unbinder bind(@NonNull Object target, @NonNull View source) {
    Class<?> targetClass = target.getClass();
    if (debug) Log.d(TAG, "Looking up binding for " + targetClass.getName());
    Constructor<? extends Unbinder> constructor = findBindingConstructorForClass(targetClass);

    if (constructor == null) {
      return Unbinder.EMPTY;
    }

    //noinspection TryWithIdenticalCatches Resolves to API 19+ only type.
    try {
      return constructor.newInstance(target, source);
    } catch (IllegalAccessException e) {
      throw new RuntimeException("Unable to invoke " + constructor, e);
    } catch (InstantiationException e) {
      throw new RuntimeException("Unable to invoke " + constructor, e);
    } catch (InvocationTargetException e) {
      Throwable cause = e.getCause();
      if (cause instanceof RuntimeException) {
        throw (RuntimeException) cause;
      }
      if (cause instanceof Error) {
        throw (Error) cause;
      }
      throw new RuntimeException("Unable to create binding instance.", cause);
    }
  }
963267
public void addValidation(Object key, Validation validation){
        initMapOnce();
        validations.put(key, validation);
        // update aggregated value
        passedAll = passedAll && validation.passed();
    }
976185
public void unbind(ValidationSession session, ValidationObject validationObject,
			Map<ValidationObject, ProxyObject> boundMap) {
		if (validationObject == null) {
			return;
		}
		// For all the fields: look for attached objects.
		ProxyObject proxyObject = session.getProxyObject(validationObject);
		Map<String,ProxyField> fieldMap = proxyObject.getFieldMap();
		for (String fieldName: fieldMap.keySet()) {
			if (fieldName != null) {
				final ClassMetadata classMetadata = m_validationEngine.getClassMetadata(validationObject.getClass());
				final PropertyMetadata fieldMetadata = classMetadata.getField(fieldName);
				if (fieldMetadata == null) {
					continue;
				}
				ProxyField proxyField = proxyObject.getProxyField(fieldName);
				Method getter = proxyField.getGetter();
				if (getter.getReturnType().isAssignableFrom(List.class)) {
					// if this is a list then walk the list and unbind the objects there.
					try {
						@SuppressWarnings("unchecked")
						final List<ValidationObject> validationObjects = 
								(List<ValidationObject>) getter.invoke(validationObject, new Object[] {});
						for (ValidationObject child : validationObjects) {
							m_validationEngine.unbind(session, proxyField, child, boundMap);
							if (child != null) {
								child.setValidationSession(null);
							}
						}
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
					continue;
				}
				if (m_validationEngine.getClassMetadata(getter.getReturnType()) != null) {
					// if this is a known object then unbind it
					try {
						ValidationObject child = (ValidationObject) getter
								.invoke(validationObject, new Object[] {});
						m_validationEngine.unbind(session, proxyField, child, boundMap);
						if (child != null) {
							child.setValidationSession(null);
						}
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
					continue;
				}
			}
		}
	}