Class PropertyHandler


  • public class PropertyHandler
    extends 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 Detail

      • PropertyHandler

        public PropertyHandler​(String serverUri,
                               Map<String,​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​(String url,
                                String value,
                                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