use of org.jboss.as.ee.component.ComponentDescription in project wildfly by wildfly.
the class EjbDependsOnMergingProcessor method setupDependencies.
private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException {
for (final String annotationValue : annotationValues) {
final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot());
if (components.isEmpty()) {
throw EjbLogger.ROOT_LOGGER.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName());
} else if (components.size() != 1) {
throw EjbLogger.ROOT_LOGGER.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components);
}
final ComponentDescription component = components.iterator().next();
description.addDependency(component.getStartServiceName(), DependencyType.REQUIRED);
if (description instanceof SingletonComponentDescription) {
((SingletonComponentDescription) description).getDependsOn().add(component.getStartServiceName());
if (ROOT_LOGGER.isDebugEnabled()) {
ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName());
}
}
}
}
use of org.jboss.as.ee.component.ComponentDescription in project wildfly by wildfly.
the class DefaultJMSConnectionFactoryBindingProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(EAR, deploymentUnit)) {
return;
}
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
final String defaultJMSConnectionFactory = moduleDescription.getDefaultResourceJndiNames().getJmsConnectionFactory();
if (defaultJMSConnectionFactory == null) {
return;
}
final LookupInjectionSource injectionSource = new LookupInjectionSource(defaultJMSConnectionFactory);
if (DeploymentTypeMarker.isType(WAR, deploymentUnit)) {
moduleDescription.getBindingConfigurations().add(new BindingConfiguration(MODULE_DEFAULT_JMS_CONNECTION_FACTORY, injectionSource));
} else {
if (DeploymentTypeMarker.isType(APPLICATION_CLIENT, deploymentUnit)) {
moduleDescription.getBindingConfigurations().add(new BindingConfiguration(COMP_DEFAULT_JMS_CONNECTION_FACTORY, injectionSource));
}
for (ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
if (componentDescription.getNamingMode() == ComponentNamingMode.CREATE) {
componentDescription.getBindingConfigurations().add(new BindingConfiguration(COMP_DEFAULT_JMS_CONNECTION_FACTORY, injectionSource));
}
}
}
}
use of org.jboss.as.ee.component.ComponentDescription 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.ComponentDescription in project wildfly by wildfly.
the class MessageDrivenComponentDescription method createConfiguration.
@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
final ComponentConfiguration mdbComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
// setup the component create service
final Class<?> messageListenerInterface;
try {
messageListenerInterface = Class.forName(getMessageListenerInterfaceName(), true, moduleClassLoader);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
mdbComponentConfiguration.setComponentCreateServiceFactory(new MessageDrivenComponentCreateServiceFactory(messageListenerInterface));
// setup the configurator to inject the PoolConfig in the MessageDrivenComponentCreateService
final MessageDrivenComponentDescription mdbComponentDescription = (MessageDrivenComponentDescription) mdbComponentConfiguration.getComponentDescription();
mdbComponentConfiguration.getCreateDependencies().add(new PoolInjectingConfigurator(mdbComponentDescription));
// setup the configurator to inject the resource adapter
mdbComponentConfiguration.getCreateDependencies().add(new ResourceAdapterInjectingConfiguration());
mdbComponentConfiguration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final MessageDrivenComponentCreateService mdbComponentCreateService) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(EJBUtilities.SERVICE_NAME, EJBUtilities.class, mdbComponentCreateService.getEJBUtilitiesInjector());
serviceBuilder.addDependency(SuspendController.SERVICE_NAME, SuspendController.class, mdbComponentCreateService.getSuspendControllerInjectedValue());
}
});
// add the bmt interceptor
if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) {
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
// add the bmt interceptor factory
configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
}
});
} else {
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
}
});
}
return mdbComponentConfiguration;
}
use of org.jboss.as.ee.component.ComponentDescription 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());
}
});
}
});
}
}
}
Aggregations