Package org.eclipse.hono.util
Class AddressHelper
- java.lang.Object
-
- org.eclipse.hono.util.AddressHelper
-
public class AddressHelper extends Object
Utility class for handling AMQP addresses.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getTargetAddress(String endpoint, String tenantId, String resourceId, ClientConfigProperties config)
Gets the AMQP target address to use for creating with specific Hono endpoint.static String
rewrite(String address, ClientConfigProperties config)
Rewrites address for a certain endpoint according to the provided rule.
-
-
-
Method Detail
-
getTargetAddress
public static String getTargetAddress(String endpoint, String tenantId, String resourceId, ClientConfigProperties config)
Gets the AMQP target address to use for creating with specific Hono endpoint.- Parameters:
endpoint
- The endpoint for the address (e.g. telemetry).tenantId
- The tenant of the address.resourceId
- The device to upload data for. Ifnull
, the target address can be used to upload data for arbitrary devices belonging to the tenant.config
- The client configuration containing the rewrite rule to be applied to the address. Seerewrite(String, ClientConfigProperties)
for more information about syntax and behavior of this property.- Returns:
- The target address.
- Throws:
NullPointerException
- if endpoint or tenant isnull
.
-
rewrite
public static String rewrite(String address, ClientConfigProperties config)
Rewrites address for a certain endpoint according to the provided rule.- Parameters:
address
- The address to be rewritten.config
- The client configuration containing the rewrite rule. The rule is in the $PATTERN $REPLACEMENT format. Pattern and replacement use the regular Java pattern syntax. The pattern should match the original address.Example: ([a-z_]+)/([\\w-]+) test-vhost/$1/$2 will rewrite telemetry/DEFAULT_TENANT to test-vhost/telemetry/DEFAULT-TENANT
If the configuration is
null
or the rule isnull
, empty, in the wrong format or the pattern doesn't match the address, the original address will be returned.- Returns:
- The address to be used.
-
-