Search in sources :

Example 31 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class TransactionRollbackCauseTest method test.

public void test() throws Exception {
    final Map<String, Object> map = new HashMap<String, Object>();
    map.put(EJBContainer.MODULES, new SingletonBean(Orange.class));
    EJBContainer.createEJBContainer(map).getContext().bind("inject", this);
    userTransaction.begin();
    orange.exceptionRollback();
    try {
        userTransaction.commit();
        fail("transaction should have been rolled back");
    } catch (final RollbackException e) {
        final Throwable throwable = e.getCause();
        assertTrue(throwable instanceof UserException);
    }
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) HashMap(java.util.HashMap) RollbackException(javax.transaction.RollbackException)

Example 32 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class VagueEnvEntriesMatchTest method foo.

@Module
public SingletonBean foo() {
    final SingletonBean singletonBean = new SingletonBean(Blue.class);
    singletonBean.getEnvEntry().add(new EnvEntry().name("one").type(String.class).value("hello"));
    singletonBean.getEnvEntry().add(new EnvEntry().name("two").type(String.class).value("false"));
    singletonBean.getEnvEntry().add(new EnvEntry().name(Blue.class.getName() + "/two").type(String.class).value("true"));
    return singletonBean;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) EnvEntry(org.apache.openejb.jee.EnvEntry) Module(org.apache.openejb.testing.Module)

Example 33 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class CheckInvalidCallbacksTest method test.

@Keys({ @Key(value = "ignoredMethodAnnotation", count = 10, type = KeyType.WARNING), @Key("callback.invalidArguments"), @Key("callback.badReturnType"), @Key("callback.badModifier"), @Key("callback.invalidArguments"), @Key("aroundInvoke.missing"), @Key("callback.missing"), @Key(value = "callback.sessionSynchronization.invalidUse", count = 2) })
public EjbJar test() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean testBean = ejbJar.addEnterpriseBean(new StatelessBean("TestStateless", TestBean.class));
    testBean.addAroundInvoke("wrongMethod");
    testBean.addPostConstruct("wrongMethod");
    ejbJar.addEnterpriseBean(new SingletonBean("TestSingleton", TestBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean("FooStateful", FooBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean("BarStateful", BarBean.class));
    final StatefulBean starBean = ejbJar.addEnterpriseBean(new StatefulBean("StarStateful", StarBean.class));
    starBean.setAfterBeginMethod(new NamedMethod("myAfterBegin"));
    starBean.setBeforeCompletionMethod(new NamedMethod("myBeforeCompletion"));
    starBean.setAfterCompletionMethod(new NamedMethod("myAfterCompletion"));
    return ejbJar;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) StatelessBean(org.apache.openejb.jee.StatelessBean) StatefulBean(org.apache.openejb.jee.StatefulBean) NamedMethod(org.apache.openejb.jee.NamedMethod) EjbJar(org.apache.openejb.jee.EjbJar)

Example 34 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class CheckInvalidConcurrencyAttributeTest method test.

@Keys({ @Key(value = "ann.invalidConcurrencyAttribute", type = KeyType.WARNING), @Key(value = "aroundInvoke.invalidArguments") })
public EjbJar test() throws Exception {
    System.setProperty("openejb.validation.output.level", "VERBOSE");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(TestBean.class));
    return ejbJar;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 35 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class SystemApps method getSystemModule.

public static EjbModule getSystemModule() {
    final EjbModule module = new EjbModule(new EjbJar("openejb"), new OpenejbJar());
    final OpenejbJar openejbJar = module.getOpenejbJar();
    final EjbJar ejbJar = module.getEjbJar();
    // 
    // 
    // DONT MODIFY IT WITHOUT VALIDATING org.apache.openejb.config.SystemAppInfo.preComputedInfo()
    // 
    // 
    ejbJar.addEnterpriseBean(singleton(DeployerEjb.class));
    ejbJar.addEnterpriseBean(singleton(ConfigurationInfoEjb.class));
    ejbJar.addEnterpriseBean(singleton(MEJBBean.class));
    ejbJar.addInterceptor(new Interceptor(InternalSecurityInterceptor.class));
    ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", InternalSecurityInterceptor.class.getName()));
    module.getMbeans().add(JMXDeployer.class.getName());
    final SingletonBean bean = ejbJar.addEnterpriseBean(new SingletonBean("openejb/WebappDeployer", "org.apache.tomee.catalina.deployer.WebappDeployer"));
    final EjbDeployment deployment = openejbJar.addEjbDeployment(bean);
    deployment.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}");
    final SingletonBean exceptionManager = ejbJar.addEnterpriseBean(new SingletonBean("openejb/ExceptionManagerFacade", "org.apache.tomee.catalina.facade.ExceptionManagerFacadeBean"));
    final EjbDeployment exceptionMgr = openejbJar.addEjbDeployment(exceptionManager);
    exceptionMgr.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}");
    openejbJar.getProperties().put("openejb.deploymentId.format", "{ejbName}");
    openejbJar.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.openejbLegacyName}");
    return module;
}
Also used : MEJBBean(org.apache.openejb.mgmt.MEJBBean) InternalSecurityInterceptor(org.apache.openejb.security.internal.InternalSecurityInterceptor) InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) SingletonBean(org.apache.openejb.jee.SingletonBean) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) DeployerEjb(org.apache.openejb.assembler.DeployerEjb) JMXDeployer(org.apache.openejb.assembler.monitoring.JMXDeployer) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) ConfigurationInfoEjb(org.apache.openejb.assembler.classic.cmd.ConfigurationInfoEjb) Interceptor(org.apache.openejb.jee.Interceptor) InternalSecurityInterceptor(org.apache.openejb.security.internal.InternalSecurityInterceptor) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

SingletonBean (org.apache.openejb.jee.SingletonBean)49 EjbJar (org.apache.openejb.jee.EjbJar)42 EjbModule (org.apache.openejb.config.EjbModule)21 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)17 Module (org.apache.openejb.testing.Module)16 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)12 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)12 AppModule (org.apache.openejb.config.AppModule)11 Properties (java.util.Properties)10 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)10 InitialContext (javax.naming.InitialContext)8 StatelessBean (org.apache.openejb.jee.StatelessBean)8 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)7 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)6 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)6 Empty (org.apache.openejb.jee.Empty)6 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)5 Test (org.junit.Test)5