use of org.jboss.as.ee.component.ComponentConfiguration in project wildfly by wildfly.
the class WSComponentDescription method createConfiguration.
@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
final ComponentConfiguration cc = super.createConfiguration(classIndex, moduleClassLoader, moduleLoader);
cc.setComponentCreateServiceFactory(WSComponentCreateServiceFactory.INSTANCE);
return cc;
}
use of org.jboss.as.ee.component.ComponentConfiguration in project wildfly by wildfly.
the class ComponentInstallProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(MODULE);
final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
if (module == null || moduleConfiguration == null) {
return;
}
ComponentRegistry componentRegistry = deploymentUnit.getAttachment(COMPONENT_REGISTRY);
final List<ServiceName> dependencies = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES);
final ServiceName bindingDependencyService = JndiNamingDependencyProcessor.serviceName(deploymentUnit.getServiceName());
// Iterate through each component, installing it into the container
for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
try {
ROOT_LOGGER.tracef("Installing component %s", configuration.getComponentClass().getName());
deployComponent(phaseContext, configuration, dependencies, bindingDependencyService);
componentRegistry.addComponent(configuration);
//we need to make sure that the web deployment has a dependency on all components it the app, so web components are started
//when the web subsystem is starting
//we only add a dependency on components in the same sub deployment, otherwise we get circular dependencies when initialize-in-order is used
deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.WEB_DEPENDENCIES, configuration.getComponentDescription().getStartServiceName());
} catch (Exception e) {
throw EeLogger.ROOT_LOGGER.failedToInstallComponent(e, configuration.getComponentName());
}
}
}
use of org.jboss.as.ee.component.ComponentConfiguration in project wildfly by wildfly.
the class AsynchronousMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
final SessionBeanMetaData data = description.getDescriptorData();
final boolean isSecurityDomainKnown = description.isSecurityDomainKnown();
if (data != null) {
if (data instanceof SessionBean31MetaData) {
final SessionBean31MetaData sessionBeanData = (SessionBean31MetaData) data;
final AsyncMethodsMetaData async = sessionBeanData.getAsyncMethods();
if (async != null) {
for (AsyncMethodMetaData method : async) {
final Collection<Method> methods = MethodResolutionUtils.resolveMethods(method.getMethodName(), method.getMethodParams(), componentClass, deploymentReflectionIndex);
for (final Method m : methods) {
description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(m));
}
}
}
}
}
if (!description.getAsynchronousClasses().isEmpty() || !description.getAsynchronousMethods().isEmpty()) {
//setup a dependency on the executor service
description.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
configuration.getCreateDependencies().add(new DependencyConfigurator<SessionBeanComponentCreateService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final SessionBeanComponentCreateService service) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(asynchronousThreadPoolService, ExecutorService.class, service.getAsyncExecutorService());
}
});
}
});
for (final ViewDescription view : description.getViews()) {
final EJBViewDescription ejbView = (EJBViewDescription) view;
ejbView.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
//we need the component method to get the correct declaring class
final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method);
if (componentMethod != null) {
if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) {
addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
configuration.addAsyncMethod(method);
} else {
MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method);
if (componentDescription.getAsynchronousMethods().contains(id)) {
addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
configuration.addAsyncMethod(method);
}
}
}
}
}
});
}
}
}
use of org.jboss.as.ee.component.ComponentConfiguration in project wildfly by wildfly.
the class StartupAwaitDeploymentUnitProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
if (component instanceof EJBComponentDescription) {
component.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) {
StartupCountdown countdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN);
for (ViewConfiguration view : configuration.getViews()) {
EJBViewConfiguration ejbView = (EJBViewConfiguration) view;
if (INTFS.contains(ejbView.getMethodIntf())) {
ejbView.addViewInterceptor(new ImmediateInterceptorFactory(new StartupAwaitInterceptor(countdown)), InterceptorOrder.View.STARTUP_AWAIT_INTERCEPTOR);
}
}
}
});
}
}
}
use of org.jboss.as.ee.component.ComponentConfiguration in project wildfly by wildfly.
the class SessionBeanMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
if (SessionBean.class.isAssignableFrom(componentClass)) {
// add the setSessionContext(SessionContext) method invocation interceptor for session bean implementing the javax.ejb.SessionContext
// interface
description.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
if (SessionBean.class.isAssignableFrom(configuration.getComponentClass())) {
configuration.addPostConstructInterceptor(SessionBeanSetSessionContextMethodInvocationInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.EJB_SET_CONTEXT_METHOD_INVOCATION_INTERCEPTOR);
}
}
});
//now lifecycle callbacks
final MethodIdentifier ejbRemoveIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbRemove");
final MethodIdentifier ejbActivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbActivate");
final MethodIdentifier ejbPassivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbPassivate");
boolean ejbActivate = false, ejbPassivate = false, ejbRemove = false;
Class<?> c = componentClass;
while (c != null && c != Object.class) {
final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(c);
if (!ejbActivate) {
final Method method = index.getMethod(ejbActivateIdentifier);
if (method != null) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
builder.setPostActivate(ejbActivateIdentifier);
description.addInterceptorMethodOverride(c.getName(), builder.build());
ejbActivate = true;
}
}
if (!ejbPassivate) {
final Method method = index.getMethod(ejbPassivateIdentifier);
if (method != null) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
builder.setPrePassivate(ejbPassivateIdentifier);
description.addInterceptorMethodOverride(c.getName(), builder.build());
ejbPassivate = true;
}
}
if (!ejbRemove) {
final Method method = index.getMethod(ejbRemoveIdentifier);
if (method != null) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
builder.setPreDestroy(ejbRemoveIdentifier);
description.addInterceptorMethodOverride(c.getName(), builder.build());
ejbRemove = true;
}
}
c = c.getSuperclass();
}
}
}
Aggregations