Search in sources :

Example 21 with Component

use of org.jboss.as.ee.component.Component 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);
    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);
    startService = new ApplicationClientStartService(mainMethod, parameters, moduleDescription.getNamespaceContextSelector(), module.getClassLoader(), setupActions);
    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();
}
Also used : ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) SetupAction(org.jboss.as.server.deployment.SetupAction) Method(java.lang.reflect.Method) ApplicationClientStartService(org.jboss.as.appclient.service.ApplicationClientStartService) ApplicationClientComponentDescription(org.jboss.as.appclient.component.ApplicationClientComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ApplicationClientMetaData(org.jboss.metadata.appclient.spec.ApplicationClientMetaData) Module(org.jboss.modules.Module) Component(org.jboss.as.ee.component.Component) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Aggregations

Component (org.jboss.as.ee.component.Component)21 ComponentView (org.jboss.as.ee.component.ComponentView)9 Method (java.lang.reflect.Method)8 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)8 SessionID (org.jboss.ejb.client.SessionID)5 InterceptorContext (org.jboss.invocation.InterceptorContext)5 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)5 SessionBeanComponent (org.jboss.as.ejb3.component.session.SessionBeanComponent)4 ServiceName (org.jboss.msc.service.ServiceName)4 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)4 PrivilegedActionException (java.security.PrivilegedActionException)3 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)3 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)3 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CancellationException (java.util.concurrent.CancellationException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 EJBException (javax.ejb.EJBException)2