private Class findClassById(final int interfaceId) { return DefaultClassDictionary.get().getClassById(interfaceId); }
public StreamReference(SimpleStreamExtension provider, final Class<T> dataClass, final String id) { this.provider = provider; this.dataClass = dataClass; final int dataClassId = DefaultClassDictionary.get().getClassId(dataClass); final String oid = dataClassId + ":" + id; //noinspection unchecked this.streamActorRef = (SimpleStream) Actor.getReference(SimpleStream.class, oid); }
@Override public void onRead(final HandlerContext ctx, final Object msg) throws Exception { Message message = (Message) msg; final Class<?> clazz = DefaultClassDictionary.get().getClassById(message.getInterfaceId()); // TODO: check method access, check object access } }
public int intIdFromValueAndType(Object value, Class<?> type) { if (type != null && type.isArray()) { return 0; } if (value != null) { if (value.getClass().isArray() || value instanceof Collection || value instanceof Map) { return 0; } return DefaultClassDictionary.get().getClassId(value.getClass()); } return DefaultClassDictionary.get().getClassId(type); }
default ObjectInvoker<?> getInvoker(int classId) { return getInvoker(DefaultClassDictionary.get().getClassById(classId)); }
@SuppressWarnings("unchecked") private ClassDescriptor getDescriptor(final Class<?> aInterface) { ClassDescriptor descriptor = descriptorMapByInterface.get(aInterface); if (descriptor == null) { if (aInterface == Actor.class || aInterface == ActorObserver.class) { return null; } descriptor = new ClassDescriptor(); descriptor.isObserver = ActorObserver.class.isAssignableFrom(aInterface); if (aInterface.isInterface()) { descriptor.factory = dynamicReferenceFactory.getFactoryFor(aInterface); descriptor.invoker = (ObjectInvoker<Object>) descriptor.factory.getInvoker(); } ClassDescriptor concurrentInterfaceDescriptor = descriptorMapByInterface.putIfAbsent(aInterface, descriptor); if (concurrentInterfaceDescriptor != null) { descriptorMapByInterfaceId.put(DefaultClassDictionary.get().getClassId(aInterface), concurrentInterfaceDescriptor); return concurrentInterfaceDescriptor; } descriptorMapByInterfaceId.put(DefaultClassDictionary.get().getClassId(aInterface), descriptor); } return descriptor; }
@Override protected JavaType _typeFromId(final String id, final DatabindContext ctxt) { final TypeFactory typeFactory = ctxt.getTypeFactory(); Class<?> cls = DefaultClassDictionary.get().getClassById(Integer.parseInt(id), true); return typeFactory.constructSpecializedType(_baseType, cls); } }
protected String _locateTypeId(JsonParser jp, DeserializationContext ctxt) throws IOException { if (!jp.isExpectedStartArrayToken()) { if (_defaultImpl != null) { return _idResolver.idFromBaseType(); } throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "Missing type information for: " + baseTypeName()); } return String.valueOf(DefaultClassDictionary.get().getClassId(ArrayList.class)); }
final Class<?> targetClass = DefaultClassDictionary.get().getClassById(interfaceId); if(targetClass != null) { output.append("interfaceName=");
@SuppressWarnings("unchecked") public <T> ReferenceFactory<T> getFactoryFor(final Class<T> aInterface) { final String interfaceFullName = aInterface.getName().replace('$', '.'); final int interfaceId = DefaultClassDictionary.get().getClassId(aInterface); final String referenceFullName = aInterface.getName() + "$Reference"; try { final Class<T> referenceClass = makeReferenceClass(aInterface, interfaceFullName, interfaceId, referenceFullName); final GenericActorFactory<T> dyn = new GenericActorFactory<>(); dyn.interfaceId = interfaceId; dyn.interfaceClass = aInterface; dyn.referenceConstructor = referenceClass.getConstructor(String.class); return dyn; } catch (final Exception e) { throw new UncheckedException(e); } }
public ObjectInvoker<?> getInvoker(final int interfaceId) { final ClassDescriptor descriptor = getDescriptor(interfaceId); if (descriptor == null) { return getInvoker(DefaultClassDictionary.get().getClassById(interfaceId)); } if (descriptor.invoker == null) { descriptor.invoker = dynamicReferenceFactory.getInvokerFor(descriptor.factory.getInterface()); } return descriptor.invoker; }
@SuppressWarnings("unchecked") public <T> Task<StreamSubscriptionHandle<T>> subscribe(String provider, Class<T> dataClass, String streamId, AsyncObserver<T> observer) { StreamKey streamKey = new StreamKey(provider, dataClass, streamId); ConcurrentMap<Handle, AsyncObserver> observers = observerMap.get(streamKey); if (observers == null) { observers = InternalUtils.putIfAbsentAndGet(observerMap, streamKey, new ConcurrentHashMap<>()); ServerSideStreamProxy serverSideStreamProxy = runtime.getRemoteObserverReference(null, ServerSideStreamProxy.class, "0"); int dataClassId = DefaultClassDictionary.get().getClassId(dataClass); Task<StreamSubscriptionHandle<Object>> subscriptionHandleTask = serverSideStreamProxy.subscribe(provider, dataClassId, streamId, localReference); await(subscriptionHandleTask); } observers = (observers != null) ? observers : InternalUtils.putIfAbsentAndGet(observerMap, streamKey, new ConcurrentHashMap<>()); Handle handle = new Handle(streamKey, nextId.incrementAndGet()); observers.put(handle, observer); return Task.fromValue(handle); }
private String getInvokedClassAndMethodName(Message message) { if (message.getInterfaceId() != 0) { final Class clazz = DefaultClassDictionary.get().getClassById(message.getInterfaceId()); if (clazz != null) { final Method method = DefaultDescriptorFactory.get().getInvoker(clazz).getMethod(message.getMethodId()); return clazz.getSimpleName() + "." + method.getName(); } } return null; }
protected String _locateTypeId(JsonParser jp, DeserializationContext ctxt) throws IOException { if (!jp.isExpectedStartArrayToken()) { if (_defaultImpl != null) { return _idResolver.idFromBaseType(); } throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "Missing type information for: " + baseTypeName()); } return String.valueOf(DefaultClassDictionary.get().getClassId(ArrayList.class)); }
@Override @SuppressWarnings("unchecked") public <T> Task<StreamSubscriptionHandle<T>> subscribe(final String provider, final int dataClassId, final String streamId, final ClientSideStreamProxy proxy) { logger.debug("Subscribing server side stream proxy."); Class<?> dataClass = DefaultClassDictionary.get().getClassById(dataClassId); AsyncStream<?> stream = stage.getStream(provider, dataClass, streamId); Task<? extends StreamSubscriptionHandle<?>> subscription = stream.subscribe(new AsyncObserver() { @Override public Task<Void> onNext(final Object data, final StreamSequenceToken sequenceToken) { return proxy.onNext(provider, streamId, data); } }, null); await(subscription); final StreamReference.SimpleStreamHandle<T> handle = new StreamReference.SimpleStreamHandle<>(String.valueOf(IdUtils.sequentialLongId())); handleMap.putIfAbsent(handle, new SubscriptionInfo(stream, subscription.join(), proxy)); logger.debug("Successfully subscribed server stream proxy."); return Task.fromValue(handle); }
private long getResponseTimeoutMillis(final Message message) { final Class<?> clazz = DefaultClassDictionary.get().getClassById(message.getInterfaceId()); if (clazz != null) { final Method method = DefaultDescriptorFactory.get().getInvoker(clazz).getMethod(message.getMethodId()); final Timeout timeout = timeoutAnnotationCache.getAnnotation(method); if (timeout != null) { return timeout.timeUnit().toMillis(timeout.value()); } } return responseTimeoutMillis; }
if (message.getInterfaceId() != 0) Class clazz = DefaultClassDictionary.get().getClassById(message.getInterfaceId()); if (clazz != null)
final Class classById = DefaultClassDictionary.get().getClassById(classId); final RemoteReference reference = (RemoteReference) DefaultDescriptorFactory.get().getReference( runtime,
default ObjectInvoker<?> getInvoker(int classId) { return getInvoker(DefaultClassDictionary.get().getClassById(classId)); }
@Override protected JavaType _typeFromId(final String id, final DatabindContext ctxt) { final TypeFactory typeFactory = ctxt.getTypeFactory(); Class<?> cls = DefaultClassDictionary.get().getClassById(Integer.parseInt(id), true); return typeFactory.constructSpecializedType(_baseType, cls); } }