protected void processTxAttr( final EJBComponentDescription ejbComponentDescription, final MethodIntf methodIntf, final Method method) { if (this.getTransactionManagementType().equals(TransactionManagementType.BEAN)) { // it's a BMT bean return; } MethodIntf defaultMethodIntf = (ejbComponentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN; TransactionAttributeType txAttr = ejbComponentDescription .getTransactionAttributes() .getAttribute(methodIntf, method, defaultMethodIntf); if (txAttr != null) { txAttrs.put( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txAttr); } Integer txTimeout = ejbComponentDescription .getTransactionTimeouts() .getAttribute(methodIntf, method, defaultMethodIntf); if (txTimeout != null) { txTimeouts.put( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txTimeout); } }
public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Create method indexes final DeploymentReflectionIndex reflectionIndex = context.getDeploymentUnit().getAttachment(REFLECTION_INDEX); final List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (final Method method : methods) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); Method componentMethod = ClassReflectionIndexUtil.findMethod( reflectionIndex, componentConfiguration.getComponentClass(), methodIdentifier); if (componentMethod != null) { if ((BRIDGE & componentMethod.getModifiers()) != 0) { Collection<Method> otherMethods = ClassReflectionIndexUtil.findMethods( reflectionIndex, reflectionIndex.getClassIndex(componentConfiguration.getComponentClass()), methodIdentifier.getName(), methodIdentifier.getParameterTypes()); // try and find the non-bridge method to delegate to for (final Method other : otherMethods) { if ((BRIDGE & other.getModifiers()) == 0) { componentMethod = other; break; } } } configuration.addViewInterceptor( method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor( method, CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } } configuration.addClientPostConstructInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }
public int getTransactionTimeout(final MethodIntf methodIntf, final Method method) { Integer txTimeout = txTimeouts.get( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method))); if (txTimeout == null && methodIntf != MethodIntf.BEAN) { txTimeout = txTimeouts.get( new MethodTransactionAttributeKey( MethodIntf.BEAN, MethodIdentifier.getIdentifierForMethod(method))); } if (txTimeout == null) return -1; return txTimeout; }
public TransactionAttributeType getTransactionAttributeType( final MethodIntf methodIntf, final Method method) { TransactionAttributeType txAttr = txAttrs.get( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method))); // fall back to type bean if not found if (txAttr == null && methodIntf != MethodIntf.BEAN) { txAttr = txAttrs.get( new MethodTransactionAttributeKey( MethodIntf.BEAN, MethodIdentifier.getIdentifierForMethod(method))); } if (txAttr == null) return TransactionAttributeType.REQUIRED; return txAttr; }
private void clearUnknownProperties( final DeploymentReflectionIndex reflectionIndex, final Class<?> dataSourceClass, final Map<String, String> props) { final Iterator<Map.Entry<String, String>> it = props.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, String> entry = it.next(); String value = entry.getKey(); if (value == null || "".equals(value)) { it.remove(); } else { StringBuilder builder = new StringBuilder("set").append(entry.getKey()); builder.setCharAt(3, Character.toUpperCase(entry.getKey().charAt(0))); final String methodName = builder.toString(); final Class<?> paramType = value.getClass(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType); final Method setterMethod = ClassReflectionIndexUtil.findMethod(reflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod == null) { it.remove(); ConnectorLogger.DS_DEPLOYER_LOGGER.methodNotFoundOnDataSource( methodName, dataSourceClass); } } } }
public TransactionAttributeType getTransactionAttributeType( MethodIntf methodIntf, Method method) { TransactionAttributeType txAttr = txAttrs.get( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method))); if (txAttr == null) return TransactionAttributeType.REQUIRED; return txAttr; }
public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Create method indexes final DeploymentReflectionIndex reflectionIndex = context.getDeploymentUnit().getAttachment(REFLECTION_INDEX); final List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (final Method method : methods) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); Method componentMethod = ClassReflectionIndexUtil.findMethod( reflectionIndex, componentConfiguration.getComponentClass(), methodIdentifier); if (componentMethod == null && method.getDeclaringClass().isInterface() && (method.getModifiers() & (ABSTRACT | PUBLIC | STATIC)) == PUBLIC) { // no component method and the interface method is defaulted, so we really do want to // invoke on the interface method componentMethod = method; } if (componentMethod != null) { if ((BRIDGE & componentMethod.getModifiers()) != 0) { Method other = findRealMethodForBridgeMethod( componentMethod, componentConfiguration, reflectionIndex, methodIdentifier); // try and find the non-bridge method to delegate to if (other != null) { componentMethod = other; } } configuration.addViewInterceptor( method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor( method, CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } } configuration.addClientPostConstructInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }
private void setProperty( final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> dataSourceClass, final Map<String, String> properties, final String name, final Object value) { // Ignore defaulted values if (value == null) return; if (value instanceof String && "".equals(value)) return; if (value instanceof Integer && ((Integer) value).intValue() == -1) return; StringBuilder builder = new StringBuilder("set").append(name); builder.setCharAt(3, Character.toUpperCase(name.charAt(0))); final String methodName = builder.toString(); final Class<?> paramType = value.getClass(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType); Method setterMethod = ClassReflectionIndexUtil.findMethod( deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } else if (paramType == Integer.class) { // if this is an Integer also look for int setters (WFLY-1364) methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, int.class); setterMethod = ClassReflectionIndexUtil.findMethod( deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } } else if (paramType == Boolean.class) { methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, boolean.class); setterMethod = ClassReflectionIndexUtil.findMethod( deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } } }
protected void processTxAttr( final EJBComponentDescription ejbComponentDescription, final MethodIntf methodIntf, final Method method) { if (this.getTransactionManagementType().equals(TransactionManagementType.BEAN)) { // it's a BMT bean return; } TransactionAttributeType txAttr = ejbComponentDescription.getTransactionAttributes().getAttribute(methodIntf, method); txAttrs.put( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txAttr); Integer txTimeout = ejbComponentDescription.getTransactionTimeouts().getAttribute(methodIntf, method); if (txTimeout != null) { txTimeouts.put( new MethodTransactionAttributeKey( methodIntf, MethodIdentifier.getIdentifierForMethod(method)), txTimeout); } }
public int getTransactionTimeout(final MethodIntf methodIntf, final Method method) { return getTransactionTimeout(methodIntf, MethodIdentifier.getIdentifierForMethod(method)); }
public TransactionAttributeType getTransactionAttributeType( final MethodIntf methodIntf, final Method method) { return getTransactionAttributeType(methodIntf, MethodIdentifier.getIdentifierForMethod(method)); }
@Override public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // note that we don't have to handle all methods on the EJBObject, as some are handled client // side final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { if (method.getName().equals("getPrimaryKey") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); configuration.addViewInterceptor( method, PRIMARY_KEY_INTERCEPTOR, InterceptorOrder.View.COMPONENT_DISPATCHER); } else if (method.getName().equals("remove") && method.getParameterTypes().length == 0) { handleRemoveMethod(componentConfiguration, configuration, index, method); } else if (method.getName().equals("getEJBLocalHome") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory(); configuration.addViewInterceptor( method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER); final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); componentConfiguration .getStartDependencies() .add( new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency( final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException { EjbHomeViewDescription ejbLocalHomeView = componentDescription.getEjbLocalHomeView(); if (ejbLocalHomeView == null) { throw EjbLogger.ROOT_LOGGER.beanLocalHomeInterfaceIsNull( componentDescription.getComponentName()); } serviceBuilder.addDependency( ejbLocalHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate()); } }); } else if (method.getName().equals("getEJBHome") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory(); configuration.addViewInterceptor( method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER); final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); componentConfiguration .getStartDependencies() .add( new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency( final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException { EjbHomeViewDescription ejbHomeView = componentDescription.getEjbHomeView(); if (ejbHomeView == null) { throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull( componentDescription.getComponentName()); } serviceBuilder.addDependency( ejbHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate()); } }); } else if (method.getName().equals("getHandle") && method.getParameterTypes().length == 0) { // ignore, handled client side } else if (method.getName().equals("isIdentical") && method.getParameterTypes().length == 1 && (method.getParameterTypes()[0].equals(EJBObject.class) || method.getParameterTypes()[0].equals(EJBLocalObject.class))) { handleIsIdenticalMethod(componentConfiguration, configuration, index, method); } else { final Method componentMethod = ClassReflectionIndexUtil.findMethod( index, componentConfiguration.getComponentClass(), MethodIdentifier.getIdentifierForMethod(method)); if (componentMethod != null) { if (!Modifier.isPublic(componentMethod.getModifiers())) { throw EjbLogger.ROOT_LOGGER.ejbBusinessMethodMustBePublic(componentMethod); } configuration.addViewInterceptor( method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } else if (method.getDeclaringClass() != Object.class && method.getDeclaringClass() != WriteReplaceInterface.class) { throw EjbLogger.ROOT_LOGGER.couldNotFindViewMethodOnEjb( method, description.getViewClassName(), componentConfiguration.getComponentName()); } } } configuration.addClientPostConstructInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }