Create a SuperviseAndProxyHandler subclass with given parameters
776973
def _make_serverproxy_handler(name, command, environment, timeout, absolute_url, port):
    
    # FIXME: Set 'name' properly
    class _Proxy(SuperviseAndProxyHandler):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)
            self.name = name
            self.proxy_base = name
            self.absolute_url = absolute_url
            self.requested_port = port

        @property
        def process_args(self):
            return {
                'port': self.port,
                'base_url': self.base_url,
            }

        def _render_template(self, value):
            args = self.process_args
            if type(value) is str:
                return value.format(**args)
            elif type(value) is list:
                return [self._render_template(v) for v in value]
            elif type(value) is dict:
                return {
                    self._render_template(k): self._render_template(v)
                    for k, v in value.items()
                }
            else:
                raise ValueError('Value of unrecognized type {}'.format(type(value)))

        def get_cmd(self):
            if callable(command):
                return self._render_template(call_with_asked_args(command, self.process_args))
            else:
                return self._render_template(command)

        def get_env(self):
            if callable(environment):
                return self._render_template(call_with_asked_args(environment, self.process_args))
            else:
                return self._render_template(environment)

        def get_timeout(self):
            return timeout

    return _Proxy
1316046
@Override
    public ProxyHandler createProxyHandler() {
        final HttpProxyHandler handler;

        // For reasons that are not immediately clear, HttpProxyHandler doesn't allow null usernames/passwords if
        // specified. If we want them to be null, we have to use the constructor that doesn't take a username/password
        // at all.
        if (this.username != null && this.password != null) {
            handler = new HttpProxyHandler(this.proxyAddress, this.username, this.password);
        } else {
            handler = new HttpProxyHandler(this.proxyAddress);
        }

        return handler;
    }
168851
def proxy_manager_for(self, proxy, **proxy_kwargs):
        """"""
        try:
            proxy_kwargs['ssl_version'] = ssl.PROTOCOL_TLS
        except AttributeError:
            proxy_kwargs['ssl_version'] = ssl.PROTOCOL_SSLv23
        return super(SSLAdapter, self).proxy_manager_for(proxy, **proxy_kwargs)
332209
private ServerEventHandler createServerEventHandler(
			SFSEventType type, Class<?> clazz) {
		try {
			return (ServerEventHandler)
					ReflectClassUtil.newInstance(
					clazz, BaseAppContext.class, context);
		} catch (ExtensionException e) {
		    getLogger().error("Error when create server event handlers", e);
			throw new RuntimeException("Can not create event handler of class "
					+ clazz, e);
		}
	}
803736
void activateProbeProxyTarget() throws Exception {
        Method method = ReflectionHelper.getDeclaredMethod(
                                                           probeManagerImpl.getClass(),
                                                           ProbeMethodAdapter.FIRE_PROBE_METHOD_NAME,
                                                           long.class, Object.class, Object.class, Object.class);
        ReflectionHelper.setAccessible(method, true);
        if (!Type.getMethodDescriptor(method).equals(ProbeMethodAdapter.FIRE_PROBE_METHOD_DESC)) {
            throw new IncompatibleClassChangeError("Proxy method signature does not match byte code");
        }
        findProbeProxySetFireProbeTargetMethod().invoke(null, probeManagerImpl, method);
    }
