use of org.apache.openejb.server.ServiceDaemon in project tomee by apache.
the class FullPoolFailoverTest method createServiceDaemon.
private ServiceDaemon createServiceDaemon(final int poolSize, final EjbServer ejbServer, URI uri) throws ServiceException {
ServiceIdentifier serviceIdentifier = new ServiceIdentifier(ejbServer, uri);
KeepAliveServer keepAliveServer = new KeepAliveServer(serviceIdentifier);
ServicePool pool = new ServicePool(keepAliveServer, poolSize);
final ServiceDaemon daemon = new ServiceDaemon(pool, 0, "localhost");
daemon.start();
return daemon;
}
use of org.apache.openejb.server.ServiceDaemon in project tomee by apache.
the class PropertiesPropogationTest method test.
public void test() throws Exception {
EjbServer ejbServer = new EjbServer();
Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
ejbServer.init(new Properties());
ServicePool pool = new ServicePool(ejbServer, 10);
ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
serviceDaemon.start();
int port = serviceDaemon.getPort();
Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
ConfigurationFactory config = new ConfigurationFactory();
EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
EjbJar ejbJar = ejbModule.getEjbJar();
OpenejbJar openejbJar = ejbModule.getOpenejbJar();
StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
deployment.getProperties().put("color", "orange");
deployment.getProperties().put("openejb.client.color", "red");
EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
assertTrue(beanInfo.properties.containsKey("color"));
assertTrue(beanInfo.properties.containsKey("openejb.client.color"));
assertEquals("orange", beanInfo.properties.get("color"));
assertEquals("red", beanInfo.properties.get("openejb.client.color"));
assembler.createApplication(ejbJarInfo);
ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class);
BeanContext info = cs.getBeanContext("WidgetBean");
assertNotNull(info);
assertTrue(info.getProperties().containsKey("color"));
assertTrue(info.getProperties().containsKey("openejb.client.color"));
assertEquals("orange", info.getProperties().get("color"));
assertEquals("red", info.getProperties().get("openejb.client.color"));
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", "ejbd://127.0.0.1:" + port);
Context context = new InitialContext(props);
Widget remote = (Widget) context.lookup("WidgetBeanRemote");
InvocationHandler handler = ProxyManager.getInvocationHandler(remote);
EJBObjectHandler objectHandler = EJBObjectHandler.class.cast(handler);
Properties properties = objectHandler.getEjb().getProperties();
// Should only contain "openejb.client.*" properties
assertFalse(properties.containsKey("color"));
// The openejb.client.color property should have been propogated
assertTrue(properties.containsKey("openejb.client.color"));
assertEquals("red", properties.getProperty("openejb.client.color"));
serviceDaemon.stop();
OpenEJB.destroy();
}
use of org.apache.openejb.server.ServiceDaemon in project tomee by apache.
the class Server2ServerEjbRefTest method server.
private ServiceDaemon server() throws Exception {
final EjbServer ejbServer = new EjbServer();
ejbServer.init(new Properties());
final ServicePool pool = new ServicePool(ejbServer, 10, 5000, true);
final ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
serviceDaemon.start();
return serviceDaemon;
}
use of org.apache.openejb.server.ServiceDaemon in project tomee by apache.
the class Server2ServerEjbRefTest method test.
public void test() throws Exception {
final Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
final ServiceDaemon blue = server();
final ServiceDaemon orange = server();
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
final ConfigurationFactory config = new ConfigurationFactory();
final JndiProvider jndiProvider = new JndiProvider("orange");
final Properties p = jndiProvider.getProperties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
p.setProperty(Context.PROVIDER_URL, "ejbd://localhost:" + orange.getPort());
final JndiContextInfo contextInfo = config.configureService(jndiProvider, JndiContextInfo.class);
assembler.createExternalContext(contextInfo);
{
// Create the "Orange" bean
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
// Lets look it up the normal way to be sure it can work
final InitialContext initialContext = new InitialContext(jndiProvider.getProperties());
final OrangeRemote orangeBeanRemote = (OrangeRemote) initialContext.lookup("OrangeBeanRemote");
assertNotNull(orangeBeanRemote);
}
{
// Create the "Blue" bean
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(BlueBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
// Lets look it up the normal way to be sure it can work
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:" + blue.getPort());
final InitialContext initialContext = new InitialContext(properties);
final BlueRemote blueBeanRemote = (BlueRemote) initialContext.lookup("BlueBeanRemote");
assertNotNull(blueBeanRemote);
blueBeanRemote.hasOrangeRemote();
}
blue.stop();
orange.stop();
OpenEJB.destroy();
}
use of org.apache.openejb.server.ServiceDaemon in project tomee by apache.
the class FailoverTest method server.
private ServerService server(final Host host) throws Exception {
ServerService server = new EjbServer();
server = new HostFilter(server, host);
server = new ServiceDaemon(server, 0, "localhost");
server = new AgentFilter(server, agent, host);
server.init(new Properties());
return server;
}
Aggregations