diff --git a/corant-context/src/main/java/org/corant/context/ComponentManager.java b/corant-context/src/main/java/org/corant/context/ComponentManager.java index f606212df..6f6a74002 100644 --- a/corant-context/src/main/java/org/corant/context/ComponentManager.java +++ b/corant-context/src/main/java/org/corant/context/ComponentManager.java @@ -29,6 +29,11 @@ /** * corant-context + *

+ * A CDI component management class for hosting the creation and destruction of various bean + * instances using CDI-related scopes. These instances can be obtained by specifying a unique name + * key. These instances are also destroyed through the scope of CDI, and manual destruction is also + * supported. * * @author bingo 下午5:29:56 * @@ -86,21 +91,53 @@ private void writeObject(ObjectOutputStream stream) throws IOException { } } + /** + * corant-context + *

+ * Request scoped component manager + * + * @author bingo 上午10:50:08 + * + */ @RequestScoped abstract class RsComponentManager extends AbstractComponentManager { private static final long serialVersionUID = -2588026760995417834L; } + /** + * corant-context + *

+ * Session scoped component manager + * + * @author bingo 上午10:50:29 + * + */ @SessionScoped abstract class SsComponentManager extends AbstractComponentManager { private static final long serialVersionUID = 7462742316873226368L; } + /** + * corant-context + *

+ * Thread scoped component manager + * + * @author bingo 上午10:50:50 + * + */ @ThreadScoped - abstract class thComponentManager extends AbstractComponentManager { + abstract class ThComponentManager extends AbstractComponentManager { private static final long serialVersionUID = -5758319290954516372L; } + /** + * corant-context + *

+ * Transaction scoped component manager + * + * @author bingo 上午10:51:21 + * + */ @TransactionScoped abstract class TsComponentManager extends AbstractComponentManager { private static final long serialVersionUID = -2804585149568989342L; diff --git a/corant-context/src/main/java/org/corant/context/proxy/ContextualInvocationHandler.java b/corant-context/src/main/java/org/corant/context/proxy/ContextualInvocationHandler.java index 451dc81e3..140a5e67b 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/ContextualInvocationHandler.java +++ b/corant-context/src/main/java/org/corant/context/proxy/ContextualInvocationHandler.java @@ -24,6 +24,8 @@ /** * corant-context * + *

+ * A simple CDI base invocation handler implementation, supports method interceptor. * * @author bingo 下午2:12:51 * @@ -54,13 +56,13 @@ public int hashCode() { } @Override - public Object invoke(Object o, Method method, Object[] args) throws Throwable { + public Object invoke(Object target, Method method, Object[] args) throws Throwable { List interceptorInvocations = interceptorChains.get(method); if (isNotEmpty(interceptorInvocations)) { - return new InvocationContextImpl(clazz, o, method, invokers.get(method), args, + return new InvocationContextImpl(clazz, target, method, invokers.get(method), args, interceptorInvocations).proceed(); } else { - return new InvocationContextImpl(clazz, o, method, invokers.get(method), args, + return new InvocationContextImpl(clazz, target, method, invokers.get(method), args, Collections.emptyList()).proceed(); } } diff --git a/corant-context/src/main/java/org/corant/context/proxy/ContextualMethodHandler.java b/corant-context/src/main/java/org/corant/context/proxy/ContextualMethodHandler.java index 2c8306f12..402ad0dfa 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/ContextualMethodHandler.java +++ b/corant-context/src/main/java/org/corant/context/proxy/ContextualMethodHandler.java @@ -35,6 +35,10 @@ /** * corant-context * + *

+ * A simple contextual method handler, use for constructs a contextual CDI invocation from a method + * object. + * * @author bingo 下午2:26:15 * */ @@ -47,34 +51,34 @@ public class ContextualMethodHandler implements Serializable { protected transient Method method; // ?? use java.lang.invoke.MethodHandle protected MethodSignature methodSignature; - public ContextualMethodHandler(Class beanClass, Method beanMethod, Annotation... qualifiers) { + public ContextualMethodHandler(Method method, Annotation... qualifiers) { + this(method.getDeclaringClass(), method, qualifiers); + } + + protected ContextualMethodHandler(Class beanClass, Method beanMethod, + Annotation... qualifiers) { method = shouldNotNull(beanMethod); methodSignature = MethodSignature.of(method); clazz = defaultObject(beanClass, beanMethod::getDeclaringClass); this.qualifiers = qualifiers; } - public ContextualMethodHandler(Method method) { - this(null, method); - } - public static Set from(Class clazz, Predicate methodPredicate, Annotation... qualifiers) { - Set annotatedMethods = new LinkedHashSet<>(); + Set handlers = new LinkedHashSet<>(); if (!clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers())) { for (Method m : clazz.getMethods()) { if (methodPredicate.test(m)) { - annotatedMethods.add(new ContextualMethodHandler(clazz, m, qualifiers)); + handlers.add(new ContextualMethodHandler(clazz, m, qualifiers)); } } } - return annotatedMethods; + return handlers; } public static Set fromDeclared(Class clazz, Predicate methodPredicate, Annotation... qualifiers) { - Set annotatedMethods = new LinkedHashSet<>(); - // FIXME the class qualifiers + Set handlers = new LinkedHashSet<>(); if (!clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers())) { for (Method m : clazz.getDeclaredMethods()) { if (methodPredicate.test(m)) { @@ -85,11 +89,11 @@ public static Set fromDeclared(Class clazz, return null; }); } - annotatedMethods.add(new ContextualMethodHandler(clazz, m, qualifiers)); + handlers.add(new ContextualMethodHandler(clazz, m, qualifiers)); } } } - return annotatedMethods; + return handlers; } @Override @@ -119,7 +123,6 @@ public boolean equals(Object obj) { } /** - * * @return the clazz */ public Class getClazz() { @@ -127,7 +130,6 @@ public Class getClazz() { } /** - * * @return the method */ public Method getMethod() { diff --git a/corant-context/src/main/java/org/corant/context/proxy/InterceptorInvocation.java b/corant-context/src/main/java/org/corant/context/proxy/InterceptorInvocation.java index d3d98d69e..54581ebf9 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/InterceptorInvocation.java +++ b/corant-context/src/main/java/org/corant/context/proxy/InterceptorInvocation.java @@ -20,6 +20,13 @@ /** * corant-context * + *

+ * An object representing an interceptor meta object and an interceptor instance, while providing an + * interceptor to call the entry method. + * + *

+ * Note: Only supports {@code InterceptionType.AROUND_INVOKE} + * * @author bingo 上午10:41:54 * */ diff --git a/corant-context/src/main/java/org/corant/context/proxy/InvocationContextImpl.java b/corant-context/src/main/java/org/corant/context/proxy/InvocationContextImpl.java index b02545c3f..fc7b1c05d 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/InvocationContextImpl.java +++ b/corant-context/src/main/java/org/corant/context/proxy/InvocationContextImpl.java @@ -25,6 +25,9 @@ /** * corant-context * + *

+ * A simple interceptor call context implementation that works with {@link InterceptorInvocation}. + * * @author bingo 上午11:10:02 * */ @@ -47,12 +50,14 @@ public class InvocationContextImpl implements InvocationContext { private final MethodInvoker methodInvoker; /** - * @param targetClass - * @param target - * @param method - * @param methodInvoker - * @param args - * @param chain + * Build a simple invocation context + * + * @param targetClass the invocation target class + * @param target the invocation target object + * @param method the invocation method + * @param methodInvoker the method implementation + * @param args the method parameters + * @param chain the interceptor chain */ public InvocationContextImpl(final Class targetClass, final Object target, final Method method, final MethodInvoker methodInvoker, final Object[] args, @@ -61,18 +66,17 @@ public InvocationContextImpl(final Class targetClass, final Object target, fi } /** - * @param targetClass - * @param target - * @param method - * @param args - * @param chain + * Build a simple invocation context with interceptor chain position + * + * @param targetClass the invocation target class + * @param target the invocation target object + * @param method the invocation method + * @param methodInvoker the method implementation + * @param args the method parameters + * @param chain the interceptor chain + * @param position the current interceptor chain position */ - public InvocationContextImpl(final Class targetClass, final Object target, final Method method, - final Object[] args, final List chain) { - this(targetClass, target, method, null, args, chain, 0); - } - - private InvocationContextImpl(final Class targetClass, final Object target, + protected InvocationContextImpl(final Class targetClass, final Object target, final Method method, final MethodInvoker methodInvoker, final Object[] args, final List chain, final int position) { this.targetClass = targetClass; diff --git a/corant-context/src/main/java/org/corant/context/proxy/MethodInvoker.java b/corant-context/src/main/java/org/corant/context/proxy/MethodInvoker.java index 063cbe5f6..7497c462c 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/MethodInvoker.java +++ b/corant-context/src/main/java/org/corant/context/proxy/MethodInvoker.java @@ -16,6 +16,9 @@ /** * corant-context * + *

+ * A simple implementation interface, use for proxy invoking. + * * @author bingo 上午10:38:27 * */ diff --git a/corant-context/src/main/java/org/corant/context/proxy/ProxyBuilder.java b/corant-context/src/main/java/org/corant/context/proxy/ProxyBuilder.java index 76185d1c0..99549ae1e 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/ProxyBuilder.java +++ b/corant-context/src/main/java/org/corant/context/proxy/ProxyBuilder.java @@ -32,12 +32,15 @@ public class ProxyBuilder { /** * Build normal Interface-based dynamic proxy instance. * - * @see MethodInvoker * - * @param - * @param interfaceType - * @param invokerHandler - * @return build + * @param interface type + * @param interfaceType interface for the proxy class to implement + * @param invokerHandler the invocation handler creator, used to create concrete implementation + * from a method. + * @return a dynamic proxy instance for the specified interface that dispatches method invocations + * to the specified invocation handler. + * + * @see MethodInvoker */ @SuppressWarnings("unchecked") public static T build(final Class interfaceType, @@ -49,11 +52,15 @@ public static T build(final Class interfaceType, /** * Build contextual Interface-based dynamic proxy instance. * - * @param - * @param beanManager - * @param interfaceType - * @param invokerHandler - * @return buildContextual + * @param interface type + * @param beanManager bean manager for contextual bean handling + * @param interfaceType interface for the proxy class to implement + * @param invokerHandler the invocation handler creator, used to create concrete implementation + * from a method. + * @return a dynamic proxy contextual instance for the specified interface that dispatches method + * invocations to the specified invocation handler. + * + * @see MethodInvoker */ @SuppressWarnings("unchecked") public static T buildContextual(final BeanManager beanManager, final Class interfaceType, @@ -63,12 +70,15 @@ public static T buildContextual(final BeanManager beanManager, final Class buildDeclaredMethods(final Class clazz, Predicate methodPredicate, Annotation... appendQualifiers) { @@ -76,12 +86,14 @@ public static Set buildDeclaredMethods(final Class c } /** - * Build contextual bean method handler instance. + * Build contextual bean method handler instance from the methods of the given bean class. + * + * @param clazz bean class + * @param methodPredicate the method predicate use for method selecting + * @param appendQualifiers the append qualifiers for bean instance selecting + * @return a contextual method handlers * - * @param clazz - * @param methodPredicate - * @param appendQualifiers - * @return buildMethods + * @see Class#getMethods() */ public static Set buildMethods(final Class clazz, Predicate methodPredicate, Annotation... appendQualifiers) { diff --git a/corant-context/src/main/java/org/corant/context/proxy/ProxyInvocationHandler.java b/corant-context/src/main/java/org/corant/context/proxy/ProxyInvocationHandler.java index c85fe60d2..de3efc4d3 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/ProxyInvocationHandler.java +++ b/corant-context/src/main/java/org/corant/context/proxy/ProxyInvocationHandler.java @@ -26,6 +26,8 @@ /** * corant-context + *

+ * A simple invocation handler implementation. * * @author bingo 下午3:20:16 * @@ -79,18 +81,18 @@ public int hashCode() { } @Override - public Object invoke(Object o, Method method, Object[] args) throws Throwable { + public Object invoke(Object target, Method method, Object[] args) throws Throwable { MethodInvoker methodInvoker = invokers.get(method); if (methodInvoker == null) { // The default method and java.lang.Object methods use for hq in Collection if (method.isDefault()) { - return ProxyUtils.invokeDefaultMethod(o, method, args); + return ProxyUtils.invokeDefaultMethod(target, method, args); } else if ("equals".equals(method.getName()) && method.getParameterTypes()[0] == Object.class && args != null && args.length == 1) { if (args[0] == null) { return false; } - if (o == args[0]) { + if (target == args[0]) { return true; } return ProxyUtils.isProxyOfSameInterfaces(args[0], clazz) @@ -103,7 +105,7 @@ public Object invoke(Object o, Method method, Object[] args) throws Throwable { throw new CorantRuntimeException("Can not find method %s.", method); } } - return methodInvoker.invoke(o, args); + return methodInvoker.invoke(target, args); } diff --git a/corant-context/src/main/java/org/corant/context/proxy/ProxyUtils.java b/corant-context/src/main/java/org/corant/context/proxy/ProxyUtils.java index f69ff3c48..691d24ebc 100644 --- a/corant-context/src/main/java/org/corant/context/proxy/ProxyUtils.java +++ b/corant-context/src/main/java/org/corant/context/proxy/ProxyUtils.java @@ -47,6 +47,13 @@ public class ProxyUtils { static final Map defaultMethodHandleCache = new ConcurrentHashMap<>(); + /** + * Returns interceptor bindings from the given annotations and the given bean manager. + * + * @param annotations the annotations to find out interceptor bindings + * @param beanManager the bean manager use to filter + * @return a annotations list in the given annotation that match the interceptor binding + */ public static List getInterceptorBindings(Annotation[] annotations, BeanManager beanManager) { if (annotations.length == 0) { @@ -61,16 +68,34 @@ public static List getInterceptorBindings(Annotation[] annotations, return bindings; } + /** + * Resolve bean methods and their interceptor invocations from the given bean type with the given + * bean manager and the given creational context. + *

+ * Note: Currently we do not support resolving static methods. + *

+ * FIXME for now I am not sure yet, the default method interceptor? + * + * @param beanManager bean manager to handle interceptors + * @param creationalContext the creational context use for interceptor instantiation + * @param beanType the target bean interface type with some interceptors + * @return a maps that key is the method of target bean interface and value is the interceptor + * invocations of the method, the interceptor invocation contains interceptor instance and + * the meta object of the interceptor. + * + * @see BeanManager#resolveInterceptors(InterceptionType, Annotation...) + * @see InterceptorInvocation + */ public static Map> getInterceptorChains( - BeanManager beanManager, CreationalContext creationalContext, Class interfaceType) { + BeanManager beanManager, CreationalContext creationalContext, Class beanType) { Map> chains = new HashMap<>(); Map, Object> interceptorInstances = new HashMap<>(); List classLevelBindings = - getInterceptorBindings(interfaceType.getAnnotations(), beanManager); + getInterceptorBindings(beanType.getAnnotations(), beanManager); - for (Method method : interfaceType.getMethods()) { + for (Method method : beanType.getMethods()) { if ( /* method.isDefault() || */ Modifier.isStatic(method.getModifiers())) { - continue; // FIXME for now I am not sure yet, the default method interceptor? + continue; } List methodLevelBindings = getInterceptorBindings(method.getAnnotations(), beanManager); @@ -94,14 +119,18 @@ public static Map> getInterceptorChains( } /** - * FIXME UNFINISH YET! NOTE: FOR JAVA 8 ONLY! + * Returns the result of calling the given default method on the given target object with the + * given method arguments. + * + *

+ * FIXME UNFINISHED YET! * - * @param o - * @param method - * @param args - * @return invokeDefaultMethod + * @param target target object + * @param method target object default method + * @param args target object default method parameters + * @return invoke default method result */ - public static Object invokeDefaultMethod(Object o, Method method, Object[] args) { + public static Object invokeDefaultMethod(Object target, Method method, Object[] args) { try { return defaultMethodHandleCache.computeIfAbsent(method, m -> { try { @@ -121,7 +150,7 @@ public static Object invokeDefaultMethod(Object o, Method method, Object[] args) } catch (Throwable e) { throw new CorantRuntimeException(e); } - }).bindTo(o).invokeWithArguments(args); + }).bindTo(target).invokeWithArguments(args); } catch (Throwable e) { throw new CorantRuntimeException(e); } diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSConfig.java b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSConfig.java index 1103ca84b..f68d5c56d 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSConfig.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSConfig.java @@ -55,6 +55,9 @@ public abstract class AbstractJMSConfig implements JMSConfig, NamedObject, Decla @ConfigKeyItem protected boolean xa = true; + @ConfigKeyItem + protected boolean propagateSecurityContext = false; + @Override public boolean equals(Object obj) { if (this == obj) { @@ -83,14 +86,16 @@ public String getClientId() { } /** - * - * @return the connectionFactoryId + * @return the connection factory id, the connection factory id means a broker server or cluster. */ @Override public String getConnectionFactoryId() { return connectionFactoryId; } + /** + * Same as {@link #getConnectionFactoryId()} + */ @Override public String getName() { return connectionFactoryId; @@ -116,6 +121,10 @@ public boolean isEnable() { return enable; } + public boolean isPropagateSecurityContext() { + return propagateSecurityContext; + } + @Override public boolean isXa() { return xa; diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSExtension.java b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSExtension.java index bdfbf0c8d..65ec8bfe9 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSExtension.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/AbstractJMSExtension.java @@ -38,6 +38,7 @@ import javax.jms.JMSConnectionFactory; import javax.jms.Session; import org.corant.context.proxy.ContextualMethodHandler; +import org.corant.context.proxy.ProxyBuilder; import org.corant.context.qualifier.Qualifiers.NamedQualifierObjectManager; import org.corant.modules.jms.annotation.MessageContext; import org.corant.modules.jms.annotation.MessageDestination; @@ -109,7 +110,7 @@ protected void onProcessAnnotatedType( } } logger.fine(() -> String.format("Scanning message driven on bean: %s.", beanClass.getName())); - ContextualMethodHandler.fromDeclared(beanClass, m -> m.isAnnotationPresent(MessageDriven.class)) + ProxyBuilder.buildDeclaredMethods(beanClass, m -> m.isAnnotationPresent(MessageDriven.class)) .forEach(cm -> { Method method = cm.getMethod(); logger.fine(() -> String.format("Found message driven method %s.", method.getName())); diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/ExtendedJMSContext.java b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/ExtendedJMSContext.java index a627735c1..d65af4533 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/ExtendedJMSContext.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/ExtendedJMSContext.java @@ -188,8 +188,10 @@ public ObjectMessage createObjectMessage(final Serializable object) { @Override public JMSProducer createProducer() { JMSProducer producer = context().createProducer(); - find(SecurityContextPropagator.class).orElse(SimpleSecurityContextPropagator.INSTANCE) - .propagate(producer); + if (key.getConfig().isPropagateSecurityContext()) { + find(SecurityContextPropagator.class).orElse(SimpleSecurityContextPropagator.INSTANCE) + .propagate(producer); + } return producer; } diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/JMSContextKey.java b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/JMSContextKey.java index 40e90f09b..9eec8ebf2 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/JMSContextKey.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/context/JMSContextKey.java @@ -109,6 +109,10 @@ public boolean equals(Object o) { } + public AbstractJMSConfig getConfig() { + return config; + } + public String getConnectionFactoryId() { return connectionFactoryId; } diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/receive/DefaultMessageHandler.java b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/receive/DefaultMessageHandler.java index b27ba8bc9..2e0b4f11b 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/receive/DefaultMessageHandler.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-shared/src/main/java/org/corant/modules/jms/shared/receive/DefaultMessageHandler.java @@ -26,6 +26,7 @@ import org.corant.context.security.SecurityContexts; import org.corant.modules.jms.JMSNames; import org.corant.modules.jms.receive.ManagedMessageReceivingHandler; +import org.corant.modules.jms.shared.AbstractJMSExtension; import org.corant.modules.jms.shared.context.SecurityContextPropagator; import org.corant.modules.jms.shared.context.SecurityContextPropagator.SimpleSecurityContextPropagator; import org.corant.shared.exception.CorantRuntimeException; @@ -43,12 +44,15 @@ public class DefaultMessageHandler implements ManagedMessageReceivingHandler { final MessageReceivingMediator mediator; final Class messageClass; final MessageReceivingExecutorConfig config; + final boolean propagateSecurityContext; protected DefaultMessageHandler(MessageReceivingMetaData meta, MessageReceivingMediator mediator) { method = meta.getMethod(); config = MessageReceivingExecutorConfig.getExecutorConfig(meta.getConnectionFactoryId()); messageClass = method.getMethod().getParameterTypes()[0]; + propagateSecurityContext = AbstractJMSExtension.getConfig(config.getConnectionFactoryId()) + .isPropagateSecurityContext(); this.mediator = mediator; } @@ -81,6 +85,9 @@ protected Object resolvePayload(Message message) throws JMSException { } protected void resolveSecurityContext(Message message) { + if (!propagateSecurityContext) { + return; + } try { SecurityContext ctx = find(SecurityContextPropagator.class) .orElse(SimpleSecurityContextPropagator.INSTANCE).extract(message); diff --git a/corant-modules/corant-modules-quartz/corant-modules-quartz-embeddable/src/main/java/org/corant/modules/quartz/embeddable/CorantSchedulerExtension.java b/corant-modules/corant-modules-quartz/corant-modules-quartz-embeddable/src/main/java/org/corant/modules/quartz/embeddable/CorantSchedulerExtension.java index 08d50cc48..b31c96d36 100644 --- a/corant-modules/corant-modules-quartz/corant-modules-quartz-embeddable/src/main/java/org/corant/modules/quartz/embeddable/CorantSchedulerExtension.java +++ b/corant-modules/corant-modules-quartz/corant-modules-quartz-embeddable/src/main/java/org/corant/modules/quartz/embeddable/CorantSchedulerExtension.java @@ -10,7 +10,7 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; import javax.enterprise.inject.spi.WithAnnotations; import org.corant.context.ContainerEvents.PreContainerStopEvent; -import org.corant.context.proxy.ContextualMethodHandler; +import org.corant.context.proxy.ProxyBuilder; import org.corant.shared.normal.Priorities; import org.corant.shared.util.Services; @@ -40,7 +40,7 @@ protected void onProcessAnnotatedType( return; } final Class beanClass = pat.getAnnotatedType().getJavaClass(); - ContextualMethodHandler.fromDeclared(beanClass, m -> m.isAnnotationPresent(CorantTrigger.class)) + ProxyBuilder.buildDeclaredMethods(beanClass, m -> m.isAnnotationPresent(CorantTrigger.class)) .stream().map(CorantDeclarativeJobMetaData::of).forEach(declarativeJobMetaDatas::add); } } diff --git a/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/FetchQueryHandler.java b/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/FetchQueryHandler.java index 2428ac417..1e9220ce3 100644 --- a/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/FetchQueryHandler.java +++ b/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/FetchQueryHandler.java @@ -20,8 +20,8 @@ * corant-modules-query-api * *

- * This interface is used to process fetch queries, provide the query parameters of the fetch query, - * and provide processing of the fetch query result set. + * This interface is used to process fetch queries, provide query parameters and query result + * handling for fetch query. * * @author bingo 上午10:03:39 * diff --git a/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/QueryParameter.java b/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/QueryParameter.java index c105b4acc..295315319 100644 --- a/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/QueryParameter.java +++ b/corant-modules/corant-modules-query/corant-modules-query-api/src/main/java/org/corant/modules/query/QueryParameter.java @@ -47,19 +47,20 @@ public interface QueryParameter extends Serializable { String CTX_QHH_DONT_CONVERT_RESULT = "__QHH_DONT_CONVERT_RESULT"; /** - * Return the query context that may be contain current user context or security context. + * Returns the query context that may be contain current caller context, the context information + * may include the security context information of the caller, etc. * - * @return getContext + * @return the context maps */ default Map getContext() { return Collections.emptyMap(); } /** - * Return query criteria. The criteria can be Map or POJO that are used to construct query - * conditions or specifications for construct query conditions or specifications. + * Returns the query criteria, the criteria can be a Map or a POJO that are used to construct + * query conditions or specifications. * - * @return getCriteria + * @return the criteria object or null */ Object getCriteria(); @@ -69,8 +70,7 @@ default Map getContext() { * specified forwarding range queries({@link QueryService#forward(Object, Object)}) or select * queries({@link QueryService#select(Object, Object)}) , but in streaming * queries({@link QueryService#stream(Object, Object)}), this value represents the size of the - * result set fetched from the underlying database in each iteration. Default is null, means that - * if it is used in paging/forwarding/streaming query value is 16. + * result set fetched from the underlying database in each iteration. * * * @return The expected number of query result set or the expected size of the result set of each diff --git a/corant-shared/src/main/java/org/corant/shared/resource/FileSystemResource.java b/corant-shared/src/main/java/org/corant/shared/resource/FileSystemResource.java index b2845dbf7..191d8ae5f 100644 --- a/corant-shared/src/main/java/org/corant/shared/resource/FileSystemResource.java +++ b/corant-shared/src/main/java/org/corant/shared/resource/FileSystemResource.java @@ -22,8 +22,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; @@ -131,12 +129,12 @@ public OutputStream openOutputStream() throws IOException { } @Override - public ReadableByteChannel openReadableChannel() throws IOException { + public FileChannel openReadableChannel() throws IOException { return FileChannel.open(file.toPath(), StandardOpenOption.READ); } @Override - public WritableByteChannel openWritableChannel() throws IOException { + public FileChannel openWritableChannel() throws IOException { return FileChannel.open(file.toPath(), StandardOpenOption.WRITE); }