Search in sources :

Example 1 with ClientInfo

use of org.apache.openejb.assembler.classic.ClientInfo in project tomee by apache.

the class AnnotationDeployerTest method badMainClassFormatTest.

@Test
public /**
     *  For https://issues.apache.org/jira/browse/OPENEJB-1063
     */
void badMainClassFormatTest() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "test-app");
    final ClientModule clientModule = new ClientModule(null, app.getClassLoader(), app.getJarLocation(), null, null);
    // change "." --> "/" to check that main class is changed by the AnnotationDeployer
    final String mainClass = MyMainClass.class.getName().replaceAll("\\.", "/");
    clientModule.setMainClass(mainClass);
    app.getClientModules().add(clientModule);
    final AppInfo appInfo = config.configureApplication(app);
    assembler.createApplication(appInfo);
    final ClientInfo clientInfo = appInfo.clients.get(0);
    Assert.assertNotNull(clientInfo);
    Assert.assertEquals(MyMainClass.class.getName(), clientInfo.mainClass);
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) ClientInfo(org.apache.openejb.assembler.classic.ClientInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 2 with ClientInfo

use of org.apache.openejb.assembler.classic.ClientInfo in project tomee by apache.

the class AppInfoBuilder method buildClientModules.

private void buildClientModules(final AppModule appModule, final AppInfo appInfo, final JndiEncInfoBuilder jndiEncInfoBuilder) throws OpenEJBException {
    for (final ClientModule clientModule : appModule.getClientModules()) {
        final ApplicationClient applicationClient = clientModule.getApplicationClient();
        final ClientInfo clientInfo = new ClientInfo();
        clientInfo.description = applicationClient.getDescription();
        clientInfo.displayName = applicationClient.getDisplayName();
        clientInfo.path = clientModule.getJarLocation();
        clientInfo.mainClass = clientModule.getMainClass();
        clientInfo.localClients.addAll(clientModule.getLocalClients());
        clientInfo.remoteClients.addAll(clientModule.getRemoteClients());
        clientInfo.callbackHandler = applicationClient.getCallbackHandler();
        clientInfo.moduleId = getClientModuleId(clientModule);
        clientInfo.watchedResources.addAll(clientModule.getWatchedResources());
        clientInfo.validationInfo = ValidatorBuilder.getInfo(clientModule.getValidationConfig());
        clientInfo.uniqueId = clientModule.getUniqueId();
        jndiEncInfoBuilder.build(applicationClient, clientModule.getJarLocation(), clientInfo.moduleId, clientModule.getModuleUri(), clientInfo.jndiEnc, clientInfo.jndiEnc);
        appInfo.clients.add(clientInfo);
    }
}
Also used : ApplicationClient(org.apache.openejb.jee.ApplicationClient) ClientInfo(org.apache.openejb.assembler.classic.ClientInfo)

Example 3 with ClientInfo

use of org.apache.openejb.assembler.classic.ClientInfo in project tomee by apache.

the class VmDeploymentManager method toTargetModuleId.

private static TargetModuleID toTargetModuleId(final AppInfo appInfo, final ModuleType allowedModuleType) {
    final List<InfoObject> infos = new ArrayList<InfoObject>();
    infos.addAll(appInfo.clients);
    infos.addAll(appInfo.ejbJars);
    infos.addAll(appInfo.webApps);
    infos.addAll(appInfo.connectors);
    // if the module id is the same as the appInfo, then it is a standalone module
    if (infos.size() == 1) {
        final InfoObject infoObject = infos.get(0);
        if (infoObject instanceof ClientInfo) {
            final ClientInfo clientInfo = (ClientInfo) infoObject;
            if (null != appInfo.path && appInfo.path.equals(clientInfo.path)) {
                // are client modules allowed
                if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.CAR)) {
                    return null;
                }
                if (null != clientInfo.moduleId && clientInfo.moduleId.equals(appInfo.path)) {
                    return new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
                }
            }
        }
        if (infoObject instanceof EjbJarInfo) {
            final EjbJarInfo ejbJarInfo = (EjbJarInfo) infoObject;
            if (null != appInfo.path && appInfo.path.equals(ejbJarInfo.path)) {
                // are ejb modules allowed
                if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EJB)) {
                    return null;
                }
                if (null != ejbJarInfo.moduleName && ejbJarInfo.moduleName.equals(appInfo.appId)) {
                    return new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleName);
                }
            }
        }
        if (infoObject instanceof ConnectorInfo) {
            final ConnectorInfo connectorInfo = (ConnectorInfo) infoObject;
            if (null != appInfo.path && appInfo.path.equals(connectorInfo.path)) {
                // are connector modules allowed
                if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.RAR)) {
                    return null;
                }
                if (null != connectorInfo.moduleId && connectorInfo.moduleId.equals(appInfo.path)) {
                    return new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
                }
            }
        }
        if (infoObject instanceof WebAppInfo) {
            final WebAppInfo webAppInfo = (WebAppInfo) infoObject;
            if (null != appInfo.path && appInfo.path.equals(webAppInfo.path)) {
                // are web app modules allowed
                if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.WAR)) {
                    return null;
                }
                if (null != webAppInfo.moduleId && webAppInfo.moduleId.equals(appInfo.path)) {
                    //todo web module
                    return new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId);
                }
            }
        }
    }
    // are ear modules allowed
    if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EAR)) {
        return null;
    }
    final TargetModuleIDImpl earModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, appInfo.path);
    for (final ClientInfo clientInfo : appInfo.clients) {
        final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
        clientModuleId.setParentTargetModuleID(earModuleId);
    }
    for (final EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
        final TargetModuleIDImpl ejbJarModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleName);
        ejbJarModuleId.setParentTargetModuleID(earModuleId);
    }
    for (final ConnectorInfo connectorInfo : appInfo.connectors) {
        final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
        clientModuleId.setParentTargetModuleID(earModuleId);
    }
    for (final WebAppInfo webAppInfo : appInfo.webApps) {
        final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId, webAppInfo.contextRoot);
        clientModuleId.setParentTargetModuleID(earModuleId);
    }
    return earModuleId;
}
Also used : WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) ConnectorInfo(org.apache.openejb.assembler.classic.ConnectorInfo) InfoObject(org.apache.openejb.assembler.classic.InfoObject) ArrayList(java.util.ArrayList) ClientInfo(org.apache.openejb.assembler.classic.ClientInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo)

