Author: andygumbrecht
Date: Thu Jan 10 15:18:26 2013
New Revision: 1431412
URL: http://svn.apache.org/viewvc?rev=1431412&view=rev
Log:
Default constructor.
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/KeepAilveTest.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/MultithreadTest.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/Server2ServerEjbRefTest.java
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
Thu Jan 10 15:18:26 2013
@@ -40,6 +40,7 @@ import java.util.Properties;
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public class RemoteServer {
+
private static final Options options = new Options(System.getProperties());
public static final String SERVER_DEBUG_PORT = "server.debug.port";
public static final String SERVER_SHUTDOWN_PORT = "server.shutdown.port";
@@ -94,7 +95,7 @@ public class RemoteServer {
public static void main(final String[] args) {
assert args.length > 0 : "no arguments supplied: valid argumen -efts
are 'start' or 'stop'";
- if (args[0].equalsIgnoreCase("start")){
+ if (args[0].equalsIgnoreCase("start")) {
new RemoteServer().start();
} else if (args[0].equalsIgnoreCase("stop")) {
final RemoteServer remoteServer = new RemoteServer();
@@ -104,6 +105,7 @@ public class RemoteServer {
throw new OpenEJBRuntimeException("valid arguments are 'start' or
'stop'");
}
}
+
public Properties getProperties() {
return properties;
}
@@ -141,9 +143,9 @@ public class RemoteServer {
final File home = getHome();
final String javaVersion = System.getProperty("java.version");
if (verbose) {
- System.out.println("OPENEJB_HOME = "+
home.getAbsolutePath());
+ System.out.println("OPENEJB_HOME = " +
home.getAbsolutePath());
final String systemInfo = "Java " + javaVersion + "; " +
System.getProperty("os.name") + "/" + System.getProperty("os.version");
- System.out.println("SYSTEM_INFO = "+systemInfo);
+ System.out.println("SYSTEM_INFO = " + systemInfo);
}
serverHasAlreadyBeenStarted = false;
@@ -171,22 +173,22 @@ public class RemoteServer {
final int debugPort = options.get(SERVER_DEBUG_PORT, 5005);
if (!tomcat) {
if (debug) {
- args = new String[] { java,
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-Xdebug",
- "-Xnoagent",
- "-Djava.compiler=NONE",
-
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + debugPort,
+ args = new String[]{java,
+ "-XX:+HeapDumpOnOutOfMemoryError",
+ "-Xdebug",
+ "-Xnoagent",
+ "-Djava.compiler=NONE",
+
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + debugPort,
- "-javaagent:" + javaagentJar.getAbsolutePath(),
+ "-javaagent:" +
javaagentJar.getAbsolutePath(),
- "-jar", openejbJar.getAbsolutePath(), "start"
+ "-jar",
openejbJar.getAbsolutePath(), "start"
};
} else {
- args = new String[] { java,
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-javaagent:" + javaagentJar.getAbsolutePath(),
- "-jar", openejbJar.getAbsolutePath(), "start"
+ args = new String[]{java,
+ "-XX:+HeapDumpOnOutOfMemoryError",
+ "-javaagent:" +
javaagentJar.getAbsolutePath(),
+ "-jar",
openejbJar.getAbsolutePath(), "start"
};
}
} else {
@@ -199,14 +201,14 @@ public class RemoteServer {
final File conf = new File(home, "conf");
final File loggingProperties = new File(conf,
"logging.properties");
-
File endorsed = new File(home, "endorsed");
if (javaVersion != null && javaVersion.startsWith("1.7."))
{ // java 7
endorsed = new File(home, "endorsed7"); // doesn't
exist but just to ignore it with j7
}
final File temp = new File(home, "temp");
- final List<String> argsList = new ArrayList<String>() {};
+ final List<String> argsList = new ArrayList<String>() {
+ };
argsList.add(java);
argsList.add("-XX:+HeapDumpOnOutOfMemoryError");
@@ -218,8 +220,9 @@ public class RemoteServer {
}
if (profile) {
- String yourkitHome =
options.get("yourkit.home","/Applications/YourKit_Java_Profiler_9.5.6.app/bin/mac/");
- if (!yourkitHome.endsWith("/")) yourkitHome += "/";
+ String yourkitHome = options.get("yourkit.home",
"/Applications/YourKit_Java_Profiler_9.5.6.app/bin/mac/");
+ if (!yourkitHome.endsWith("/"))
+ yourkitHome += "/";
final String yourkitOpts = options.get("yourkit.opts",
"disablestacktelemetry,disableexceptiontelemetry,builtinprobes=none,delay=10000,sessionname=Tomcat");
argsList.add("-agentpath:" + yourkitHome +
"libyjpagent.jnilib=" + yourkitOpts);
}
@@ -305,7 +308,6 @@ public class RemoteServer {
args = argsList.toArray(new String[argsList.size()]);
}
-
if (verbose) {
System.out.println(Join.join("\n", args));
}
@@ -322,17 +324,20 @@ public class RemoteServer {
}
} catch (Exception e) {
- throw (RuntimeException) new OpenEJBRuntimeException("Cannot
start the server. Exception: "+e.getClass().getName()+":
"+e.getMessage()).initCause(e);
+ throw (RuntimeException) new OpenEJBRuntimeException("Cannot
start the server. Exception: " + e.getClass().getName() + ": " +
e.getMessage()).initCause(e);
}
if (checkPortAvailable) {
if (debug) {
- if (!connect(Integer.MAX_VALUE)) throw new
OpenEJBRuntimeException("Could not connect to server");
+ if (!connect(Integer.MAX_VALUE))
+ throw new OpenEJBRuntimeException("Could not connect
to server");
} else {
- if (!connect(tries)) throw new
OpenEJBRuntimeException("Could not connect to server");
+ if (!connect(tries))
+ throw new OpenEJBRuntimeException("Could not connect
to server");
}
}
} else {
- if (verbose) System.out.println("[] FOUND STARTED SERVER");
+ if (verbose)
+ System.out.println("[] FOUND STARTED SERVER");
}
}
@@ -391,9 +396,12 @@ public class RemoteServer {
final File[] files = dir.listFiles();
if (files != null) {
for (final File file : files) {
- if (!file.isFile()) continue;
- if (!file.getName().endsWith(".jar")) continue;
- if (file.getName().startsWith(name)) return file;
+ if (!file.isFile())
+ continue;
+ if (!file.getName().endsWith(".jar"))
+ continue;
+ if (file.getName().startsWith(name))
+ return file;
}
}
}
@@ -484,7 +492,7 @@ public class RemoteServer {
try {
socket = new Socket(host, shutdownPort);
stream = socket.getOutputStream();
- String shutdown = command + Character.toString((char) 0);
+ final String shutdown = command + Character.toString((char) 0);
for (int i = 0; i < shutdown.length(); i++) {
stream.write(shutdown.charAt(i));
}
@@ -506,17 +514,22 @@ public class RemoteServer {
}
private boolean connect(int tries) {
- if (verbose) System.out.println("[] CONNECT ATTEMPT " + (this.tries -
tries));
+ if (verbose)
+ System.out.println("[] CONNECT ATTEMPT " + (this.tries - tries));
- Socket socket = null;
+ Socket s = null;
try {
- socket = new Socket(); // wee need a timeout here
- socket.connect(new InetSocketAddress(host, shutdownPort), 1000);
- socket.getOutputStream().close();
- if (verbose) System.out.println("[] CONNECTED IN " + (this.tries -
tries));
+ s = new Socket();
+ s.connect(new InetSocketAddress(host, shutdownPort), 1000);
+ s.getOutputStream().close();
+ if (verbose) {
+ System.out.println("[] CONNECTED IN " + (this.tries - tries));
+ }
} catch (Exception e) {
if (tries < 2) {
- if (verbose) System.out.println("[] CONNECT ATTEMPTS FAILED (
" + (this.tries - tries) + " tries)");
+ if (verbose) {
+ System.out.println("[] CONNECT ATTEMPTS FAILED ( " +
(this.tries - tries) + " tries)");
+ }
return false;
} else {
try {
@@ -527,9 +540,9 @@ public class RemoteServer {
return connect(--tries);
}
} finally {
- if (socket != null) {
+ if (s != null) {
try {
- socket.close();
+ s.close();
} catch (Exception ignored) {
// no-op
}
@@ -544,7 +557,8 @@ public class RemoteServer {
}
public void killOnExit() {
- if (!serverHasAlreadyBeenStarted && kill.contains(this.server)) return;
+ if (!serverHasAlreadyBeenStarted && kill.contains(this.server))
+ return;
kill.add(this.server);
}
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
Thu Jan 10 15:18:26 2013
@@ -16,24 +16,21 @@
*/
package org.apache.openejb.util;
-import javax.naming.InitialContext;
-import javax.naming.Context;
import java.net.Socket;
-import java.io.OutputStream;
-import java.util.Properties;
/**
* @version $Rev$ $Date$
*/
public class Connect {
- public static boolean connect(int tries, String host, int port) {
+ public static boolean connect(int tries, final String host, final int
port) {
- try {
+ Socket s = null;
- Socket socket = new Socket(host, port);
+ try {
- OutputStream out = socket.getOutputStream();
+ s = new Socket(host, port);
+ s.getOutputStream().close();
} catch (Exception e) {
@@ -57,10 +54,18 @@ public class Connect {
}
+ } finally {
+
+ if (s != null) {
+ try {
+ s.close();
+ } catch (Throwable e) {
+ //Ignore
+ }
+ }
}
return true;
}
-
}
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/NetworkUtil.java
Thu Jan 10 15:18:26 2013
@@ -21,6 +21,7 @@ import java.net.ServerSocket;
import java.util.Collection;
public final class NetworkUtil {
+
private NetworkUtil() {
// no-op
}
@@ -29,52 +30,66 @@ public final class NetworkUtil {
return getNextAvailablePort(new int[]{0});
}
- public static int getNextAvailablePort(int[] portList) {
+ public static int getNextAvailablePort(final int[] portList) {
int port;
ServerSocket s = null;
try {
s = create(portList);
port = s.getLocalPort();
- s.close();
} catch (IOException ioe) {
port = -1;
+ } finally {
+ if (s != null) {
+ try {
+ s.close();
+ } catch (Throwable e) {
+ //Ignore
+ }
+ }
}
return port;
}
- public static int getNextAvailablePort(int min, int max,
Collection<Integer> excepted) {
+ public static int getNextAvailablePort(final int min, final int max, final
Collection<Integer> excepted) {
int port = -1;
ServerSocket s = null;
for (int i = min; i <= max; i++) {
try {
- s = create(new int[] { i });
+ s = create(new int[]{i});
port = s.getLocalPort();
- s.close();
if (excepted == null || !excepted.contains(port)) {
break;
}
} catch (IOException ioe) {
port = -1;
+ } finally {
+ if (s != null) {
+ try {
+ s.close();
+ } catch (Throwable e) {
+ //Ignore
+ }
+ }
}
}
return port;
}
- private static ServerSocket create(int[] ports) throws IOException {
- for (int port : ports) {
+ private static ServerSocket create(final int[] ports) throws IOException {
+ for (final int port : ports) {
try {
return new ServerSocket(port);
} catch (IOException ex) {
- continue; // try next port
+ // try next port
}
}
// if the program gets here, no port in the range was found
- throw new IOException("no free port found");
+ throw new IOException("No free port found");
}
- public static String getLocalAddress(String start, String end) {
+ public static String getLocalAddress(final String start, final String end)
{
return start + "localhost:" + getNextAvailablePort() + end;
}
}
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/KeepAilveTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/KeepAilveTest.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/KeepAilveTest.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/KeepAilveTest.java
Thu Jan 10 15:18:26 2013
@@ -115,7 +115,7 @@ public class KeepAilveTest extends TestC
OpenEJB.init(initProps, new ServerFederation());
ejbServer.init(new Properties());
- final ServicePool pool = new ServicePool(keepAliveServer, 10);
+ final ServicePool pool = new ServicePool(keepAliveServer, 10, 5000,
true);
final ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0,
"localhost");
serviceDaemon.start();
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/MultithreadTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/MultithreadTest.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/MultithreadTest.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/MultithreadTest.java
Thu Jan 10 15:18:26 2013
@@ -16,8 +16,6 @@
*/
package org.apache.openejb.server.ejbd;
-import java.util.concurrent.atomic.AtomicReference;
-import junit.framework.TestCase;
import org.apache.openejb.OpenEJB;
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
@@ -28,19 +26,20 @@ import org.apache.openejb.jee.StatelessB
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.server.ServiceDaemon;
import org.apache.openejb.server.ServicePool;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import javax.ejb.ConcurrentAccessException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
-import javax.ejb.ConcurrentAccessException;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import java.util.concurrent.atomic.AtomicReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -66,7 +65,8 @@ public class MultithreadTest {
final CountDownLatch finishingLine = new CountDownLatch(30);
// Do a business method...
- Runnable r = new Runnable() {
+ final Runnable r = new Runnable() {
+ @Override
public void run() {
counter.race();
finishingLine.countDown();
@@ -77,7 +77,7 @@ public class MultithreadTest {
// How much ever the no of client invocations the count should be 10
as only 10 instances will be created.
for (int i = 0; i < 30; i++) {
- Thread t = new Thread(r);
+ final Thread t = new Thread(r);
t.start();
}
@@ -103,15 +103,16 @@ public class MultithreadTest {
@Test
public void testStatelessBeanRelease() throws Exception {
- invocations = new CountDownLatch(30);
+ invocations = new CountDownLatch(30);
// Do a business method...
- Runnable r = new Runnable(){
- public void run(){
- try{
- counter.explode();
- }catch(Exception e){
-
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ counter.explode();
+ } catch (Exception e) {
+ //Ignore
}
}
};
@@ -120,11 +121,11 @@ public class MultithreadTest {
// 30 instances should be created and discarded.
for (int i = 0; i < 30; i++) {
- Thread t = new Thread(r);
+ final Thread t = new Thread(r);
t.start();
}
- boolean success = invocations.await(10000, TimeUnit.MILLISECONDS);
+ final boolean success = invocations.await(10000,
TimeUnit.MILLISECONDS);
assertTrue(success);
@@ -132,6 +133,7 @@ public class MultithreadTest {
}
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Test
public void testStatelessBeanTimeout() throws Exception {
@@ -141,26 +143,26 @@ public class MultithreadTest {
// Do a business method...
final AtomicReference<Throwable> error = new
AtomicReference<Throwable>();
- Runnable r = new Runnable(){
- public void run(){
- try{
+ final Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
counter.race();
- }catch (ConcurrentAccessException ex){
+ } catch (ConcurrentAccessException ex) {
comment("Leap Start");
timeouts.countDown();
assertEquals("An invocation of the Stateless Session Bean
CounterBean has timed-out", ex.getMessage());
- } catch (Throwable t) {
+ } catch (Throwable t) {
error.set(t);
fail("Unexpected exception" + t.getClass().getName() + " "
+ t.getMessage()); // useless in another thread
}
- }
+ }
};
-
comment("On your mark!");
for (int i = 0; i < 20; i++) {
- Thread t = new Thread(r);
+ final Thread t = new Thread(r);
t.start();
}
@@ -192,30 +194,30 @@ public class MultithreadTest {
@Before
public void setUp() throws Exception {
- int poolSize = 10;
+ final int poolSize = 10;
- System.setProperty("openejb.client.connectionpool.size", "" +
(poolSize*2));
+ System.setProperty("openejb.client.connectionpool.size", "" +
(poolSize * 2));
- EjbServer ejbServer = new EjbServer();
- KeepAliveServer keepAliveServer = new KeepAliveServer(ejbServer);
+ final EjbServer ejbServer = new EjbServer();
+ final KeepAliveServer keepAliveServer = new KeepAliveServer(ejbServer,
false);
- Properties initProps = new Properties();
+ final 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(keepAliveServer, (poolSize*2));
+ final ServicePool pool = new ServicePool(keepAliveServer, (poolSize *
2));
this.serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
serviceDaemon.start();
- int port = serviceDaemon.getPort();
+ final int port = serviceDaemon.getPort();
- ConfigurationFactory config = new ConfigurationFactory();
- Assembler assembler =
SystemInstance.get().getComponent(Assembler.class);
+ final ConfigurationFactory config = new ConfigurationFactory();
+ final Assembler assembler =
SystemInstance.get().getComponent(Assembler.class);
// containers
- StatelessSessionContainerInfo statelessContainerInfo =
config.configureService(StatelessSessionContainerInfo.class);
+ final StatelessSessionContainerInfo statelessContainerInfo =
config.configureService(StatelessSessionContainerInfo.class);
statelessContainerInfo.properties.setProperty("TimeOut", "100");
statelessContainerInfo.properties.setProperty("PoolSize", "" +
poolSize);
statelessContainerInfo.properties.setProperty("MinSize", "2");
@@ -224,36 +226,36 @@ public class MultithreadTest {
// Setup the descriptor information
- StatelessBean bean = new StatelessBean(CounterBean.class);
+ final StatelessBean bean = new StatelessBean(CounterBean.class);
bean.addBusinessLocal(Counter.class.getName());
bean.addBusinessRemote(RemoteCounter.class.getName());
bean.addPostConstruct("init");
bean.addPreDestroy("destroy");
- EjbJar ejbJar = new EjbJar();
+ final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
CounterBean.instances.set(0);
assembler.createApplication(config.configureApplication(ejbJar));
- Properties props = new Properties();
+ final 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);
+ final Context context = new InitialContext(props);
counter = (Counter) context.lookup("CounterBeanRemote");
}
-
public static Object lock = new Object[]{};
- private static void comment(String x) {
-// synchronized(lock){
-// System.out.println(x);
-// System.out.flush();
-// }
+ private static void comment(final String x) {
+ // synchronized(lock){
+ // System.out.println(x);
+ // System.out.flush();
+ // }
}
public static interface Counter {
+
int count();
void race();
@@ -272,12 +274,13 @@ public class MultithreadTest {
public static AtomicInteger instances = new AtomicInteger();
public static AtomicInteger discardedInstances = new AtomicInteger();
- private int count;
+ private final int count;
public CounterBean() {
count = instances.incrementAndGet();
}
+ @Override
public int count() {
return instances.get();
}
@@ -286,6 +289,7 @@ public class MultithreadTest {
return discardedInstances.get();
}
+ @Override
public void explode() {
try {
discardedInstances.incrementAndGet();
@@ -295,6 +299,7 @@ public class MultithreadTest {
}
}
+ @Override
public void race() {
comment("ready = " + count);
startingLine.countDown();
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/Server2ServerEjbRefTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/Server2ServerEjbRefTest.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/Server2ServerEjbRefTest.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/Server2ServerEjbRefTest.java
Thu Jan 10 15:18:26 2013
@@ -44,17 +44,16 @@ public class Server2ServerEjbRefTest ext
public void test() throws Exception {
- Properties initProps = new Properties();
+ 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 int blue = server();
+ final int orange = server();
- int blue = server();
- int orange = server();
-
- Assembler assembler =
SystemInstance.get().getComponent(Assembler.class);
- ConfigurationFactory config = new ConfigurationFactory();
+ final Assembler assembler =
SystemInstance.get().getComponent(Assembler.class);
+ final ConfigurationFactory config = new ConfigurationFactory();
final JndiProvider jndiProvider = new JndiProvider("orange");
final Properties p = jndiProvider.getProperties();
@@ -64,9 +63,8 @@ public class Server2ServerEjbRefTest ext
final JndiContextInfo contextInfo =
config.configureService(jndiProvider, JndiContextInfo.class);
assembler.createExternalContext(contextInfo);
-
{// Create the "Orange" bean
- EjbJar ejbJar = new EjbJar();
+ final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
@@ -78,7 +76,7 @@ public class Server2ServerEjbRefTest ext
}
{// Create the "Blue" bean
- EjbJar ejbJar = new EjbJar();
+ final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(BlueBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
@@ -93,25 +91,23 @@ public class Server2ServerEjbRefTest ext
blueBeanRemote.hasOrangeRemote();
}
-
}
private int server() throws Exception {
- EjbServer ejbServer = new EjbServer();
+ final EjbServer ejbServer = new EjbServer();
ejbServer.init(new Properties());
- ServicePool pool = new ServicePool(ejbServer, 10);
- ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
+ final ServicePool pool = new ServicePool(ejbServer, 10, 5000, true);
+ final ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0,
"localhost");
serviceDaemon.start();
return serviceDaemon.getPort();
}
-
public static class OrangeBean implements OrangeRemote {
@Override
- public String echo(String message) {
+ public String echo(final String message) {
return new StringBuilder(message).reverse().toString();
}
}
@@ -127,6 +123,7 @@ public class Server2ServerEjbRefTest ext
@EJB(mappedName = "jndi:ext://orange/OrangeBeanRemote")
private OrangeRemote orangeRemote;
+ @Override
public void hasOrangeRemote() {
Assert.assertNotNull("orangeRemote is null", orangeRemote);
assertEquals("olleh", orangeRemote.echo("hello"));
@@ -135,6 +132,7 @@ public class Server2ServerEjbRefTest ext
@Remote
public static interface BlueRemote {
+
public void hasOrangeRemote();
}
}
Modified:
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java?rev=1431412&r1=1431411&r2=1431412&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
(original)
+++
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
Thu Jan 10 15:18:26 2013
@@ -48,6 +48,10 @@ public class ServicePool extends ServerS
this(next, new Options(properties).get("threads", 50), new
Options(properties).get("queue", 50000), new Options(properties).get("block",
false));
}
+ public ServicePool(final ServerService next, final int threads) {
+ this(next, threads, 50000, true);
+ }
+
public ServicePool(final ServerService next, int threads, int queue, final
boolean block) {
super(next);