@Override @JsonIgnore public <T> T get(final String key, final Class<T> type) { return TypeUtil.inject(get(key), type); }
@Override @JsonIgnore public <T> T get(final String key, final JavaType type) { return TypeUtil.inject(get(key), type); }
@Override @JsonIgnore public <T> T get(final String key, final Type type) { return TypeUtil.inject(get(key), type); }
@Override @JsonIgnore public <T> T get(final String key, final TypeUtil<T> type) { return type.inject(get(key)); }
/** * Put value. * * @param state * the {@link State} to update with specified {@code value} * @param value * the new value for this {@link StateEntry} in specified * @return the previous value or {@code null} if none existed {@code state} * @see java.util.Map#put(Object, Object) */ public T putValue(final State state, final T value) { try { return TypeUtil.inject(state.put(getKey(), value), valueType); } catch (final ClassCastException e) { LOG.log(Level.WARNING, "Problem casting agent's previous state value, key: " + key, e); return null; } }
/** * Instantiates a new jSONRPC exception. * * @param exception * the exception * @throws JsonProcessingException * the json processing exception */ public JSONRPCException(final JsonNode exception) throws JsonProcessingException { super(); JSONRPCException cause = null; if (exception != null && !exception.isNull()) { cause = JOM.getInstance().treeToValue(exception, JSONRPCException.class); cause.setRemote(true); if (exception.has("stackTrace")) { final TypeUtil<List<StackTraceElement>> injector = new TypeUtil<List<StackTraceElement>>() {}; final List<StackTraceElement> trace = injector.inject(exception .get("stackTrace")); cause.setStackTrace(trace.toArray(new StackTraceElement[0])); } } init(CODE.REMOTE_EXCEPTION, JSONRPCException.class.getSimpleName() + " received!", cause); }
final Handler<Receiver> newHandle = Transport.TYPEUTIL.inject(handle); final HttpTransportConfig config = new HttpTransportConfig(params); HttpTransport result = null;
@Override public SimpleScheduler build(){ final SimpleSchedulerConfig config = new SimpleSchedulerConfig(getParams()); String id = config.getId(); if (id == null) { id = new UUID().toString(); LOG.warning("Parameter 'id' is required for SimpleScheduler. (giving temporary name: " + id + ")"); } SimpleScheduler result = null; if (INSTANCES.containsKey(id)) { result = INSTANCES.get(id); final Handler<Receiver> oldHandle = result.getHandle(); oldHandle.update(TYPEUTIL.inject(getHandle())); } else { result = new SimpleScheduler(config, TYPEUTIL.inject(getHandle())); } INSTANCES.put(id, result); return result; }
return TypeUtil.inject(callback.get(), method.getGenericReturnType()); } catch (final Exception e) {
objects[i + offset] = TypeUtil.inject( paramsObject.get(name), p.getGenericType());
/** * Gets the. * * @param <T> * the generic type * @param <V> * the value type * @param params * the params * @param handle * the handle * @return the websocket transport */ public <T extends Capability, V> WebsocketTransport get( final ObjectNode params, final Handler<V> handle) { final Handler<Receiver> newHandle = Transport.TYPEUTIL .inject(handle); final WebsocketTransportConfig config = new WebsocketTransportConfig( params); if (config.isServer()) { return getServer(config, newHandle); } else { return getClient(config, newHandle); } }
@Override public Transport build() { final Handler<Receiver> newHandle = Transport.TYPEUTIL .inject(getHandle()); final LocalTransportConfig config = new LocalTransportConfig( getParams()); final String id = config.getId(); if (id == null) { LOG.warning("Parameter 'id' is required!"); return null; } final URI address = URI.create("local:" + config.getId()); LocalService result = getLocal(address); if (result == null) { result = new LocalService(address, newHandle, getParams()); INSTANCES.put(address, result); } else { result.getHandle().update(newHandle); } return result; }
@Override public void onSuccess(final JSONResponse response) { final Exception err = response.getError(); if (err != null) { asyncCallback.onFailure(err); } if (asyncCallback.getType() != null && !asyncCallback.getType().getJavaType().getRawClass() .equals(Void.class)) { try { final T res = asyncCallback.getType().inject( response.getResult()); asyncCallback.onSuccess(res); } catch (final ClassCastException cce) { asyncCallback.onFailure(new JSONRPCException( "Incorrect return type received for JSON-RPC call:" + request.getMethod(), cce)); } } else { asyncCallback.onSuccess(null); } }