use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class SessionBeanObjectViewConfigurator method configure.
@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);
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class EJBDefaultSecurityDomainProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
if (eeModuleDescription == null) {
return;
}
final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions();
if (componentDescriptions == null || componentDescriptions.isEmpty()) {
return;
}
final String defaultSecurityDomain;
if (eeModuleDescription.getDefaultSecurityDomain() == null) {
defaultSecurityDomain = this.defaultSecurityDomainName;
} else {
defaultSecurityDomain = eeModuleDescription.getDefaultSecurityDomain();
}
String knownSecurityDomainName = null;
boolean gotKnownSecurityDomain = false;
for (ComponentDescription componentDescription : componentDescriptions) {
if (componentDescription instanceof EJBComponentDescription) {
EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentDescription;
ejbComponentDescription.setDefaultSecurityDomain(defaultSecurityDomain);
ejbComponentDescription.setKnownSecurityDomainFunction(knownSecurityDomain);
ejbComponentDescription.setOutflowSecurityDomainsConfigured(outflowSecurityDomainsConfigured);
// Ensure the EJB components within a deployment are associated with at most one Elytron security domain
if (ejbComponentDescription.isSecurityDomainKnown()) {
if (!gotKnownSecurityDomain) {
knownSecurityDomainName = ejbComponentDescription.getSecurityDomain();
gotKnownSecurityDomain = true;
} else if (!knownSecurityDomainName.equals(ejbComponentDescription.getSecurityDomain())) {
throw EjbLogger.ROOT_LOGGER.multipleSecurityDomainsDetected();
}
}
}
}
// If this EJB deployment is associated with an Elytron security domain, set up the security domain mapping
if (knownSecurityDomainName != null && !knownSecurityDomainName.isEmpty()) {
final EJBSecurityDomainService ejbSecurityDomainService = new EJBSecurityDomainService(deploymentUnit);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
ServiceName serviceName = deploymentUnit.getServiceName().append(EJBSecurityDomainService.SERVICE_NAME);
final ServiceBuilder<Void> builder = phaseContext.getServiceTarget().addService(serviceName, ejbSecurityDomainService).addDependency(support.getCapabilityServiceName(ApplicationSecurityDomainDefinition.APPLICATION_SECURITY_DOMAIN_CAPABILITY, knownSecurityDomainName), ApplicationSecurityDomain.class, ejbSecurityDomainService.getApplicationSecurityDomainInjector());
builder.install();
for (final ComponentDescription componentDescription : componentDescriptions) {
if (componentDescription instanceof EJBComponentDescription) {
componentDescription.getConfigurators().add((context, description, configuration) -> configuration.getCreateDependencies().add((serviceBuilder, service) -> serviceBuilder.addDependency(serviceName)));
}
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class EJBComponentDescription method addTransactionManagerDependencies.
/**
* Sets up a {@link ComponentConfigurator} which then sets up the relevant dependencies on the transaction manager services for the {@link EJBComponentCreateService}
*/
protected void addTransactionManagerDependencies() {
this.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration componentConfiguration) throws DeploymentUnitProcessingException {
componentConfiguration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final EJBComponentCreateService ejbComponentCreateService) throws DeploymentUnitProcessingException {
// add dependency on transaction manager
serviceBuilder.addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, ejbComponentCreateService.getTransactionManagerInjector());
// add dependency on UserTransaction
serviceBuilder.addDependency(TxnServices.JBOSS_TXN_USER_TRANSACTION, UserTransaction.class, ejbComponentCreateService.getUserTransactionInjector());
// add dependency on TransactionSynchronizationRegistry
serviceBuilder.addDependency(TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY, TransactionSynchronizationRegistry.class, ejbComponentCreateService.getTransactionSynchronizationRegistryInjector());
}
});
}
});
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class StatelessComponentDescription method setupViewInterceptors.
@Override
protected void setupViewInterceptors(EJBViewDescription view) {
// let super do its job first
super.setupViewInterceptors(view);
addViewSerializationInterceptor(view);
// add the instance associating interceptor at the start of the interceptor chain
view.getConfigurators().addFirst(new ViewConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
//add equals/hashCode interceptor
for (Method method : configuration.getProxyFactory().getCachedMethods()) {
if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) {
configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE);
}
}
// add the stateless component instance associating interceptor
configuration.addViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
}
});
if (view instanceof EJBViewDescription) {
EJBViewDescription ejbViewDescription = (EJBViewDescription) view;
if (ejbViewDescription.getMethodIntf() == MethodIntf.REMOTE) {
view.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final String earApplicationName = componentConfiguration.getComponentDescription().getModuleDescription().getEarApplicationName();
configuration.setViewInstanceFactory(new StatelessRemoteViewInstanceFactory(earApplicationName, componentConfiguration.getModuleName(), componentConfiguration.getComponentDescription().getModuleDescription().getDistinctName(), componentConfiguration.getComponentName()));
}
});
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class StatelessComponentDescription method addViewSerializationInterceptor.
private void addViewSerializationInterceptor(final ViewDescription view) {
view.setSerializable(true);
view.setUseWriteReplace(true);
view.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class);
for (Method method : (Collection<Method>) classIndex.getMethods()) {
configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE);
}
}
});
}
Aggregations