@Override public ManagedReference run() throws Exception { return view.createInstance(contextData); } });
@Override public String getInstanceClassName() { return view.getComponent().getComponentClass().getName(); }
public Object processInvocation(final InterceptorContext context) throws Exception { ComponentView view = context.getPrivateData(ComponentView.class); return view.invoke(context); } });
@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)); }
final String viewClassOfInvokedMethod = componentView.getViewClass().getName(); final MethodInterfaceType methodIntfType = this.getMethodInterfaceType(componentView.getPrivateData(MethodIntf.class)); if (!securityManager.authorize(ejbComponent.getComponentName(), componentView.getProxyClass().getProtectionDomain().getCodeSource(), methodIntfType.name(), this.viewMethod, this.getMethodRolesAsPrincipals(), this.contextID)) { throw EjbLogger.ROOT_LOGGER.invocationOfMethodNotAllowed(invokedMethod,ejbComponent.getComponentName());
interceptorContext.setParameters(content.getParameters()); interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); interceptorContext.putPrivateData(ComponentView.class, componentView); interceptorContext.putPrivateData(InvocationType.class, InvocationType.REMOTE); final boolean isAsync = componentView.isAsynchronous(method); final boolean oneWay = isAsync && method.getReturnType() == void.class; final boolean isSessionBean = componentView.getComponent() instanceof SessionBeanComponent; if (isAsync && isSessionBean) { if (! oneWay) {
final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods()); final InterceptorContext context = new InterceptorContext(); prepareForInvocation(context, wsInvocation); context.setParameters(wsInvocation.getArgs()); context.setTarget(reference.getInstance()); context.putPrivateData(Component.class, componentView.getComponent()); context.putPrivateData(ComponentView.class, componentView); final Object retObj = componentView.invoke(context);
final ObjectCloner parameterCloner = createCloner(paramConfig); final Method method = view.getMethod(invocation.getInvokedMethod().getName(), DescriptorUtils.methodDescriptor(invocation.getInvokedMethod())); final boolean async = view.isAsynchronous(method) || invocation.isClientAsync(); final CancellationFlag flag = new CancellationFlag(); final SessionBeanComponent component = (SessionBeanComponent) ejbComponent; final boolean isAsync = view.isAsynchronous(method); final boolean oneWay = isAsync && method.getReturnType() == void.class; final boolean isSessionBean = view.getComponent() instanceof SessionBeanComponent; if (isAsync && isSessionBean) { if (! oneWay) { final Object result; try { result = view.invoke(interceptorContext); } catch (Exception e) { final Object result; try { result = view.invoke(interceptorContext); } catch (Exception e) {
throw new BAD_OPERATION(opName); final NamespaceContextSelector selector = componentView.getComponent().getNamespaceContextSelector(); final ClassLoader oldCl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); NamespaceContextSelector.pushCurrentSelector(selector); try { final AuthenticationContext context = AuthenticationContext.captureCurrent().with(MatchRule.ALL.matchProtocol("iiop"), authenticationConfiguration); retVal = identity.runAs((PrivilegedExceptionAction<Object>) () -> context.run((PrivilegedExceptionAction<Object>) () -> this.componentView.invoke(interceptorContext))); } catch (PrivilegedActionException e) { throw e.getCause(); retVal = this.componentView.invoke(interceptorContext); } finally { if (legacyContext != null) {
interceptorContext.setParameters(args); interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); interceptorContext.putPrivateData(ComponentView.class, componentView); interceptorContext.putPrivateData(InvocationType.class, InvocationType.REMOTE); interceptorContext.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, primaryKey); if (componentView.isAsynchronous(method)) { final Component component = componentView.getComponent(); if (!(component instanceof SessionBeanComponent)) { EjbLogger.EJB3_LOGGER.asyncMethodSupportedOnlyForSessionBeans(component.getComponentClass(), method); return componentView.invoke(interceptorContext); return ((Future)componentView.invoke(interceptorContext)).get(); } finally { return componentView.invoke(interceptorContext);
@Override public Object processInvocation(InterceptorContext context) throws Exception { final ComponentView componentView = context.getPrivateData(ComponentView.class); if (componentView == null) { throw EjbLogger.ROOT_LOGGER.componentViewNotAvailableInContext(context); } return "Proxy for view class: " + componentView.getViewClass().getName() + " of EJB: " + name; } }
final Method method = view.getMethod(invocation.getInvokedMethod().getName(), DescriptorUtils.methodDescriptor(invocation.getInvokedMethod())); final boolean async = view.isAsynchronous(method); final Object result; try { result = view.invoke(context); } catch (Exception e) {
private static Method findMethod(final ComponentView componentView, final EJBMethodLocator ejbMethodLocator) { final Set<Method> viewMethods = componentView.getViewMethods(); for (final Method method : viewMethods) { if (method.getName().equals(ejbMethodLocator.getMethodName())) { final Class<?>[] methodParamTypes = method.getParameterTypes(); if (methodParamTypes.length != ejbMethodLocator.getParameterCount()) { continue; } boolean found = true; for (int i = 0; i < methodParamTypes.length; i++) { if (!methodParamTypes[i].getName().equals(ejbMethodLocator.getParameterTypeName(i))) { found = false; break; } } if (found) { return method; } } } return null; }
Component component = componentView.getComponent(); final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods()); final InterceptorContext context = new InterceptorContext(); prepareForInvocation(context, wsInvocation); final Object retObj = componentView.invoke(context);
throw new BAD_OPERATION(opName); final NamespaceContextSelector selector = componentView.getComponent().getNamespaceContextSelector(); final ClassLoader oldCl = SecurityActions.getContextClassLoader(); NamespaceContextSelector.pushCurrentSelector(selector); retVal = componentView.invoke(interceptorContext); } finally { if (sc != null) {
@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(componentView.getViewClass(), applicationName, moduleName, beanName, distinctName); } else { statefulEJBLocator = new StatefulEJBLocator(componentView.getViewClass(), applicationName, moduleName, beanName, distinctName, sessionID, statefulSessionComponent.getCache().getStrictAffinity()); } final Object ejbProxy = EJBClient.createProxy(statefulEJBLocator); return new ValueManagedReference(new ImmediateValue(ejbProxy)); }
final boolean isAsync = componentView.isAsynchronous(invokedMethod); if (componentView.getComponent() instanceof StatefulSessionComponent && exception instanceof EJBException && cause != null) { if (!(componentView.getComponent().isRemotable(cause))) {
public Class<?> getInvokedBusinessInterface() throws IllegalStateException { final InterceptorContext invocation = CurrentInvocationContext.get(); final ComponentView view = invocation.getPrivateData(ComponentView.class); if (view.getViewClass().equals(getComponent().getEjbObjectType()) || view.getViewClass().equals(getComponent().getEjbLocalObjectType())) { throw EjbLogger.ROOT_LOGGER.cannotCall("getInvokedBusinessInterface", "EjbObject", "EJBLocalObject"); } return view.getViewClass(); }
@Override public Object processInvocation(InterceptorContext context) throws Exception { final Component component = context.getPrivateData(Component.class); if (component instanceof EJBComponent == false) { throw MESSAGES.unexpectedComponent(component,EJBComponent.class); } final Method invokedMethod = context.getMethod(); final ComponentView componentView = context.getPrivateData(ComponentView.class); final String viewClassOfInvokedMethod = componentView.getViewClass().getName(); // shouldn't really happen if the interceptor was setup correctly. But let's be safe and do a check if (!this.viewClassName.equals(viewClassOfInvokedMethod) || !this.viewMethod.equals(invokedMethod)) { throw MESSAGES.failProcessInvocation(this.getClass().getName(), invokedMethod,viewClassOfInvokedMethod, viewMethod, viewClassName); } final EJBComponent ejbComponent = (EJBComponent) component; final ServerSecurityManager securityManager = ejbComponent.getSecurityManager(); final MethodInterfaceType methodIntfType = this.getMethodInterfaceType(componentView.getPrivateData(MethodIntf.class)); // set the JACC contextID before calling the security manager. final String previousContextID = setContextID(this.contextID); try { if (!securityManager.authorize(ejbComponent.getComponentName(), componentView.getProxyClass().getProtectionDomain().getCodeSource(), methodIntfType.name(), this.viewMethod, this.getMethodRolesAsPrincipals(), this.contextID)) throw MESSAGES.invocationOfMethodNotAllowed(invokedMethod,ejbComponent.getComponentName()); } finally { // reset the previous JACC contextID. setContextID(previousContextID); } // successful authorization, let the invocation proceed return context.proceed(); }
private Method findMethod(final ComponentView componentView, final String methodName, final String[] paramTypes) { final Set<Method> viewMethods = componentView.getViewMethods(); for (final Method method : viewMethods) { if (method.getName().equals(methodName)) { final Class<?>[] methodParamTypes = method.getParameterTypes(); if (methodParamTypes.length != paramTypes.length) { continue; } boolean found = true; for (int i = 0; i < methodParamTypes.length; i++) { if (!methodParamTypes[i].getName().equals(paramTypes[i])) { found = false; break; } } if (found) { return method; } } } return null; }