Constructs a binding adapter class from it's class name using reflection.
514368
@SuppressWarnings("unchecked")
    static <T, A extends BindingCollectionAdapter<T>> A createClass(Class<? extends BindingCollectionAdapter> adapterClass, ItemBinding<T> itemBinding) {
        try {
            return (A) adapterClass.getConstructor(ItemBinding.class).newInstance(itemBinding);
        } catch (Exception e1) {
            throw new RuntimeException(e1);
        }
    }
831914
private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) {
    try {
      final Constructor<?> constructor = resultClass.getConstructor(String.class);
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return constructor.newInstance(value);
        }
      };
    } catch (Exception e) {
      return null;
    }
  }
994412
def generate_adapter(adapter, name='url_for', map_name='url_map'):
    """"""
    values = {
        u'server_name':     dumps(adapter.server_name),
        u'script_name':     dumps(adapter.script_name),
        u'subdomain':       dumps(adapter.subdomain),
        u'url_scheme':      dumps(adapter.url_scheme),
        u'name':            name,
        u'map_name':        map_name
    }
    return u'''\
var %(name)s = %(map_name)s(
    %(server_name)s,
    %(script_name)s,
    %(subdomain)s,
    %(url_scheme)s
);''' % values
716047
function loadAdapter(type, location) {
    var options = adapterConfig[type];
    try {
        var modulePath = adapterModulePath(type, options);

        global.JuttleAdapterAPI = JuttleAdapterAPI;

        var start = new Date();

        if (!options.builtin) {
            checkCompatible(type, modulePath, location);
        }

        var init = require(modulePath);

        var loaded = new Date();
        var adapter = init(options);

        global.JuttleAdapterAPI = undefined;

        if (adapter.name !== type) {
            throw new Error('adapter name ', adapter.name, ' != type ', type);
        }
        var initialized = new Date();

        logger.debug(adapter.name, 'adapter loaded in', (loaded - start), 'ms,',
                     'initialized in', (initialized - loaded), 'ms');

        register(adapter.name, adapter);

        return adapter;
    } catch (err) {
        logger.error('error loading adapter ' + type + ': ' + err.message);
        throw err;
    }
}
1076488
public String getBindMapperName(BindTypeContext context, TypeName typeName) {
		Converter<String, String> format = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);
		TypeName bindMapperName=TypeUtility.mergeTypeNameWithSuffix(typeName,BindTypeBuilder.SUFFIX);
		String simpleName=format.convert(TypeUtility.simpleName(bindMapperName));
	
		if (!alreadyGeneratedMethods.contains(simpleName))
		{
			alreadyGeneratedMethods.add(simpleName);
			if (bindMapperName.equals(beanTypeName))
			{
				context.builder.addField(FieldSpec.builder(bindMapperName, simpleName, modifiers)					
						.addJavadoc("$T", bindMapperName)
						.initializer("this")
						.build());
			} else {				
				context.builder.addField(FieldSpec.builder(bindMapperName, simpleName, modifiers)					
						.addJavadoc("$T", bindMapperName)
						.initializer("$T.mapperFor($T.class)", BinderUtils.class, typeName)
						.build());	
			}		
		}
		
		return simpleName;
	}
864910
def register_custom_adapter(cls, target_class, adapter):
        

        class_name = target_class.__name__

        if adapter.can_serialize():
            cls._custom_serializers[class_name] = adapter

        if adapter.can_deserialize():
            cls._custom_deserializers[class_name] = adapter
295060
def bind(self, container, attr_name):
        
        instance = super(DependencyProvider, self).bind(container)
        instance.attr_name = attr_name
        self.attr_name = attr_name
        return instance
172663
public void bind(String name, T binding) {
        put(name, binding);

        Map<String, Map<String, NameClassPair>> bindingsByContext = this.contextBindings;
        if (bindingsByContext != null) {
            addContextBinding(bindingsByContext, name, binding);
        }

        Set<String> contexts = this.contexts;
        if (contexts != null) {
            contexts.add(getContextName(name));
        }
    }
716299
def _make_target_adaptor(base_class, target_type):
  """"""
  if not target_type.supports_default_sources() or target_type.default_sources_globs is None:
    return base_class

  globs = _tuplify(target_type.default_sources_globs)
  excludes = _tuplify(target_type.default_sources_exclude_globs)

  class GlobsHandlingTargetAdaptor(base_class):
    @property
    def default_sources_globs(self):
      if globs is None:
        return super(GlobsHandlingTargetAdaptor, self).default_sources_globs
      else:
        return globs

    @property
    def default_sources_exclude_globs(self):
      if excludes is None:
        return super(GlobsHandlingTargetAdaptor, self).default_sources_exclude_globs
      else:
        return excludes

  return GlobsHandlingTargetAdaptor
