use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.
the class EJBComponentDescription method addRemoteTransactionsDependency.
/**
* Adds a dependency for the ComponentConfiguration on the remote transaction service if the EJB exposes at least one remote view
*/
protected void addRemoteTransactionsDependency() {
this.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration componentConfiguration) throws DeploymentUnitProcessingException {
if (this.hasRemoteView((EJBComponentDescription) description)) {
// add a dependency on local transaction service
componentConfiguration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {
@Override
public void configureDependency(ServiceBuilder<?> serviceBuilder, EJBComponentCreateService ejbComponentCreateService) throws DeploymentUnitProcessingException {
CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
// add dependency on the remote transaction service
serviceBuilder.requires(support.getCapabilityServiceName(REMOTE_TRANSACTION_SERVICE_CAPABILITY_NAME));
}
});
}
}
/**
* Returns true if the passed EJB component description has at least one remote view
* @param ejbComponentDescription
* @return
*/
private boolean hasRemoteView(final EJBComponentDescription ejbComponentDescription) {
final Set<ViewDescription> views = ejbComponentDescription.getViews();
for (final ViewDescription view : views) {
if (!(view instanceof EJBViewDescription)) {
continue;
}
final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
if (viewType == MethodIntf.REMOTE || viewType == MethodIntf.HOME) {
return true;
}
}
return false;
}
});
}
use of org.jboss.as.ee.component.ComponentConfigurator 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 {
CapabilityServiceSupport support = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
// add dependency on the local transaction provider
serviceBuilder.requires(support.getCapabilityServiceName(TRANSACTION_GLOBAL_DEFAULT_LOCAL_PROVIDER_CAPABILITY_NAME));
// add dependency on TransactionSynchronizationRegistry
serviceBuilder.addDependency(support.getCapabilityServiceName(TRANSACTION_SYNCHRONIZATION_REGISTRY_CAPABILITY_NAME), TransactionSynchronizationRegistry.class, ejbComponentCreateService.getTransactionSynchronizationRegistryInjector());
}
});
}
});
}
use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.
the class EJBComponentSuspendDeploymentUnitProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext context) {
final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
final String topLevelName;
// check if the controller is installed
if (!RequestControllerActivationMarker.isRequestControllerEnabled(deploymentUnit)) {
return;
}
if (deploymentUnit.getParent() == null) {
topLevelName = deploymentUnit.getName();
} else {
topLevelName = deploymentUnit.getParent().getName();
}
for (ComponentDescription component : deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION).getComponentDescriptions()) {
if (component instanceof EJBComponentDescription) {
final String entryPoint = ENTRY_POINT_NAME + deploymentUnit.getName() + "." + component.getComponentName();
ControlPointService.install(context.getServiceTarget(), topLevelName, entryPoint);
component.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) {
EjbSuspendInterceptor interceptor = null;
ImmediateInterceptorFactory factory = null;
for (ViewConfiguration view : configuration.getViews()) {
EJBViewConfiguration ejbView = (EJBViewConfiguration) view;
if (INTERFACES.contains(ejbView.getMethodIntf())) {
if (factory == null) {
interceptor = new EjbSuspendInterceptor();
factory = new ImmediateInterceptorFactory(interceptor);
}
view.addViewInterceptor(factory, InterceptorOrder.View.GRACEFUL_SHUTDOWN);
}
}
configuration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() {
@Override
public void configureDependency(ServiceBuilder<?> serviceBuilder, EJBComponentCreateService service) {
serviceBuilder.addDependency(ControlPointService.serviceName(topLevelName, entryPoint), ControlPoint.class, service.getControlPointInjector());
}
});
}
});
}
}
}
use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.
the class EjbJndiBindingsDeploymentUnitProcessor method registerRemoteBinding.
private void registerRemoteBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName) {
final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient)));
componentDescription.getConfigurators().add(new ComponentConfigurator() {
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
}
});
}
use of org.jboss.as.ee.component.ComponentConfigurator in project wildfly by wildfly.
the class EEConcurrencyContextHandleFactoryProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (eeModuleDescription == null) {
return;
}
final ComponentConfigurator componentConfigurator = new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, final ComponentConfiguration configuration) {
final TransactionLeakContextHandleFactory transactionLeakContextHandleFactory = new TransactionLeakContextHandleFactory();
context.requires(TransactionManagerService.INTERNAL_SERVICE_NAME, transactionLeakContextHandleFactory.getTransactionManagerSupplier());
configuration.getConcurrentContext().addFactory(transactionLeakContextHandleFactory);
}
};
for (ComponentDescription componentDescription : eeModuleDescription.getComponentDescriptions()) {
componentDescription.getConfigurators().add(componentConfigurator);
}
}
Aggregations