Как запустить java приложение под прокси. А пофиг!: Java for fun: Замечательный proxy-сервер на java

    • Field Detail

    • Constructor Detail

      • Proxy

        protected Proxy(InvocationHandler h)

        Constructs a new Proxy instance from a subclass (typically, a dynamic proxy class) with the specified value for its invocation handler.

        Parameters: h - the invocation handler for this proxy instance
    • Method Detail

      • getProxyClass

        public static Class getProxyClass(ClassLoader loader, Class ... interfaces) throws IllegalArgumentException

        Returns the java.lang.Class object for a proxy class given a class loader and an array of interfaces. The proxy class will be defined by the specified class loader and will implement all of the supplied interfaces. If a proxy class for the same permutation of interfaces has already been defined by the class loader, then the existing proxy class will be returned; otherwise, a proxy class for those interfaces will be generated dynamically and defined by the class loader.

        There are several restrictions on the parameters that may be passed to Proxy.getProxyClass:

        • All of the Class objects in the interfaces array must represent interfaces, not classes or primitive types.
        • No two elements in the interfaces array may refer to identical Class objects.
        • All of the interface types must be visible by name through the specified class loader. In other words, for class loader cl and every interface i , the following expression must be true: Class.forName(i.getName(), false, cl) == i
        • All non-public interfaces must be in the same package; otherwise, it would not be possible for the proxy class to implement all of the interfaces, regardless of what package it is defined in.
        • For any set of member methods of the specified interfaces that have the same signature:
          • If the return type of any of the methods is a primitive type or void, then all of the methods must have that same return type.
          • Otherwise, one of the methods must have a return type that is assignable to all of the return types of the rest of the methods.
        • The resulting proxy class must not exceed any limits imposed on classes by the virtual machine. For example, the VM may limit the number of interfaces that a class may implement to 65535; in that case, the size of the interfaces array must not exceed 65535.

        If any of these restrictions are violated, Proxy.getProxyClass will throw an IllegalArgumentException . If the interfaces array argument or any of its elements are null , a NullPointerException will be thrown.IllegalArgumentException

        Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler. This method is equivalent to: Proxy.getProxyClass(loader, interfaces). getConstructor(new Class { InvocationHandler.class }). newInstance(new Object { handler });

        Proxy.newProxyInstance throws IllegalArgumentException for the same reasons that Proxy.getProxyClass does.

        Parameters: loader - the class loader to define the proxy class interfaces - the list of interfaces for the proxy class to implement h - the invocation handler to dispatch method invocations to Returns: a proxy instance with the specified invocation handler of a proxy class that is defined by the specified class loader and that implements the specified interfaces Throws: IllegalArgumentException - if any of the restrictions on the parameters that may be passed to getProxyClass are violated NullPointerException - if the interfaces array argument or any of its elements are null , or if the invocation handler, h , is null
      • isProxyClass

        public static boolean isProxyClass(Class cl)

        Returns true if and only if the specified class was dynamically generated to be a proxy class using the getProxyClass method or the newProxyInstance method.

        The reliability of this method is important for the ability to use it to make security decisions, so its implementation should not just test if the class in question extends Proxy .

        Parameters: cl - the class to test Returns: true if the class is a proxy class and false otherwise Throws: NullPointerException - if cl is null
      • getInvocationHandler

        public static InvocationHandler getInvocationHandler(Object proxy) throws IllegalArgumentException

        Returns the invocation handler for the specified proxy instance.

        Parameters: proxy - the proxy instance to return the invocation handler for Returns: the invocation handler for the proxy instance Throws: IllegalArgumentException - if the argument is not a proxy instance

Последние материалы раздела:

Ол взмш при мгу: отделение математики Заочные математические школы для школьников
Ол взмш при мгу: отделение математики Заочные математические школы для школьников

Для учащихся 6-х классов: · математика, русский язык (курс из 2-х предметов) - охватывает материал 5-6 классов. Для учащихся 7–11 классов...

Интересные факты о физике
Интересные факты о физике

Какая наука богата на интересные факты? Физика! 7 класс - это время, когда школьники начинают изучать её. Чтобы серьезный предмет не казался таким...

Дмитрий конюхов путешественник биография
Дмитрий конюхов путешественник биография

Личное дело Федор Филиппович Конюхов (64 года) родился на берегу Азовского моря в селе Чкалово Запорожской области Украины. Его родители были...