this.globalInterceptors = InterceptorList.EMPTY; } else { this.globalInterceptors = new InterceptorList(arrayList.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
static <T> EJBProxyInterceptorInformation<T> construct(Class<T> clazz, EJBClientContext clientContext) { final EJBProxyInformation<T> proxyInformation = EJBProxyInformation.forViewType(clazz); final Collection<EJBProxyInformation.ProxyMethodInfo> methods = proxyInformation.getMethods(); final String className = clazz.getName(); final InterceptorList list0 = EJBClientContext.defaultInterceptors; final InterceptorList list1 = clientContext.getGlobalInterceptors(); final InterceptorList list2 = clientContext.getClassPathInterceptors(); final InterceptorList list3 = clientContext.getConfiguredPerClassInterceptors().getOrDefault(className, EMPTY); final InterceptorList list5 = proxyInformation.getClassInterceptors(); final IdentityHashMap<Method, InterceptorList> interceptorsByMethod = new IdentityHashMap<>(methods.size()); final HashMap<InterceptorList, InterceptorList> cache = new HashMap<>(); cache.computeIfAbsent(list0, Function.identity()); final InterceptorList tailList = list3.combine(list2).combine(list1).combine(list0); cache.computeIfAbsent(tailList, Function.identity()); for (EJBProxyInformation.ProxyMethodInfo method : methods) { // compile interceptor information final InterceptorList list4 = clientContext.getConfiguredPerMethodInterceptors().getOrDefault(className, emptyMap()).getOrDefault(method.getMethodLocator(), EMPTY); final InterceptorList list6 = method.getInterceptors(); interceptorsByMethod.put(method.getMethod(), cache.computeIfAbsent(list6.combine(list5).combine(list4).combine(tailList), Function.identity())); } return new EJBProxyInterceptorInformation<T>(proxyInformation, interceptorsByMethod, cache.computeIfAbsent(list5.combine(tailList), Function.identity())); }
final EJBClientInterceptorInformation[] chain = list.getInformation(); final EJBReceiverInvocationContext.ResultProducer resultProducer; Throwable fail = null;
this.globalInterceptors = InterceptorList.EMPTY; } else { this.globalInterceptors = new InterceptorList(arrayList.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
this.globalInterceptors = InterceptorList.EMPTY; } else { this.globalInterceptors = new InterceptorList(arrayList.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
final EJBClientInterceptorInformation[] chain = list.getInformation(); final EJBReceiverInvocationContext.ResultProducer resultProducer; Throwable fail = null;
final EJBClientInterceptorInformation[] chain = list.getInformation(); final EJBReceiverInvocationContext.ResultProducer resultProducer; Throwable fail = null;
final Object lock = this.lock; Assert.assertNotHoldsLock(lock); final EJBClientInterceptorInformation[] chain = interceptorList.getInformation(); synchronized (lock) { if (state != State.SENDING) {
final Object lock = this.lock; Assert.assertNotHoldsLock(lock); final EJBClientInterceptorInformation[] chain = interceptorList.getInformation(); synchronized (lock) { if (state != State.SENDING) {
return InterceptorList.EMPTY; } else { return new InterceptorList(list.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
return InterceptorList.EMPTY; } else { return new InterceptorList(list.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
/** * Proceed with the next interceptor in the chain, calling the resolved receiver in the end. * * @return the session ID (not {@code null}) * @throws Exception if the EJB session creation failed for some reason */ public SessionID proceed() throws Exception { final int idx = interceptorChainIndex++; try { final EJBClientInterceptorInformation[] chain = interceptorList.getInformation(); if (idx > chain.length) { throw Assert.unreachableCode(); } if (chain.length == idx) { final URI destination = getDestination(); final EJBReceiver receiver = getClientContext().resolveReceiver(destination, getLocator()); setReceiver(receiver); final SessionID sessionID = receiver.createSession(new EJBReceiverSessionCreationContext(this, authenticationContext)); if (sessionID == null) { throw Logs.INVOCATION.nullSessionID(receiver, getLocator().asStateless()); } retry = false; return sessionID; } else { return chain[idx].getInterceptorInstance().handleSessionCreation(this); } } finally { interceptorChainIndex --; } }
Builder(final EJBClientContext clientContext) { globalInterceptors = Arrays.stream(clientContext.globalInterceptors.getInformation()).collect(Collectors.toCollection(ArrayList::new)); classInterceptors = new ArrayList<>(); for (Map.Entry<String, InterceptorList> entry : clientContext.getConfiguredPerClassInterceptors().entrySet()) { final String className = entry.getKey(); for (EJBClientInterceptorInformation information : entry.getValue().getInformation()) { classInterceptors.add(new ClassInterceptor(className, information)); } } methodInterceptors = new ArrayList<>(); for (Map.Entry<String, Map<EJBMethodLocator, InterceptorList>> entry : clientContext.getConfiguredPerMethodInterceptors().entrySet()) { final String className = entry.getKey(); for (Map.Entry<EJBMethodLocator, InterceptorList> entry1 : entry.getValue().entrySet()) { final EJBMethodLocator methodLocator = entry1.getKey(); for (EJBClientInterceptorInformation information : entry1.getValue().getInformation()) { methodInterceptors.add(new MethodInterceptor(className, methodLocator, information)); } } } transportProviders = new ArrayList<>(); Collections.addAll(transportProviders, clientContext.transportProviders); clientConnections = new ArrayList<>(); clientConnections.addAll(clientContext.getConfiguredConnections()); clientClusters = new ArrayList<>(); clientClusters.addAll(clientContext.configuredClusters.values()); clusterNodeSelector = clientContext.clusterNodeSelector; deploymentNodeSelector = clientContext.deploymentNodeSelector; invocationTimeout = clientContext.invocationTimeout; }
/** * Proceed with the next interceptor in the chain, calling the resolved receiver in the end. * * @return the session ID (not {@code null}) * @throws Exception if the EJB session creation failed for some reason */ public SessionID proceed() throws Exception { final int idx = interceptorChainIndex++; try { final EJBClientInterceptorInformation[] chain = interceptorList.getInformation(); if (idx > chain.length) { throw Assert.unreachableCode(); } if (chain.length == idx) { final URI destination = getDestination(); final EJBReceiver receiver = getClientContext().resolveReceiver(destination, getLocator()); setReceiver(receiver); final SessionID sessionID = receiver.createSession(new EJBReceiverSessionCreationContext(this, authenticationContext)); if (sessionID == null) { throw Logs.INVOCATION.nullSessionID(receiver, getLocator().asStateless()); } retry = false; return sessionID; } else { return chain[idx].getInterceptorInstance().handleSessionCreation(this); } } finally { interceptorChainIndex --; } }
Builder(final EJBClientContext clientContext) { globalInterceptors = Arrays.stream(clientContext.globalInterceptors.getInformation()).collect(Collectors.toCollection(ArrayList::new)); classInterceptors = new ArrayList<>(); for (Map.Entry<String, InterceptorList> entry : clientContext.getConfiguredPerClassInterceptors().entrySet()) { final String className = entry.getKey(); for (EJBClientInterceptorInformation information : entry.getValue().getInformation()) { classInterceptors.add(new ClassInterceptor(className, information)); } } methodInterceptors = new ArrayList<>(); for (Map.Entry<String, Map<EJBMethodLocator, InterceptorList>> entry : clientContext.getConfiguredPerMethodInterceptors().entrySet()) { final String className = entry.getKey(); for (Map.Entry<EJBMethodLocator, InterceptorList> entry1 : entry.getValue().entrySet()) { final EJBMethodLocator methodLocator = entry1.getKey(); for (EJBClientInterceptorInformation information : entry1.getValue().getInformation()) { methodInterceptors.add(new MethodInterceptor(className, methodLocator, information)); } } } transportProviders = new ArrayList<>(); Collections.addAll(transportProviders, clientContext.transportProviders); clientConnections = new ArrayList<>(); clientConnections.addAll(clientContext.getConfiguredConnections()); clientClusters = new ArrayList<>(); clientClusters.addAll(clientContext.configuredClusters.values()); clusterNodeSelector = clientContext.clusterNodeSelector; deploymentNodeSelector = clientContext.deploymentNodeSelector; invocationTimeout = clientContext.invocationTimeout; }
static <T> EJBProxyInterceptorInformation<T> construct(Class<T> clazz, EJBClientContext clientContext) { final EJBProxyInformation<T> proxyInformation = EJBProxyInformation.forViewType(clazz); final Collection<EJBProxyInformation.ProxyMethodInfo> methods = proxyInformation.getMethods(); final String className = clazz.getName(); final InterceptorList list0 = EJBClientContext.defaultInterceptors; final InterceptorList list1 = clientContext.getGlobalInterceptors(); final InterceptorList list2 = clientContext.getClassPathInterceptors(); final InterceptorList list3 = clientContext.getConfiguredPerClassInterceptors().getOrDefault(className, EMPTY); final InterceptorList list5 = proxyInformation.getClassInterceptors(); final IdentityHashMap<Method, InterceptorList> interceptorsByMethod = new IdentityHashMap<>(methods.size()); final HashMap<InterceptorList, InterceptorList> cache = new HashMap<>(); cache.computeIfAbsent(list0, Function.identity()); final InterceptorList tailList = list3.combine(list2).combine(list1).combine(list0); cache.computeIfAbsent(tailList, Function.identity()); for (EJBProxyInformation.ProxyMethodInfo method : methods) { // compile interceptor information final InterceptorList list4 = clientContext.getConfiguredPerMethodInterceptors().getOrDefault(className, emptyMap()).getOrDefault(method.getMethodLocator(), EMPTY); final InterceptorList list6 = method.getInterceptors(); interceptorsByMethod.put(method.getMethod(), cache.computeIfAbsent(list6.combine(list5).combine(list4).combine(tailList), Function.identity())); } return new EJBProxyInterceptorInformation<T>(proxyInformation, interceptorsByMethod, cache.computeIfAbsent(list5.combine(tailList), Function.identity())); }
static <T> EJBProxyInterceptorInformation<T> construct(Class<T> clazz, EJBClientContext clientContext) { final EJBProxyInformation<T> proxyInformation = EJBProxyInformation.forViewType(clazz); final Collection<EJBProxyInformation.ProxyMethodInfo> methods = proxyInformation.getMethods(); final String className = clazz.getName(); final InterceptorList list0 = EJBClientContext.defaultInterceptors; final InterceptorList list1 = clientContext.getGlobalInterceptors(); final InterceptorList list2 = clientContext.getClassPathInterceptors(); final InterceptorList list3 = clientContext.getConfiguredPerClassInterceptors().getOrDefault(className, EMPTY); final InterceptorList list5 = proxyInformation.getClassInterceptors(); final IdentityHashMap<Method, InterceptorList> interceptorsByMethod = new IdentityHashMap<>(methods.size()); final HashMap<InterceptorList, InterceptorList> cache = new HashMap<>(); cache.computeIfAbsent(list0, Function.identity()); final InterceptorList tailList = list3.combine(list2).combine(list1).combine(list0); cache.computeIfAbsent(tailList, Function.identity()); for (EJBProxyInformation.ProxyMethodInfo method : methods) { // compile interceptor information final InterceptorList list4 = clientContext.getConfiguredPerMethodInterceptors().getOrDefault(className, emptyMap()).getOrDefault(method.getMethodLocator(), EMPTY); final InterceptorList list6 = method.getInterceptors(); interceptorsByMethod.put(method.getMethod(), cache.computeIfAbsent(list6.combine(list5).combine(list4).combine(tailList), Function.identity())); } return new EJBProxyInterceptorInformation<T>(proxyInformation, interceptorsByMethod, cache.computeIfAbsent(list5.combine(tailList), Function.identity())); }
private EJBClientContext.InterceptorList getInterceptorsFromAnnotation(final ClientInterceptors classClientInterceptors) { if (classClientInterceptors != null) { final Class<?>[] interceptorClasses = classClientInterceptors.value(); final int length = interceptorClasses.length; if (length == 0) { return EJBClientContext.InterceptorList.EMPTY; } else if (length == 1) { return EJBClientInterceptorInformation.forClass(interceptorClasses[0]).getSingletonList(); } else { final EJBClientInterceptorInformation[] interceptors = new EJBClientInterceptorInformation[length]; for (int i = 0; i < length; i++) { interceptors[i] = EJBClientInterceptorInformation.forClass(interceptorClasses[i]); } return new EJBClientContext.InterceptorList(interceptors); } } else { return EJBClientContext.InterceptorList.EMPTY; } }
private EJBClientContext.InterceptorList getInterceptorsFromAnnotation(final ClientInterceptors classClientInterceptors) { if (classClientInterceptors != null) { final Class<?>[] interceptorClasses = classClientInterceptors.value(); final int length = interceptorClasses.length; if (length == 0) { return EJBClientContext.InterceptorList.EMPTY; } else if (length == 1) { return EJBClientInterceptorInformation.forClass(interceptorClasses[0]).getSingletonList(); } else { final EJBClientInterceptorInformation[] interceptors = new EJBClientInterceptorInformation[length]; for (int i = 0; i < length; i++) { interceptors[i] = EJBClientInterceptorInformation.forClass(interceptorClasses[i]); } return new EJBClientContext.InterceptorList(interceptors); } } else { return EJBClientContext.InterceptorList.EMPTY; } }
InterceptorList getGlobalInterceptors() { return globalInterceptors.combine(registeredInterceptors()); }