Build the multiple queries for one relationship because of limitation of IN(...)
@param proxies Collection containing all proxy objects to load
@param realSubjects Collection where real subjects found in the cache should be added.
355284
protected Query[] buildPrefetchQueries(Collection proxies, Collection realSubjects)
    {
        Collection queries = new ArrayList();
        Collection idsSubset;
        Object proxy;
        IndirectionHandler handler;
        Identity id;
        Class realClass;
        HashMap classToIds = new HashMap();
        Class topLevelClass = getItemClassDescriptor().getClassOfObject();
        PersistenceBroker pb = getBroker();
        ObjectCache cache = pb.serviceObjectCache();

        for (Iterator it = proxies.iterator(); it.hasNext(); )
        {
            proxy = it.next();
            handler = ProxyHelper.getIndirectionHandler(proxy);

            if (handler == null)
            {
                continue;
            }
            
            id = handler.getIdentity();
            if (cache.lookup(id) != null)
            {
                realSubjects.add(pb.getObjectByIdentity(id));
                continue;
            }
            realClass = id.getObjectsRealClass();
            if (realClass == null)
            {
                realClass = Object.class; // to remember that the real class is unknown
            }
            idsSubset = (HashSet) classToIds.get(realClass);
            if (idsSubset == null)
            {
                idsSubset = new HashSet();
                classToIds.put(realClass, idsSubset);
            }
            idsSubset.add(id);
            if (idsSubset.size() == pkLimit)
            {
                Query query;
                if (realClass == Object.class)
                {
                    query = buildPrefetchQuery(topLevelClass, idsSubset, true);
                }
                else
                {
                    query = buildPrefetchQuery(realClass, idsSubset, false);
                }
                queries.add(query);
                idsSubset.clear();
            }
        }

        for (Iterator it = classToIds.entrySet().iterator(); it.hasNext(); )
        {
            Map.Entry entry = (Map.Entry) it.next();
            realClass = (Class) entry.getKey();
            idsSubset = (HashSet) entry.getValue();
            if (idsSubset.size() > 0)
            {
                Query query;
                if (realClass == Object.class)
                {
                    query = buildPrefetchQuery(topLevelClass, idsSubset, true);
                }
                else
                {
                    query = buildPrefetchQuery(realClass, idsSubset, false);
                }
                queries.add(query);
            }
        }

        return (Query[]) queries.toArray(new Query[queries.size()]);
    }
642390
public static <T> T newProxyInstance(InvocationHandler invocationHandler, Class<?>... interfaces) {
		return newProxyInstance(ClassUtil.getClassLoader(), invocationHandler, interfaces);
	}
445587
public List<Subject> setupSubjects(List<Map<URI, List<AttributeValue>>> subjs) {

        if (subjs == null || subjs.size() == 0) {
            return Collections.singletonList(new Subject(new ArrayList<Attribute>()));
        }

        List<Subject> subjects = new ArrayList<Subject>(subjs.size());
        // Go through each of the subjects
        for (Map<URI, List<AttributeValue>> s : subjs) {
            List<Attribute> attributes = new ArrayList<Attribute>();

            // Extract and create the attributes for this subject and add them
            // to the set
            for (URI uri : s.keySet()) {
                List<AttributeValue> attributeValues = s.get(uri);
                if (attributeValues != null && attributeValues.size() > 0) {
                    attributes.add(
                        new BasicAttribute(uri, attributeValues.get(0).getType(),
                            null, null, attributeValues));
                }
            }

            // Create a new subject and add the attributes for this subject
            subjects.add(new Subject(attributes));
        }

        return subjects;
    }
