use of org.jboss.as.ee.component.ComponentDescription in project wildfly by wildfly.
the class JSFManagedBeanProcessor method installManagedBeanComponent.
private void installManagedBeanComponent(String className, final EEModuleDescription moduleDescription, final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClassesDescription) {
final ComponentDescription componentDescription = new WebComponentDescription(MANAGED_BEAN.toString() + "." + className, className, moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription);
moduleDescription.addComponent(componentDescription);
deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, componentDescription.getStartServiceName());
}
use of org.jboss.as.ee.component.ComponentDescription 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.ComponentDescription 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);
}
}
use of org.jboss.as.ee.component.ComponentDescription in project wildfly by wildfly.
the class AsynchronousMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SessionBeanComponentDescription description) throws DeploymentUnitProcessingException {
final SessionBeanMetaData data = description.getDescriptorData();
final boolean isSecurityDomainKnown = description.isSecurityDomainKnown();
if (data != null) {
if (data instanceof SessionBean31MetaData) {
final SessionBean31MetaData sessionBeanData = (SessionBean31MetaData) data;
final AsyncMethodsMetaData async = sessionBeanData.getAsyncMethods();
if (async != null) {
for (AsyncMethodMetaData method : async) {
final Collection<Method> methods = MethodResolutionUtils.resolveMethods(method.getMethodName(), method.getMethodParams(), componentClass, deploymentReflectionIndex);
for (final Method m : methods) {
description.addAsynchronousMethod(MethodIdentifier.getIdentifierForMethod(m));
}
}
}
}
}
if (!description.getAsynchronousClasses().isEmpty() || !description.getAsynchronousMethods().isEmpty()) {
//setup a dependency on the executor service
description.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
configuration.getCreateDependencies().add(new DependencyConfigurator<SessionBeanComponentCreateService>() {
@Override
public void configureDependency(final ServiceBuilder<?> serviceBuilder, final SessionBeanComponentCreateService service) throws DeploymentUnitProcessingException {
serviceBuilder.addDependency(asynchronousThreadPoolService, ExecutorService.class, service.getAsyncExecutorService());
}
});
}
});
for (final ViewDescription view : description.getViews()) {
final EJBViewDescription ejbView = (EJBViewDescription) view;
ejbView.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription();
for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
//we need the component method to get the correct declaring class
final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method);
if (componentMethod != null) {
if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) {
addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
configuration.addAsyncMethod(method);
} else {
MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method);
if (componentDescription.getAsynchronousMethods().contains(id)) {
addAsyncInterceptor(configuration, method, isSecurityDomainKnown);
configuration.addAsyncMethod(method);
}
}
}
}
}
});
}
}
}
use of org.jboss.as.ee.component.ComponentDescription in project wildfly by wildfly.
the class StartupAwaitDeploymentUnitProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
if (component instanceof EJBComponentDescription) {
component.getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) {
StartupCountdown countdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN);
for (ViewConfiguration view : configuration.getViews()) {
EJBViewConfiguration ejbView = (EJBViewConfiguration) view;
if (INTFS.contains(ejbView.getMethodIntf())) {
ejbView.addViewInterceptor(new ImmediateInterceptorFactory(new StartupAwaitInterceptor(countdown)), InterceptorOrder.View.STARTUP_AWAIT_INTERCEPTOR);
}
}
}
});
}
}
}
Aggregations