Search in sources :

Example 96 with StatelessBean

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

the class InvalidInterfacesTest method test1.

@Keys({ @Key(value = "interface.beanOnlyAnnotation", type = KeyType.WARNING), @Key(value = "interfaceMethod.beanOnlyAnnotation", type = KeyType.WARNING), @Key("aroundInvoke.invalidArguments") })
public EjbJar test1() {
    SystemInstance.get().setProperty("openejb.strict.interface.declaration", "true");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(DBean.class));
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 97 with StatelessBean

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

the class InvalidInterfacesTest method test2.

@Keys({ @Key(value = "ann.remoteOrLocal.converse.parent", count = 2) })
public EjbJar test2() {
    SystemInstance.get().setProperty("openejb.strict.interface.declaration", "true");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(EBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(FBean.class));
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 98 with StatelessBean

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

the class InvalidInterfacesTest method testCorrectInterfaces.

@Keys
public EjbJar testCorrectInterfaces() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
    bean.setHomeAndRemote(FooEJBHome.class, FooEJBObject.class);
    bean.setHomeAndLocal(FooEJBLocalHome.class, FooEJBLocalObject.class);
    bean.addBusinessLocal(FooLocal.class.getName());
    bean.addBusinessRemote(FooRemote.class.getName());
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 99 with StatelessBean

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

the class UberInterfaceTest method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
    assertEquals(asList(Everything.class.getName()), beanInfo.businessLocal);
    assertEquals(asList(Everything.class.getName()), beanInfo.businessRemote);
    assertEquals(Everything.class.getName(), beanInfo.serviceEndpoint);
    assembler.createApplication(ejbJarInfo);
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext deployment = containerSystem.getBeanContext(beanInfo.ejbDeploymentId);
    assertEquals(asList(Everything.class), deployment.getBusinessLocalInterfaces());
    assertEquals(asList(Everything.class), deployment.getBusinessRemoteInterfaces());
    assertEquals(Everything.class, deployment.getServiceEndpointInterface());
    final InitialContext context = new InitialContext();
    final Everything local = (Everything) context.lookup("SuperBeanLocal");
    final Everything remote = (Everything) context.lookup("SuperBeanRemote");
    final Reference reference = new Reference("test");
    assertEquals(reference, local.echo(reference));
    // pass by reference
    assertSame(reference, local.echo(reference));
    assertEquals(reference, remote.echo(reference));
    // pass by value
    assertNotSame(reference, remote.echo(reference));
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) BeanContext(org.apache.openejb.BeanContext) 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 100 with StatelessBean

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

the class LocalClientTest method setUp.

public void setUp() throws OpenEJBException, NamingException, IOException {
    // avoid linkage error on mac, only used for tests so don't need to add it in Core
    JULLoggerFactory.class.getName();
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "test-app");
    final Persistence persistence = new Persistence(new org.apache.openejb.jee.jpa.unit.PersistenceUnit("foo-unit"));
    app.addPersistenceModule(new PersistenceModule("root", persistence));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    final ClientModule clientModule = new ClientModule(null, app.getClassLoader(), app.getJarLocation(), null, null);
    clientModule.getLocalClients().add(this.getClass().getName());
    app.getClientModules().add(clientModule);
    assembler.createApplication(config.configureApplication(app));
}
Also used : Persistence(org.apache.openejb.jee.jpa.unit.Persistence) 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) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

StatelessBean (org.apache.openejb.jee.StatelessBean)132 EjbJar (org.apache.openejb.jee.EjbJar)120 Assembler (org.apache.openejb.assembler.classic.Assembler)58 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)46 EjbModule (org.apache.openejb.config.EjbModule)39 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)33 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)33 InitialContext (javax.naming.InitialContext)31 Properties (java.util.Properties)30 Module (org.apache.openejb.testing.Module)25 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)19 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)18 AppModule (org.apache.openejb.config.AppModule)18 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)17 ServerFederation (org.apache.openejb.core.ServerFederation)15 Context (javax.naming.Context)14 ContainerSystem (org.apache.openejb.spi.ContainerSystem)14 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)13 Empty (org.apache.openejb.jee.Empty)13 StatefulBean (org.apache.openejb.jee.StatefulBean)12