[camel] branch exchange-factory updated: CAMEL-16222: PooledExchangeFactory experiment

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch exchange-factory updated: CAMEL-16222: PooledExchangeFactory experiment

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch exchange-factory
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/exchange-factory by this push:
     new 6c8d49a  CAMEL-16222: PooledExchangeFactory experiment
6c8d49a is described below

commit 6c8d49ac1e8c8b40af56a2490fe37722c59a66b6
Author: Claus Ibsen <[hidden email]>
AuthorDate: Tue Feb 23 07:22:56 2021 +0100

    CAMEL-16222: PooledExchangeFactory experiment
---
 .../apache/camel/component/irc/IrcConsumer.java    | 90 +++++++++++++++++++---
 .../apache/camel/component/irc/IrcEndpoint.java    | 77 +-----------------
 2 files changed, 82 insertions(+), 85 deletions(-)

diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
index f1141ca..b6cf0b3 100644
--- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
@@ -78,6 +78,78 @@ public class IrcConsumer extends DefaultConsumer {
         endpoint.joinChannels();
     }
 
+    private Exchange createOnPrivmsgExchange(String target, IRCUser user, String msg) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "PRIVMSG", target, user, msg);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnNickExchange(IRCUser user, String newNick) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "NICK", user, newNick);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnQuitExchange(IRCUser user, String msg) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "QUIT", user, msg);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnJoinExchange(String channel, IRCUser user) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "JOIN", channel, user);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnKickExchange(String channel, IRCUser user, String whoWasKickedNick, String msg) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "KICK", channel, user, whoWasKickedNick, msg);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnModeExchange(String channel, IRCUser user, IRCModeParser modeParser) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "MODE", channel, user, modeParser.getLine());
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnPartExchange(String channel, IRCUser user, String msg) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "PART", channel, user, msg);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnReplyExchange(int num, String value, String msg) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "REPLY", num, value, msg);
+        exchange.setIn(im);
+        return exchange;
+    }
+
+    private Exchange createOnTopicExchange(String channel, IRCUser user, String topic) {
+        Exchange exchange = createExchange(true);
+        exchange.setProperty(Exchange.BINDING, endpoint.getBinding());
+        IrcMessage im = new IrcMessage(endpoint.getCamelContext(), "TOPIC", channel, user, topic);
+        exchange.setIn(im);
+        return exchange;
+    }
+
     public IRCConnection getConnection() {
         return connection;
     }
@@ -95,7 +167,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onNick(IRCUser user, String newNick) {
             if (configuration.isOnNick()) {
-                Exchange exchange = endpoint.createOnNickExchange(user, newNick);
+                Exchange exchange = createOnNickExchange(user, newNick);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -107,7 +179,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onQuit(IRCUser user, String msg) {
             if (configuration.isOnQuit()) {
-                Exchange exchange = endpoint.createOnQuitExchange(user, msg);
+                Exchange exchange = createOnQuitExchange(user, msg);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -119,7 +191,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onJoin(String channel, IRCUser user) {
             if (configuration.isOnJoin()) {
-                Exchange exchange = endpoint.createOnJoinExchange(channel, user);
+                Exchange exchange = createOnJoinExchange(channel, user);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -137,7 +209,7 @@ public class IrcConsumer extends DefaultConsumer {
             }
 
             if (configuration.isOnKick()) {
-                Exchange exchange = endpoint.createOnKickExchange(channel, user, passiveNick, msg);
+                Exchange exchange = createOnKickExchange(channel, user, passiveNick, msg);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -149,7 +221,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onMode(String channel, IRCUser user, IRCModeParser modeParser) {
             if (configuration.isOnMode()) {
-                Exchange exchange = endpoint.createOnModeExchange(channel, user, modeParser);
+                Exchange exchange = createOnModeExchange(channel, user, modeParser);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -161,7 +233,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onPart(String channel, IRCUser user, String msg) {
             if (configuration.isOnPart()) {
-                Exchange exchange = endpoint.createOnPartExchange(channel, user, msg);
+                Exchange exchange = createOnPartExchange(channel, user, msg);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -173,7 +245,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onReply(int num, String value, String msg) {
             if (configuration.isOnReply()) {
-                Exchange exchange = endpoint.createOnReplyExchange(num, value, msg);
+                Exchange exchange = createOnReplyExchange(num, value, msg);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -185,7 +257,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onTopic(String channel, IRCUser user, String topic) {
             if (configuration.isOnTopic()) {
-                Exchange exchange = endpoint.createOnTopicExchange(channel, user, topic);
+                Exchange exchange = createOnTopicExchange(channel, user, topic);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
@@ -197,7 +269,7 @@ public class IrcConsumer extends DefaultConsumer {
         @Override
         public void onPrivmsg(String target, IRCUser user, String msg) {
             if (configuration.isOnPrivmsg()) {
-                Exchange exchange = endpoint.createOnPrivmsgExchange(target, user, msg);
+                Exchange exchange = createOnPrivmsgExchange(target, user, msg);
                 try {
                     getProcessor().process(exchange);
                 } catch (Exception e) {
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
index 32f1f00..4a81b56 100644
--- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
@@ -17,8 +17,6 @@
 package org.apache.camel.component.irc;
 
 import org.apache.camel.Category;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
@@ -27,16 +25,13 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.schwering.irc.lib.IRCConnection;
 import org.schwering.irc.lib.IRCConstants;
-import org.schwering.irc.lib.IRCModeParser;
-import org.schwering.irc.lib.IRCUser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Send and receive messages to/from and IRC chat.
  */
-@UriEndpoint(
-             firstVersion = "1.1.0",
+@UriEndpoint(firstVersion = "1.1.0",
              scheme = "irc",
              title = "IRC",
              syntax = "irc:hostname:port",
@@ -58,76 +53,6 @@ public class IrcEndpoint extends DefaultEndpoint {
     }
 
     @Override
-    public Exchange createExchange(ExchangePattern pattern) {
-        Exchange exchange = super.createExchange(pattern);
-        exchange.setProperty(Exchange.BINDING, getBinding());
-        return exchange;
-    }
-
-    public Exchange createOnPrivmsgExchange(String target, IRCUser user, String msg) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "PRIVMSG", target, user, msg);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnNickExchange(IRCUser user, String newNick) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "NICK", user, newNick);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnQuitExchange(IRCUser user, String msg) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "QUIT", user, msg);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnJoinExchange(String channel, IRCUser user) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "JOIN", channel, user);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnKickExchange(String channel, IRCUser user, String whoWasKickedNick, String msg) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "KICK", channel, user, whoWasKickedNick, msg);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnModeExchange(String channel, IRCUser user, IRCModeParser modeParser) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "MODE", channel, user, modeParser.getLine());
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnPartExchange(String channel, IRCUser user, String msg) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "PART", channel, user, msg);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnReplyExchange(int num, String value, String msg) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "REPLY", num, value, msg);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    public Exchange createOnTopicExchange(String channel, IRCUser user, String topic) {
-        Exchange exchange = createExchange();
-        IrcMessage im = new IrcMessage(getCamelContext(), "TOPIC", channel, user, topic);
-        exchange.setIn(im);
-        return exchange;
-    }
-
-    @Override
     public IrcProducer createProducer() throws Exception {
         return new IrcProducer(this);
     }