use of org.jboss.as.ejb3.remote.LocalTransportProvider in project wildfly by wildfly.
the class EJBRemoteInvocationPassByValueWriteHandler method updateDefaultLocalEJBReceiverService.
void updateDefaultLocalEJBReceiverService(final OperationContext context, final ModelNode model) throws OperationFailedException {
final ModelNode passByValueModel = this.attributeDefinition.resolveModelAttribute(context, model);
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName localTransportProviderServiceName;
if (passByValueModel.isDefined()) {
final boolean passByValue = passByValueModel.asBoolean(true);
if (passByValue) {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_REFERENCE_SERVICE_NAME;
}
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
}
// uninstall the existing default local EJB receiver service
final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME);
if (existingDefaultLocalEJBReceiverServiceController != null) {
context.removeService(existingDefaultLocalEJBReceiverServiceController);
}
final ServiceTarget serviceTarget = context.getServiceTarget();
// now install the new default local EJB receiver service which points to an existing Local EJB receiver service
final ValueInjectionService<LocalTransportProvider> newDefaultLocalTransportProviderService = new ValueInjectionService<LocalTransportProvider>();
final ServiceBuilder<LocalTransportProvider> defaultLocalEJBReceiverServiceBuilder = serviceTarget.addService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, newDefaultLocalTransportProviderService);
defaultLocalEJBReceiverServiceBuilder.addDependency(localTransportProviderServiceName, LocalTransportProvider.class, newDefaultLocalTransportProviderService.getInjector());
// install the service
defaultLocalEJBReceiverServiceBuilder.install();
}
use of org.jboss.as.ejb3.remote.LocalTransportProvider in project wildfly by wildfly.
the class EJB3SubsystemAdd method addRemoteInvocationServices.
private static void addRemoteInvocationServices(final OperationContext context, final ModelNode ejbSubsystemModel, final boolean appclient) throws OperationFailedException {
final ServiceTarget serviceTarget = context.getServiceTarget();
//add the default EjbClientContext
final EJBClientConfiguratorService clientConfiguratorService = new EJBClientConfiguratorService();
final ServiceBuilder<EJBClientConfiguratorService> configuratorBuilder = serviceTarget.addService(EJBClientConfiguratorService.SERVICE_NAME, clientConfiguratorService);
if (context.hasOptionalCapability(REMOTING_ENDPOINT_CAPABILITY, EJB3SubsystemRootResourceDefinition.EJB_CLIENT_CONFIGURATOR.getName(), null)) {
ServiceName serviceName = context.getCapabilityServiceName(REMOTING_ENDPOINT_CAPABILITY, Endpoint.class);
configuratorBuilder.addDependency(serviceName, Endpoint.class, clientConfiguratorService.getEndpointInjector());
}
configuratorBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
//TODO: This should be managed
final EJBClientContextService clientContextService = new EJBClientContextService(true);
final ServiceBuilder<EJBClientContextService> clientContextServiceBuilder = context.getServiceTarget().addService(EJBClientContextService.DEFAULT_SERVICE_NAME, clientContextService);
clientContextServiceBuilder.addDependency(EJBClientConfiguratorService.SERVICE_NAME, EJBClientConfiguratorService.class, clientContextService.getConfiguratorServiceInjector());
if (appclient) {
clientContextServiceBuilder.addDependency(EJBClientContextService.APP_CLIENT_URI_SERVICE_NAME, URI.class, clientContextService.getAppClientUri());
}
if (!appclient) {
//the default spec compliant EJB receiver
final LocalTransportProvider byValueLocalEjbReceiver = new LocalTransportProvider(false);
ServiceBuilder<LocalTransportProvider> byValueServiceBuilder = serviceTarget.addService(LocalTransportProvider.BY_VALUE_SERVICE_NAME, byValueLocalEjbReceiver).addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, byValueLocalEjbReceiver.getDeploymentRepository()).setInitialMode(ServiceController.Mode.ON_DEMAND);
byValueServiceBuilder.install();
//the receiver for invocations that allow pass by reference
final LocalTransportProvider byReferenceLocalEjbReceiver = new LocalTransportProvider(true);
ServiceBuilder<LocalTransportProvider> byReferenceServiceBuilder = serviceTarget.addService(LocalTransportProvider.BY_REFERENCE_SERVICE_NAME, byReferenceLocalEjbReceiver).addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, byReferenceLocalEjbReceiver.getDeploymentRepository()).setInitialMode(ServiceController.Mode.ON_DEMAND);
byReferenceServiceBuilder.install();
// setup the default local ejb receiver service
EJBRemoteInvocationPassByValueWriteHandler.INSTANCE.updateDefaultLocalEJBReceiverService(context, ejbSubsystemModel);
// add the default local ejb receiver to the client context
clientContextServiceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, clientContextService.getLocalProviderInjector());
}
// install the default EJB client context service
clientContextServiceBuilder.install();
}
Aggregations