Example 4 with ClientInfo

use of org.apache.openejb.assembler.classic.ClientInfo in project tomee by apache.

the class Deploy method print.

private static void print(final AppInfo appInfo) {
    System.out.println("App(id=" + appInfo.path + ")");
    for (final EjbJarInfo info : appInfo.ejbJars) {
        System.out.println("    EjbJar(id=" + info.moduleName + ", path=" + info.path + ")");
        for (final EnterpriseBeanInfo beanInfo : info.enterpriseBeans) {
            System.out.println("        Ejb(ejb-name=" + beanInfo.ejbName + ", id=" + beanInfo.ejbDeploymentId + ")");
            for (final String name : beanInfo.jndiNames) {
                System.out.println("            Jndi(name=" + name + ")");
            }
            System.out.println("");
        }
        for (final InterceptorInfo interceptorInfo : info.interceptors) {
            System.out.println("        Interceptor(class=" + interceptorInfo.clazz + ")");
        }
        System.out.println("");
    }
    for (final ClientInfo clientInfo : appInfo.clients) {
        System.out.println("    Client(main-class=" + clientInfo.mainClass + ", id=" + clientInfo.moduleId + ", path=" + clientInfo.path + ")");
        System.out.println("");
    }
    for (final ConnectorInfo connectorInfo : appInfo.connectors) {
        System.out.println("    Connector(id=" + connectorInfo.moduleId + ", path=" + connectorInfo.path + ")");
        System.out.println("");
    }
    for (final WebAppInfo webAppInfo : appInfo.webApps) {
        System.out.println("    WebApp(context-root=" + webAppInfo.contextRoot + ", id=" + webAppInfo.moduleId + ", path=" + webAppInfo.path + ")");
        System.out.println("");
    }
    for (final PersistenceUnitInfo persistenceUnitInfo : appInfo.persistenceUnits) {
        System.out.println("    PersistenceUnit(name=" + persistenceUnitInfo.name + ", provider=" + persistenceUnitInfo.provider + ")");
        System.out.println("");
    }
}
Also used : EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) ConnectorInfo(org.apache.openejb.assembler.classic.ConnectorInfo) InterceptorInfo(org.apache.openejb.assembler.classic.InterceptorInfo) ClientInfo(org.apache.openejb.assembler.classic.ClientInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) PersistenceUnitInfo(org.apache.openejb.assembler.classic.PersistenceUnitInfo)

Aggregations

ClientInfo (org.apache.openejb.assembler.classic.ClientInfo)4 ConnectorInfo (org.apache.openejb.assembler.classic.ConnectorInfo)2 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 ArrayList (java.util.ArrayList)1 AppInfo (org.apache.openejb.assembler.classic.AppInfo)1 Assembler (org.apache.openejb.assembler.classic.Assembler)1 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)1 InfoObject (org.apache.openejb.assembler.classic.InfoObject)1 InterceptorInfo (org.apache.openejb.assembler.classic.InterceptorInfo)1 PersistenceUnitInfo (org.apache.openejb.assembler.classic.PersistenceUnitInfo)1 ApplicationClient (org.apache.openejb.jee.ApplicationClient)1 Test (org.junit.Test)1