Share this

RFID Middleware Technology (Part 2)

2026-04-06 07:20:39 · · #1
3.2 Facade and Factory Patterns Exposing API Interfaces to the External Environment To avoid excessive coupling between the backend application system (i.e., the middleware client), the Facade pattern is used to clearly isolate the internal and external implementations of the system. The processing flow can be seen in the sequence diagram shown in Figure 6. The client only interacts with the Facade class. If the Facade interface is clearly defined, the client can be completely unaware of the middleware's internal implementation, reflecting encapsulation in object-oriented programming. The class design can be seen in the source code example, which shows that the Simple Factory pattern allows for flexible replacement of the API implementation class version without the client's knowledge. The middleware API interface clearly defines the operations provided by the middleware; the client only needs to know that the factory class (APIFactory) can obtain instances of the middleware API interface. Middleware API interface MiddlewareAPI: publicinterfaceMiddlewareAPI{ void define (String specName, ECSpec spec); void undefine (String specName); void subscribe (String specName, String uri); void unsubscribe (String specName, String uri); EPCReports poll (String specName); EPCReports immediate (ECSpec spec); &nnbsp; } Factory class APIFactory: publicclassAPIFactory{ publicstaticMiddlewareAPIgetAPIInstance(){} } API implementation class A: publicclassClient{ publicstaticvoidmain(String[] args) { MiddlewareAPI api = APIFactory.getAPIInstance(); api.define("a new spec", new EPCSpec()); } } 3.3 State Pattern Simulation of Rule State Machine A rule has different states during its lifecycle, and each state has a different behavior for a series of operations. Therefore, the state pattern can be used to simulate the state machine of the rule, encapsulating the different behaviors of different states as variable factors. See the code example. Rule state interface ECState: public interface ECState { void subscribe(String specName, String uri); void unsubscribe(String specName, String uri); EPCReportspoll(String specName); } Unrequested state class ECStateUnrequested: public class ECStateUnrequested implements ECState { } Requested state class ECStateRequested: public class ECStateRequested implements ECState { } Active state class ECStateActive: public class ECStateActive implements ECState { } Rule class ECSpec: public class ECSpec { private ECStatestate; public ECStategetState() { return state; } public void setState(ECStatestate) { this.state = state; } } In this way, when performing corresponding operations on the rules, the corresponding operations can be directly delegated to its state property (ECState). For example, the subscribe operation of ECSpec only requires one line of code "state.suscribe(specName, uri);". Among them, specName and uri are temporary variables, and their specific values ​​are determined before the method is called. Due to the polymorphism of object-oriented programming, the specific implementation class of the ECState interface is dynamically determined to perform the work based on the object currently pointed to by the state field. The implementation class of the ECState interface determines whether it is necessary to modify the state property (state) of the ECSpec object during the processing based on the actual situation. Here, when applying the state pattern, multiple timer classes need to be designed to assist the state machine transition [3]. 3.4 Strategy Pattern Switching Multiple Report Upload and Command Issuance Methods After the event cycle ends, the middleware needs to assemble the report and upload it to the rule subscriber, i.e., the application system. There are multiple upload methods, such as HTTP, Socket, JMS, etc. The core logic processing module of the middleware should not be concerned with the specific upload technology. The corresponding work should be handled by the report upload module. The core logic processing module only needs to complete its own work and then send the data in a certain format through the report upload module. See the code example. The ReportSender interface sends reports via HTTP. The ReportSenderByHttp interface implements this interface via HTTP: `public class ReportSenderByHttp implements ReportSender { public void sendReport(ECReports reports) { } }`. The ReportSenderBySocket interface implements this interface via Socket: `public class ReportSenderBySocket implements ReportSender { public void sendReport(ECReports reports) { } }`. The ReportSenderByJms interface implements this interface via JMS: `public class ReportSenderByJms implements ReportSender { public void sendReport(ECReports reports) { } }`. Example client class for sending reports: `SendReportWorker`: `public class SendReportWorker { private ReportSender sender; private ECReportsreports;   public void setReports(ECReportsreports) { this.reports = reports; } public static void main(String[] args) { SendReportWorker worker = new SendReportWorker(); worker.sender.sendReport(reports); } public void setSender(ReportSender sender) { this.sender = sender; } }` In this way, the worker sending messages can flexibly configure its sending method by setting an instance of `ReportSender`. Similarly, the middleware's inventory command issuance, i.e., the interface between the middleware and the reader, also has various methods, such as Socket and SOAP, and can also adopt a similar design. 3.5 Observer Pattern for Handling Reported Messages: Message reports from the reader are converted into message objects. The reception and distribution of these message objects can be implemented using the classic observer pattern. 4. Middleware Development Directions 4.1 Integration with Reader Management Systems: Middleware acts as a bridge between the reader and the backend application system. Readers typically have device management needs, such as software version downloads, device alarm management, parameter configuration, etc. The reader management system is also a software module that directly interacts with the reader. Therefore, how to manage the relationship between middleware and the reader management system becomes a pressing issue. Considering software deployment (deployment on the same host) and software module reuse (reusing the reader communication module), the integration of middleware and the reader management system will inevitably become an advantage of the middleware itself. 4.2 Support for Multi-Standard Tags: The development and application of RFID technology is booming both domestically and internationally. Multiple international standards organizations are attempting to unify RFID standards, but for a certain period, the coexistence of multiple tags is inevitable. Therefore, support for multi-standard tags is also a development direction for middleware systems. 4.3 Support for Multi-Vendor Readers The interface, communication methods, and information formats between middleware and readers cannot be standardized. Support for multi-vendor readers, or at least readers from a few mainstream vendors, is a basic requirement for middleware.
Read next

A Brief Discussion on Artistic Design in Human-Computer Interface Design

[Abstract] With people's higher pursuit of life and the development of ergonomics, art design is increasingly valued...

Articles 2026-02-22