Class PropertyHandler
- java.lang.Object
-
- org.swisspush.gateleen.core.property.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 Summary
Constructors Constructor Description PropertyHandler(String serverUri, Map<String,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 voidaddProperty(String url, String value, String propertyName)Assigns the property name to an id value of a given url.voidaddRefreshable(Refreshable refreshable)Adds a new Refreshable.booleanhandle(io.vertx.core.http.HttpServerRequest request)Checks if the request must be handeld by the PropertyHandler.
-
-
-
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 betrueotherwise it will befalse.- Parameters:
request- - the original request- Returns:
- true if the handler processes the request, false otherwise
-
-