use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EjbInjectionSource method resolve.
/**
* Checks if this ejb injection has been resolved yet, and if not resolves it.
*/
private void resolve() {
if (!resolved) {
synchronized (this) {
if (!resolved) {
final Set<ViewDescription> views = getViews();
final Set<EJBViewDescription> ejbsForViewName = new HashSet<EJBViewDescription>();
for (final ViewDescription view : views) {
if (view instanceof EJBViewDescription) {
final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
// @EJB injection *shouldn't* consider the @WebService endpoint view or MDBs
if (viewType == MethodIntf.SERVICE_ENDPOINT || viewType == MethodIntf.MESSAGE_ENDPOINT) {
continue;
}
ejbsForViewName.add((EJBViewDescription) view);
}
}
if (ejbsForViewName.isEmpty()) {
if (beanName == null) {
error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, bindingName);
} else {
error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, beanName, bindingName);
}
} else if (ejbsForViewName.size() > 1) {
if (beanName == null) {
error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, bindingName, ejbsForViewName);
} else {
error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, beanName, bindingName, ejbsForViewName);
}
} else {
final EJBViewDescription description = ejbsForViewName.iterator().next();
final EJBViewDescription ejbViewDescription = (EJBViewDescription) description;
if (ejbViewDescription.getMethodIntf() == MethodIntf.REMOTE || ejbViewDescription.getMethodIntf() == MethodIntf.HOME) {
final EJBComponentDescription componentDescription = (EJBComponentDescription) description.getComponentDescription();
final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
final String earApplicationName = moduleDescription.getEarApplicationName();
final Value<ClassLoader> viewClassLoader = new Value<ClassLoader>() {
@Override
public ClassLoader getValue() throws IllegalStateException, IllegalArgumentException {
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
return module != null ? module.getClassLoader() : null;
}
};
remoteFactory = new RemoteViewManagedReferenceFactory(earApplicationName, moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), description.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
}
final ServiceName serviceName = description.getServiceName();
resolvedViewName = serviceName;
}
resolved = true;
}
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class ServiceComponentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final JBossServiceXmlDescriptor serviceXmlDescriptor = deploymentUnit.getAttachment(JBossServiceXmlDescriptor.ATTACHMENT_KEY);
if (serviceXmlDescriptor == null) {
// Skip deployments without a service xml descriptor
return;
}
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
// not an EE deployment
return;
}
final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Map<String, ServiceComponentInstantiator> serviceComponents = new HashMap<String, ServiceComponentInstantiator>();
for (final JBossServiceConfig serviceConfig : serviceXmlDescriptor.getServiceConfigs()) {
ServiceComponentDescription componentDescription = new ServiceComponentDescription(serviceConfig.getName(), serviceConfig.getCode(), moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription);
moduleDescription.addComponent(componentDescription);
serviceComponents.put(serviceConfig.getName(), new ServiceComponentInstantiator(deploymentUnit, componentDescription));
}
deploymentUnit.putAttachment(ServiceAttachments.SERVICE_COMPONENT_INSTANTIATORS, serviceComponents);
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class ApplicationClientStartProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final ApplicationClientMetaData appClientData = deploymentUnit.getAttachment(AppClientAttachments.APPLICATION_CLIENT_META_DATA);
final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(Attachments.REFLECTION_INDEX);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
//setup the callback handler
final CallbackHandler callbackHandler;
if (appClientData != null && appClientData.getCallbackHandler() != null && !appClientData.getCallbackHandler().isEmpty()) {
try {
final Class<?> callbackClass = ClassLoadingUtils.loadClass(appClientData.getCallbackHandler(), module);
callbackHandler = new RealmCallbackWrapper((CallbackHandler) callbackClass.newInstance());
} catch (ClassNotFoundException e) {
throw AppClientLogger.ROOT_LOGGER.couldNotLoadCallbackClass(appClientData.getCallbackHandler());
} catch (Exception e) {
throw AppClientLogger.ROOT_LOGGER.couldNotCreateCallbackHandler(appClientData.getCallbackHandler());
}
} else {
callbackHandler = new DefaultApplicationClientCallbackHandler();
}
Boolean activate = deploymentUnit.getAttachment(AppClientAttachments.START_APP_CLIENT);
if (activate == null || !activate) {
return;
}
final Class<?> mainClass = deploymentUnit.getAttachment(AppClientAttachments.MAIN_CLASS);
if (mainClass == null) {
throw AppClientLogger.ROOT_LOGGER.cannotStartAppClient(deploymentUnit.getName());
}
final ApplicationClientComponentDescription component = deploymentUnit.getAttachment(AppClientAttachments.APPLICATION_CLIENT_COMPONENT);
Method mainMethod = null;
Class<?> klass = mainClass;
while (klass != Object.class) {
final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(klass);
mainMethod = index.getMethod(void.class, "main", String[].class);
if (mainMethod != null) {
break;
}
klass = klass.getSuperclass();
}
if (mainMethod == null) {
throw AppClientLogger.ROOT_LOGGER.cannotStartAppClient(deploymentUnit.getName(), mainClass);
}
final ApplicationClientStartService startService;
final List<SetupAction> setupActions = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.OTHER_EE_SETUP_ACTIONS);
if (connectionPropertiesUrl != null) {
try {
final File file = new File(connectionPropertiesUrl);
final URL url;
if (file.exists()) {
url = file.toURI().toURL();
} else {
url = new URL(connectionPropertiesUrl);
}
Properties properties = new Properties();
InputStream stream = null;
try {
stream = url.openStream();
properties.load(stream);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
//ignore
}
}
}
final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
startService = new ApplicationClientStartService(mainMethod, parameters, moduleDescription.getNamespaceContextSelector(), module.getClassLoader(), setupActions);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
}
} catch (Exception e) {
throw AppClientLogger.ROOT_LOGGER.exceptionLoadingEjbClientPropertiesURL(connectionPropertiesUrl, e);
}
} else {
startService = new ApplicationClientStartService(mainMethod, parameters, moduleDescription.getNamespaceContextSelector(), module.getClassLoader(), setupActions, hostUrl, callbackHandler);
}
phaseContext.getServiceTarget().addService(deploymentUnit.getServiceName().append(ApplicationClientStartService.SERVICE_NAME), startService).addDependency(ApplicationClientDeploymentService.SERVICE_NAME, ApplicationClientDeploymentService.class, startService.getApplicationClientDeploymentServiceInjectedValue()).addDependency(component.getCreateServiceName(), Component.class, startService.getApplicationClientComponent()).install();
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class AroundInvokeAnnotationParsingProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final List<AnnotationInstance> aroundInvokes = index.getAnnotations(AROUND_INVOKE_ANNOTATION_NAME);
for (AnnotationInstance annotation : aroundInvokes) {
processAroundInvoke(eeModuleDescription, annotation.target());
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EarMessageDestinationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final EarMetaData metadata = deploymentUnit.getAttachment(Attachments.EAR_METADATA);
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (metadata != null) {
if (metadata.getEarEnvironmentRefsGroup() != null) {
if (metadata.getEarEnvironmentRefsGroup().getMessageDestinations() != null) {
for (final MessageDestinationMetaData destination : metadata.getEarEnvironmentRefsGroup().getMessageDestinations()) {
//TODO: should these be two separate metadata attributes?
if (destination.getJndiName() != null) {
eeModuleDescription.addMessageDestination(destination.getName(), destination.getJndiName());
} else if (destination.getLookupName() != null) {
eeModuleDescription.addMessageDestination(destination.getName(), destination.getLookupName());
}
}
}
}
}
}
}
Aggregations