use of org.jboss.as.ejb3.iiop.EjbIIOPService in project wildfly by wildfly.
the class EjbIIOPDeploymentUnitProcessor method processEjb.
private void processEjb(final EJBComponentDescription componentDescription, final DeploymentReflectionIndex deploymentReflectionIndex, final Module module, final ServiceTarget serviceTarget, final IIOPMetaData iiopMetaData) {
componentDescription.setExposedViaIiop(true);
// Create bean method mappings for container invoker
final EJBViewDescription remoteView = componentDescription.getEjbRemoteView();
final Class<?> remoteClass;
try {
remoteClass = ClassLoadingUtils.loadClass(remoteView.getViewClassName(), module);
} catch (ClassNotFoundException e) {
throw EjbLogger.ROOT_LOGGER.failedToLoadViewClassForComponent(e, componentDescription.getEJBClassName());
}
final EJBViewDescription homeView = componentDescription.getEjbHomeView();
final Class<?> homeClass;
try {
homeClass = ClassLoadingUtils.loadClass(homeView.getViewClassName(), module);
} catch (ClassNotFoundException e) {
throw EjbLogger.ROOT_LOGGER.failedToLoadViewClassForComponent(e, componentDescription.getEJBClassName());
}
componentDescription.getEjbHomeView().getConfigurators().add(new IIOPInterceptorViewConfigurator());
componentDescription.getEjbRemoteView().getConfigurators().add(new IIOPInterceptorViewConfigurator());
final InterfaceAnalysis remoteInterfaceAnalysis;
try {
// TODO: change all this to use the deployment reflection index
remoteInterfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(remoteClass);
} catch (RMIIIOPViolationException e) {
throw EjbLogger.ROOT_LOGGER.failedToAnalyzeRemoteInterface(e, componentDescription.getComponentName());
}
final Map<String, SkeletonStrategy> beanMethodMap = new HashMap<String, SkeletonStrategy>();
final AttributeAnalysis[] remoteAttrs = remoteInterfaceAnalysis.getAttributes();
for (int i = 0; i < remoteAttrs.length; i++) {
final OperationAnalysis op = remoteAttrs[i].getAccessorAnalysis();
if (op != null) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", op.getJavaName(), op.getIDLName());
// translate to the deployment reflection index method
// TODO: this needs to be fixed so it just returns the correct method
final Method method = translateMethod(deploymentReflectionIndex, op);
beanMethodMap.put(op.getIDLName(), new SkeletonStrategy(method));
final OperationAnalysis setop = remoteAttrs[i].getMutatorAnalysis();
if (setop != null) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", setop.getJavaName(), setop.getIDLName());
// translate to the deployment reflection index method
// TODO: this needs to be fixed so it just returns the correct method
final Method realSetmethod = translateMethod(deploymentReflectionIndex, setop);
beanMethodMap.put(setop.getIDLName(), new SkeletonStrategy(realSetmethod));
}
}
}
final OperationAnalysis[] ops = remoteInterfaceAnalysis.getOperations();
for (int i = 0; i < ops.length; i++) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", ops[i].getJavaName(), ops[i].getIDLName());
beanMethodMap.put(ops[i].getIDLName(), new SkeletonStrategy(translateMethod(deploymentReflectionIndex, ops[i])));
}
// Initialize repository ids of remote interface
final String[] beanRepositoryIds = remoteInterfaceAnalysis.getAllTypeIds();
// Create home method mappings for container invoker
final InterfaceAnalysis homeInterfaceAnalysis;
try {
// TODO: change all this to use the deployment reflection index
homeInterfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(homeClass);
} catch (RMIIIOPViolationException e) {
throw EjbLogger.ROOT_LOGGER.failedToAnalyzeRemoteInterface(e, componentDescription.getComponentName());
}
final Map<String, SkeletonStrategy> homeMethodMap = new HashMap<String, SkeletonStrategy>();
final AttributeAnalysis[] attrs = homeInterfaceAnalysis.getAttributes();
for (int i = 0; i < attrs.length; i++) {
final OperationAnalysis op = attrs[i].getAccessorAnalysis();
if (op != null) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", op.getJavaName(), op.getIDLName());
homeMethodMap.put(op.getIDLName(), new SkeletonStrategy(translateMethod(deploymentReflectionIndex, op)));
final OperationAnalysis setop = attrs[i].getMutatorAnalysis();
if (setop != null) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", setop.getJavaName(), setop.getIDLName());
homeMethodMap.put(setop.getIDLName(), new SkeletonStrategy(translateMethod(deploymentReflectionIndex, setop)));
}
}
}
final OperationAnalysis[] homeops = homeInterfaceAnalysis.getOperations();
for (int i = 0; i < homeops.length; i++) {
EjbLogger.DEPLOYMENT_LOGGER.debugf(" %s%n %s", homeops[i].getJavaName(), homeops[i].getIDLName());
homeMethodMap.put(homeops[i].getIDLName(), new SkeletonStrategy(translateMethod(deploymentReflectionIndex, homeops[i])));
}
// Initialize repository ids of home interface
final String[] homeRepositoryIds = homeInterfaceAnalysis.getAllTypeIds();
final EjbIIOPService service = new EjbIIOPService(beanMethodMap, beanRepositoryIds, homeMethodMap, homeRepositoryIds, settingsService.isUseQualifiedName(), iiopMetaData, module);
final ServiceBuilder<EjbIIOPService> builder = serviceTarget.addService(componentDescription.getServiceName().append(EjbIIOPService.SERVICE_NAME), service);
builder.addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, service.getEjbComponentInjectedValue());
builder.addDependency(homeView.getServiceName(), ComponentView.class, service.getHomeView());
builder.addDependency(remoteView.getServiceName(), ComponentView.class, service.getRemoteView());
builder.addDependency(CorbaORBService.SERVICE_NAME, ORB.class, service.getOrb());
builder.addDependency(POARegistry.SERVICE_NAME, POARegistry.class, service.getPoaRegistry());
builder.addDependency(CorbaPOAService.INTERFACE_REPOSITORY_SERVICE_NAME, POA.class, service.getIrPoa());
builder.addDependency(CorbaNamingService.SERVICE_NAME, NamingContextExt.class, service.getCorbaNamingContext());
builder.addDependency(IORSecConfigMetaDataService.SERVICE_NAME, IORSecurityConfigMetaData.class, service.getIORSecConfigMetaDataInjectedValue());
builder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ServiceModuleLoader.class, service.getServiceModuleLoaderInjectedValue());
builder.addDependency(TxnServices.JBOSS_TXN_ARJUNA_TRANSACTION_MANAGER, TransactionManagerService.class, service.getTransactionManagerInjectedValue());
builder.install();
}
use of org.jboss.as.ejb3.iiop.EjbIIOPService in project wildfly by wildfly.
the class RemoteObjectSubstitutionService method writeReplaceRemote.
@Override
public Object writeReplaceRemote(final Object object) {
final DeploymentRepository deploymentRepository = deploymentRepositoryInjectedValue.getOptionalValue();
// if we are not started yet just return
if (deploymentRepository == null) {
return object;
}
if (EJBClient.isEJBProxy(object)) {
return createIIOPReferenceForBean(object, deploymentRepository);
} else if (object instanceof EJBHandle) {
final EJBHandle<?> handle = (EJBHandle<?>) object;
final EJBLocator<?> locator = handle.getLocator();
final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
if (factory != null) {
return factory.handleForLocator(locator);
}
} else if (object instanceof EJBHomeHandle) {
final EJBHomeHandle<?> handle = (EJBHomeHandle<?>) object;
final EJBLocator<?> locator = handle.getLocator();
final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
if (factory != null) {
return factory.handleForLocator(locator);
}
} else if (object instanceof EJBMetaDataImpl) {
final EJBMetaDataImpl metadata = (EJBMetaDataImpl) object;
Class<?> pk = null;
if (!metadata.isSession()) {
pk = metadata.getPrimaryKeyClass();
}
final EJBLocator<?> locator = EJBClient.getLocatorFor(metadata.getEJBHome());
final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
if (factory != null) {
return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
}
} else if (object instanceof AbstractEJBMetaData) {
final AbstractEJBMetaData<?, ?> metadata = (AbstractEJBMetaData<?, ?>) object;
final EJBHomeLocator<?> locator = metadata.getHomeLocator();
final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
Class<?> pk = metadata instanceof EntityEJBMetaData ? metadata.getPrimaryKeyClass() : null;
if (factory != null) {
return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
}
}
return object;
}
use of org.jboss.as.ejb3.iiop.EjbIIOPService 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.iiop.EjbIIOPService 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;
}
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
// don't create this for EAR's, as they cannot hold Jakarta Enterprise Beans's
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 Jakarta Enterprise Beans 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);
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(), Object.class, (InjectedValue<Object>) entry.getValue());
}
builder.addDependency(DeploymentRepositoryService.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);
for (final ServiceName componentStartService : componentStartServices) {
startBuilder.requires(componentStartService);
}
startBuilder.requires(moduleDeploymentService);
startBuilder.addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, deploymentStart.getDeploymentRepository());
startBuilder.install();
}
Aggregations