iSIM and The Proxy Pattern

[Introduction] [iPAQ Proxy] [iSIM Proxy] [iSIM Homepage]

 

        This webpage will help to explain how the proxy pattern can be used in iSIM, and how it fits into the overall design of the system.  The proxy pattern can be added to both iSIM and the iPAQ applications as described in the following two sections.    

        

        In the next section is a visualization of the Proxy Pattern being used in an iPAQ application.  The proxy pattern allows for the application to easily connect to a real GPS serial unit or a simulator such as iSIM.  The switch can be made dynamically and the application never has to know (or it doesn't know) that it is receiving real or simulated data.  In this way, the proxy controls access to the world outside of the iPAQ application, and acts as a place holder for the application to use for message passing.  The proxy is mainly a pass-through for commands and data going to the simulator. 

 

        The driving force behind using the proxy pattern in iSIM is so that the proxy controls all incoming and outgoing data, so that the actual heart of the iPAQ application does not have to be aware what the application is connected to.  The proxy will take both real and simulated data and send it to the application as the same data.  Likewise, all data to be sent goes to the proxy which will send the data to a simulator or to a real device or connection, and once again the rest of the iPAQ application knows nothing about what goes on.

 

Key points to remember:

  1. Proxy handles all connections real or simulated, so that the iPAQ application does not have to worry about it.  

  2. By using the proxy pattern, the application should behave the same whether connected to a simulator or the real world. 

 

The iPAQ Proxy

 

 

       Currently there is no true Proxy in the iPAQ Applications.  However, the applications are designed so that the addition of a proxy should be simple.  In the GPS iPAQ application is a class GpsMonitor.java, which begins the iPAQ application and handles connections to the simulator or real GPS unit.  This is not the correct approach.  Instead, there should be a proxy to act as a middleperson in between the application and the connection to the simulator.  In the drawing below is visualization of how the proxy should work.  Some code is provided below, however, you will need to edit GpsMonitor.java to use the proxy, and you will need to edit and rename the methods provided in the interface iPAQProxy.java and the class GpsProxy.java

         

 

Sample Code:

iPAQProxy.java       GpsProxy.java        NmeaSerialGps.java     NmeaSocketGps.java

 
 

 

       iSIM also has no proxy pattern currently in the code, however, there are several locations where the addition of a proxy pattern can be made to improve the system.  For example, iSIM currently has the ability to communicate with iPAQ applications running on the localhost, but we would the ability to communicate with applications running on a real iPAQ handheld.   The SocketReceiverListener in iSIM is Controller.java.  The Controller class directly controls the transport package used for sending and receiving messages and data.  Ideally, we would like to create a proxy which would fit in between Controller.java and the transport classes such as SocketReceiver.java and SocketSender.java.  The benefit is that the proxy will act as a placeholder for the transport classes, and can thus control and manipulate the transport classes without the Controller knowing.  Thus, the proxy could manipulate how the transport classes communicate to iPAQ applications, without having to change code in the rest of the iSIM program.