450910
public void addHeaders(HttpServletRequest reqSource, HttpRequestBase httpTarget)
    {
    	Enumeration<?> headerNames = reqSource.getHeaderNames();
    	while (headerNames.hasMoreElements())
    	{
    		String key = headerNames.nextElement().toString();
    		if (CONTENT_LENGTH.equalsIgnoreCase(key))
    			continue;	// Length will be different
    		Enumeration<?> headers = reqSource.getHeaders(key);
    		while (headers.hasMoreElements())
    		{
    			String value = (String)headers.nextElement();
    			if (HOST.equalsIgnoreCase(key))
    			{
    				value = proxyURLPrefix;
    				if (value.indexOf(":") != -1)
    				{
    					value = value.substring(value.indexOf(":") + 1);
    					while (value.startsWith("/"))
    					{
    						value = value.substring(1);
    					}
    				}
    				if (value.indexOf("/") != -1)
    					value = value.substring(0, value.indexOf("/"));
    			}
    			httpTarget.setHeader(new BasicHeader(key, value));
    		}
    	}
    }
784305
private void setSubjectPrincipals() {
        if (null != userPrincipal) {
            this.subject.getPrincipals().add(userPrincipal);
        }
        if (null != rolePrincipals) {
            for (Principal rolePrincipal : rolePrincipals) {
                this.subject.getPrincipals().add(rolePrincipal);
            }
        }
    }
545039
public function setProxies(array $relations = null)
    {
        $attributes = $this->getEntityAttributes();
        $proxies = [];

        $relations = $this->getRelationsToProxy();

        // Before calling the relationship methods, we'll set the relationship
        // method to null, to avoid hydration error on class properties
        foreach ($relations as $relation) {
            $this->setEntityAttribute($relation, null);
        }

        foreach ($relations as $relation) {
            // First, we check that the relation has not been already
            // set, in which case, we'll just pass.
            if (array_key_exists($relation, $attributes) && !is_null($attributes[$relation])) {
                continue;
            }

            // If the key is handled locally and we know it not to be set,
            // we'll set the relationship to null value
            if (!$this->relationNeedsProxy($relation, $attributes)) {
                $proxies[$relation] = $this->entityMap->getEmptyValueForRelationship($relation);
            } else {
                $targetClass = $this->getClassToProxy($relation, $attributes);
                $proxies[$relation] = $this->proxyFactory->make($this->getObject(), $relation, $targetClass);
            }
        }

        foreach ($proxies as $key => $value) {
            $this->setEntityAttribute($key, $value);
        }
    }
512094
public static void configureCustomProxyProperties(
      Map<SFSessionProperty, Object> connectionPropertiesMap)
  {
    if (connectionPropertiesMap.containsKey(SFSessionProperty.USE_PROXY))
    {
      useProxy = (boolean) connectionPropertiesMap.get(
          SFSessionProperty.USE_PROXY);
    }

    if (useProxy)
    {
      proxyHost =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_HOST);
      proxyPort =
          Integer.parseInt(
              connectionPropertiesMap.get(SFSessionProperty.PROXY_PORT).toString());
      proxyUser =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_USER);
      proxyPassword =
          (String) connectionPropertiesMap.get(SFSessionProperty.PROXY_PASSWORD);
      nonProxyHosts =
          (String) connectionPropertiesMap.get(SFSessionProperty.NON_PROXY_HOSTS);
    }
  }
630466
function createDefaultProxies(items, proxyRole) {
  const proxies = items ?
    items.map(() => template.createElement(proxyRole)) :
    [];
  // Make the array immutable to help update performance.
  Object.freeze(proxies);
  return proxies;
}
466755
public void setSubDomains(java.util.Collection<SubDomain> subDomains) {
        if (subDomains == null) {
            this.subDomains = null;
            return;
        }

        this.subDomains = new java.util.ArrayList<SubDomain>(subDomains);
    }
1293283
public void addProxy(String protocol, String host, int port, String username, String password) {
    Proxy proxy = new Proxy(protocol, host, port, username, password);
    proxies.add(proxy);
  }
715204
public void setProxy(Proxy proxy)
    {
        if(proxy != null)
        {
            java.net.Proxy p = new java.net.Proxy(java.net.Proxy.Type.HTTP,
                    new InetSocketAddress(proxy.getHost(), proxy.getPort()));
            client.setProxy(p);
        }
        else
            client.setProxy(java.net.Proxy.NO_PROXY);
    }
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);
    }
