当前位置:网站首页>Agent mode - power node of station B
Agent mode - power node of station B
2022-07-19 03:35:00 【KK-Greyson】
List of articles
001- The proxy pattern



002- Static proxy

2.1 Implementation of static proxy





If there are multiple stars to perform , Then use interface oriented programming :






2.2 The flaw of static proxy


003- A dynamic proxy

3.1 JDK A dynamic proxy ( master )

(1)JDK Classes and interfaces used by dynamic proxy


(2) Realization JDK A dynamic proxy




package com.bjpowernode.proxy;
import com.bjpowernode.service.Service;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/** * */
public class ProxyFactory {
// The member variables in the class are designed as interfaces , Target audience
Service target;
// Incoming target object
public ProxyFactory(Service target){
this.target = target;
}
// Returns the dynamic proxy object
public Object getAgent(){
return Proxy.newProxyInstance(
//ClassLoader loader, Class loader , Finish loading the target object
target.getClass().getClassLoader(),
//Class<?>[] interfaces, All interfaces implemented by the target object
target.getClass().getInterfaces(),
//InvocationHandler h, Interface to implement proxy function , What we passed in is an anonymous internal implementation
new InvocationHandler() {
@Override
public Object invoke(
// Create proxy object
Object proxy,
//method It's the target method sing(),show()
Method method,
// Parameters of the target method
Object[] args) throws Throwable {
// Agent function
System.out.println(" Booking time ........");
// Agent function
System.out.println(" Booking a venue ........");
// The main business function is realized
//target.sing(); Or write dead the method call , no
//sing(),show(),one()
Object obj = method.invoke(target,args);
// Agent function
System.out.println(" Settle the expenses ........");
return obj; // Bear in mind : This is the return value of the target method
}
}
);
}
}








3.2 CGLib A dynamic proxy ( understand )
(1) characteristic

(2)CGLib Dynamic agent implementation
The simplified version implements :



Complete the implementation :




004- summary

边栏推荐
- Cmake common commands
- JDBC connection to MySQL database
- Unicast、Multicast、Broadcast
- 代理模式——B站动力节点
- ES6学习笔记——B站小马哥
- SQL classic exercises (x30)
- Latest installation tutorial of VMware Tools (rhel8)
- Wechat applet
- Chengxin University envi_ IDL second week homework: extract aerosol thickness at n points + detailed analysis
- MySQL log management and full backup incremental backup and recovery
猜你喜欢

Several methods of face detection
![[MySQL] MHA high availability](/img/d3/d9830f3c331193fd40b8f00ebe35fa.png)
[MySQL] MHA high availability
![[template record] string hash to judge palindrome string](/img/90/43109c6bd008990fa5b8147e629685.png)
[template record] string hash to judge palindrome string

Vscode+ros2 environment configuration

Rtx3090 installing pytorch3d
![In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]](/img/9f/a0d03b23e66849f12150f9a72f36c5.png)
In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
![mysqldump: [Warning] Using a password on the command line interface can be insecure.](/img/91/8b0d35f85bc0f46daac4e1e9bc9e34.png)
mysqldump: [Warning] Using a password on the command line interface can be insecure.

Through openharmony compatibility evaluation, the big brother development board and rich teaching and training resources have been ready

Graphql first acquaintance

Ubuntu clear CUDA cache
随机推荐
基于MFC如何实现单个文档的文件读写
The third day of the three questions of Luogu daily (make up on the fourth day)
IEEE754 standard floating point format
Several methods of face detection
374. Guess the size of numbers (must be able to get started)
2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
Through openharmony compatibility evaluation, the big brother development board and rich teaching and training resources have been ready
Rhce8 Study Guide Chapter 2 use of basic commands
Browser cannot open tensorboard
oracle 查询非自增长分区的最大分区
Comparison between redis and other databases
leetcode:50. Pow(x, n)
Ncnn allocator memory allocator
Es6 notes d'étude - station B Xiao Ma Ge
Affine transformation implementation
Flutter development: running the flutter upgrade command reports an error exception:flutter failed to create a directory at... Solution
論文閱讀:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation
SQL classic exercises (x30)
leetcode:50. Pow(x, n)
The installation software prompts that the program input point adddlldirectory cannot be located in the dynamic link library kernel32 DLL (download address at the end of the text)