Package jfun.yan

Examples of jfun.yan.PropertyBinder


  /**
   * Decorate the autowire mode by filtering out setters defined
   * in the Spring XXXAware marker interfaces.
   */
  public PropertyBinder getPropertyAutowireMode() {
    final PropertyBinder mode = super.getPropertyAutowireMode();
    if(mode==null) return null;
    return SpringUtils.getAutowireWithoutAwareMarkerInterfaces(mode);
  }
View Full Code Here


    }
    catch(IntrospectionException e){
      throw raise(e);
    }
    if(!prop_elements.isEmpty()){
      component = component.bindProperties(new PropertyBinder(){
        public Creator bind(Class component_type, Object key, Class type) {
          final Prop prop = (Prop)valnames.get(key);
          if(prop!=null){
            Component result = prop.getVal(type);
            if(result==null){
              result = Components.value(null);//Components.useProperty(component_type, key, type);
            }
            final Component def = prop.getDefault(type);
            if(def!=null){
              result = Monad.mplus(result, def);
            }
            else if(prop.isOptional()){
              result = result.optional();
            }
            return result;
          }
          else return Components.useProperty(component_type, key, type);
        }
      });
    }
    if(optional_properties){
      component = component.optionalProperties();
    }
    final PropertyBinder autowiring = getPropertyAutowireMode();
    if(autowiring!=null){
      component = component.bindProperties(autowiring);
    }
    return component;
  }
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();
    final HashMap custom_naming_service = new HashMap();
    custom_naming_service.put("tests/jfun/models/BankAccount/balance", new Integer(1000));
    custom_naming_service.put("tests/jfun/models/BankAccount/id", "auto lookup");
    final PropertyBinder lookup = new NamingServiceWiring(custom_naming_service);
    final PropertyBinder autolookup = new MapNamingServiceWiring("namingservice");
   
    processor = new NutsProcessor();
    processor.registerAutoWiring("lookup", lookup);
    processor.registerAutoWiring("autolookup", autolookup);
    processor.registerService("echo_msg", "there ya go:");
View Full Code Here

    final String autowire = tag.getAttribute(AUTOWIRE);
    final Location loc = tag.getLocation();
    final ParameterBinder param_wiring = MyUtil.getParamWiring(autowire,
        interpreter.getCustomWiringModes(), loc,
        interpreter.getParameterWiring());
    final PropertyBinder prop_wiring = MyUtil.getPropWiring(autowire,
        interpreter.getCustomWiringModes(), loc,
        interpreter.getPropertyWiring());
    final SingletonMode singleton =
      MyUtil.getSingletonStrategy(tag.getAttribute(SINGLETON), loc,
          interpreter.getSingletonMode());
View Full Code Here

    for(int i=0;i<mandatory_params.length;i++){
      final String name = mandatory_params[i];
      params.put(name, name);
    }
    return cc.fromProperties(mandatory_params).bean()
      .bindProperties(new PropertyBinder(){
        public Creator bind(Class component_type, Object key, Class type){
          final Component p = Components.useProperty(component_type, key, type);
          if(params.containsKey(key)){
            return p;
          }
View Full Code Here

    return result;
  }

  private static HashMap getResolutionNames(){
    final HashMap result = new HashMap();
    final PropertyBinder bytype = Modes.props_bytype;
    result.put(Constants.BYNAME, Modes.props_byname);
    result.put(Constants.BYTYPE, bytype);
    result.put(Constants.AUTODETECT, Modes.props_autodetect);
    //result.put(Constants.ON, bytype);
    //result.put(Constants.TRUE, bytype);
View Full Code Here

  }
  public static PropertyBinder getPropWiring(String autowire,
      AutoWiringMap custom_wirings, Location loc, PropertyBinder def){
    if(autowire!=null){
      autowire = autowire.trim().toLowerCase(Locale.US);
      PropertyBinder custom = custom_wirings.getPropertyWiringMode(autowire);
      if(custom!=null) return custom;
     
      if(manual_names.containsKey(autowire)){
        return null;
      }
      final PropertyBinder result = (PropertyBinder)auto_resolutions.get(autowire);
      if(result != null) return result;
      else if(custom_wirings.getParameterWiringMode(autowire)!=null){
          throw new ConfigurationException("unrecognized autowire mode: "+autowire,
              loc);
      }
View Full Code Here

    };
  }
  static PropertyBinder autocast(final PropertyBinder binder,
      final Location loc, final Converter conv){
    if(binder==null) return null;
    return new PropertyBinder(){
      public String toString(){
        return binder.toString();
      }
      public Creator bind(Class component_type, Object key, Class type) {
        return cast(type, Components.adapt(binder.bind(component_type, key, type)),
View Full Code Here

TOP

Related Classes of jfun.yan.PropertyBinder

Copyright © 2018 www.massapicom. 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.