use of org.jboss.as.server.deployment.DeploymentUnitProcessingException 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.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class EjbJndiBindingsDeploymentUnitProcessor method registerControlPointBinding.
private void registerControlPointBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName, final DeploymentUnit deploymentUnit) {
final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
final InjectedValue<ControlPoint> controlPointInjectedValue = new InjectedValue<>();
final RemoteViewInjectionSource delegate = new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
final ServiceName depName = ControlPointService.serviceName(deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName(), EJBComponentSuspendDeploymentUnitProcessor.ENTRY_POINT_NAME + deploymentUnit.getName() + "." + componentDescription.getComponentName());
componentDescription.getConfigurators().add((context, description, configuration) -> {
viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
configuration.getCreateDependencies().add((serviceBuilder, service) -> serviceBuilder.addDependency(depName, ControlPoint.class, controlPointInjectedValue));
});
//we need to wrap the injection source to allow graceful shutdown to function, although this is not ideal
//as it will also reject local lookups as well, although in general local code should never be looking up the
//exported bindings
//the other option would be to reject it at the remote naming service level, however then we loose the per-deployment granularity
final InjectionSource is = new InjectionSource() {
@Override
public void getResourceValue(ResolutionContext resolutionContext, ServiceBuilder<?> serviceBuilder, DeploymentPhaseContext phaseContext, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
final InjectedValue<ManagedReferenceFactory> delegateInjection = new InjectedValue<>();
delegate.getResourceValue(resolutionContext, serviceBuilder, phaseContext, delegateInjection);
injector.inject(new ManagedReferenceFactory() {
@Override
public ManagedReference getReference() {
ControlPoint cp = controlPointInjectedValue.getValue();
try {
RunResult res = cp.beginRequest();
if (res != RunResult.RUN) {
throw EjbLogger.ROOT_LOGGER.containerSuspended();
}
try {
return delegateInjection.getValue().getReference();
} finally {
cp.requestComplete();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
};
moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, is));
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class MessageDrivenComponentDescription method setupViewInterceptors.
@Override
protected void setupViewInterceptors(EJBViewDescription view) {
// let the super do its job
super.setupViewInterceptors(view);
view.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
//add the invocation type to the start of the chain
//TODO: is there a cleaner way to do this?
configuration.addViewInterceptor(new ImmediateInterceptorFactory(new Interceptor() {
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
context.putPrivateData(InvocationType.class, InvocationType.MESSAGE_DELIVERY);
return context.proceed();
}
}), InterceptorOrder.View.INVOCATION_TYPE);
// add the instance associating interceptor at the start of the interceptor chain
configuration.addViewInterceptor(MessageDrivenComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
final MessageDrivenComponentDescription mdb = (MessageDrivenComponentDescription) componentConfiguration.getComponentDescription();
if (mdb.getTransactionManagementType() == TransactionManagementType.CONTAINER) {
configuration.addViewInterceptor(CMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
}
}
});
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException 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.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class SessionBeanComponentDescription method addNoInterfaceView.
public void addNoInterfaceView() {
noInterfaceViewPresent = true;
final ViewDescription viewDescription = registerView(getEJBClassName(), MethodIntf.LOCAL);
//set up interceptor for non-business methods
viewDescription.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX);
for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
if (!Modifier.isPublic(method.getModifiers()) && isNotOverriden(method, componentConfiguration.getComponentClass(), index)) {
configuration.addClientInterceptor(method, new ImmediateInterceptorFactory(new NotBusinessMethodInterceptor(method)), InterceptorOrder.Client.NOT_BUSINESS_METHOD_EXCEPTION);
}
}
}
});
}
Aggregations