/** * Get the context manager. Simply calls the {@code static} method {@link #getContextManager()}. * * @return the context manager (not {@code null}) */ public ContextManager<EJBClientContext> getInstanceContextManager() { return getContextManager(); }
EJBTransactionOperations(final Connection connection) throws IOException { final EJBClientContext ejbClientContext = EJBClientContext.getCurrent(); final RemoteEJBReceiver receiver = ejbClientContext.getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); if (receiver != null) { this.channel = receiver.getClientChannel(connection); } else { throw Logs.REMOTING.noRemoteTransportOnEJBContext(); } }
public EJBClientContext build() { return new EJBClientContext(this); } }
<T> StatefulEJBLocator<T> createSession(final StatelessEJBLocator<T> statelessLocator, final AuthenticationContext authenticationContext, final NamingProvider namingProvider) throws Exception { EJBSessionCreationInvocationContext context = createSessionCreationInvocationContext(statelessLocator, authenticationContext); return createSession(context, statelessLocator, namingProvider); }
/** * Create a new EJB session. * * @param statelessLocator the stateless locator identifying the stateful EJB * @param authenticationContext the authentication context to use for the request and the resultant proxy * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ static <T> StatefulEJBLocator<T> createSession(StatelessEJBLocator<T> statelessLocator, AuthenticationContext authenticationContext) throws Exception { final EJBClientContext clientContext = EJBClientContext.getCurrent(); return clientContext.createSession(statelessLocator, authenticationContext, null); }
@Override public ContextSelector<EJBClientContext> run() { return EJBClientContext.setSelector(selector); } }
return DiscoveryRequest.NULL; final EJBClientContext ejbClientContext = getCurrent(); final RemoteEJBReceiver ejbReceiver = ejbClientContext.getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); if (ejbReceiver == null) { final List<EJBClientConnection> configuredConnections = ejbClientContext.getConfiguredConnections(); final String clusterName = entry.getKey(); final Set<String> nodeSet = entry.getValue(); int maxConnections = ejbClientContext.getMaximumConnectedClusterNodes(); nodeLoop: for (String nodeName : nodeSet) { if (maxConnections <= 0) break;
static <T> T createSessionProxy(final StatelessEJBLocator<T> statelessLocator, Supplier<AuthenticationContext> authenticationContextSupplier, NamingProvider namingProvider) throws Exception { final EJBClientContext clientContext = EJBClientContext.getCurrent(); // this is the auth context to use just for the invocation final AuthenticationContext authenticationContext; if (authenticationContextSupplier != null) { authenticationContext = authenticationContextSupplier.get(); } else { authenticationContext = AuthenticationContext.captureCurrent(); } final EJBSessionCreationInvocationContext context = clientContext.createSessionCreationInvocationContext(statelessLocator, authenticationContext); final StatefulEJBLocator<T> statefulLocator = clientContext.createSession(context, statelessLocator, namingProvider); final T proxy = createProxy(statefulLocator, authenticationContextSupplier); final Affinity weakAffinity = context.getWeakAffinity(); if (weakAffinity != null && Affinity.NONE != weakAffinity) { setWeakAffinity(proxy, weakAffinity); } return proxy; }
public EJBReceiver getReceiver(final EJBReceiverContext receiverContext, final String uriScheme) throws IllegalArgumentException { switch (uriScheme) { case "remote": case "remote+http": case "remote+https": // compatibility case "remoting": case "http-remoting": case "https-remoting": { final RemoteEJBReceiver receiver = receiverContext.getClientContext().getAttachment(ATTACHMENT_KEY); if (receiver != null) { return receiver; } // else fall through } default: { throw new IllegalArgumentException("Unsupported EJB receiver protocol " + uriScheme); } } } }
private EJBClientContext getContext(final Connection connection) { synchronized (contextByConnection) { EJBClientContext ret = contextByConnection.get(connection); if(ret == null) { ret = EJBClientContext.create(); ret.registerConnection(connection); contextByConnection.put(connection, ret); connection.addCloseHandler(new CloseHandler<Connection>() { @Override public void handleClose(final Connection connection, final IOException e) { synchronized (contextByConnection) { contextByConnection.remove(connection); } } }); } return ret; } } }
@Override public synchronized void start(StartContext startContext) throws StartException { // setup the context with the receivers final EJBClientContext context; if (this.clientContextClassloader != null) { context = EJBClientContext.create(this.ejbClientConfiguration, this.clientContextClassloader); } else { context = EJBClientContext.create(this.ejbClientConfiguration); } // add the (optional) local EJB receiver final LocalEjbReceiver localEjbReceiver = this.localEjbReceiverInjectedValue.getOptionalValue(); if (localEjbReceiver != null) { context.registerEJBReceiver(localEjbReceiver); logger.debug("Added a local EJB receiver to descriptor based EJB client context named " + startContext.getController().getName()); } // now process the remoting receivers this.registerRemotingEJBReceivers(startContext, context); // we now have a fully configured EJB client context for use this.ejbClientContext = context; }
if (outerIter.hasNext()) { Map<String, Map<EJBMethodLocator, InterceptorList>> targetMap = new HashMap<>(map.size()); targetMap.put(first.getKey(), calculateMethodInterceptors(first.getValue())); do { final Map.Entry<String, HashMap<EJBMethodLocator, ArrayList<EJBClientInterceptorInformation>>> next = outerIter.next(); targetMap.put(next.getKey(), calculateMethodInterceptors(next.getValue())); } while (outerIter.hasNext()); this.configuredPerMethodInterceptors = targetMap; } else { this.configuredPerMethodInterceptors = Collections.singletonMap(first.getKey(), calculateMethodInterceptors(first.getValue()));
public static RemoteNamingStoreEJBClientHandler setupEJBClientContext(final Properties ejbClientProperties, final List<RemoteContext.CloseTask> closeTasks) { EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(ejbClientProperties); final EJBClientContext ejbClientContext = EJBClientContext.create(clientConfiguration); final String ejbClientContextName = EJB_CLIENT_CONTEXT_NAME_PREFIX + nextEJBClientContextNumber.addAndGet(1); final EJBClientContextIdentifier ejbClientContextIdentifier = new NamedEJBClientContextIdentifier(ejbClientContextName); // register the context with the selector registerEJBClientContextWithSelector(ejbClientContextIdentifier, ejbClientContext); // add a close task which closes the EJB client context when the remote naming context is closed if (closeTasks != null) { closeTasks.add(new RemoteNamingEJBClientContextCloseTask(ejbClientContext)); } return new RemoteNamingStoreEJBClientHandler(ejbClientContextIdentifier, ejbClientContext); }
@Override public ContextSelector<EJBClientContext> run() { return EJBClientContext.setSelector(selector); } }
return DiscoveryRequest.NULL; final EJBClientContext ejbClientContext = getCurrent(); final RemoteEJBReceiver ejbReceiver = ejbClientContext.getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); if (ejbReceiver == null) { final List<EJBClientConnection> configuredConnections = ejbClientContext.getConfiguredConnections(); final String clusterName = entry.getKey(); final Set<String> nodeSet = entry.getValue(); int maxConnections = ejbClientContext.getMaximumConnectedClusterNodes(); nodeLoop: for (String nodeName : nodeSet) { if (maxConnections <= 0) break;
static <T> T createSessionProxy(final StatelessEJBLocator<T> statelessLocator, Supplier<AuthenticationContext> authenticationContextSupplier, NamingProvider namingProvider) throws Exception { final EJBClientContext clientContext = EJBClientContext.getCurrent(); // this is the auth context to use just for the invocation final AuthenticationContext authenticationContext; if (authenticationContextSupplier != null) { authenticationContext = authenticationContextSupplier.get(); } else { authenticationContext = AuthenticationContext.captureCurrent(); } final EJBSessionCreationInvocationContext context = clientContext.createSessionCreationInvocationContext(statelessLocator, authenticationContext); final StatefulEJBLocator<T> statefulLocator = clientContext.createSession(context, statelessLocator, namingProvider); final T proxy = createProxy(statefulLocator, authenticationContextSupplier); final Affinity weakAffinity = context.getWeakAffinity(); if (weakAffinity != null && Affinity.NONE != weakAffinity) { setWeakAffinity(proxy, weakAffinity); } return proxy; }
@Override public EJBReceiver getReceiver(EJBReceiverContext ejbReceiverContext, String s) throws IllegalArgumentException { if(PROTOCOLS.contains(s)) { HttpEJBReceiver receiver = ejbReceiverContext.getClientContext().getAttachment(RECEIVER); if(receiver != null) { return receiver; } } throw EjbHttpClientMessages.MESSAGES.couldNotCreateHttpEjbReceiverFor(s); }
<T> StatefulEJBLocator<T> createSession(final StatelessEJBLocator<T> statelessLocator, final AuthenticationContext authenticationContext, final NamingProvider namingProvider) throws Exception { EJBSessionCreationInvocationContext context = createSessionCreationInvocationContext(statelessLocator, authenticationContext); return createSession(context, statelessLocator, namingProvider); }
/** * Create a new EJB session. * * @param statelessLocator the stateless locator identifying the stateful EJB * @param authenticationContext the authentication context to use for the request and the resultant proxy * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ static <T> StatefulEJBLocator<T> createSession(StatelessEJBLocator<T> statelessLocator, AuthenticationContext authenticationContext) throws Exception { final EJBClientContext clientContext = EJBClientContext.getCurrent(); return clientContext.createSession(statelessLocator, authenticationContext, null); }
private synchronized void createConnection() { try { endpoint = Remoting.createEndpoint("endpoint", OptionMap.EMPTY); endpoint.addConnectionProvider("remote", new RemoteConnectionProviderFactory(), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE)); // open a connection final IoFuture<Connection> futureConnection = endpoint.connect(new URI(hostUrl), OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE, Options.SASL_POLICY_NOPLAINTEXT, Boolean.FALSE), callbackHandler); connection = IoFutureHelper.get(futureConnection, 30L, TimeUnit.SECONDS); final EJBClientContext ejbClientContext = EJBClientContext.create(); ejbClientContext.registerConnection(connection); this.clientContext = ejbClientContext; } catch (IOException e) { throw new RuntimeException(e); } catch (URISyntaxException e) { throw new RuntimeException(e); } }