685325
function makeProxy(definition, names, send, rootDefinition) {
    if (! names) throw new Error("No name proxying definition " + JSON.stringify(definition));
    if (! Array.isArray(names)) names = [ names ];

    /* All definitions are objects! */
    if (typeof(definition) !== 'object') {
      throw new Error("Wrong proxy definition at " + names.join('.') + " for \n"
                    + JSON.stringify(rootDefinition, null, 1));
    }

    /* Initial object */
    var object = {};

    /* Function definitions, can be also at top level */
    if (definition['!$invocable$!'] === true) {
      var clone = names.slice(0);

      /* Can be called as "new F()" or "f()" */
      var Invocable = function() {

        /* Prepare our message */
        var message = { proxy: { proxy: clone, arguments: arguments }};

        /* Is this "new F()" or a normal call? */
        if (this instanceof Invocable) {
          message.newInstance = true;
          ProxyPromise.call(this, message, send);
          this.asProxy(true);
        } else {
          return new ProxyPromise(message, send);
        }
      }

      /* Functions can have members, so keep processing */
      object = Invocable;

    }

    /* Clone all the members of the definition */
    for (var i in definition) {
      (function(i) {
        var child = definition[i];
        var clone = names.slice(0);
        clone.push(i);

        /* Basic properties for the object to define */
        var props = { enumerable: true, configurable: false };

        /* Function definitions */
        if (child['!$invocable$!'] === true) {
          props.value = makeProxy(child, clone, send, rootDefinition);
        }

        /* Setters/getters definitions */
        else if (child.hasOwnProperty('!$value$!')) {
          var initialValue = child['!$value$!'];
          props['get'] = function() {
            var message = { proxy: { proxy: clone } };
            var promise = new ProxyPromise(message, send, initialValue);
            promise.asProxy = function() { return promise } // already a proxy
            promise.then(function(success) { initialValue = success });
            return promise; // return the original ProxyPromise instance
          };
          props['set'] = function(value) {
            initialValue = value;
            send({ proxy: { value: value, proxy: clone } })
              .then(function(success) { initialValue = success });
          };
        }

        /* Nested definitions get recursively processed */
        else if (typeof(child) === 'object') {
          props.value = makeProxy(child, clone, send, rootDefinition);
        }

        else if (i !== '!$invocable$!') {
          throw new Error("Wrong proxy definition at " + names.join('.') + "." + i + " for \n"
                        + JSON.stringify(rootDefinition, null, 1));
        }

        /* Define the properties for this */
        Object.defineProperty(object, i, props);
      })(i);
    }

    /* All done, return our object clone */
    return object;
  }
435915
function makeObserver(handlers) {
  console.assert(handlers && typeof handlers === 'object', "Argument to makeObserver must be hash.");
  var handler = assign(create(observerPrototype), handlers);
  var observer = handler.handle.bind(handler);
  observer.keys = getTypesFromHandlers(handlers);
  return observer;
}
1238021
public void addProxy(String protocol, String host, int port, String username, String password,
                       int socketTimeout, int connectTimeout, int connectionRequestTimeout) {
    Proxy proxy = new Proxy(protocol, host, port, username, password, socketTimeout, connectTimeout, connectionRequestTimeout);
    proxies.add(proxy);
  }
1283860
static EntityManager createProxy(final HibernateEntityManagerFactory factory) {
        final EntityManagerInterceptor handler = new EntityManagerInterceptor(factory);

        final Enhancer e = new Enhancer();

        // make sure we're Serializable and have a write replace method
        e.setInterfaces(new Class[] { EntityManager.class, Serializable.class, IWriteReplace.class });
        e.setSuperclass(Object.class);
        e.setCallback(handler);
        e.setNamingPolicy(new DefaultNamingPolicy() {
            @Override
            public String getClassName(final String prefix,
                                       final String source,
                                       final Object key,
                                       final Predicate names) {
                return super.getClassName("CROQUET_ENTITY_MANAGER_PROXY_" + prefix, source, key, names);
            }
        });

        LOG.trace("Created proxy for an EntityManager");

        return (EntityManager)e.create();
    }
333694
def proxy_manager_for(self, proxy, **proxy_kwargs):
        """"""
        context = create_urllib3_context(ciphers=self.CIPHERS,
                                         ssl_version=ssl.PROTOCOL_TLSv1)
        proxy_kwargs['ssl_context'] = context
        return super(TLSv1Adapter, self).proxy_manager_for(proxy,
                                                           **proxy_kwargs)
