| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
19 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,9 +21,11 @@ | |||
| 21 | 21 | <executable>java</executable> | |
| 22 | 22 | <arguments> | |
| 23 | 23 | <argument>-showversion</argument> | |
| 24 | - <argument>-Xmx2g</argument> | ||
| 25 | - <argument>-Xms2g</argument> | ||
| 24 | + <argument>-Xmx1g</argument> | ||
| 25 | + <argument>-Xms1g</argument> | ||
| 26 | + <!-- | ||
| 26 | 27 | <argument>-Xmn1g</argument> | |
| 28 | + --> | ||
| 27 | 29 | <argument>-XX:+PrintCommandLineFlags</argument> | |
| 28 | 30 | <argument>-XX:-UseSplitVerifier</argument> | |
| 29 | 31 | <argument>-XX:+PrintGCDateStamps</argument> | |
@@ -75,11 +77,7 @@ | |||
| 75 | 77 | <artifactId>jetty-jmx</artifactId> | |
| 76 | 78 | <version>${jetty-version}</version> | |
| 77 | 79 | </dependency> | |
| 78 | - <dependency> | ||
| 79 | - <groupId>org.codehaus.jackson</groupId> | ||
| 80 | - <artifactId>jackson-mapper-asl</artifactId> | ||
| 81 | - <version>${jackson-version}</version> | ||
| 82 | - </dependency> | ||
| 80 | + | ||
| 83 | 81 | <dependency> | |
| 84 | 82 | <groupId>org.slf4j</groupId> | |
| 85 | 83 | <artifactId>slf4j-log4j12</artifactId> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ | |||
| 49 | 49 | import org.cometd.client.BayeuxClient; | |
| 50 | 50 | import org.cometd.client.transport.ClientTransport; | |
| 51 | 51 | import org.cometd.client.transport.LongPollingTransport; | |
| 52 | - import org.cometd.common.JacksonJSONContextClient; | ||
| 52 | + import org.cometd.common.Jackson1JSONContextClient; | ||
| 53 | 53 | import org.cometd.websocket.client.WebSocketTransport; | |
| 54 | 54 | import org.eclipse.jetty.client.HttpClient; | |
| 55 | 55 | import org.eclipse.jetty.jmx.MBeanContainer; | |
@@ -430,13 +430,13 @@ private ClientTransport newClientTransport(ClientTransportType clientTransportTy | |||
| 430 | 430 | case LONG_POLLING: | |
| 431 | 431 | { | |
| 432 | 432 | Map<String, Object> options = new HashMap<>(); | |
| 433 | - options.put(ClientTransport.JSON_CONTEXT, new JacksonJSONContextClient()); | ||
| 433 | + options.put(ClientTransport.JSON_CONTEXT, new Jackson1JSONContextClient()); | ||
| 434 | 434 | return new LongPollingTransport(options, httpClient); | |
| 435 | 435 | } | |
| 436 | 436 | case WEBSOCKET: | |
| 437 | 437 | { | |
| 438 | 438 | Map<String, Object> options = new HashMap<>(); | |
| 439 | - options.put(ClientTransport.JSON_CONTEXT, new JacksonJSONContextClient()); | ||
| 439 | + options.put(ClientTransport.JSON_CONTEXT, new Jackson1JSONContextClient()); | ||
| 440 | 440 | options.put(WebSocketTransport.IDLE_TIMEOUT_OPTION, 35000); | |
| 441 | 441 | return new WebSocketTransport(options, webSocketClient, scheduler); | |
| 442 | 442 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,16 +78,35 @@ | |||
| 78 | 78 | <artifactId>websocket-server</artifactId> | |
| 79 | 79 | <version>${jetty-version}</version> | |
| 80 | 80 | </dependency> | |
| 81 | - <dependency> | ||
| 81 | + <dependency> | ||
| 82 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 83 | + <artifactId>jackson-databind</artifactId> | ||
| 84 | + <version>${jackson2-version}</version> | ||
| 85 | + </dependency> | ||
| 86 | + | ||
| 87 | + <dependency> | ||
| 88 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 89 | + <artifactId>jackson-core</artifactId> | ||
| 90 | + <version>${jackson2-version}</version> | ||
| 91 | + </dependency> | ||
| 92 | + | ||
| 93 | + <dependency> | ||
| 82 | 94 | <groupId>org.codehaus.jackson</groupId> | |
| 83 | 95 | <artifactId>jackson-mapper-asl</artifactId> | |
| 84 | - <version>${jackson-version}</version> | ||
| 96 | + <version>${jackson1-version}</version> | ||
| 97 | + </dependency> | ||
| 98 | + | ||
| 99 | + <dependency> | ||
| 100 | + <groupId>org.slf4j</groupId> | ||
| 101 | + <artifactId>slf4j-simple</artifactId> | ||
| 102 | + <!-- Travis build failing if I use ${slf4j-version}, trying hard-coding version --> | ||
| 103 | + <version>1.7.5</version> | ||
| 104 | + <scope>runtime</scope> | ||
| 85 | 105 | </dependency> | |
| 86 | 106 | <dependency> | |
| 87 | 107 | <groupId>org.slf4j</groupId> | |
| 88 | 108 | <artifactId>slf4j-log4j12</artifactId> | |
| 89 | 109 | <scope>runtime</scope> | |
| 90 | 110 | </dependency> | |
| 91 | 111 | </dependencies> | |
| 92 | - | ||
| 93 | 112 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,7 +54,7 @@ | |||
| 54 | 54 | import org.cometd.server.AbstractService; | |
| 55 | 55 | import org.cometd.server.BayeuxServerImpl; | |
| 56 | 56 | import org.cometd.server.CometDServlet; | |
| 57 | - import org.cometd.server.JacksonJSONContextServer; | ||
| 57 | + import org.cometd.server.Jackson2JSONContextServer; | ||
| 58 | 58 | import org.cometd.websocket.server.WebSocketTransport; | |
| 59 | 59 | import org.eclipse.jetty.jmx.MBeanContainer; | |
| 60 | 60 | import org.eclipse.jetty.server.AbstractConnectionFactory; | |
@@ -206,7 +206,7 @@ public void run() throws Exception | |||
| 206 | 206 | // Explicitly set the timeout value | |
| 207 | 207 | cometdServletHolder.setInitParameter(AbstractServerTransport.TIMEOUT_OPTION, String.valueOf(30000)); | |
| 208 | 208 | // Use the faster JSON parser/generator | |
| 209 | - cometdServletHolder.setInitParameter(BayeuxServerImpl.JSON_CONTEXT, JacksonJSONContextServer.class.getName()); | ||
| 209 | + cometdServletHolder.setInitParameter(BayeuxServerImpl.JSON_CONTEXT, Jackson2JSONContextServer.class.getName()); | ||
| 210 | 210 | context.addServlet(cometdServletHolder, cometServletPath + "/*"); | |
| 211 | 211 | ||
| 212 | 212 | server.start(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,13 +90,18 @@ | |||
| 90 | 90 | <version>${jetty-version}</version> | |
| 91 | 91 | <scope>test</scope> | |
| 92 | 92 | </dependency> | |
| 93 | - <dependency> | ||
| 93 | + <dependency> | ||
| 94 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 95 | + <artifactId>jackson-databind</artifactId> | ||
| 96 | + <version>${jackson2-version}</version> | ||
| 97 | + <scope>test</scope> | ||
| 98 | + </dependency> | ||
| 99 | + <dependency> | ||
| 94 | 100 | <groupId>org.codehaus.jackson</groupId> | |
| 95 | 101 | <artifactId>jackson-mapper-asl</artifactId> | |
| 96 | - <version>${jackson-version}</version> | ||
| 102 | + <version>${jackson1-version}</version> | ||
| 97 | 103 | <scope>test</scope> | |
| 98 | 104 | </dependency> | |
| 99 | - | ||
| 100 | 105 | </dependencies> | |
| 101 | 106 | ||
| 102 | 107 | </project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,12 +45,44 @@ protected ClientTransport(String name, Map<String, Object> options) | |||
| 45 | 45 | super(name, options); | |
| 46 | 46 | } | |
| 47 | 47 | ||
| 48 | - public void init() | ||
| 49 | - { | ||
| 50 | - jsonContext = (JSONContext.Client)getOption(JSON_CONTEXT); | ||
| 51 | - if (jsonContext == null) | ||
| 52 | - jsonContext = new JettyJSONContextClient(); | ||
| 53 | - } | ||
| 48 | + public void init() | ||
| 49 | + { | ||
| 50 | + Object option = null; | ||
| 51 | + try | ||
| 52 | + { | ||
| 53 | + option = getOption(JSON_CONTEXT); | ||
| 54 | + if (option == null) | ||
| 55 | + { | ||
| 56 | + jsonContext = new JettyJSONContextClient(); | ||
| 57 | + } | ||
| 58 | + else | ||
| 59 | + { | ||
| 60 | + if (option instanceof String) | ||
| 61 | + { | ||
| 62 | + Class<?> jsonContextClass = Thread.currentThread().getContextClassLoader().loadClass((String) option); | ||
| 63 | + if (JSONContext.Client.class.isAssignableFrom(jsonContextClass)) | ||
| 64 | + { | ||
| 65 | + jsonContext = (JSONContext.Client) jsonContextClass.newInstance(); | ||
| 66 | + } | ||
| 67 | + else | ||
| 68 | + { | ||
| 69 | + throw new IllegalArgumentException("Invalid implementation of " + JSONContext.Client.class.getName() + " provided (" + option + ")"); | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + else if (option instanceof JSONContext.Client) | ||
| 73 | + { | ||
| 74 | + jsonContext = (JSONContext.Client) option; | ||
| 75 | + } | ||
| 76 | + else | ||
| 77 | + { | ||
| 78 | + throw new IllegalArgumentException("Invalid implementation of " + JSONContext.Client.class.getName() + " provided (" + option + ")"); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + setOption(JSON_CONTEXT, jsonContext); | ||
| 82 | + } catch (Exception ex) { | ||
| 83 | + throw new IllegalArgumentException("Exception ["+ex+"] while trying to initialise "+this+" with JSON Context "+option, ex); | ||
| 84 | + } | ||
| 85 | + } | ||
| 54 | 86 | ||
| 55 | 87 | public boolean isDebugEnabled() | |
| 56 | 88 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | package org.cometd.client; | |
| 18 | 18 | ||
| 19 | + import java.util.Arrays; | ||
| 19 | 20 | import java.util.HashMap; | |
| 20 | 21 | import java.util.Map; | |
| 21 | 22 | import java.util.concurrent.TimeUnit; | |
@@ -26,15 +27,44 @@ | |||
| 26 | 27 | import org.cometd.bayeux.client.ClientSessionChannel; | |
| 27 | 28 | import org.cometd.client.transport.ClientTransport; | |
| 28 | 29 | import org.cometd.client.transport.LongPollingTransport; | |
| 29 | - import org.cometd.common.JacksonJSONContextClient; | ||
| 30 | + import org.cometd.common.Jackson1JSONContextClient; | ||
| 31 | + import org.cometd.common.Jackson2JSONContextClient; | ||
| 32 | + import org.cometd.common.JettyJSONContextClient; | ||
| 30 | 33 | import org.cometd.server.BayeuxServerImpl; | |
| 31 | - import org.cometd.server.JacksonJSONContextServer; | ||
| 34 | + import org.cometd.server.Jackson1JSONContextServer; | ||
| 35 | + import org.cometd.server.Jackson2JSONContextServer; | ||
| 36 | + import org.cometd.server.JettyJSONContextServer; | ||
| 32 | 37 | import org.eclipse.jetty.util.BlockingArrayQueue; | |
| 33 | 38 | import org.junit.Assert; | |
| 34 | 39 | import org.junit.Test; | |
| 40 | + import org.junit.runner.RunWith; | ||
| 41 | + import org.junit.runners.Parameterized; | ||
| 42 | + import org.junit.runners.Parameterized.Parameters; | ||
| 35 | 43 | ||
| 44 | + @RunWith(Parameterized.class) | ||
| 36 | 45 | public class BayeuxClientUsageTest extends ClientServerTest | |
| 37 | 46 | { | |
| 47 | + @Parameters(name= "{index}: JSON Context Server: {0} JSON Context Client: {1}") | ||
| 48 | + public static Iterable<Object[]> data() | ||
| 49 | + { | ||
| 50 | + return Arrays.asList(new Object[][] | ||
| 51 | + { | ||
| 52 | + { Jackson2JSONContextServer.class, Jackson2JSONContextClient.class }, | ||
| 53 | + { Jackson1JSONContextServer.class, Jackson1JSONContextClient.class }, | ||
| 54 | + { JettyJSONContextServer.class, JettyJSONContextClient.class} | ||
| 55 | + } | ||
| 56 | + ); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private final String jacksonContextServerClassName; | ||
| 60 | + private final String jacksonContextClientClassName; | ||
| 61 | + | ||
| 62 | + public BayeuxClientUsageTest(final Object jacksonContextServerClass, final Object jacksonContextClientClass) | ||
| 63 | + { | ||
| 64 | + this.jacksonContextServerClassName = ((Class<?>) jacksonContextServerClass).getName(); | ||
| 65 | + this.jacksonContextClientClassName = ((Class<?>) jacksonContextClientClass).getName(); | ||
| 66 | + } | ||
| 67 | + | ||
| 38 | 68 | @Test | |
| 39 | 69 | public void testClientWithSelectConnector() throws Exception | |
| 40 | 70 | { | |
@@ -46,11 +76,11 @@ public void testClientWithSelectConnector() throws Exception | |||
| 46 | 76 | public void testClientWithJackson() throws Exception | |
| 47 | 77 | { | |
| 48 | 78 | Map<String, String> serverOptions = new HashMap<>(); | |
| 49 | - serverOptions.put(BayeuxServerImpl.JSON_CONTEXT, JacksonJSONContextServer.class.getName()); | ||
| 79 | + serverOptions.put(BayeuxServerImpl.JSON_CONTEXT, jacksonContextServerClassName); | ||
| 50 | 80 | startServer(serverOptions); | |
| 51 | 81 | ||
| 52 | 82 | Map<String, Object> clientOptions = new HashMap<>(); | |
| 53 | - clientOptions.put(ClientTransport.JSON_CONTEXT, new JacksonJSONContextClient()); | ||
| 83 | + clientOptions.put(ClientTransport.JSON_CONTEXT, jacksonContextClientClassName); | ||
| 54 | 84 | BayeuxClient client = new BayeuxClient(cometdURL, new LongPollingTransport(clientOptions, httpClient)); | |
| 55 | 85 | ||
| 56 | 86 | testClient(client); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ | |||
| 17 | 17 | package org.cometd.client; | |
| 18 | 18 | ||
| 19 | 19 | import java.lang.reflect.Field; | |
| 20 | + import java.util.Arrays; | ||
| 20 | 21 | import java.util.HashMap; | |
| 21 | 22 | import java.util.Map; | |
| 22 | 23 | import java.util.concurrent.CountDownLatch; | |
@@ -29,25 +30,51 @@ | |||
| 29 | 30 | import org.cometd.client.transport.ClientTransport; | |
| 30 | 31 | import org.cometd.client.transport.LongPollingTransport; | |
| 31 | 32 | import org.cometd.common.HashMapMessage; | |
| 32 | - import org.cometd.common.JacksonJSONContextClient; | ||
| 33 | + import org.cometd.common.Jackson1JSONContextClient; | ||
| 34 | + import org.cometd.common.Jackson2JSONContextClient; | ||
| 33 | 35 | import org.cometd.server.AbstractService; | |
| 34 | 36 | import org.cometd.server.BayeuxServerImpl; | |
| 35 | - import org.cometd.server.JacksonJSONContextServer; | ||
| 37 | + import org.cometd.server.Jackson1JSONContextServer; | ||
| 38 | + import org.cometd.server.Jackson2JSONContextServer; | ||
| 36 | 39 | import org.cometd.server.ServerMessageImpl; | |
| 37 | 40 | import org.junit.Assert; | |
| 38 | 41 | import org.junit.Test; | |
| 42 | + import org.junit.runner.RunWith; | ||
| 43 | + import org.junit.runners.Parameterized; | ||
| 44 | + import org.junit.runners.Parameterized.Parameters; | ||
| 39 | 45 | ||
| 46 | + @RunWith(Parameterized.class) | ||
| 40 | 47 | public class JacksonContextTest extends ClientServerTest | |
| 41 | 48 | { | |
| 49 | + @Parameters(name= "{index}: Jackson Context Server: {0} Jackson Context Client: {1}") | ||
| 50 | + public static Iterable<Object[]> data() | ||
| 51 | + { | ||
| 52 | + return Arrays.asList(new Object[][] | ||
| 53 | + { | ||
| 54 | + { Jackson2JSONContextServer.class, Jackson2JSONContextClient.class }, | ||
| 55 | + { Jackson1JSONContextServer.class, Jackson1JSONContextClient.class }, | ||
| 56 | + } | ||
| 57 | + ); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + private final String jacksonContextServerClassName; | ||
| 61 | + private final String jacksonContextClientClassName; | ||
| 62 | + | ||
| 63 | + public JacksonContextTest(final Object jacksonContextServerClass, final Object jacksonContextClientClass) | ||
| 64 | + { | ||
| 65 | + this.jacksonContextServerClassName = ((Class<?>) jacksonContextServerClass).getName(); | ||
| 66 | + this.jacksonContextClientClassName = ((Class<?>) jacksonContextClientClass).getName(); | ||
| 67 | + } | ||
| 68 | + | ||
| 42 | 69 | @Test | |
| 43 | 70 | public void testAllMessagesUseJackson() throws Exception | |
| 44 | 71 | { | |
| 45 | 72 | Map<String, String> serverParams = new HashMap<>(); | |
| 46 | - serverParams.put(BayeuxServerImpl.JSON_CONTEXT, JacksonJSONContextServer.class.getName()); | ||
| 73 | + serverParams.put(BayeuxServerImpl.JSON_CONTEXT, jacksonContextServerClassName); | ||
| 47 | 74 | startServer(serverParams); | |
| 48 | 75 | ||
| 49 | 76 | Map<String, Object> clientParams = new HashMap<>(); | |
| 50 | - clientParams.put(ClientTransport.JSON_CONTEXT, new JacksonJSONContextClient()); | ||
| 77 | + clientParams.put(ClientTransport.JSON_CONTEXT, jacksonContextClientClassName); | ||
| 51 | 78 | final BayeuxClient client = new BayeuxClient(cometdURL, new LongPollingTransport(clientParams, httpClient)); | |
| 52 | 79 | client.setDebugEnabled(debugTests()); | |
| 53 | 80 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments