final EJBClientContextService service = new EJBClientContextService(); serviceBuilder.addDependency(EJBClientContextService.APP_CLIENT_URI_SERVICE_NAME, URI.class, service.getAppClientUri()); serviceBuilder.addDependency(EJBClientContextService.APP_CLIENT_EJB_PROPERTIES_SERVICE_NAME, String.class, service.getAppClientEjbProperties()); serviceBuilder.addDependency(EJBClientConfiguratorService.SERVICE_NAME, EJBClientConfiguratorService.class, service.getConfiguratorServiceInjector()); final Injector<EJBTransportProvider> injector = service.getLocalProviderInjector(); boolean injected = false; profileServiceName = RemotingProfileService.BASE_SERVICE_NAME.append(profile); serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, profileServiceInjector); serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, service.getProfileServiceInjector()); } else { serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, service.getProfileServiceInjector()); service.setDeploymentNodeSelector(deploymentNodeSelector); service.setInvocationTimeout(invocationTimeout); service.setClientClusters(clientClusters); service.setClustersAuthenticationContext(clustersAuthenticationContext); serviceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, service.getLocalProviderInjector()); service.setClientInterceptors(ejbClientInterceptors);
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()); clientContextServiceBuilder.addDependency(EJBClientContextService.APP_CLIENT_URI_SERVICE_NAME, URI.class, clientContextService.getAppClientUri()); clientContextServiceBuilder.addDependency(EJBClientContextService.APP_CLIENT_EJB_PROPERTIES_SERVICE_NAME, String.class, clientContextService.getAppClientEjbProperties()); clientContextServiceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, clientContextService.getLocalProviderInjector());
final EJBClientContext ejbClientContext = ejbClientContextService.getClientContext(); final AuthenticationContext ejbClientClustersAuthenticationContext = ejbClientContextService.getClustersAuthenticationContext(); final ModuleClassLoader classLoader = module.getClassLoader(); EjbLogger.DEPLOYMENT_LOGGER.debugf("Registering EJB client context %s for classloader %s", ejbClientContext, classLoader);
@Override public void start(StartContext context) throws StartException { final DeploymentRepository repository = deploymentRepositoryValue.getValue(); moduleIdentifier = new DeploymentModuleIdentifier(APP_NAME, MODULE_NAME, DISTINCT_NAME); final InjectedValue<ComponentView> injectedHomeView = new InjectedValue<ComponentView>(); injectedHomeView.setValue(new ImmediateValue<ComponentView>(new ManagementHomeEjbComponentView())); final InjectedValue<ComponentView> injectedRemoteView = new InjectedValue<ComponentView>(); injectedRemoteView.setValue(new ImmediateValue<ComponentView>(new ManagementRemoteEjbComponentView(mbeanServerValue.getValue()))); Map<String, InjectedValue<ComponentView>> views = new HashMap<String, InjectedValue<ComponentView>>(); views.put(ManagementHome.class.getName(), injectedHomeView); views.put(Management.class.getName(), injectedRemoteView); final EjbDeploymentInformation ejb = new ManagementEjbDeploymentInformation(EJB_NAME, views, SecurityActions.getClassLoader(this.getClass())); final ModuleDeployment deployment = new ModuleDeployment(moduleIdentifier, Collections.singletonMap(EJB_NAME, ejb)); repository.add(moduleIdentifier, deployment); repository.startDeployment(moduleIdentifier); doPrivileged((PrivilegedAction<Void>) () -> { final ClassLoader classLoader = getClass().getClassLoader(); EJBClientContext.getContextManager().setClassLoaderDefault(classLoader, ejbClientContextValue.getValue().getClientContext()); Discovery.getContextManager().setClassLoaderDefault(classLoader, Discovery.create(associationServiceInjector.getValue().getLocalDiscoveryProvider())); return null; }); }