Class PropertyHandler


  • public class PropertyHandler
    extends java.lang.Object
    Allows you to register properties, which can be updated in realtime by a PUT request to the communication server.
    Eg.:
     // Create a new instance 
     PropertyHandler pHandler = new PropertyHandler(props);
     
     // Register refreshables
     pHandler.addRefreshable(refreshable)
     
     // Add a property
     pHandler.addProperty("/car/v1/id","carId", "car.id")
     
     // Update the property 'car.id' 
     PUT /car/v1/id
      {
          "carId" : "mynewValue"
      }
     
    Author:
    ljucam
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyHandler​(java.lang.String serverUri, java.util.Map<java.lang.String,​java.lang.Object> props)
      Creates a new instance of the PropertyHandler with the given property store as a parameter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addProperty​(java.lang.String url, java.lang.String value, java.lang.String propertyName)
      Assigns the property name to an id value of a given url.
      void addRefreshable​(Refreshable refreshable)
      Adds a new Refreshable.
      boolean handle​(io.vertx.core.http.HttpServerRequest request)
      Checks if the request must be handeld by the PropertyHandler.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertyHandler

        public PropertyHandler​(java.lang.String serverUri,
                               java.util.Map<java.lang.String,​java.lang.Object> props)
        Creates a new instance of the PropertyHandler with the given property store as a parameter.
        Parameters:
        props - - the property map
    • Method Detail

      • addRefreshable

        public void addRefreshable​(Refreshable refreshable)
        Adds a new Refreshable.
        All refreshables will be refreshed, if a property changes.
        Parameters:
        refreshable - - an instance of Refreshable
      • addProperty

        public void addProperty​(java.lang.String url,
                                java.lang.String value,
                                java.lang.String propertyName)
        Assigns the property name to an id value of a given url.
        You can add for example:
         addProperty("/vehicle/v1/id", "identityId", "identity.id")
         addProperty("/vehicle/v1/id", "vehicleId", "vehicle.id")
         
        Parameters:
        url -
        value -
        propertyName -
      • handle

        public boolean handle​(io.vertx.core.http.HttpServerRequest request)
        Checks if the request must be handeld by the PropertyHandler. If so, the return value will be true otherwise it will be false.
        Parameters:
        request - - the original request
        Returns:
        true if the handler processes the request, false otherwise