Examples of Binder


Examples of com.google.inject.Binder

  /**
   * Execute this target against the linked binding builder.
   */
  protected <T> ScopedBindingBuilder bindKeyToTarget(
      final Binding<T> binding, Binder binder, final Key<T> key) {
    final Binder sourcedBinder = binder.withSource(binding.getSource());

    return binding.acceptTargetVisitor(new BindingTargetVisitor<T, ScopedBindingBuilder>() {
      public ScopedBindingBuilder visit(InstanceBinding<? extends T> binding) {
        sourcedBinder.bind(key).toInstance(binding.getInstance());
        return null;
      }

      public ScopedBindingBuilder visit(ProviderInstanceBinding<? extends T> binding) {
        return sourcedBinder.bind(key).toProvider(binding.getProviderInstance());
      }

      public ScopedBindingBuilder visit(ProviderKeyBinding<? extends T> binding) {
        return sourcedBinder.bind(key).toProvider(binding.getProviderKey());
      }

      public ScopedBindingBuilder visit(LinkedKeyBinding<? extends T> binding) {
        return sourcedBinder.bind(key).to(binding.getLinkedKey());
      }

      public ScopedBindingBuilder visit(UntargettedBinding<? extends T> binding) {
        return sourcedBinder.bind(key);
      }

      public ScopedBindingBuilder visit(ExposedBinding<? extends T> binding) {
        throw new IllegalArgumentException("Non-module element");
      }
View Full Code Here

Examples of com.google.inject.Binder

  Module bindTo(final Key<T> returnValueKey) {
    return new PrivateModule() {
      @SuppressWarnings({ "unchecked", "RedundantCast" })
      // raw keys are necessary for the args array and return value
      @Override protected void configure() {
        Binder binder = binder();

        for (Key<?> configKey : declaredKeysToActualBindings.keySet()) {
          KeyOrInstanceUnionWithLabel<?> actualBinding =
              declaredKeysToActualBindings.get(configKey);

          if (actualBinding.key != null) {
            binder.bind((Key) configKey).to(actualBinding.key);
          } else {
            binder.bind((Key) configKey).toInstance(actualBinding.instance);
          }
        }

        // We don't use .toConstructor() to support users of Guice 2.0
        if (returnValueKey.equals(Key.get(implementationType))) {
          binder.bind(returnValueKey);
        } else {
          binder.bind(returnValueKey).to(implementationType);
        }

        expose(returnValueKey);
      }
    };
View Full Code Here

Examples of com.headius.invokebinder.Binder

        // we can handle this; do remaining transforms and return
        if (returnFilter != null) {
            Class[] newNativeParams = nativeTarget.type().parameterArray();
            Class newNativeReturn = nativeTarget.type().returnType();

            Binder exBinder = Binder
                    .from(newNativeReturn, Throwable.class, newNativeParams)
                    .drop(1, newNativeParams.length)
                    .insert(0, runtime);
            if (nativeReturn != void.class) {
                exBinder = exBinder
                        .filterReturn(Binder
                                .from(newNativeReturn)
                                .constant(nullValue(newNativeReturn)));
            }
View Full Code Here

Examples of jfun.yan.Binder

  }
  public Binder eval(){
    if(cases.isEmpty() && def==null){
      throw raise("empty " + getTagName());
    }
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
        final int sz = cases.size();
        for(int i=0; i<sz; i++){
          final BinderCase bc = (BinderCase)cases.get(i);
View Full Code Here

Examples of jfun.yan.Binder

  }

  public Component eval(){
    final Component p = getProps();
    final Component cc = getMandatory();
    Component result = p.bind(new Binder(){
      public Creator bind(Object v) throws Throwable {
        if(v==null) return cc;
        if(v instanceof java.util.Map){
          final java.util.Map m = (java.util.Map)v;
          final int sz = m.size();
View Full Code Here

Examples of jfun.yan.Binder

  public Component eval(){
    final Component a = getArgs();
    final Component cc = getMandatory();
   
    Component result = a.bind(new Binder(){
      public Creator bind(Object v) throws Throwable {
        if(v==null) return cc;
        if(v.getClass().isArray()){
          final int sz = Array.getLength(v);
          final Component[] cargs = new Component[sz];
View Full Code Here

Examples of jfun.yan.Binder

* Nov 12, 2005 7:09:29 PM
*/
public class SynchronizedNut extends DelegatingBinderNut {

  public Binder eval() throws Exception {
    final Binder binder = getMandatory();
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
       synchronized(v){
         return binder.bind(v);
       }
      }
      public String toString(){
        return binder.toString();
      }
    };
  }
View Full Code Here

Examples of jfun.yan.Binder

* @author Ben Yu
* Nov 12, 2005 11:59:27 PM
*/
public class ForeachNut extends DelegatingBinderNut {
  public Binder eval() throws Exception {
    final Binder binder = getMandatory();
    return new Binder(){
      public Creator bind(Object v)
      throws Throwable{
        if(v==null) return Components.value(null);
        final Creator[] steps = getNextSteps(v, binder);
        return Monad.sequence(steps);
View Full Code Here

Examples of jfun.yan.Binder

      final Object key, final Class type) {
    if(the_map!=null){
      return performLookup(component_type, key, type);
    }
    else{
      return detect_map.bind(new Binder(){
        public Creator bind(Object m){
          if(m instanceof Map){
            the_map = (Map)m;
            return performLookup(component_type, key, type);
          }
View Full Code Here

Examples of jfun.yan.Binder

        return null;
      }
    }, key);
  }
  private Binder getLazyBinder(){
    return new Binder(){
      public Creator bind(Object v) throws Throwable {
        final Object b = get();
        if(b instanceof Binder){
          return ((Binder)b).bind(v);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.