tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1414664 - in /openejb/trunk/openejb: server/openejb-client/src/main/java/org/apache/openejb/client/ server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/ server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server...
Date Wed, 28 Nov 2012 13:23:33 GMT
Author: rmannibucau
Date: Wed Nov 28 13:23:30 2012
New Revision: 1414664

URL: http://svn.apache.org/viewvc?rev=1414664&view=rev
Log:
OPENEJB-1958 basic gzip support for ejbd (when started by itself)

Added:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/FlushableGZIPOutputStream.java
    openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/ZEjbdTest.java
Modified:
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Registry.java
    openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/SocketConnectionFactory.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbServer.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/KeepAliveServer.java
    openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbd
    openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbds
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
    openejb/trunk/openejb/server/openejb-server/src/test/java/org/apache/openejb/server/FilteredServiceManagerTest.java
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEServiceManager.java
    openejb/trunk/openejb/tomee/tomee-webapp/src/main/resources/META-INF/org.apache.tomee/service-jar.xml

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/ConnectionManager.java
Wed Nov 28 13:23:30 2012
@@ -38,6 +38,8 @@ public class ConnectionManager {
         registerFactory("default", ejbdFactory);
         registerFactory("ejbd", ejbdFactory);
         registerFactory("ejbds", ejbdFactory);
+        registerFactory("zejbd", ejbdFactory);
+        registerFactory("zejbds", ejbdFactory);
 
         final HttpConnectionFactory httpFactory = new HttpConnectionFactory();
         registerFactory("http", httpFactory);

Added: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/FlushableGZIPOutputStream.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/FlushableGZIPOutputStream.java?rev=1414664&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/FlushableGZIPOutputStream.java
(added)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/FlushableGZIPOutputStream.java
Wed Nov 28 13:23:30 2012
@@ -0,0 +1,141 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.client;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.Deflater;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * Extension of {@link GZIPOutputStream} to workaround for a couple of long
+ * standing JDK bugs
+ * (<a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4255743">Bug
+ * 4255743</a> and
+ * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4813885">Bug
+ * 4813885</a>) so the GZIP'd output can be flushed. 
+ */
+public class FlushableGZIPOutputStream extends GZIPOutputStream {
+    public FlushableGZIPOutputStream(OutputStream os) throws IOException {
+        super(os);
+    }
+
+    /**
+     * It is used to reserve one byte of real data so that it can be used when
+     * flushing the stream.
+     */
+    private byte[] lastByte = new byte[1];
+    private boolean hasLastByte = false;
+
+    @Override
+    public void write(byte[] bytes) throws IOException {
+        write(bytes, 0, bytes.length);
+    }
+
+    @Override
+    public synchronized void write(byte[] bytes, int offset, int length)
+            throws IOException {
+        if (length > 0) {
+            flushLastByte();
+            if (length > 1) {
+                super.write(bytes, offset, length - 1);
+            }
+            rememberLastByte(bytes[offset + length - 1]);
+        }
+    }
+
+    @Override
+    public synchronized void write(int i) throws IOException {
+        flushLastByte();
+        rememberLastByte((byte) i);
+    }
+
+    @Override
+    public synchronized void finish() throws IOException {
+        try {
+            flushLastByte();
+        } catch (IOException ignore) {
+            // If our write failed, then trailer write in finish() will fail
+            // with IOException as well, but it will leave Deflater in more
+            // consistent state.
+        }
+        super.finish();
+    }
+
+    @Override
+    public synchronized void close() throws IOException {
+        try {
+            flushLastByte();
+        } catch (IOException ignored) {
+            // Ignore. As OutputStream#close() says, the contract of close()
+            // is to close the stream. It does not matter much if the
+            // stream is not writable any more.
+        }
+        super.close();
+    }
+
+    private void rememberLastByte(byte b) {
+        lastByte[0] = b;
+        hasLastByte = true;
+    }
+
+    private void flushLastByte() throws IOException {
+        if (hasLastByte) {
+            // Clear the flag first, because write() may fail
+            hasLastByte = false;
+            super.write(lastByte, 0, 1);
+        }
+    }
+
+    @Override
+    public synchronized void flush() throws IOException {
+        if (hasLastByte) {
+            // - do not allow the gzip header to be flushed on its own
+            // - do not do anything if there is no data to send
+
+            // trick the deflater to flush
+            /**
+             * Now this is tricky: We force the Deflater to flush its data by
+             * switching compression level. As yet, a perplexingly simple workaround
+             * for
+             * http://developer.java.sun.com/developer/bugParade/bugs/4255743.html
+             */
+            if (!def.finished()) {
+                def.setLevel(Deflater.NO_COMPRESSION);
+                flushLastByte();
+                def.setLevel(Deflater.DEFAULT_COMPRESSION);
+            }
+        }
+        out.flush();
+    }
+
+    /*
+     * Keep on calling deflate until it runs dry. The default implementation
+     * only does it once and can therefore hold onto data when they need to be
+     * flushed out.
+     */
+    @Override
+    protected void deflate() throws IOException {
+        int len;
+        do {
+            len = def.deflate(buf, 0, buf.length);
+            if (len > 0) {
+                out.write(buf, 0, len);
+            }
+        } while (len > 0 || !def.needsInput());
+    }
+}

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Registry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Registry.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Registry.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/Registry.java
Wed Nov 28 13:23:30 2012
@@ -34,7 +34,7 @@ public class Registry<T> {
 
 
     public static <T> Registry<T> create(Class<T> type){
-        return new Registry(type);
+        return new Registry<T>(type);
     }
 
     private Registry(Class<T> type) {

Modified: openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/SocketConnectionFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/SocketConnectionFactory.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/SocketConnectionFactory.java
(original)
+++ openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/SocketConnectionFactory.java
Wed Nov 28 13:23:30 2012
@@ -40,6 +40,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.zip.GZIPInputStream;
 
 public class SocketConnectionFactory implements ConnectionFactory {
 
@@ -198,7 +199,8 @@ public class SocketConnectionFactory imp
         private final Pool pool;
         private final Lock lock = new ReentrantLock();
         private OutputStream out;
-        private BufferedInputStream in;
+        private InputStream in;
+        private boolean gzip = false;
 
         public SocketConnection(final URI uri, final Pool pool) {
             this.uri = uri;
@@ -251,7 +253,8 @@ public class SocketConnectionFactory imp
             final InetSocketAddress address = new InetSocketAddress(uri.getHost(), uri.getPort());
 
             try {
-                if (uri.getScheme().equalsIgnoreCase("ejbds")) {
+                final String scheme = uri.getScheme();
+                if (scheme.equalsIgnoreCase("ejbds") || scheme.equalsIgnoreCase("zejbds"))
{
                     final SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
                     sslSocket.setEnabledCipherSuites(enabledCipherSuites);
                     this.socket = sslSocket;
@@ -260,6 +263,10 @@ public class SocketConnectionFactory imp
                     this.socket = new Socket();
                 }
 
+                if (scheme.startsWith("z")) {
+                    gzip = true;
+                }
+
                 this.socket.setTcpNoDelay(true);
                 this.socket.setSoLinger(true, 10);
                 this.socket.connect(address, SocketConnectionFactory.this.timeoutSocket);
@@ -319,7 +326,11 @@ public class SocketConnectionFactory imp
             /*----------------------------------*/
             try {
                 if (in == null) {
-                    in = new BufferedInputStream(socket.getInputStream());
+                    if (!gzip) {
+                        in = new BufferedInputStream(socket.getInputStream());
+                    } else {
+                        in = new GZIPInputStream(socket.getInputStream());
+                    }
                 }
 
                 return new Input(in);
@@ -341,7 +352,11 @@ public class SocketConnectionFactory imp
             try {
 
                 if (out == null) {
-                    out = new BufferedOutputStream(socket.getOutputStream());
+                    if (!gzip) {
+                        out = new BufferedOutputStream(socket.getOutputStream());
+                    } else {
+                        out = new FlushableGZIPOutputStream(socket.getOutputStream());
+                    }
                 }
 
                 return new Output(out);

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbDaemon.java
Wed Nov 28 13:23:30 2012
@@ -20,6 +20,7 @@ import org.apache.openejb.BeanContext;
 import org.apache.openejb.ProxyInfo;
 import org.apache.openejb.client.EJBRequest;
 import org.apache.openejb.client.EjbObjectInputStream;
+import org.apache.openejb.client.FlushableGZIPOutputStream;
 import org.apache.openejb.client.ProtocolMetaData;
 import org.apache.openejb.client.RequestType;
 import org.apache.openejb.client.ServerMetaData;
@@ -28,7 +29,6 @@ import org.apache.openejb.server.Discove
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
-import org.apache.openejb.util.Messages;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -38,12 +38,12 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.rmi.RemoteException;
 import java.util.Properties;
+import java.util.zip.GZIPInputStream;
 
 public class EjbDaemon implements org.apache.openejb.spi.ApplicationServer {
 
     private static final ProtocolMetaData PROTOCOL_VERSION = new ProtocolMetaData("3.1");
 
-    private static final Messages _messages = new Messages("org.apache.openejb.server.util.resources");
     static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_SERVER_REMOTE, "org.apache.openejb.server.util.resources");
 
     private ClientObjectFactory clientObjectFactory;
@@ -53,10 +53,10 @@ public class EjbDaemon implements org.ap
     private AuthRequestHandler authHandler;
     private ClusterRequestHandler clusterHandler;
 
-    boolean stop = false;
-
     static EjbDaemon instance;
+
     private ContainerSystem containerSystem;
+    private boolean gzip;
 
     private EjbDaemon() {
     }
@@ -78,6 +78,7 @@ public class EjbDaemon implements org.ap
         jndiHandler = new JndiRequestHandler(this);
         authHandler = new AuthRequestHandler(this);
         clusterHandler = new ClusterRequestHandler(this);
+        gzip = "true".equalsIgnoreCase(props.getProperty("gzip", "false"));
 
         DiscoveryAgent discovery = SystemInstance.get().getComponent(DiscoveryAgent.class);
         if (discovery != null) {
@@ -98,6 +99,10 @@ public class EjbDaemon implements org.ap
 
             in = socket.getInputStream();
             out = socket.getOutputStream();
+            if (gzip) {
+                in = new GZIPInputStream(socket.getInputStream());
+                out = new FlushableGZIPOutputStream(socket.getOutputStream());
+            }
 
             service(in, out);
         } finally {
@@ -292,5 +297,8 @@ public class EjbDaemon implements org.ap
         return clientObjectFactory.getEJBHome(info);
     }
 
+    public boolean isGzip() {
+        return gzip;
+    }
 }
 

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbServer.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbServer.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbServer.java
Wed Nov 28 13:23:30 2012
@@ -33,17 +33,18 @@ import java.util.Properties;
 
 public class EjbServer implements org.apache.openejb.server.ServerService, org.apache.openejb.spi.ApplicationServer
{
 
-    private final KeepAliveServer keepAlive;
-    private EjbDaemon server;
+    protected KeepAliveServer keepAlive;
+    protected EjbDaemon server;
 
     public EjbServer() {
-        keepAlive = new KeepAliveServer(this);
+
     }
 
     @Override
     public void init(final Properties props) throws Exception {
         server = EjbDaemon.getEjbDaemon();
         server.init(props);
+        keepAlive = new KeepAliveServer(this, server.isGzip());
     }
 
     @Override

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/KeepAliveServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/KeepAliveServer.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/KeepAliveServer.java
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/KeepAliveServer.java
Wed Nov 28 13:23:30 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.server.ejbd;
 
+import org.apache.openejb.client.FlushableGZIPOutputStream;
 import org.apache.openejb.client.KeepAliveStyle;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.ServerService;
@@ -43,6 +44,7 @@ import java.util.concurrent.ThreadPoolEx
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.zip.GZIPInputStream;
 
 /**
  * @version $Rev$ $Date$
@@ -57,13 +59,20 @@ public class KeepAliveServer implements 
     private final ConcurrentHashMap<Thread, Session> sessions = new ConcurrentHashMap<Thread,
Session>();
     private BlockingQueue<Runnable> threadQueue;
     private Timer timer;
+    private final boolean gzip;
 
     public KeepAliveServer() {
         this(new EjbServer());
     }
 
+    @Deprecated
     public KeepAliveServer(final ServerService service) {
+        this(service, false);
+    }
+
+    public KeepAliveServer(final ServerService service, final boolean gzip) {
         this.service = service;
+        this.gzip = gzip;
     }
 
     private void closeInactiveSessions() {
@@ -195,8 +204,15 @@ public class KeepAliveServer implements 
             int i = -1;
 
             try {
-                final InputStream in = new BufferedInputStream(socket.getInputStream());
-                final OutputStream out = new BufferedOutputStream(socket.getOutputStream());
+                final InputStream in;
+                final OutputStream out;
+                if (!gzip) {
+                    in = new BufferedInputStream(socket.getInputStream());
+                    out = new BufferedOutputStream(socket.getOutputStream());
+                } else {
+                    in = new GZIPInputStream(socket.getInputStream());
+                    out = new FlushableGZIPOutputStream(socket.getOutputStream());
+                }
 
                 while (running.get()) {
                     try {

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbd
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbd?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbd
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbd
Wed Nov 28 13:23:30 2012
@@ -5,3 +5,4 @@ disabled    = ${openejb.profile.custom}
 threads     = 200
 backlog     = 200
 discovery   = ejb:ejbd://{bind}:{port}
+gzip        = false

Modified: openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbds
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbds?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbds
(original)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ejbds
Wed Nov 28 13:23:30 2012
@@ -6,3 +6,4 @@ threads     = 200
 backlog     = 200
 secure      = true
 discovery   = ejb:ejbds://{bind}:{port}
+gzip        = false

Added: openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/ZEjbdTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/ZEjbdTest.java?rev=1414664&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/ZEjbdTest.java
(added)
+++ openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/ZEjbdTest.java
Wed Nov 28 13:23:30 2012
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.server.ejbd;
+
+import org.apache.openejb.client.ClientRuntimeException;
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@EnableServices("ejbd")
+@RunWith(ApplicationComposer.class)
+public class ZEjbdTest {
+    @Configuration
+    public Properties configuration() {
+        final Properties configuration = new Properties();
+        configuration.setProperty("ejbd.gzip", "true");
+        return configuration;
+    }
+
+    @Module
+    public EnterpriseBean bean() {
+        return new SingletonBean(AppClientTest.Orange.class).localBean();
+    }
+
+    @Test
+    public void checkZipIsOn() throws Exception {
+        assertTrue(EjbDaemon.getEjbDaemon().isGzip());
+    }
+
+    @Test
+    public void checkItWorks() throws Exception {
+        remoteCall("zejbd");
+    }
+
+    @Test(expected = ClientRuntimeException.class)
+    public void checkEjbdFailWithAGzipServer() throws Exception {
+        remoteCall("ejbd");
+    }
+
+    private void remoteCall(final String scheme) throws NamingException {
+        final Context ctx = new InitialContext(new Properties() {{
+            setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
+            setProperty(Context.PROVIDER_URL, scheme + "://localhost:4201");
+        }});
+        assertEquals("hello", ((AppClientTest.OrangeBusinessRemote) ctx.lookup("OrangeRemote")).echo("olleh"));
+    }
+}

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
Wed Nov 28 13:23:30 2012
@@ -45,7 +45,7 @@ public class FilteredServiceManager exte
                 realServices.addAll(Arrays.asList("cxf-rs", "httpejbd"));
             } else if (wsAliases.contains(service)) {
                 realServices.addAll(Arrays.asList("cxf", "httpejbd"));
-            } else if ("ejbd".equals(service)) {
+            } else if ("http".equals(service)) {
                 realServices.add("httpejbd");
             } else {
                 realServices.add(service);

Modified: openejb/trunk/openejb/server/openejb-server/src/test/java/org/apache/openejb/server/FilteredServiceManagerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/test/java/org/apache/openejb/server/FilteredServiceManagerTest.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/test/java/org/apache/openejb/server/FilteredServiceManagerTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-server/src/test/java/org/apache/openejb/server/FilteredServiceManagerTest.java
Wed Nov 28 13:23:30 2012
@@ -37,7 +37,7 @@ public class FilteredServiceManagerTest 
 
     @Test
     public void checkEjbd() {
-        final FilteredServiceManager fsm = new FilteredServiceManager(new String[] { "ejbd"
});
+        final FilteredServiceManager fsm = new FilteredServiceManager(new String[] { "http"
});
         assertTrue(fsm.accept("httpejbd"));
     }
 

Modified: openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
Wed Nov 28 13:23:30 2012
@@ -238,7 +238,6 @@ public class OpenEJBContextConfig extend
         super.processAnnotations(fragments, handlesTypesOnly);
     }
 
-
     @Override
     protected void processAnnotationsFile(File file, WebXml fragment, boolean handlesTypesOnly)
{
         final WebAppInfo webAppInfo = info.get();

Modified: openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEServiceManager.java?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEServiceManager.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEServiceManager.java
Wed Nov 28 13:23:30 2012
@@ -26,9 +26,9 @@ public class TomEEServiceManager extends
     @Override
     protected boolean accept(final String serviceName) {
         // managed manually or done in a different way in TomEE
-        return !"httpejbd".equals(serviceName)
-                && !"ejbd".equals(serviceName)
-                && !"ejbds".equals(serviceName)
-                && !"admin".equals(serviceName);
+        return !"httpejbd".equalsIgnoreCase(serviceName)
+                && !"ejbd".equalsIgnoreCase(serviceName)
+                && !"ejbds".equalsIgnoreCase(serviceName)
+                && !"admin".equalsIgnoreCase(serviceName);
     }
 }

Modified: openejb/trunk/openejb/tomee/tomee-webapp/src/main/resources/META-INF/org.apache.tomee/service-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-webapp/src/main/resources/META-INF/org.apache.tomee/service-jar.xml?rev=1414664&r1=1414663&r2=1414664&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-webapp/src/main/resources/META-INF/org.apache.tomee/service-jar.xml
(original)
+++ openejb/trunk/openejb/tomee/tomee-webapp/src/main/resources/META-INF/org.apache.tomee/service-jar.xml
Wed Nov 28 13:23:30 2012
@@ -48,5 +48,6 @@
   <ServiceProvider id="ProvidedByTomcat" service="Resource" class-name="org.apache.tomee.catalina.TomcatResourceFactory"
factory-name="create">
     jndiName =
     appName =
+    factory =
   </ServiceProvider>
 </ServiceJar>



Mime
View raw message