896320
@SuppressWarnings("unchecked")
    public <T> T proxy(final Object delegate, Class<?> [] interfaces)
    {
        return (T)Proxy.newProxyInstance
            (delegate.getClass().getClassLoader(),
             interfaces,
             new ProxyInvocationHandler(delegate));
    }
188371
public static boolean isForgeProxy(Object object)
   {
      if (object != null)
      {
         Class<?>[] interfaces = object.getClass().getInterfaces();
         if (interfaces != null)
         {
            for (Class<?> iface : interfaces)
            {
               if (iface.getName().equals(ForgeProxy.class.getName()))
               {
                  return true;
               }
            }
         }
      }
      return false;
   }
621056
private static Class<?> getProxyClass0(ClassLoader loader,
                                           Class<?>... interfaces) {
        if (interfaces.length > 65535) {
            throw new IllegalArgumentException("interface limit exceeded");
        }

        Class<?> proxyClass = null;

        /* collect interface names to use as key for proxy class cache */
        String[] interfaceNames = new String[interfaces.length];

        // for detecting duplicates
        Set<Class<?>> interfaceSet = new HashSet<>();

        for (int i = 0; i < interfaces.length; i++) {
            /*
             * Verify that the class loader resolves the name of this
             * interface to the same Class object.
             */
            String interfaceName = interfaces[i].getName();
            Class<?> interfaceClass = null;
            try {
                interfaceClass = Class.forName(interfaceName, false, loader);
            } catch (ClassNotFoundException e) {
            }
            if (interfaceClass != interfaces[i]) {
                throw new IllegalArgumentException(
                    interfaces[i] + " is not visible from class loader");
            }

            /*
             * Verify that the Class object actually represents an
             * interface.
             */
            if (!interfaceClass.isInterface()) {
                throw new IllegalArgumentException(
                    interfaceClass.getName() + " is not an interface");
            }

            /*
             * Verify that this interface is not a duplicate.
             */
            if (interfaceSet.contains(interfaceClass)) {
                throw new IllegalArgumentException(
                    "repeated interface: " + interfaceClass.getName());
            }
            interfaceSet.add(interfaceClass);

            interfaceNames[i] = interfaceName;
        }

        /*
         * Using string representations of the proxy interfaces as
         * keys in the proxy class cache (instead of their Class
         * objects) is sufficient because we require the proxy
         * interfaces to be resolvable by name through the supplied
         * class loader, and it has the advantage that using a string
         * representation of a class makes for an implicit weak
         * reference to the class.
         */
        List<String> key = Arrays.asList(interfaceNames);

        /*
         * Find or create the proxy class cache for the class loader.
         */
        Map<List<String>, Object> cache;
        synchronized (loaderToCache) {
            cache = loaderToCache.get(loader);
            if (cache == null) {
                cache = new HashMap<>();
                loaderToCache.put(loader, cache);
            }
            /*
             * This mapping will remain valid for the duration of this
             * method, without further synchronization, because the mapping
             * will only be removed if the class loader becomes unreachable.
             */
        }

        /*
         * Look up the list of interfaces in the proxy class cache using
         * the key.  This lookup will result in one of three possible
         * kinds of values:
         *     null, if there is currently no proxy class for the list of
         *         interfaces in the class loader,
         *     the pendingGenerationMarker object, if a proxy class for the
         *         list of interfaces is currently being generated,
         *     or a weak reference to a Class object, if a proxy class for
         *         the list of interfaces has already been generated.
         */
        synchronized (cache) {
            /*
             * Note that we need not worry about reaping the cache for
             * entries with cleared weak references because if a proxy class
             * has been garbage collected, its class loader will have been
             * garbage collected as well, so the entire cache will be reaped
             * from the loaderToCache map.
             */
            do {
                Object value = cache.get(key);
                if (value instanceof Reference) {
                    proxyClass = (Class<?>) ((Reference<?>) value).get();
                }
                if (proxyClass != null) {
                    // proxy class already generated: return it
                    return proxyClass;
                } else if (value == pendingGenerationMarker) {
                    // proxy class being generated: wait for it
                    try {
                        cache.wait();
                    } catch (InterruptedException e) {
                        /*
                         * The class generation that we are waiting for should
                         * take a small, bounded time, so we can safely ignore
                         * thread interrupts here.
                         */
                    }
                    continue;
                } else {
                    /*
                     * No proxy class for this list of interfaces has been
                     * generated or is being generated, so we will go and
                     * generate it now.  Mark it as pending generation.
                     */
                    cache.put(key, pendingGenerationMarker);
                    break;
                }
            } while (true);
        }

        try {
            String proxyPkg = null;     // package to define proxy class in

            /*
             * Record the package of a non-public proxy interface so that the
             * proxy class will be defined in the same package.  Verify that
             * all non-public proxy interfaces are in the same package.
             */
            for (int i = 0; i < interfaces.length; i++) {
                int flags = interfaces[i].getModifiers();
                if (!Modifier.isPublic(flags)) {
                    String name = interfaces[i].getName();
                    int n = name.lastIndexOf('.');
                    String pkg = ((n == -1) ? "" : name.substring(0, n + 1));
                    if (proxyPkg == null) {
                        proxyPkg = pkg;
                    } else if (!pkg.equals(proxyPkg)) {
                        throw new IllegalArgumentException(
                            "non-public interfaces from different packages");
                    }
                }
            }

            if (proxyPkg == null) {
                // if no non-public proxy interfaces, use the default package.
                proxyPkg = "";
            }

            {
                // Android-changed: Generate the proxy directly instead of calling
                // through to ProxyGenerator.
                /* J2ObjC removed.
                List<Method> methods = getMethods(interfaces);
                Collections.sort(methods, ORDER_BY_SIGNATURE_AND_SUBTYPE);
                validateReturnTypes(methods);
                List<Class<?>[]> exceptions = deduplicateAndGetExceptions(methods);

                Method[] methodsArray = methods.toArray(new Method[methods.size()]);
                Class<?>[][] exceptionsArray = exceptions.toArray(new Class<?>[exceptions.size()][]);
                */

                /*
                 * Choose a name for the proxy class to generate.
                 */
                final long num;
                synchronized (nextUniqueNumberLock) {
                    num = nextUniqueNumber++;
                }
                String proxyName = proxyPkg + proxyClassNamePrefix + num;

                proxyClass = generateProxy(proxyName, interfaces, loader);
            }
            // add to set of all generated proxy classes, for isProxyClass
            proxyClasses.put(proxyClass, null);

        } finally {
            /*
             * We must clean up the "pending generation" state of the proxy
             * class cache entry somehow.  If a proxy class was successfully
             * generated, store it in the cache (with a weak reference);
             * otherwise, remove the reserved entry.  In all cases, notify
             * all waiters on reserved entries in this cache.
             */
            synchronized (cache) {
                if (proxyClass != null) {
                    cache.put(key, new WeakReference<Class<?>>(proxyClass));
                } else {
                    cache.remove(key);
                }
                cache.notifyAll();
            }
        }
        return proxyClass;
    }
913833
func (client *Client) Proxies() (map[string]*Proxy, error) {
	resp, err := http.Get(client.endpoint + "/proxies")
	if err != nil {
		return nil, err
	}

	err = checkError(resp, http.StatusOK, "Proxies")
	if err != nil {
		return nil, err
	}

	proxies := make(map[string]*Proxy)
	err = json.NewDecoder(resp.Body).Decode(&proxies)
	if err != nil {
		return nil, err
	}
	for _, proxy := range proxies {
		proxy.client = client
		proxy.created = true
	}

	return proxies, nil
}
347698
public static base_response add(nitro_service client, cacheforwardproxy resource) throws Exception {
		cacheforwardproxy addresource = new cacheforwardproxy();
		addresource.ipaddress = resource.ipaddress;
		addresource.port = resource.port;
		return addresource.add_resource(client);
	}