@Override
    public <T> void getProperty(final String namespace, final String propertyName, final T defaultValue,
            final IAsyncResultHandler<T> handler) {
        if (defaultValue == null) {
            handler.handle(AsyncResultImpl.<T>create(new Exception("Null defaultValue is not allowed."))); //$NON-NLS-1$
            return;
        }
        String id = getPropertyId(namespace, propertyName);

        try {
            GetResponse response = getClient().get(new GetRequest(getFullIndexName()).id(id), RequestOptions.DEFAULT);
            if (response.isExists()) {
                try {
                    T value;
                    if (defaultValue.getClass().isPrimitive() || defaultValue instanceof String) {
                        value = (T) readPrimitive(response);
                    } else {
                        String sourceAsString = response.getSourceAsString();
                        value = (T) JSON_MAPPER.readValue(sourceAsString, defaultValue.getClass());
                    }
                    handler.handle(AsyncResultImpl.create(value));
                } catch (Exception e) {
                    handler.handle(AsyncResultImpl.<T>create(e));
                }
            } else {
                handler.handle(AsyncResultImpl.create(defaultValue));
            }
        } catch (Throwable e) {
            handler.handle(AsyncResultImpl.<T>create(e));
        }
    }
@see io.apiman.gateway.engine.components.ISharedStateComponent#getProperty(java.lang.String, java.lang.String, java.lang.Object, io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/EsSharedStateComponent.java