Search in sources :

Example 16 with EjbJarInfo

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

the class SystemAppInfo method preComputedInfo.

//
//
// DONT MODIFY IT WITHOUT UPDATING org.apache.openejb.config.SystemApps
//
//
public static AppInfo preComputedInfo(final ConfigurationFactory factory) {
    final String singletonContainerId;
    try {
        singletonContainerId = findSingletonContainer(factory);
    } catch (final OpenEJBException e) {
        throw new IllegalStateException(e);
    }
    final EjbJarInfo ejbJarInfo = new EjbJarInfo();
    ejbJarInfo.moduleId = "openejb";
    ejbJarInfo.moduleName = ejbJarInfo.moduleId;
    ejbJarInfo.moduleUri = URI.create(ejbJarInfo.moduleId);
    ejbJarInfo.properties.setProperty("openejb.deploymentId.format", "{ejbName}");
    ejbJarInfo.properties.setProperty("openejb.jndiname.format", "{deploymentId}{interfaceType.openejbLegacyName}");
    final SingletonBeanInfo deployer = new SingletonBeanInfo();
    deployer.ejbDeploymentId = "openejb/Deployer";
    deployer.ejbName = deployer.ejbDeploymentId;
    deployer.ejbClass = "org.apache.openejb.assembler.DeployerEjb";
    deployer.businessRemote.add("org.apache.openejb.assembler.Deployer");
    deployer.parents.add(deployer.ejbClass);
    deployer.transactionType = "BEAN";
    deployer.concurrencyType = "CONTAINER";
    deployer.containerId = singletonContainerId;
    ejbJarInfo.enterpriseBeans.add(deployer);
    final SingletonBeanInfo configuration = new SingletonBeanInfo();
    configuration.ejbDeploymentId = "openejb/ConfigurationInfo";
    configuration.ejbName = deployer.ejbDeploymentId;
    configuration.ejbClass = "org.apache.openejb.assembler.classic.cmd.ConfigurationInfoEjb";
    configuration.businessRemote.add("org.apache.openejb.assembler.classic.cmd.ConfigurationInfo");
    configuration.parents.add(deployer.ejbClass);
    configuration.transactionType = "CONTAINER";
    configuration.concurrencyType = "CONTAINER";
    configuration.containerId = singletonContainerId;
    ejbJarInfo.enterpriseBeans.add(configuration);
    final SingletonBeanInfo mejb = new SingletonBeanInfo();
    mejb.ejbDeploymentId = "MEJB";
    mejb.ejbName = deployer.ejbDeploymentId;
    mejb.ejbClass = "org.apache.openejb.mgmt.MEJBBean";
    mejb.home = "javax.management.j2ee.ManagementHome";
    mejb.remote = "javax.management.j2ee.Management";
    mejb.parents.add(deployer.ejbClass);
    mejb.transactionType = "CONTAINER";
    mejb.concurrencyType = "CONTAINER";
    mejb.containerId = singletonContainerId;
    ejbJarInfo.enterpriseBeans.add(mejb);
    for (final EnterpriseBeanInfo ebi : ejbJarInfo.enterpriseBeans) {
        final MethodInfo methodInfo = new MethodInfo();
        methodInfo.ejbDeploymentId = ebi.ejbDeploymentId;
        methodInfo.ejbName = ebi.ejbName;
        methodInfo.methodName = "*";
        methodInfo.className = ebi.ejbClass;
        final MethodConcurrencyInfo methodConcurrencyInfo = new MethodConcurrencyInfo();
        methodConcurrencyInfo.concurrencyAttribute = "READ";
        methodConcurrencyInfo.methods.add(methodInfo);
        ejbJarInfo.methodConcurrency.add(methodConcurrencyInfo);
    }
    final CallbackInfo callbackInfo = new CallbackInfo();
    callbackInfo.className = "org.apache.openejb.security.internal.InternalSecurityInterceptor";
    callbackInfo.method = "invoke";
    final InterceptorInfo interceptorInfo = new InterceptorInfo();
    interceptorInfo.clazz = "org.apache.openejb.security.internal.InternalSecurityInterceptor";
    interceptorInfo.aroundInvoke.add(callbackInfo);
    ejbJarInfo.interceptors.add(interceptorInfo);
    final InterceptorBindingInfo interceptorBindingInfo = new InterceptorBindingInfo();
    interceptorBindingInfo.ejbName = "*";
    interceptorBindingInfo.interceptors.add("org.apache.openejb.security.internal.InternalSecurityInterceptor");
    ejbJarInfo.interceptorBindings.add(interceptorBindingInfo);
    ejbJarInfo.mbeans.add("org.apache.openejb.assembler.monitoring.JMXDeployer");
    // we start at 1 so no conflict using 0
    ejbJarInfo.uniqueId = "0";
    final AppInfo appInfo = new AppInfo();
    appInfo.appId = ejbJarInfo.moduleId;
    appInfo.path = appInfo.appId;
    appInfo.ejbJars.add(ejbJarInfo);
    return appInfo;
}
Also used : EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) OpenEJBException(org.apache.openejb.OpenEJBException) CallbackInfo(org.apache.openejb.assembler.classic.CallbackInfo) InterceptorBindingInfo(org.apache.openejb.assembler.classic.InterceptorBindingInfo) InterceptorInfo(org.apache.openejb.assembler.classic.InterceptorInfo) MethodInfo(org.apache.openejb.assembler.classic.MethodInfo) SingletonBeanInfo(org.apache.openejb.assembler.classic.SingletonBeanInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) MethodConcurrencyInfo(org.apache.openejb.assembler.classic.MethodConcurrencyInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 17 with EjbJarInfo

use of org.apache.openejb.assembler.classic.EjbJarInfo 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 18 with EjbJarInfo

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

the class AutoConfigResourceRefsTest method testCaseInsensitive.

public void testCaseInsensitive() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("DeFAultDataSource", "DataSource", null), ResourceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("YeLLowDataSource", "DataSource", null), ResourceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("PurpLEDataSource", "DataSource", null), ResourceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
    final Map<String, ResourceReferenceInfo> refs = new HashMap<String, ResourceReferenceInfo>();
    for (final ResourceReferenceInfo ref : beanInfo.jndiEnc.resourceRefs) {
        refs.put(ref.referenceName.replaceAll(".*/", ""), ref);
    }
    ResourceReferenceInfo info;
    info = refs.get("yellowDataSource");
    assertNotNull(info);
    assertEquals("YeLLowDataSource", info.resourceID);
    info = refs.get("orangeDataSource");
    assertNotNull(info);
    assertEquals("DeFAultDataSource", info.resourceID);
    info = refs.get("purpleDataSource");
    assertNotNull(info);
    assertEquals("PurpLEDataSource", info.resourceID);
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) HashMap(java.util.HashMap) Resource(javax.annotation.Resource) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) ResourceReferenceInfo(org.apache.openejb.assembler.classic.ResourceReferenceInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 19 with EjbJarInfo

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

the class AutoConfigResourceRefsTest method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("defaultDataSource", "DataSource", null), ResourceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("yellowDataSource", "DataSource", null), ResourceInfo.class));
    assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("PurpleDataSource", "DataSource", null), ResourceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
    final Map<String, ResourceReferenceInfo> refs = new HashMap<String, ResourceReferenceInfo>();
    for (final ResourceReferenceInfo ref : beanInfo.jndiEnc.resourceRefs) {
        refs.put(ref.referenceName.replaceAll(".*/", ""), ref);
    }
    ResourceReferenceInfo info;
    info = refs.get("yellowDataSource");
    assertNotNull(info);
    assertEquals("yellowDataSource", info.resourceID);
    info = refs.get("orangeDataSource");
    assertNotNull(info);
    assertEquals("defaultDataSource", info.resourceID);
    info = refs.get("purpleDataSource");
    assertNotNull(info);
    assertEquals("PurpleDataSource", info.resourceID);
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) HashMap(java.util.HashMap) Resource(javax.annotation.Resource) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) ResourceReferenceInfo(org.apache.openejb.assembler.classic.ResourceReferenceInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 20 with EjbJarInfo

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

the class ConfigurationFactoryTest method testConfigureApplicationEjbJar.

@Test
public void testConfigureApplicationEjbJar() throws OpenEJBException {
    // Just to find out whether the validationDisabled message shows up
    SystemInstance.get().setProperty(ConfigurationFactory.VALIDATION_SKIP_PROPERTY, "true");
    final boolean offline = true;
    final ConfigurationFactory factory = new ConfigurationFactory(offline);
    final String id = "testConfigureApplicationEjbJar";
    final EjbJar ejbJar = new EjbJar(id);
    // no real classes engaged so disable metadata (annotation) processing
    ejbJar.setMetadataComplete(true);
    final EjbJarInfo info = factory.configureApplication(ejbJar);
    // not much to assert
    assertEquals(id, info.moduleName);
}
Also used : EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Aggregations

EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)52 Assembler (org.apache.openejb.assembler.classic.Assembler)34 EjbJar (org.apache.openejb.jee.EjbJar)26 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)21 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)21 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)17 AppInfo (org.apache.openejb.assembler.classic.AppInfo)16 HashMap (java.util.HashMap)14 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)14 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)13 BeanContext (org.apache.openejb.BeanContext)11 File (java.io.File)10 Properties (java.util.Properties)10 InitialContext (javax.naming.InitialContext)10 StatelessBean (org.apache.openejb.jee.StatelessBean)10 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)9 ArrayList (java.util.ArrayList)8 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)8 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)8 Test (org.junit.Test)8