当前位置: 首页>>代码示例>>Java>>正文


Java EJBContainer.close方法代码示例

本文整理汇总了Java中javax.ejb.embeddable.EJBContainer.close方法的典型用法代码示例。如果您正苦于以下问题:Java EJBContainer.close方法的具体用法?Java EJBContainer.close怎么用?Java EJBContainer.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ejb.embeddable.EJBContainer的用法示例。


在下文中一共展示了EJBContainer.close方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: classpath

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void classpath() throws Exception {

    final Properties p = new Properties();
    p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName());
    p.setProperty(DeploymentsResolver.CLASSPATH_INCLUDE, ".*tomee-embedded.*");
    p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1");

    EJBContainer container = null;
    try {
        container = EJBContainer.createEJBContainer(p);
        assertNotNull(container);
        assertNotNull(container.getContext());
        final ABean bean = ABean.class.cast(container.getContext().lookup("java:global/tomee-embedded/ABean"));
        assertNotNull(bean);
        assertEquals("ok", bean.embedded());
    } finally {
        if (container != null) {
            container.close();
        }
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:23,代码来源:EmbeddedTomEEContainerTest.java

示例2: accessDatasource

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void accessDatasource() throws Exception {
    // define the datasource
    Properties properties = new Properties();
    properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
    properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
    properties.setProperty("ProtectedDatasource.JdbcUrl", DATASOURCE_URL);
    properties.setProperty("ProtectedDatasource.UserName", USER);
    properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
    properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
    properties.setProperty("ProtectedDatasource.JtaManaged", "true");

    // start the context and makes junit test injections
    EJBContainer container = EJBContainer.createEJBContainer(properties);
    Context context = container.getContext();
    context.bind("inject", this);

    // test the datasource
    assertNotNull(dataSource);
    assertNotNull(dataSource.getConnection());

    // closing the context
    container.close();
}
 
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:DataSourceCipheredExampleTest.java

示例3: accessDatasourceWithMyImplementation

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void accessDatasourceWithMyImplementation() throws Exception {
    // define the datasource
    Properties properties = new Properties();
    properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
    properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
    properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
    properties.setProperty("ProtectedDatasource.UserName", USER);
    properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
    properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
    properties.setProperty("ProtectedDatasource.JtaManaged", "true");

    // start the context and makes junit test injections
    EJBContainer container = EJBContainer.createEJBContainer(properties);
    Context context = container.getContext();
    context.bind("inject", this);

    // test the datasource
    assertNotNull(dataSource);
    assertNotNull(dataSource.getConnection());

    // closing the context
    container.close();
}
 
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:DataSourceCipheredExampleTest.java

示例4: play

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void play() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
    EJBContainer container = EJBContainer.createEJBContainer(properties);

    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ObjectName objectName = new ObjectName(OBJECT_NAME);
    assertEquals(0, server.getAttribute(objectName, "value"));
    server.setAttribute(objectName, new Attribute("value", 3));
    assertEquals(3, server.getAttribute(objectName, "value"));
    assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
    assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));

    container.close();
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:GuessHowManyMBeanTest.java

