In Java. lang. the reflect package provides a Proxy class and an InvocationHandler interface. By using this class and interface, you can generate JDK dynamic Proxy class or dynamic Proxy object. proxy provides a static method for creating dynamic Proxy classes and
Design Patterns
----Proxy (
Agent
)
Mode
GOF
:Provides a proxy for other objects to control access to this object. Not like flyweight. Proxy is itself the meaning of the agent. The reason for access control for an object is to use it when we really need it, or some function of the object. In a forum system (such as the very famous "Tianya"), browsing the for
For example:
Child
Class child {Private parent;
Public parent getparent (){Return this. parent; // The instance variable is accessed.}
}
Class Parent {Private string name;
Public String getname (){Return this. Name; // The instance variable is accessed.}
Public void F (){System. Out. println ("invokeing F ()"); // no instance variable is accessed}}
If the role-to-one lazy is set to proxy. getparent (). getname () or child. getparent (). F (), the par
In Ext, the proxy class is used to exchange data. There are two types: client proxy and server proxy.
Client proxy:
Localstorageproxy
Sessionstorageproxy
Memoryproxy
Server Proxy:
Ajaxproxy
Scripttagproxy
Directproxy
Restproxy
1. localstorageproxy
No
HTTP proxy: The ability to proxy client HTTP access, mainly proxy browser access to the Web page, its port is generally 80, 8080, 3128 and so on;Socks Proxy: Socks Proxy Unlike other types of proxies, it simply passes the packet without caring about what application protocol
To sum up is:1, the agent when the client knows the server, through the proxy to access the server, then the agent is the server2, reverse proxy when the client does not know the server side, the server knows the client, through the proxy to access the server, then the agent is the clientThe concept of a forward proxyThe forward agent, the legendary agent, works
1. Forward Proxy: The Agent object is the client;For example, some companies control the company computer can only access the local area network and a few external network URLs, then the company needs a proxy server, the employee computer request the network URL is sent through the proxy server (proxy server will check
1. Forward proxy
The forward proxy is located between the original server and the client, and its role is to send requests in place of the client, for example, to protect the client, or to flip the wall (the condition is that the proxy server must not be limited by GFW, currently, most VPs instances outside China are purchased. The process is as follows:
1.
Protocol and proxy, protocol proxy
======================================
Protocols and Proxies
======================================
[Agreement]
@ Protocol
[Role of the Protocol]: Specifies the interface method to be implemented. An agreement that must be followed by the entrusting party and the agent.
Delegate by (nt. delegate = self;) [Note: you can delegate yourself or other classes]
The
Forward proxy is a client and originalServerTo get content from the original server, the client sends a request to the proxy and specifies the target (original server ), then the proxy transfers the request to the original server and returns the obtained content to the client. The client must make some special settings to use the forward
the original object. It is usually used when the object should have different access permissions. The protection proxy checks whether the caller has the required access permissions for the request. If the caller does not have the required permissions, the proxy does not call the target object to protect the target object.2. Proxy 2.1 static
I have a UbuntuLinux machine with a wireless network card that can be used to access the Internet. I want to set it as a proxy server so that other machines in the Intranet can use it as a proxy for Internet access. 1. Install squidwww.linuxidc.com @ linuxidc on UbuntuLinux :~ $ Sudoapt-getinstallsquid2. Started automatically after installation, if you use the default provisioning, set the
Java proxies include jdk dynamic proxies and cglib proxies. Here we only talk about jdk dynamic proxies. jdk dynamic proxies mainly use java reflection mechanisms (both java. lang. reflect packages)
The principle is (examples of singers and agents ):
Create a public interface, such as the Singer public interface Singer;
Use a specific class to implement the interface. For example: Jay Chou, he is a Singer, so he implements the Singer class. class MySinger implements Singer
Create a
HTTP Proxy Server construction (CCproxy) and Proxy Server ccproxy on windows
HTTP Proxy)I. Topology
2. install and configure CCproxy 1. Install CCproxy (1) download the CCproxy wireless cracking version (only three users can connect to the CCproxy without cracking ). (2) follow the instructions to install. 2. Configure CCproxy1) server (1) double-click to open
Unable to open proxy Server prompt proxy server is not set to full access what to do? Prompt when you open the FTP server address using Windows file Browser: FTP Ftp://XXX.XXX.XXX.XXX will be read-only because the proxy server is set to full access. To move, paste, rename, or delete files, you will have to use a different pro
Python crawler practice (iii) -------- sogou article (IP proxy pool and user proxy pool settings ---- scrapy ),
In learning the scrapy crawler framework, it will certainly involve setting the IP proxy pool and User-Agent pool to avoid anti-crawling of websites.
In the past two days, I watched a video about sogou's article crawling. I talked about ip
Concept:Static proxy: The source code is generated automatically by the programmer or a specific tool, and then compiled. Before the program runs, the. class file for the proxy classes already exists.Dynamic Agent: When the program is running, it is created dynamically using the reflection mechanism.The dynamic proxy of the JDK is very simple to use, when it has
A forward proxy is a server that is located between the client and the original server (Origin server), in order to obtain content from the original server, the client sends a request to the agent and specifies the target (the original server), and the agent forwards the request to the original server and returns the obtained content to the client. The client must make some special settings to use the forward proxy.Reverse
Squid cache (squid for short) is a popular free software (GNU General Public License) proxy server and Web Cache Server. Squid has a wide range of uses, from cache-related requests as front cache servers of web servers to improving the speed of web servers, to cache the World Wide Web for a group of people to share network resources, domain Name System and other network search, to help network security by filtering traffic, to the LAN through the
AOPThe idea of proxy is Aspect-Oriented. Dynamic proxy technology is added. With AOP proxy, we can add some new businesses without modifying the original business classes. Shows the implementation idea:
The following is a simple example.Code:
1,DogInterface
Public interface dog {public void Info (); Public void run ();}
2,GundogImplementation class
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.