use of org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier in project wildfly by wildfly.
the class LocalEjbReceiver method findBean.
private EjbDeploymentInformation findBean(final EJBLocator<?> locator) {
final String appName = locator.getAppName();
final String moduleName = locator.getModuleName();
final String distinctName = locator.getDistinctName();
final String beanName = locator.getBeanName();
final DeploymentModuleIdentifier moduleIdentifier = new DeploymentModuleIdentifier(appName, moduleName, distinctName);
final ModuleDeployment module = deploymentRepository.getValue().getModules().get(moduleIdentifier);
if (module == null) {
throw EjbLogger.ROOT_LOGGER.unknownDeployment(locator);
}
final EjbDeploymentInformation ejbInfo = module.getEjbs().get(beanName);
if (ejbInfo == null) {
throw EjbLogger.ROOT_LOGGER.ejbNotFoundInDeployment(locator);
}
return ejbInfo;
}
use of org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier in project wildfly by wildfly.
the class AssociationImpl method findEJB.
private EjbDeploymentInformation findEJB(final String appName, final String moduleName, final String distinctName, final String beanName) {
final DeploymentModuleIdentifier ejbModule = new DeploymentModuleIdentifier(appName, moduleName, distinctName);
final Map<DeploymentModuleIdentifier, ModuleDeployment> modules = this.deploymentRepository.getStartedModules();
if (modules == null || modules.isEmpty()) {
return null;
}
final ModuleDeployment moduleDeployment = modules.get(ejbModule);
if (moduleDeployment == null) {
return null;
}
return moduleDeployment.getEjbs().get(beanName);
}
use of org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier in project wildfly by wildfly.
the class RemoteObjectSubstitutionService method serviceForLocator.
private EjbIIOPService serviceForLocator(final EJBLocator<?> locator, DeploymentRepository deploymentRepository) {
final ModuleDeployment module = deploymentRepository.getModules().get(new DeploymentModuleIdentifier(locator.getAppName(), locator.getModuleName(), locator.getDistinctName()));
if (module == null) {
EjbLogger.ROOT_LOGGER.couldNotFindEjbForLocatorIIOP(locator);
return null;
}
final EjbDeploymentInformation ejb = module.getEjbs().get(locator.getBeanName());
if (ejb == null) {
EjbLogger.ROOT_LOGGER.couldNotFindEjbForLocatorIIOP(locator);
return null;
}
final EjbIIOPService factory = ejb.getIorFactory();
if (factory == null) {
EjbLogger.ROOT_LOGGER.ejbNotExposedOverIIOP(locator);
return null;
}
return factory;
}
use of org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier in project wildfly by wildfly.
the class RegisterManagementEJBService method start.
@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;
});
}
use of org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier in project wildfly by wildfly.
the class DeploymentRepositoryProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
if (eeModuleDescription == null) {
return;
}
// Note, we do not use the EEModuleDescription.getApplicationName() because that API returns the
// module name if the top level unit isn't a .ear, which is not what we want. We really want a
// .ear name as application name (that's the semantic in EJB spec). So use EEModuleDescription.getEarApplicationName
String applicationName = eeModuleDescription.getEarApplicationName();
// if it's not a .ear deployment then set app name to empty string
applicationName = applicationName == null ? "" : applicationName;
final DeploymentModuleIdentifier identifier = new DeploymentModuleIdentifier(applicationName, eeModuleDescription.getModuleName(), eeModuleDescription.getDistinctName());
final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions();
final Map<String, EjbDeploymentInformation> deploymentInformationMap = new HashMap<String, EjbDeploymentInformation>();
final Set<ServiceName> componentStartServices = new HashSet<ServiceName>();
final Map<ServiceName, InjectedValue<?>> injectedValues = new HashMap<ServiceName, InjectedValue<?>>();
for (final ComponentDescription component : componentDescriptions) {
if (component instanceof EJBComponentDescription) {
final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) component;
componentStartServices.add(component.getStartServiceName());
final InjectedValue<EJBComponent> componentInjectedValue = new InjectedValue<EJBComponent>();
injectedValues.put(component.getCreateServiceName(), componentInjectedValue);
final Map<String, InjectedValue<ComponentView>> remoteViews = new HashMap<String, InjectedValue<ComponentView>>();
final Map<String, InjectedValue<ComponentView>> localViews = new HashMap<String, InjectedValue<ComponentView>>();
for (final ViewDescription view : ejbComponentDescription.getViews()) {
boolean remoteView = false;
if (view instanceof EJBViewDescription) {
final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
if (viewType == MethodIntf.HOME || viewType == MethodIntf.REMOTE) {
remoteView = true;
}
}
final InjectedValue<ComponentView> componentViewInjectedValue = new InjectedValue<ComponentView>();
if (remoteView) {
remoteViews.put(view.getViewClassName(), componentViewInjectedValue);
} else {
localViews.put(view.getViewClassName(), componentViewInjectedValue);
}
injectedValues.put(view.getServiceName(), componentViewInjectedValue);
}
final InjectedValue<EjbIIOPService> iorFactory = new InjectedValue<EjbIIOPService>();
if (ejbComponentDescription.isExposedViaIiop()) {
injectedValues.put(ejbComponentDescription.getServiceName().append(EjbIIOPService.SERVICE_NAME), iorFactory);
}
final EjbDeploymentInformation info = new EjbDeploymentInformation(ejbComponentDescription.getEJBName(), componentInjectedValue, remoteViews, localViews, module.getClassLoader(), iorFactory);
deploymentInformationMap.put(ejbComponentDescription.getEJBName(), info);
}
}
final StartupCountdown countdown = deploymentUnit.getAttachment(Attachments.STARTUP_COUNTDOWN);
final ModuleDeployment deployment = new ModuleDeployment(identifier, deploymentInformationMap, countdown);
ServiceName moduleDeploymentService = deploymentUnit.getServiceName().append(ModuleDeployment.SERVICE_NAME);
final ServiceBuilder<ModuleDeployment> builder = phaseContext.getServiceTarget().addService(moduleDeploymentService, deployment);
for (Map.Entry<ServiceName, InjectedValue<?>> entry : injectedValues.entrySet()) {
builder.addDependency(entry.getKey(), (InjectedValue<Object>) entry.getValue());
}
builder.addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, deployment.getDeploymentRepository());
builder.install();
final ModuleDeployment.ModuleDeploymentStartService deploymentStart = new ModuleDeployment.ModuleDeploymentStartService(identifier, countdown);
final ServiceBuilder<Void> startBuilder = phaseContext.getServiceTarget().addService(deploymentUnit.getServiceName().append(ModuleDeployment.START_SERVICE_NAME), deploymentStart);
startBuilder.addDependencies(componentStartServices);
startBuilder.addDependency(moduleDeploymentService);
startBuilder.addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, deploymentStart.getDeploymentRepository());
startBuilder.install();
}
Aggregations