524046
private static void initPrefixHandlers()
    {
        PrefixHandlerConfig[] prefixHandlers = ConfigUtil.getConfig().getPrefixHandlers();
        if ( prefixHandlers == null )
        {
            return;
        }
        for ( int i = 0; i < prefixHandlers.length; i++ )
        {
            try
            {
                Class prefixClass = Class.forName( prefixHandlers[i].getHandlerClass() );
                String name = prefixHandlers[i].getName();
                if ( name == null || name.equals( "" ) )
                {
                    _log.warn( "The name for the prefix handler '" + prefixHandlers[i].getHandlerClass()
                            + "' must not be null" );
                    continue;
                }
                Object o = prefixClass.newInstance();
                if ( !( o instanceof RequestParameterHandler ) )
                {
                    _log.warn( "The class '" + prefixHandlers[i].getHandlerClass()
                            + "' must be an instance of RequestParameterHandler" );
                    continue;
                }
                ProcessPopulate.registerPrefixHandler( name, ( RequestParameterHandler ) o );
            }
            catch ( ClassNotFoundException e )
            {
                _log.warn( "Class '" + prefixHandlers[i].getHandlerClass() + "' not found", e );
            }
            catch ( IllegalAccessException e )
            {
                _log.warn( "Illegal access on Class '" + prefixHandlers[i].getHandlerClass() + "'", e );

            }
            catch ( InstantiationException e )
            {
                _log.warn( "InstantiationException on Class '" + prefixHandlers[i].getHandlerClass() + "'",
                        e.getCause() );
            }
        }
    }
234113
function createProxyHandler (proxies, urlRoot) {
  if (!proxies.length) {
    const nullProxy = (request, response, next) => next()
    nullProxy.upgrade = () => {}
    return nullProxy
  }

  function createProxy (request, response, next) {
    const proxyRecord = proxies.find((p) => request.url.startsWith(p.path))
    if (proxyRecord) {
      log.debug(`proxying request - ${request.url} to ${proxyRecord.host}:${proxyRecord.port}`)
      request.url = request.url.replace(proxyRecord.path, proxyRecord.baseUrl)
      proxyRecord.proxy.web(request, response)
    } else {
      return next()
    }
  }

  createProxy.upgrade = function (request, socket, head) {
    // special-case karma's route to avoid upgrading it
    if (request.url.startsWith(urlRoot)) {
      log.debug(`NOT upgrading proxyWebSocketRequest ${request.url}`)
      return
    }

    const proxyRecord = proxies.find((p) => request.url.startsWith(p.path))
    if (proxyRecord) {
      log.debug(`upgrade proxyWebSocketRequest ${request.url} to ${proxyRecord.host}:${proxyRecord.port}`)
      request.url = request.url.replace(proxyRecord.path, proxyRecord.baseUrl)
      proxyRecord.proxy.ws(request, socket, head)
    }
  }

  return createProxy
}
909953
function createProxies(config, map, parentPath) {
  parentPath = parentPath || [];

  var isBase = parentPath.length === 0;
  var proxies = {};
  var path;

  for (var key in map) {
    if (map.hasOwnProperty(key)) {
      if (isObject(map[key])) {
        proxies[key] = createProxies(config, map[key], parentPath.concat([key]));
      }
      else if (isBoolean(map[key])) {
        path = parentPath.join('/') + (isBase ? '' : '/') + key;
        proxies[key] = createProxiedMethod(config, path);
      }
    }
  }

  return proxies;
}
278537
def make_handlers(base_url, server_processes):
    
    handlers = []
    for sp in server_processes:
        handler = _make_serverproxy_handler(
            sp.name,
            sp.command,
            sp.environment,
            sp.timeout,
            sp.absolute_url,
            sp.port,
        )
        handlers.append((
            ujoin(base_url, sp.name, r'(.*)'), handler, dict(state={}),
        ))
        handlers.append((
            ujoin(base_url, sp.name), AddSlashHandler
        ))
    return handlers
1054168
function (method, path, parameters) {
    if (path && !parameters) {
      parameters = path;
      path = null;
    }

    path = normalizePath(path);
    if (!path) {
      this.handlers[method] = parameters;
      this.exportHandler(method, null, parameters);
      return;
    }

    var child = this.children[path];
    if (!child) {
      child = this.api(path);
    }
    child.addHandler(method, null, parameters);
  }
1270645
function javaClassConstructorProxy() {
    var args = [name];
    for (var i = 0; i < arguments.length; i++) {
      args.push(arguments[i]);
    }
    return java.newInstanceSync.apply(java, args);
  }
1314298
public void addProxyMethods(TypeSpec.Builder classBuilder) {
        processRemoterElements(classBuilder, new ElementVisitor() {
            @Override
            public void visitElement(TypeSpec.Builder classBuilder, Element member, int methodIndex, MethodSpec.Builder methodBuilder) {
                addProxyMethods(classBuilder, member, methodIndex);
            }
        }, null);

        addProxyExtras(classBuilder);
        addCommonExtras(classBuilder);
    }