use of org.jboss.metadata.ejb.spec.MethodMetaData in project wildfly by wildfly.
the class TransactionAttributeMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
// CMT Tx attributes
//DO NOT USE componentConfiguration.getDescriptorData()
//It will return null if there is no <enterprise-beans/> declaration even if there is an assembly descriptor entry
EjbJarMetaData ejbJarMetadata = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetadata != null) {
boolean wildcardAttributeSet = false;
boolean wildcardTimeoutSet = false;
ContainerTransactionMetaData global = null;
final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
final ContainerTransactionsMetaData globalTransactions = assemblyDescriptor.getContainerTransactionsByEjbName("*");
if (globalTransactions != null) {
if (globalTransactions.size() > 1) {
throw EjbLogger.ROOT_LOGGER.mustOnlyBeSingleContainerTransactionElementWithWildcard();
}
global = globalTransactions.iterator().next();
for (MethodMetaData method : global.getMethods()) {
if (!method.getMethodName().equals("*")) {
throw EjbLogger.ROOT_LOGGER.wildcardContainerTransactionElementsMustHaveWildcardMethodName();
}
}
}
final ContainerTransactionsMetaData containerTransactions = assemblyDescriptor.getContainerTransactionsByEjbName(componentDescription.getEJBName());
if (containerTransactions != null) {
for (final ContainerTransactionMetaData containerTx : containerTransactions) {
final TransactionAttributeType txAttr = containerTx.getTransAttribute();
final Integer timeout = timeout(containerTx);
final MethodsMetaData methods = containerTx.getMethods();
for (final MethodMetaData method : methods) {
final String methodName = method.getMethodName();
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
if (methodName.equals("*")) {
if (txAttr != null) {
wildcardAttributeSet = true;
componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, txAttr);
}
if (timeout != null) {
wildcardTimeoutSet = true;
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
}
} else {
final MethodParametersMetaData methodParams = method.getMethodParams();
// update the session bean description with the tx attribute info
if (methodParams == null) {
if (txAttr != null)
componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, methodName);
if (timeout != null)
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, methodName);
} else {
if (txAttr != null)
componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, null, methodName, this.getMethodParams(methodParams));
if (timeout != null)
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, null, methodName, this.getMethodParams(methodParams));
}
}
}
}
}
}
if (global != null) {
if (!wildcardAttributeSet && global.getTransAttribute() != null) {
for (MethodMetaData method : global.getMethods()) {
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, global.getTransAttribute());
}
}
final Integer timeout = timeout(global);
if (!wildcardTimeoutSet && timeout != null) {
for (MethodMetaData method : global.getMethods()) {
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
}
}
}
}
}
use of org.jboss.metadata.ejb.spec.MethodMetaData in project wildfly by wildfly.
the class MethodPermissionsMergingProcessor method handleExcludeMethods.
private void handleExcludeMethods(final EJBComponentDescription componentDescription, final ExcludeListMetaData excludeList) {
for (final MethodMetaData method : excludeList.getMethods()) {
final String methodName = method.getMethodName();
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
if (methodName.equals("*")) {
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, null, EJBMethodSecurityAttribute.denyAll());
} else {
final MethodParametersMetaData methodParams = method.getMethodParams();
// update the session bean description with the tx attribute info
if (methodParams == null) {
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, EJBMethodSecurityAttribute.denyAll(), methodName);
} else {
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, EJBMethodSecurityAttribute.denyAll(), null, methodName, this.getMethodParams(methodParams));
}
}
}
}
use of org.jboss.metadata.ejb.spec.MethodMetaData in project wildfly by wildfly.
the class MethodPermissionsMergingProcessor method handleMethodPermissions.
private void handleMethodPermissions(final EJBComponentDescription componentDescription, final MethodPermissionsMetaData methodPermissions) {
for (final MethodPermissionMetaData methodPermissionMetaData : methodPermissions) {
final MethodsMetaData methods = methodPermissionMetaData.getMethods();
for (final MethodMetaData method : methods) {
EJBMethodSecurityAttribute ejbMethodSecurityMetaData;
// EJB 3.1 FR 17.3.2.2 The unchecked element is used instead of a role name in the method-permission element to indicate that all roles are permitted.
if (methodPermissionMetaData.isNotChecked()) {
ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.permitAll();
} else {
ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.rolesAllowed(methodPermissionMetaData.getRoles());
}
final String methodName = method.getMethodName();
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
if (methodName.equals("*")) {
final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle1(methodIntf, null);
ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, null, ejbMethodSecurityMetaData);
} else {
final MethodParametersMetaData methodParams = method.getMethodParams();
// update the session bean description with the tx attribute info
if (methodParams == null) {
final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle2(methodIntf, methodName);
ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, methodName);
} else {
final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle3(methodIntf, null, methodName, this.getMethodParams(methodParams));
ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, null, methodName, this.getMethodParams(methodParams));
}
}
}
}
}
Aggregations