Search in sources :

Example 96 with Assembler

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

the class ServiceClasspathTest method testRelativePath.

@Test
public void testRelativePath() throws Exception {
    final String className = "org.superbiz.foo.Orange";
    final File jar = subclass(Color.class, className);
    final File xml = File.createTempFile("config-", ".xml");
    xml.deleteOnExit();
    final PrintStream out = new PrintStream(IO.write(xml));
    out.println("<openejb>\n" + "  <Resource id=\"Orange\" type=\"org.superbiz.foo.Orange\"" + "           class-name=\"org.superbiz.foo.Orange\"" + "           classpath=\"${openejb.home}/" + jar.getName() + "\">\n" + "    red = FF\n" + "    green = 99\n" + "    blue = 00\n" + "  </Resource>\n" + "</openejb>");
    out.close();
    new File(jar.getParentFile(), "temp").mkdirs();
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    final Properties properties = new Properties();
    properties.setProperty("openejb.home", jar.getParentFile().getAbsolutePath());
    SystemInstance.init(properties);
    PropertyPlaceHolderHelper.reset();
    createEnvrt();
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.buildContainerSystem(config.getOpenEjbConfiguration(xml));
    final InitialContext initialContext = new InitialContext();
    final Color color = (Color) initialContext.lookup("openejb:Resource/Orange");
    assertNotNull(color);
    assertEquals("Orange.FF", color.getRed());
    assertEquals("Orange.99", color.getGreen());
    assertEquals("Orange.00", color.getBlue());
}
Also used : PrintStream(java.io.PrintStream) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) File(java.io.File) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 97 with Assembler

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

the class ModulePropertiesTest method testOverrideAdd.

public void testOverrideAdd() throws Exception {
    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));
    }
    {
        SystemInstance.get().getProperties().put("fooModule.color", "orange");
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        final File module = Archives.fileArchive(map, WidgetBean.class);
        final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
        final AppInfo appInfo = config.configureApplication(appModule);
        assembler.createApplication(appInfo);
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    assertContexts(containerSystem);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 98 with Assembler

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

the class StatefulTimeoutTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.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));
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
    // clear cache every 3 seconds
    statefulContainerInfo.properties.setProperty("Frequency", "3");
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    Timeout timeout;
    final StatefulBean bean1 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(-1);
    timeout.setUnit(TimeUnit.SECONDS);
    bean1.setStatefulTimeout(timeout);
    final StatefulBean bean0 = new StatefulBean("BeanZero", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(0);
    timeout.setUnit(TimeUnit.SECONDS);
    bean0.setStatefulTimeout(timeout);
    final StatefulBean bean5 = new StatefulBean("Bean", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(5);
    timeout.setUnit(TimeUnit.SECONDS);
    bean5.setStatefulTimeout(timeout);
    ejbJar.addEnterpriseBean(bean1);
    ejbJar.addEnterpriseBean(bean0);
    ejbJar.addEnterpriseBean(bean5);
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) Timeout(org.apache.openejb.jee.Timeout) StatefulBean(org.apache.openejb.jee.StatefulBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 99 with Assembler

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

the class StatelessInstanceManagerPoolingTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.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));
    // containers
    final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
    statelessContainerInfo.properties.setProperty("TimeOut", "100");
    statelessContainerInfo.properties.setProperty("MaxSize", "10");
    statelessContainerInfo.properties.setProperty("MinSize", "2");
    statelessContainerInfo.properties.setProperty("StrictPooling", "true");
    assembler.createContainer(statelessContainerInfo);
    // Setup the descriptor information
    final StatelessBean bean = new StatelessBean(CounterBean.class);
    bean.addBusinessLocal(Counter.class.getName());
    bean.addBusinessRemote(RemoteCounter.class.getName());
    bean.addPostConstruct("init");
    bean.addPreDestroy("destroy");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(bean);
    instances.set(0);
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) 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) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 100 with Assembler

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

the class StatelessInterceptorTest method setUp.

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 EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
    assertNotNull(ejbJar);
    assembler.createApplication(ejbJar);
    final Properties properties = new Properties(System.getProperties());
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    ctx = new InitialContext(properties);
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) InitialContext(javax.naming.InitialContext)

Aggregations

Assembler (org.apache.openejb.assembler.classic.Assembler)173 EjbJar (org.apache.openejb.jee.EjbJar)90 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)83 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)80 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)80 StatelessBean (org.apache.openejb.jee.StatelessBean)54 File (java.io.File)49 InitialContext (javax.naming.InitialContext)49 Properties (java.util.Properties)45 AppInfo (org.apache.openejb.assembler.classic.AppInfo)44 HashMap (java.util.HashMap)39 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)39 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)34 ContainerSystem (org.apache.openejb.spi.ContainerSystem)33 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)29 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)28 Test (org.junit.Test)27 EjbModule (org.apache.openejb.config.EjbModule)26 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)22 Map (java.util.Map)21