In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to achieve the agent model in Android, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Agent mode
Proxy pattern (Proxy Pattern): to provide a proxy object for the access object to achieve access to the visited object is to add a mediation between the accessed object and the accessed object to isolate the specific implementation details of the visitor and the visited. It is a structural design pattern.
Pattern structure
Abstract object: declares a common interface between the target object and the proxy object
Target object: the object that is proxied or accessed
Proxy object: the proxy object holds the reference of the target object, and the proxy object implements the same interface as the target object. Client access proxy object is equivalent to indirect access to the target object.
The picture is from the Internet.
Pattern realization
Here is a very simple example.
Abstract object
Target object
Proxy object
Client
Running
Agent Mode in Android
Android Binder class is the medium to realize the inter-process communication. Because the inter-process communication runs through the use of the four components, the inter-process communication can be seen everywhere in the process of Android development, and the Android Binder IPC model is based on the proxy pattern.
Android Binder IPC communication model:
Client: the proxy object that holds the local Binder object of the Server
Server: holds the local Binder object and provides functional services for the Client side
ServiceManager: responsible for managing Binder services. You can obtain Binder references according to Binder Name. The function is similar to DNS server.
Binder driver: the communication between Client and Server, as well as between Server and ServiceManager, is driven by Binder to maintain the mapping between Binder Proxy and Binder entity references. According to the Client side, the packet is packaged and sent by Binder Proxy, the Server method is called, and the returned result is packaged and transmitted back to the Client side by Binder Proxy.
The following implements the simplest Binder IPC model:
Abstract object interface
Target object (Binder local object)
Proxy object
Client
Advantages and disadvantages of the agent model
Reduce the coupling between visitors and interviewees
You can control the visitor's access to the interviewee.
Virtual agents can reduce system overhead by using a small object to proxy a large object.
Shortcoming
Proxy objects increase the complexity of logic
Slow down access to the target object
On how to achieve the agent model in Android to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.