use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class DefaultBindingsConfigurationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
// store subsystem config in module description
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (eeModuleDescription != null) {
// set names only if these are not set yet
final EEDefaultResourceJndiNames defaultResourceJndiNames = eeModuleDescription.getDefaultResourceJndiNames();
if (defaultResourceJndiNames.getContextService() == null) {
defaultResourceJndiNames.setContextService(contextService);
}
if (defaultResourceJndiNames.getDataSource() == null) {
defaultResourceJndiNames.setDataSource(dataSource);
}
if (defaultResourceJndiNames.getJmsConnectionFactory() == null) {
defaultResourceJndiNames.setJmsConnectionFactory(jmsConnectionFactory);
}
if (defaultResourceJndiNames.getManagedExecutorService() == null) {
defaultResourceJndiNames.setManagedExecutorService(managedExecutorService);
}
if (defaultResourceJndiNames.getManagedScheduledExecutorService() == null) {
defaultResourceJndiNames.setManagedScheduledExecutorService(managedScheduledExecutorService);
}
if (defaultResourceJndiNames.getManagedThreadFactory() == null) {
defaultResourceJndiNames.setManagedThreadFactory(managedThreadFactory);
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EEDistinctNameProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription module = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (module == null) {
return;
}
// see if the deployment unit has an explicit distinct-name
final String distinctName = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME);
if (distinctName != null) {
module.setDistinctName(distinctName);
return;
}
// check the parent DU for any explicit distinct-name
if (deploymentUnit.getParent() != null) {
final DeploymentUnit parentDU = deploymentUnit.getParent();
final String distinctNameInParentDeployment = parentDU.getAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME);
if (distinctNameInParentDeployment != null) {
module.setDistinctName(distinctNameInParentDeployment);
}
return;
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EEModuleNameProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final List<DeploymentUnit> subDeployments = deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
final Set<String> moduleNames = new HashSet<String>();
final Set<String> moduleConflicts = new HashSet<String>();
//
for (DeploymentUnit deployment : subDeployments) {
final EEModuleDescription module = deployment.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (module != null) {
if (moduleNames.contains(module.getModuleName())) {
moduleConflicts.add(module.getModuleName());
}
moduleNames.add(module.getModuleName());
}
}
for (DeploymentUnit deployment : subDeployments) {
final EEModuleDescription module = deployment.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (module != null) {
if (moduleConflicts.contains(module.getModuleName())) {
module.setModuleName(deployment.getName());
}
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class JaxrsComponentDeployer method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
if (module == null) {
return;
}
final ResteasyDeploymentData resteasy = deploymentUnit.getAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA);
if (resteasy == null) {
return;
}
// right now I only support resources
if (!resteasy.isScanResources())
return;
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
final ClassLoader loader = module.getClassLoader();
for (final ComponentDescription component : moduleDescription.getComponentDescriptions()) {
Class<?> componentClass = null;
try {
componentClass = loader.loadClass(component.getComponentClassName());
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException(e);
}
if (!GetRestful.isRootResource(componentClass))
continue;
if (isInstanceOf(component, SESSION_BEAN_DESCRIPTION_CLASS_NAME)) {
if (isInstanceOf(component, STATEFUL_SESSION_BEAN_DESCRIPTION_CLASS_NAME)) {
//using SFSB's as JAX-RS endpoints is not recommended, but if people really want to do it they can
JAXRS_LOGGER.debugf("Stateful session bean %s is being used as a JAX-RS endpoint, this is not recommended", component.getComponentName());
if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
//if possible just let CDI handle the integration
continue;
}
}
Class<?>[] jaxrsType = GetRestful.getSubResourceClasses(componentClass);
final String jndiName;
if (component.getViews().size() == 1) {
//only 1 view, just use the simple JNDI name
jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName();
} else {
boolean found = false;
String foundType = null;
for (final ViewDescription view : component.getViews()) {
for (Class<?> subResource : jaxrsType) {
if (view.getViewClassName().equals(subResource.getName())) {
foundType = subResource.getName();
found = true;
break;
}
}
if (found) {
break;
}
}
if (!found) {
throw JAXRS_LOGGER.typeNameNotAnEjbView(Arrays.asList(jaxrsType), component.getComponentName());
}
jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName() + "!" + foundType;
}
JAXRS_LOGGER.debugf("Found JAX-RS Managed Bean: %s local jndi jaxRsTypeName: %s", component.getComponentClassName(), jndiName);
StringBuilder buf = new StringBuilder();
buf.append(jndiName).append(";").append(component.getComponentClassName()).append(";").append("true");
resteasy.getScannedJndiComponentResources().add(buf.toString());
// make sure its removed from list
resteasy.getScannedResourceClasses().remove(component.getComponentClassName());
} else if (component instanceof ManagedBeanComponentDescription) {
String jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName();
JAXRS_LOGGER.debugf("Found JAX-RS Managed Bean: %s local jndi name: %s", component.getComponentClassName(), jndiName);
StringBuilder buf = new StringBuilder();
buf.append(jndiName).append(";").append(component.getComponentClassName()).append(";").append("true");
resteasy.getScannedJndiComponentResources().add(buf.toString());
// make sure its removed from list
resteasy.getScannedResourceClasses().remove(component.getComponentClassName());
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class SessionBeanXmlDescriptorProcessor method processBeanMetaData.
/**
* Processes the passed {@link org.jboss.metadata.ejb.spec.SessionBeanMetaData} and creates appropriate {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} out of it.
* The {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} is then added to the {@link org.jboss.as.ee.component.EEModuleDescription module description} available
* in the deployment unit of the passed {@link DeploymentPhaseContext phaseContext}
*
* @param sessionBean The session bean metadata
* @param phaseContext
* @throws DeploymentUnitProcessingException
*
*/
@Override
protected void processBeanMetaData(final SessionBeanMetaData sessionBean, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
// get the module description
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final String beanName = sessionBean.getName();
ComponentDescription bean = moduleDescription.getComponentByName(beanName);
if (appclient) {
if (bean == null) {
for (final ComponentDescription component : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
if (component.getComponentName().equals(beanName)) {
bean = component;
break;
}
}
}
}
if (!(bean instanceof SessionBeanComponentDescription)) {
//if this is a GenericBeanMetadata it may actually represent an MDB
return;
}
SessionBeanComponentDescription sessionBeanDescription = (SessionBeanComponentDescription) bean;
sessionBeanDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", sessionBean));
// mapped-name
sessionBeanDescription.setMappedName(sessionBean.getMappedName());
// local business interface views
final BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
if (businessLocals != null && !businessLocals.isEmpty()) {
sessionBeanDescription.addLocalBusinessInterfaceViews(businessLocals);
}
final String local = sessionBean.getLocal();
if (local != null) {
sessionBeanDescription.addEjbLocalObjectView(local);
}
final String remote = sessionBean.getRemote();
if (remote != null) {
sessionBeanDescription.addEjbObjectView(remote);
}
// remote business interface views
final BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
if (businessRemotes != null && !businessRemotes.isEmpty()) {
sessionBeanDescription.addRemoteBusinessInterfaceViews(businessRemotes);
}
// process EJB3.1 specific session bean description
if (sessionBean instanceof SessionBean31MetaData) {
this.processSessionBean31((SessionBean31MetaData) sessionBean, sessionBeanDescription);
}
}
Aggregations