1170967
protected <T> T instantiate(String name, ClassLoader classLoader) {
    try {
      Class<?> generatedClass = loadClass(classLoader, name);
      if (generatedClass == Void.class) {
        return null;
      }
      @SuppressWarnings("unchecked")
      T instance = (T) generatedClass.newInstance();
      return instance;
    } catch (InstantiationException e) {
      throw new RuntimeException("Failed to initialize " + name, e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException("Failed to initialize " + name, e);
    }
  }
1060857
function createResolveFunction(Class){
  return function resolve(context, fn, source, property, factoryContext){
    var oldAdapter = context[property] || null;
    var newAdapter = null;

    if (fn !== resolveAdapterProxy && typeof source == 'function')
      source = source.call(factoryContext || context, factoryContext || context);

    if (source && source.bindingBridge)
    {
      if (!oldAdapter || oldAdapter.source !== source)
        newAdapter = new BBResolveAdapter(context, fn, source, DEFAULT_CHANGE_ADAPTER_HANDLER);
      else
        newAdapter = oldAdapter;

      source = resolve(newAdapter, resolveAdapterProxy, source.bindingBridge.get(source), 'next');
    }

    if (source instanceof Class == false)
      source = null;

    if (property && oldAdapter !== newAdapter)
    {
      var cursor = oldAdapter;

      // drop old adapter chain
      while (cursor)
      {
        var adapter = cursor;
        adapter.detach();
        cursor = adapter.next;
        adapter.next = null;
      }

      if (newAdapter)
        newAdapter.attach(DEFAULT_DESTROY_ADAPTER_HANDLER);

      context[property] = newAdapter;
    }

    return source;
  };
}
807356
@SuppressWarnings({"unchecked", "rawtypes"})
    public T adapter(Adapter adapter) {

        if (view instanceof AdapterView) {
            AdapterView av = (AdapterView) view;
            av.setAdapter(adapter);
        }
        return self();
    }
867743
def from_namespace(cls, namespace):
        """"""
        config = cls()
        for slot in cls.__slots__:
            if slot.startswith('_'):
                slot = slot[1:]
            if not hasattr(namespace, slot):
                continue
            setattr(config, slot, getattr(namespace, slot))

        return config
698296
private Object getDefaultJavaCompObjectInstance(NamingConstants.JavaColonNamespace namespace,
                                                    String bindingName,
                                                    ResourceInfo resourceRefInfo) throws Exception {
        String name = namespace.unprefix(bindingName);
        // Use a filter that ignores an extra service for the supertype that config processing code creates
        // with the properties of the subtype (currently the extra service is required to support ibm:extends)
        StringBuilder filter = new StringBuilder("(&")
                        .append(FilterUtils.createPropertyFilter(com.ibm.ws.resource.ResourceFactory.JAVA_COMP_DEFAULT_NAME, name))
                        .append("(!(ibm.extends.source.factoryPid=*))")
                        .append(')');
        return createResourceWithFilter(filter.toString(), resourceRefInfo);
    }
1262572
private static Class<?> getBoundGinjector(GinjectorBindings bindings) {

    if (bindings.getGinjectorInterface() == null) {
      return null;
    }

    TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
    Key<?> ginjectorKey = Key.get(ginjectorInterface);

    if (!bindings.isBound(ginjectorKey)) {
      return null;
    }

    if (!(bindings.getBinding(ginjectorKey) instanceof GinjectorBinding)) {
      return null;
    }

    return ginjectorInterface.getRawType();
  }
814999
@SuppressWarnings("rawtypes")
	static <D extends TypeAdapter> D generateAdapter(HashMap<Class<? extends TypeAdapter>, TypeAdapter> cache, ReentrantLock lock, Class<D> clazz) {
		D adapter = null;
		try {
			lock.lock();
			adapter = clazz.newInstance();
			cache.put(clazz, adapter);
		} catch (Throwable e) {
			throw (new KriptonRuntimeException(e));
		} finally {
			lock.unlock();			
		}
		return adapter;
	}
742439
@SuppressWarnings("unchecked")
    private <T> TypedStringConverter<T> findAnyConverter(final Class<T> cls) {
        // check factories
        for (StringConverterFactory factory : factories) {
            StringConverter<T> factoryConv = (StringConverter<T>) factory.findConverter(cls);
            if (factoryConv != null) {
                return TypedAdapter.adapt(cls, factoryConv);
            }
        }
        return null;
    }