org.enodeframework.messaging.impl.DefaultMessageHandlerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode Show documentation
Show all versions of enode Show documentation
The enodeframework core implementation.
package org.enodeframework.messaging.impl;
import org.enodeframework.common.container.IObjectContainer;
import org.enodeframework.common.container.ObjectContainer;
import org.enodeframework.infrastructure.impl.AbstractHandlerProvider;
import org.enodeframework.messaging.IMessage;
import org.enodeframework.messaging.IMessageHandlerProvider;
import org.enodeframework.messaging.IMessageHandlerProxy1;
import java.lang.reflect.Method;
/**
* @author [email protected]
*/
public class DefaultMessageHandlerProvider extends AbstractHandlerProvider, IMessageHandlerProxy1, Class>> implements IMessageHandlerProvider {
@Override
protected Class> getKey(Method method) {
return method.getParameterTypes()[0];
}
@Override
protected Class extends IMessageHandlerProxy1> getHandlerProxyImplementationType() {
return MessageHandlerProxy1.class;
}
@Override
protected boolean isHandlerSourceMatchKey(Class> handlerSource, Class> key) {
return key.equals(handlerSource);
}
@Override
protected boolean isHandleMethodMatch(Method method) {
if (method.getParameterTypes().length != 1) {
return false;
}
if (IMessage.class.equals(method.getParameterTypes()[0])) {
return false;
}
if (!IMessage.class.isAssignableFrom(method.getParameterTypes()[0])) {
return false;
}
return isMethodAnnotationSubscribe(method);
}
@Override
protected IObjectContainer getObjectContainer() {
return ObjectContainer.INSTANCE;
}
}