示例5: noRestart

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void noRestart() throws Exception {
    final EJBContainer container1 = EJBContainer.createEJBContainer(new Properties() {{
        put(EJBContainer.MODULES, new EjbJar());
        put(OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE, OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE_SINGLE);
    }});
    container1.close();
    final EJBContainer container2 = EJBContainer.createEJBContainer(new Properties() {{
        put(EJBContainer.MODULES, new EjbJar());
    }});
    container2.close();
    assertTrue(SystemInstance.isInitialized());
    assertSame(container1, container2);
    Reflections.invokeByReflection(container2, "doClose", new Class<?>[0], null);
    assertFalse(SystemInstance.isInitialized());
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:OpenEjbContainerNoRestartTest.java

示例6: testGetList

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
/**
 * Test of getList method, of class QaEJB.
 */
@Test
public void testGetList() throws Exception {
    System.out.println("getList");
    EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
    QaEJB instance = (QaEJB)container.getContext().lookup("java:global/classes/QaEJB");
    List expResult = null;
    List result = instance.getList();
    assertEquals(expResult, result);
    container.close();
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:16,代码来源:QaEJBTest.java

示例7: containerTest

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void containerTest() throws Exception {

    final File war = createWar();
    final Properties p = new Properties();
    p.setProperty(EJBContainer.APP_NAME, "test");
    p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName());
    p.put(EJBContainer.MODULES, war.getAbsolutePath());
    p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1");

    EJBContainer container = null;
    try {
        container = EJBContainer.createEJBContainer(p);
        assertNotNull(container);
        assertNotNull(container.getContext());
        final URL url = new URL("http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/test/index.html");
        assertEquals("true", getOk(url, 2));

    } finally {

        if (container != null) {
            container.close();
        }

        try {
            FileUtils.forceDelete(war);
        } catch (final IOException e) {
            FileUtils.deleteQuietly(war);
        }
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:32,代码来源:EmbeddedTomEEContainerTest.java

示例8: test

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
public void test() throws Exception {

        final Properties p = new Properties();
        p.put("movieDatabase", "new://Resource?type=DataSource");
        p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");

        EJBContainer container = EJBContainer.createEJBContainer(p);
        final Context context = container.getContext();

        Movies movies = (Movies) context.lookup("java:global/injection-of-entitymanager/Movies");

        movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
        movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
        movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));

        List<Movie> list = movies.getMovies();
        assertEquals("List.size()", 3, list.size());

        for (Movie movie : list) {
            movies.deleteMovie(movie);
        }

        assertEquals("Movies.getMovies()", 0, movies.getMovies().size());

        container.close();
    }
 
开发者ID:apache,项目名称:tomee,代码行数:28,代码来源:MoviesTest.java

示例9: test

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final Properties p = new Properties();
    p.put("movieDatabase", "new://Resource?type=DataSource");
    p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
    p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");

    final EJBContainer container = EJBContainer.createEJBContainer(p);
    final Context context = container.getContext();
    context.bind("inject", this);

    assertTrue(((ReloadableEntityManagerFactory) emf).getManagedClasses().contains(Movie.class.getName()));

    container.close();
}
 
开发者ID:apache,项目名称:tomee,代码行数:16,代码来源:MoviesTest.java

示例10: execute

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    MavenLogStreamFactory.setLogger(getLog());
    final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(createClassLoader(oldCl));

    EJBContainer container = null;
    try {
        container = EJBContainer.createEJBContainer(map());
        if (await) {
            final CountDownLatch latch = new CountDownLatch(1);
            Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                @Override
                public void run() {
                    latch.countDown();
                }
            }));
            try {
                latch.await();
            } catch (final InterruptedException e) {
                // ignored
            }
        }
    } finally {
        if (container != null) {
            container.close();
        }
        Thread.currentThread().setContextClassLoader(oldCl);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:31,代码来源:OpenEJBEmbeddedMojo.java

示例11: after

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Override
protected void after() throws Exception {
    final EJBContainer container = startingStatement.getContainer();
    if (container != null) {
        container.close();
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:8,代码来源:ShutingDownStatement.java

示例12: normalRestart

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
@Test
public void normalRestart() throws Exception {
    final EJBContainer container1 = EJBContainer.createEJBContainer(new Properties() {{
        put(EJBContainer.MODULES, new EjbJar());
    }});
    container1.close();
    final EJBContainer container2 = EJBContainer.createEJBContainer(new Properties() {{
        put(EJBContainer.MODULES, new EjbJar());
    }});
    container2.close();
    assertNotSame(container1, container2);
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:OpenEjbContainerNoRestartTest.java

示例13: test

import javax.ejb.embeddable.EJBContainer; //导入方法依赖的package包/类
public void test() throws Exception {

        final Properties p = new Properties();
        p.put("movieDatabase", "new://Resource?type=DataSource");
        p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");

        EJBContainer container = EJBContainer.createEJBContainer(p);
        final Context context = container.getContext();

        final Movies movies = (Movies) context.lookup("java:global/jpa-enumerated/Movies");

        movies.addMovie(new Movie("James Frawley", "The Muppet Movie", 1979, Rating.G));
        movies.addMovie(new Movie("Jim Henson", "The Great Muppet Caper", 1981, Rating.G));
        movies.addMovie(new Movie("Frank Oz", "The Muppets Take Manhattan", 1984, Rating.G));
        movies.addMovie(new Movie("James Bobin", "The Muppets", 2011, Rating.PG));

        assertEquals("List.size()", 4, movies.getMovies().size());

        assertEquals("List.size()", 3, movies.findByRating(Rating.G).size());

        assertEquals("List.size()", 1, movies.findByRating(Rating.PG).size());

        assertEquals("List.size()", 0, movies.findByRating(Rating.R).size());

        container.close();
    }
 
开发者ID:apache,项目名称:tomee,代码行数:28,代码来源:MoviesTest.java


注:本文中的javax.ejb.embeddable.EJBContainer.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。