Search in sources :

Example 1 with Assembler

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

the class OpenEjbContainer method doClose.

private synchronized void doClose() {
    if (instance == null) {
        return;
    }
    if (serviceManager != null) {
        serviceManager.stop();
    }
    try {
        globalJndiContext.close();
    } catch (final NamingException e) {
        throw new IllegalStateException(e);
    }
    final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
    if (assembler != null) {
        for (final AppInfo info : assembler.getDeployedApplications()) {
            try {
                assembler.destroyApplication(info);
            } catch (final UndeployException e) {
                logger().error(e.getMessage(), e);
            }
        }
    }
    if (webBeanContext != null) {
        try {
            stopContexts(webBeanContext.getContextsService(), servletContext, session);
        } catch (final Exception e) {
            logger().warning("can't stop all CDI contexts", e);
        }
    }
    logger().info("Destroying OpenEJB container");
    OpenEJB.destroy();
    instance = null;
}
Also used : NamingException(javax.naming.NamingException) Assembler(org.apache.openejb.assembler.classic.Assembler) NamingException(javax.naming.NamingException) EJBException(javax.ejb.EJBException) ValidationFailedException(org.apache.openejb.config.ValidationFailedException) NameNotFoundException(javax.naming.NameNotFoundException) MalformedURLException(java.net.MalformedURLException) ValidationException(javax.validation.ValidationException) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 2 with Assembler

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

the class AutoDeployer method fileAdded.

private boolean fileAdded(final File file) {
    final String appPath = file.getAbsolutePath();
    logger.info("Starting Auto-Deployment of: " + appPath);
    try {
        final AppInfo appInfo = factory.configureApplication(file);
        appInfo.paths.add(appPath);
        appInfo.paths.add(appInfo.path);
        if (logger.isDebugEnabled()) {
            for (final String path : appInfo.paths) {
                logger.debug("Auto-Deployment path: " + path);
            }
        }
        final Assembler assembler = getAssembler();
        if (null == assembler) {
            throw new Exception("Assembler is not available for Auto-Deployment of: " + appPath);
        }
        assembler.createApplication(appInfo);
        // war can be unpacked so it changes the last modified time
        files.get(appPath).setModified(getLastModifiedInDir(new File(appPath)));
    } catch (final Exception e) {
        logger.error("Failed Auto-Deployment of: " + appPath, e);
    }
    return true;
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 3 with Assembler

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

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

the class ApplicationWideTest method testShouldCreateAResourceAndNotRemoveOnUndeploy.

public void testShouldCreateAResourceAndNotRemoveOnUndeploy() throws Exception {
    final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
    final EjbJar ejbJar = ejbModule.getEjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
    final AppModule appModule = new AppModule(ejbModule);
    final Container container = new Container();
    container.setId("My Container");
    container.setCtype("STATELESS");
    container.getProperties().setProperty("ApplicationWide", "true");
    appModule.getContainers().add(container);
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    {
        // setup the system
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    }
    final AppInfo appInfo = config.configureApplication(appModule);
    assembler.createApplication(appInfo);
    {
        final ContainerSystem containerSystem = assembler.getContainerSystem();
        final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
        assertNotNull(appContainer);
    }
    assembler.destroyApplication(appInfo);
    {
        final ContainerSystem containerSystem = assembler.getContainerSystem();
        final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
        assertNotNull(appContainer);
    }
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Container(org.apache.openejb.config.sys.Container) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 5 with Assembler

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

the class CdiDecoratorTest method setUp.

@Before
public void setUp() throws Exception {
    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.createContainer(config.configureService(StatelessSessionContainerInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean("HelloOne", RedBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean("HelloTwo", RedBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
    final Beans beans = new Beans();
    beans.addInterceptor(OrangeCdiInterceptor.class);
    beans.addDecorator(OrangeOneDecorator.class);
    beans.addDecorator(OrangeTwoDecorator.class);
    beans.addManagedClass(YellowBean.class);
    final EjbModule module = new EjbModule(ejbJar);
    module.setBeans(beans);
    assembler.createApplication(config.configureApplication(module));
    final Properties properties = new Properties(System.getProperties());
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    ctx = new InitialContext(properties);
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) Beans(org.apache.openejb.jee.Beans) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) Before(org.junit.Before)

Aggregations

Assembler (org.apache.openejb.assembler.classic.Assembler)177 EjbJar (org.apache.openejb.jee.EjbJar)93 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)88 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)81 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)81 StatelessBean (org.apache.openejb.jee.StatelessBean)58 File (java.io.File)51 InitialContext (javax.naming.InitialContext)50 AppInfo (org.apache.openejb.assembler.classic.AppInfo)49 Properties (java.util.Properties)44 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)40 HashMap (java.util.HashMap)39 ContainerSystem (org.apache.openejb.spi.ContainerSystem)36 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)31 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)30 EjbModule (org.apache.openejb.config.EjbModule)30 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)30 Test (org.junit.Test)29 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)22 Map (java.util.Map)21