当前位置:网站首页>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

边栏推荐
- MySQL面试题(2022)
- Vscode+ros2 environment configuration
- Leetcode: dynamic programming [basic problem solving]
- Common MySQL commands you can use
- 论文阅读:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation
- Shell script receives and returns parameters
- Zabbix6.0 monitoring vcenter7.0
- Ubuntu clear CUDA cache
- Replacement operation not supported by ncnn partial operators
- In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
猜你喜欢
![[NoSQL] redis configuration and optimization of NoSQL (simple operation)](/img/e4/dcfeb675fd0ff4be3687547b28048d.png)
[NoSQL] redis configuration and optimization of NoSQL (simple operation)

ES6学习笔记——B站小马哥

Rtx3090 installing pytorch3d

Flutter开发:运行flutter upgrade命令报错Exception:Flutter failed to create a directory at…解决方法

Affine transformation implementation

Basic IDL content of note 1: common data types_ Create array_ Type conversion_ Print output_ Basic operation_ Relational operation

Visual analysis of ncnn param file and bin model
![Theoretical basis and code implementation of dueling dqn [pytoch + pendulum-v0]](/img/f6/cbfe32991449975fe51f2e2c0c1d47.png)
Theoretical basis and code implementation of dueling dqn [pytoch + pendulum-v0]

Graphql first acquaintance

Bisenetv1 face segmentation
随机推荐
Dqn theoretical basis and code implementation [pytoch + cartpole-v0]
SQL classic exercises (x30)
[MySQL] MHA high availability
洛谷每日三题之第五天
It's good to take more exercise
CorelDRAW cannot be installed. Solution
In depth understanding of machine learning - unbalanced learning: sample sampling technology - [adasyn sampling method of manual sampling technology]
[template record] string hash to judge palindrome string
laravel的问题
ncnn DataReader&Extractor&blob
Theoretical basis and code implementation of dueling dqn [pytoch + pendulum-v0]
Rewrite equals why rewrite hashcode
[Jianzhi offer] 31-35 questions (judge whether a sequence is one of the out of stack sequences, sequence print binary tree, branch print, and reverse print each line), judge whether the sequence is th
2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
論文閱讀:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation
leetcode:78. subset
Solve the error of 0x00000709 when win10 connects to the shared printer
Neural network learning notes 2.2 -- write a simple convolution neural network image classifier with MATLAB
Automatic assembly & set injection
KubeCon + CloudNativeCon Europe 2022