/** * Get the EJB home interface. * * @return the EJB home interface */ public H getEJBHome() { return EJBClient.createProxy(homeLocator); }
/** * @param ejbProxy The EJB proxy * @throws IllegalArgumentException If the passed proxy is not an EJB proxy */ SerializableEJBProxy(final Object ejbProxy) { // we hold on to the EJB locator and the EJB client context identifier this.ejbLocator = EJBClient.getLocatorFor(ejbProxy); }
@Override public ManagedReference createViewInstance(final ComponentView componentView, final Map<Object, Object> contextData) throws Exception { SessionID sessionID = (SessionID) contextData.get(SessionID.class); final StatefulEJBLocator<?> statefulEJBLocator; final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) componentView.getComponent(); if (sessionID == null) { statefulEJBLocator = EJBClient.createSession(StatelessEJBLocator.create(componentView.getViewClass(), identifier, Affinity.LOCAL)); } else { statefulEJBLocator = StatefulEJBLocator.create(componentView.getViewClass(), identifier, sessionID, statefulSessionComponent.getCache().getStrictAffinity()); } final Object ejbProxy = EJBClient.createProxy(statefulEJBLocator); return new ValueManagedReference(new ImmediateValue<Object>(ejbProxy)); }
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; }
if (stateful) { try { proxy = EJBClient.createSessionProxy(statelessLocator, providerEnvironment.getAuthenticationContextSupplier(), namingProvider); } catch (Exception e) { throw Logs.MAIN.lookupFailed(name, name, e); proxy = EJBClient.createProxy(statelessLocator, providerEnvironment.getAuthenticationContextSupplier()); if (namingProvider != null) EJBClient.putProxyAttachment(proxy, Keys.NAMING_PROVIDER_ATTACHMENT_KEY, namingProvider); EJBClient.putProxyAttachment(proxy, ClusterAffinityInterest.KEY, baseAffinity); EJBClient.setInvocationTimeout(proxy, invocationTimeout.longValue(), TimeUnit.MILLISECONDS);
/** * Create a new EJB session. * * @param statelessLocator the stateless locator identifying the stateful EJB * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ public static <T> StatefulEJBLocator<T> createSession(StatelessEJBLocator<T> statelessLocator) throws Exception { return createSession(statelessLocator, null); }
@Override public Object handleLookupReturnInstance(Object instance) { if (instance == null) { return null; } if (!EJBClient.isEJBProxy(instance)) { return instance; } final EJBLocator ejbLocator = EJBClient.getLocatorFor(instance); // recreate the proxy by associating it with the EJB client context identifier applicable for this // remote naming context return EJBClient.createProxy(ejbLocator, this.ejbClientContextIdentifier); }
final SessionID sessionID = SessionID.createSessionID(encoded); final Object invokedProxy = context.getInvokedProxy(); EJBClient.convertToStateful(invokedProxy, sessionID); context.setLocator(EJBClient.getLocatorFor(invokedProxy));
if (EJBClient.isEJBProxy(object)) { return createIIOPReferenceForBean(object, deploymentRepository); } else if (object instanceof EJBHandle) { pk = metadata.getPrimaryKeyClass(); final EJBLocator<?> locator = EJBClient.getLocatorFor(metadata.getEJBHome()); final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository); return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
/** * @param ejbProxy The EJB proxy * @throws IllegalArgumentException If the passed proxy is not an EJB proxy */ SerializableEJBProxyWithEJBClientContextIdentifier(final Object ejbProxy) { // we hold on to the EJB locator and the EJB client context identifier this.ejbLocator = EJBClient.getLocatorFor(ejbProxy); this.ejbClientContextIdentifier = EJBClient.getEJBClientContextIdentifierFor(ejbProxy); }
/** * Create a new EJB session proxy. The returned proxy will be cluster-aware if a cluster affinity is used in the locator. * * @param statelessLocator the stateless locator identifying the stateful EJB * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ public static <T> T createSessionProxy(final StatelessEJBLocator<T> statelessLocator) throws Exception { return createSessionProxy(statelessLocator, null, null); }
@Override public Writer getObjectWriter(Object o) throws IOException { if (o == null) { return null; } // we just care about EJB proxies if (!EJBClient.isEJBProxy(o)) { return null; } return EJBClientContextIdentifierWriter.INSTANCE; }
} else { EJBClient.setFutureResult(invocationContext.getFutureResponse()); return null;
if (stateful) { try { proxy = EJBClient.createSessionProxy(statelessLocator, providerEnvironment.getAuthenticationContextSupplier(), namingProvider); } catch (Exception e) { throw Logs.MAIN.lookupFailed(name, name, e); proxy = EJBClient.createProxy(statelessLocator, providerEnvironment.getAuthenticationContextSupplier()); if (namingProvider != null) EJBClient.putProxyAttachment(proxy, Keys.NAMING_PROVIDER_ATTACHMENT_KEY, namingProvider); EJBClient.putProxyAttachment(proxy, ClusterAffinityInterest.KEY, baseAffinity); EJBClient.setInvocationTimeout(proxy, invocationTimeout.longValue(), TimeUnit.MILLISECONDS);
/** * Create a new EJB session. * * @param viewType the view type class * @param appName the application name * @param moduleName the module name * @param beanName the EJB name * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ public static <T> StatefulEJBLocator<T> createSession(final Class<T> viewType, final String appName, final String moduleName, final String beanName) throws Exception { return createSession(new StatelessEJBLocator<T>(viewType, appName, moduleName, beanName, Affinity.NONE)); }
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; }
final SessionID sessionID = SessionID.createSessionID(encoded); final Object invokedProxy = context.getInvokedProxy(); EJBClient.convertToStateful(invokedProxy, sessionID); context.setLocator(EJBClient.getLocatorFor(invokedProxy));
if (EJBClient.isEJBProxy(object)) { return createIIOPReferenceForBean(object, deploymentRepository); } else if (object instanceof EJBHandle) { pk = metadata.getPrimaryKeyClass(); final EJBLocator<?> locator = EJBClient.getLocatorFor(metadata.getEJBHome()); final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository); return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
/** * Create a new EJB session proxy. The returned proxy will be cluster-aware if a cluster affinity is used in the locator. * * @param statelessLocator the stateless locator identifying the stateful EJB * @param <T> the view type * @return the new EJB locator * @throws CreateException if an error occurs */ public static <T> T createSessionProxy(final StatelessEJBLocator<T> statelessLocator) throws Exception { return createSessionProxy(statelessLocator, null, null); }
/** * {@inheritDoc} */ @Override public Object writeReplace(Object object) { return EJBClient.isEJBProxy(object) ? new SerializableEJBProxy(object) : object; } }