@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return readers[buildKey(this,method.getName())].read(args); }
private static <T> T slowCreate(final EventProducer consumer, Class<T> clazz) { int msgIdx = FieldReferenceOffsetManager.lookupTemplateLocator(clazz.getAnnotation(ProngTemplateMessage.class).templateId(), Pipe.from(consumer.input)); if (PipeReader.tryReadFragment(consumer.input)) { T result = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new InputPipeInvocationHandler(consumer.input, PipeReader.getMsgIdx(consumer.input), clazz)); consumer.cached = result; //TODO: needs smarter pool but this is fine for now. consumer.cachedMsgId = PipeReader.getMsgIdx(consumer.input); return result; } else { return null; } }
private static <T> T slowCreate(final EventProducer consumer, Class<T> clazz) { int msgIdx = FieldReferenceOffsetManager.lookupTemplateLocator(clazz.getAnnotation(ProngTemplateMessage.class).templateId(), Pipe.from(consumer.input)); if (PipeReader.tryReadFragment(consumer.input)) { T result = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new InputPipeInvocationHandler(consumer.input, PipeReader.getMsgIdx(consumer.input), clazz)); consumer.cached = result; //TODO: needs smarter pool but this is fine for now. consumer.cachedMsgId = PipeReader.getMsgIdx(consumer.input); return result; } else { return null; } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return readers[buildKey(this,method.getName())].read(args); }
private static <T> T slowCreate(final EventProducer consumer, Class<T> clazz) { int msgIdx = FieldReferenceOffsetManager.lookupTemplateLocator(clazz.getAnnotation(ProngTemplateMessage.class).templateId(), Pipe.from(consumer.input)); if (PipeReader.tryReadFragment(consumer.input)) { T result = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new InputPipeInvocationHandler(consumer.input, PipeReader.getMsgIdx(consumer.input), clazz)); consumer.cached = result; //TODO: needs smarter pool but this is fine for now. consumer.cachedMsgId = PipeReader.getMsgIdx(consumer.input); return result; } else { return null; } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return readers[buildKey(this,method.getName())].read(args); }
public InputPipeInvocationHandler(Pipe pipe, int msgIdx, Class<?> clazz) { super(clazz.getMethods()); FieldReferenceOffsetManager from = Pipe.from(pipe); final Method[] methods = clazz.getMethods(); readers = new InputPipeReaderMethod[MAX_METHODS]; int j = methods.length; while (--j>=0) { final Method method = methods[j]; ProngTemplateField fieldAnnotation = method.getAnnotation(ProngTemplateField.class); if (null!=fieldAnnotation) { int fieldLoc = FieldReferenceOffsetManager.lookupFieldLocator(fieldAnnotation.fieldId(), msgIdx, from); int key = buildKey(this, method.getName()); if (null!=readers[key]) { throw new UnsupportedOperationException(); } readers[key] = InputPipeReaderMethod.buildReadForYourType(pipe, fieldLoc, (fieldLoc >> FieldReferenceOffsetManager.RW_FIELD_OFF_BITS) & TokenBuilder.MASK_TYPE, from); } } }
public InputPipeInvocationHandler(Pipe pipe, int msgIdx, Class<?> clazz) { super(clazz.getMethods()); FieldReferenceOffsetManager from = Pipe.from(pipe); final Method[] methods = clazz.getMethods(); readers = new InputPipeReaderMethod[MAX_METHODS]; int j = methods.length; while (--j>=0) { final Method method = methods[j]; ProngTemplateField fieldAnnotation = method.getAnnotation(ProngTemplateField.class); if (null!=fieldAnnotation) { int fieldLoc = FieldReferenceOffsetManager.lookupFieldLocator(fieldAnnotation.fieldId(), msgIdx, from); int key = buildKey(this, method.getName()); if (null!=readers[key]) { throw new UnsupportedOperationException(); } readers[key] = InputPipeReaderMethod.buildReadForYourType(pipe, fieldLoc, (fieldLoc >> FieldReferenceOffsetManager.RW_FIELD_OFF_BITS) & TokenBuilder.MASK_TYPE, from); } } }
public InputPipeInvocationHandler(Pipe pipe, int msgIdx, Class<?> clazz) { super(clazz.getMethods()); FieldReferenceOffsetManager from = Pipe.from(pipe); final Method[] methods = clazz.getMethods(); readers = new InputPipeReaderMethod[MAX_METHODS]; int j = methods.length; while (--j>=0) { final Method method = methods[j]; ProngTemplateField fieldAnnotation = method.getAnnotation(ProngTemplateField.class); if (null!=fieldAnnotation) { int fieldLoc = FieldReferenceOffsetManager.lookupFieldLocator(fieldAnnotation.fieldId(), msgIdx, from); int key = buildKey(this, method.getName()); if (null!=readers[key]) { throw new UnsupportedOperationException(); } readers[key] = InputPipeReaderMethod.buildReadForYourType(pipe, fieldLoc, (fieldLoc >> FieldReferenceOffsetManager.RW_FIELD_OFF_BITS) & TokenBuilder.MASK_TYPE, from); } } }