/** * Get the locator for a proxy, if it has one. * * @param proxy the proxy (may not be {@code null}) * @param <T> the proxy type * @return the locator * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance */ public static <T> EJBLocator<? extends T> getLocatorFor(T proxy) throws IllegalArgumentException { Assert.checkNotNullParam("proxy", proxy); return EJBInvocationHandler.forProxy(proxy).getLocator(); }
Assert.checkNotNullParam("transformOperator", transformOperator); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); Affinity oldAffinity = invocationHandler.getLocator().getAffinity(); Affinity newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity); oldAffinity = invocationHandler.getLocator().getAffinity(); newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity);
EJBClientInvocationContext(final EJBInvocationHandler<?> invocationHandler, final EJBClientContext ejbClientContext, final Object invokedProxy, final Object[] parameters, final EJBProxyInformation.ProxyMethodInfo methodInfo, final int allowedRetries, final Supplier<AuthenticationContext> authenticationContextSupplier) { super(invocationHandler.getLocator(), ejbClientContext); this.invocationHandler = invocationHandler; authenticationContext = authenticationContextSupplier != null ? authenticationContextSupplier.get() : AuthenticationContext.captureCurrent(); this.invokedProxy = invokedProxy; this.parameters = parameters; this.methodInfo = methodInfo; long timeout = invocationHandler.getInvocationTimeout(); if (timeout == -1) { timeout = ejbClientContext.getInvocationTimeout(); } this.timeout = timeout; remainingRetries = allowedRetries; interceptorList = getClientContext().getInterceptors(getViewClass(), getInvokedMethod()); }
/** * Compare and change the strong affinity of a proxy. All subsequent invocations against the proxy will use the new affinity. * Subsequent calls to {@link #getLocatorFor(Object)} for the given proxy will return the updated locator. If the * affinity is not equal to the expected value, {@code false} is returned and no change is made. * * @param proxy the proxy (may not be {@code null}) * @param newAffinity the new affinity (may not be {@code null}) * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance * @throws SecurityException if a security manager is present and the caller does not have the {@code changeStrongAffinity} {@link EJBClientPermission} */ public static boolean compareAndSetStrongAffinity(Object proxy, Affinity expectedAffinity, Affinity newAffinity) throws IllegalArgumentException, SecurityException { Assert.checkNotNullParam("proxy", proxy); Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); final Affinity existing = invocationHandler.getLocator().getAffinity(); if (! expectedAffinity.equals(existing)) { return false; } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(EJBClientPermission.CHANGE_STRONG_AFFINITY); } return invocationHandler.compareAndSetStrongAffinity(expectedAffinity, newAffinity); }
/** * Get the locator for a proxy, if it has one. * * @param proxy the proxy (may not be {@code null}) * @param <T> the proxy type * @return the locator * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance */ public static <T> EJBLocator<? extends T> getLocatorFor(T proxy) throws IllegalArgumentException { Assert.checkNotNullParam("proxy", proxy); return EJBInvocationHandler.forProxy(proxy).getLocator(); }
/** * Get the locator for a proxy, if it has one. * * @param proxy the proxy (may not be {@code null}) * @param <T> the proxy type * @return the locator * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance */ public static <T> EJBLocator<? extends T> getLocatorFor(T proxy) throws IllegalArgumentException { Assert.checkNotNullParam("proxy", proxy); return EJBInvocationHandler.forProxy(proxy).getLocator(); }
Assert.checkNotNullParam("transformOperator", transformOperator); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); Affinity oldAffinity = invocationHandler.getLocator().getAffinity(); Affinity newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity); oldAffinity = invocationHandler.getLocator().getAffinity(); newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity);
Assert.checkNotNullParam("transformOperator", transformOperator); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); Affinity oldAffinity = invocationHandler.getLocator().getAffinity(); Affinity newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity); oldAffinity = invocationHandler.getLocator().getAffinity(); newAffinity = transformOperator.apply(oldAffinity); Assert.assertNotNull(newAffinity);
EJBClientInvocationContext(final EJBInvocationHandler<?> invocationHandler, final EJBClientContext ejbClientContext, final Object invokedProxy, final Object[] parameters, final EJBProxyInformation.ProxyMethodInfo methodInfo, final int allowedRetries, final Supplier<AuthenticationContext> authenticationContextSupplier) { super(invocationHandler.getLocator(), ejbClientContext); this.invocationHandler = invocationHandler; authenticationContext = authenticationContextSupplier != null ? authenticationContextSupplier.get() : AuthenticationContext.captureCurrent(); this.invokedProxy = invokedProxy; this.parameters = parameters; this.methodInfo = methodInfo; long timeout = invocationHandler.getInvocationTimeout(); if (timeout == -1) { timeout = ejbClientContext.getInvocationTimeout(); } this.timeout = timeout; remainingRetries = allowedRetries; interceptorList = getClientContext().getInterceptors(getViewClass(), getInvokedMethod()); }
/** * Compare and change the strong affinity of a proxy. All subsequent invocations against the proxy will use the new affinity. * Subsequent calls to {@link #getLocatorFor(Object)} for the given proxy will return the updated locator. If the * affinity is not equal to the expected value, {@code false} is returned and no change is made. * * @param proxy the proxy (may not be {@code null}) * @param newAffinity the new affinity (may not be {@code null}) * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance * @throws SecurityException if a security manager is present and the caller does not have the {@code changeStrongAffinity} {@link EJBClientPermission} */ public static boolean compareAndSetStrongAffinity(Object proxy, Affinity expectedAffinity, Affinity newAffinity) throws IllegalArgumentException, SecurityException { Assert.checkNotNullParam("proxy", proxy); Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); final Affinity existing = invocationHandler.getLocator().getAffinity(); if (! expectedAffinity.equals(existing)) { return false; } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(EJBClientPermission.CHANGE_STRONG_AFFINITY); } return invocationHandler.compareAndSetStrongAffinity(expectedAffinity, newAffinity); }
EJBClientInvocationContext(final EJBInvocationHandler<?> invocationHandler, final EJBClientContext ejbClientContext, final Object invokedProxy, final Object[] parameters, final EJBProxyInformation.ProxyMethodInfo methodInfo, final int allowedRetries, final Supplier<AuthenticationContext> authenticationContextSupplier) { super(invocationHandler.getLocator(), ejbClientContext); this.invocationHandler = invocationHandler; authenticationContext = authenticationContextSupplier != null ? authenticationContextSupplier.get() : AuthenticationContext.captureCurrent(); this.invokedProxy = invokedProxy; this.parameters = parameters; this.methodInfo = methodInfo; long timeout = invocationHandler.getInvocationTimeout(); if (timeout == -1) { timeout = ejbClientContext.getInvocationTimeout(); } this.timeout = timeout; remainingRetries = allowedRetries; interceptorList = getClientContext().getInterceptors(getViewClass(), getInvokedMethod()); }
/** * Compare and change the strong affinity of a proxy. All subsequent invocations against the proxy will use the new affinity. * Subsequent calls to {@link #getLocatorFor(Object)} for the given proxy will return the updated locator. If the * affinity is not equal to the expected value, {@code false} is returned and no change is made. * * @param proxy the proxy (may not be {@code null}) * @param newAffinity the new affinity (may not be {@code null}) * @throws IllegalArgumentException if the given proxy is not a valid client proxy instance * @throws SecurityException if a security manager is present and the caller does not have the {@code changeStrongAffinity} {@link EJBClientPermission} */ public static boolean compareAndSetStrongAffinity(Object proxy, Affinity expectedAffinity, Affinity newAffinity) throws IllegalArgumentException, SecurityException { Assert.checkNotNullParam("proxy", proxy); Assert.checkNotNullParam("expectedAffinity", expectedAffinity); Assert.checkNotNullParam("newAffinity", newAffinity); final EJBInvocationHandler<?> invocationHandler = EJBInvocationHandler.forProxy(proxy); final Affinity existing = invocationHandler.getLocator().getAffinity(); if (! expectedAffinity.equals(existing)) { return false; } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(EJBClientPermission.CHANGE_STRONG_AFFINITY); } return invocationHandler.compareAndSetStrongAffinity(expectedAffinity, newAffinity); }