use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription 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));
}
}
}
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class MdbDeliveryDependenciesProcessor method undeploy.
@Override
public void undeploy(DeploymentUnit deploymentUnit) {
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (moduleConfiguration == null) {
return;
}
final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry();
boolean clusteredSingletonFound = false;
for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
final ComponentDescription description = configuration.getComponentDescription();
if (description instanceof MessageDrivenComponentDescription) {
MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
clusteredSingletonFound = clusteredSingletonFound || mdbDescription.isClusteredSingleton();
if (mdbDescription.isClusteredSingleton() || mdbDescription.getDeliveryGroup() != null) {
serviceRegistry.getRequiredService(mdbDescription.getDeliveryControllerName()).setMode(Mode.REMOVE);
}
}
}
if (clusteredSingletonFound) {
serviceRegistry.getRequiredService(createClusteredSingletonDemanderServiceName(deploymentUnit)).setMode(Mode.REMOVE);
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class MdbDeliveryDependenciesProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (moduleConfiguration == null) {
return;
}
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
boolean clusteredSingletonFound = false;
for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
ComponentDescription description = configuration.getComponentDescription();
if (description instanceof MessageDrivenComponentDescription) {
final MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
if (mdbDescription.isDeliveryControlled()) {
final MdbDeliveryControllerService mdbDeliveryControllerService = new MdbDeliveryControllerService();
final ServiceBuilder<MdbDeliveryControllerService> builder = serviceTarget.addService(mdbDescription.getDeliveryControllerName(), mdbDeliveryControllerService).addDependency(description.getCreateServiceName(), MessageDrivenComponent.class, mdbDeliveryControllerService.getMdbComponent()).setInitialMode(Mode.PASSIVE);
if (mdbDescription.isClusteredSingleton()) {
clusteredSingletonFound = true;
builder.addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName().append("primary"));
}
if (mdbDescription.getDeliveryGroup() != null) {
final ServiceName deliveyGroupServiceName = MdbDeliveryGroupResourceDefinition.getDeliveryGroupServiceName(mdbDescription.getDeliveryGroup());
if (phaseContext.getServiceRegistry().getService(deliveyGroupServiceName) == null) {
throw EjbLogger.DEPLOYMENT_LOGGER.missingMdbDeliveryGroup(mdbDescription.getDeliveryGroup());
}
builder.addDependency(deliveyGroupServiceName);
}
builder.install();
}
}
}
if (clusteredSingletonFound) {
// trigger the start of the clustered singleton capability, since our service above is PASSIVE, and not ACTIVE
// (the MDB delivery controller won't demand the clustered singleton service to start)
serviceTarget.addService(createClusteredSingletonDemanderServiceName(deploymentUnit), Service.NULL).addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName()).install();
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class MessageDrivenComponentDescriptionFactory method processMessageDrivenBeanMetaData.
private void processMessageDrivenBeanMetaData(final DeploymentUnit deploymentUnit, final MessageDrivenBeanMetaData mdb) throws DeploymentUnitProcessingException {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final String beanName = mdb.getName();
final String beanClassName = mdb.getEjbClass();
String messageListenerInterface = mdb.getMessagingType();
if (messageListenerInterface == null || messageListenerInterface.trim().isEmpty()) {
// TODO: This isn't really correct to default to MessageListener
messageListenerInterface = MessageListener.class.getName();
}
final Properties activationConfigProps = getActivationConfigProperties(mdb.getActivationConfig());
final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
final MessageDrivenComponentDescription mdbComponentDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName(), messageListenerInterface, activationConfigProps, defaultResourceAdapterName, mdb);
mdbComponentDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", mdb));
addComponent(deploymentUnit, mdbComponentDescription);
}
Aggregations