Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-03-24 16:16:45 +0000
committerEike Stepper2020-03-24 16:16:45 +0000
commit2b493f78abedf6edcb6710e74708272deadf163c (patch)
tree117c119ec7fff43e7835ef57c49a9ee441950aae /plugins/org.eclipse.net4j.tcp
parent850a75fe1a44b4245f4bcffcfd9d7e8b49746e8d (diff)
downloadcdo-2b493f78abedf6edcb6710e74708272deadf163c.tar.gz
cdo-2b493f78abedf6edcb6710e74708272deadf163c.tar.xz
cdo-2b493f78abedf6edcb6710e74708272deadf163c.zip
[561421] Provide configurable AcceptorDescriptionParsers for the TransportConfigurator
https://bugs.eclipse.org/bugs/show_bug.cgi?id=561421
Diffstat (limited to 'plugins/org.eclipse.net4j.tcp')
-rw-r--r--plugins/org.eclipse.net4j.tcp/plugin.xml26
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java30
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ssl/SSLAcceptor.java29
3 files changed, 76 insertions, 9 deletions
diff --git a/plugins/org.eclipse.net4j.tcp/plugin.xml b/plugins/org.eclipse.net4j.tcp/plugin.xml
index c54ef87c84..55e991c2f3 100644
--- a/plugins/org.eclipse.net4j.tcp/plugin.xml
+++ b/plugins/org.eclipse.net4j.tcp/plugin.xml
@@ -16,13 +16,13 @@
<extension
point="org.eclipse.net4j.util.factories">
<factory
- class="org.eclipse.net4j.internal.tcp.ssl.SSLAcceptorFactory"
- productGroup="org.eclipse.net4j.acceptors"
- type="ssl"/>
+ class="org.eclipse.net4j.internal.tcp.TCPSelectorFactory"
+ productGroup="org.eclipse.net4j.selectors"
+ type="tcp"/>
<factory
- class="org.eclipse.net4j.internal.tcp.ssl.SSLConnectorFactory"
- productGroup="org.eclipse.net4j.connectors"
- type="ssl"/>
+ class="org.eclipse.net4j.internal.tcp.TCPAcceptor$DescriptionParserFactory"
+ productGroup="org.eclipse.net4j.acceptorDescriptionParsers"
+ type="tcp"/>
<factory
class="org.eclipse.net4j.internal.tcp.TCPAcceptorFactory"
productGroup="org.eclipse.net4j.acceptors"
@@ -32,9 +32,17 @@
productGroup="org.eclipse.net4j.connectors"
type="tcp"/>
<factory
- class="org.eclipse.net4j.internal.tcp.TCPSelectorFactory"
- productGroup="org.eclipse.net4j.selectors"
- type="tcp"/>
+ class="org.eclipse.net4j.internal.tcp.ssl.SSLAcceptor$DescriptionParserFactory"
+ productGroup="org.eclipse.net4j.acceptorDescriptionParsers"
+ type="ssl"/>
+ <factory
+ class="org.eclipse.net4j.internal.tcp.ssl.SSLAcceptorFactory"
+ productGroup="org.eclipse.net4j.acceptors"
+ type="ssl"/>
+ <factory
+ class="org.eclipse.net4j.internal.tcp.ssl.SSLConnectorFactory"
+ productGroup="org.eclipse.net4j.connectors"
+ type="ssl"/>
</extension>
<extension
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
index d4d281398e..b825560660 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
@@ -11,17 +11,22 @@
*/
package org.eclipse.net4j.internal.tcp;
+import org.eclipse.net4j.TransportConfigurator.AcceptorDescriptionParser;
import org.eclipse.net4j.internal.tcp.bundle.OM;
import org.eclipse.net4j.tcp.ITCPAcceptor;
import org.eclipse.net4j.tcp.ITCPPassiveSelectorListener;
import org.eclipse.net4j.tcp.ITCPSelector;
+import org.eclipse.net4j.tcp.TCPUtil;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.concurrent.Worker;
+import org.eclipse.net4j.util.factory.ProductCreationException;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.spi.net4j.Acceptor;
+import org.w3c.dom.Element;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -302,4 +307,29 @@ public class TCPAcceptor extends Acceptor implements ITCPAcceptor, ITCPPassiveSe
selectionKey = null;
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class DescriptionParserFactory extends AcceptorDescriptionParser.Factory implements AcceptorDescriptionParser
+ {
+ public DescriptionParserFactory()
+ {
+ super(TCPUtil.FACTORY_TYPE);
+ }
+
+ @Override
+ public AcceptorDescriptionParser create(String description) throws ProductCreationException
+ {
+ return this;
+ }
+
+ @Override
+ public String getAcceptorDescription(Element acceptorConfig)
+ {
+ String listenAddr = acceptorConfig.getAttribute("listenAddr"); //$NON-NLS-1$
+ String port = acceptorConfig.getAttribute("port"); //$NON-NLS-1$
+ return (listenAddr == null ? "" : listenAddr) + (port == null ? "" : ":" + port); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ssl/SSLAcceptor.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ssl/SSLAcceptor.java
index 768c369715..c9321ecfb2 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ssl/SSLAcceptor.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ssl/SSLAcceptor.java
@@ -11,8 +11,12 @@
*/
package org.eclipse.net4j.internal.tcp.ssl;
+import org.eclipse.net4j.TransportConfigurator.AcceptorDescriptionParser;
import org.eclipse.net4j.internal.tcp.TCPAcceptor;
import org.eclipse.net4j.internal.tcp.TCPConnector;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import org.w3c.dom.Element;
import java.text.MessageFormat;
@@ -34,4 +38,29 @@ public class SSLAcceptor extends TCPAcceptor
{
return new SSLServerConnector(this);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class DescriptionParserFactory extends AcceptorDescriptionParser.Factory implements AcceptorDescriptionParser
+ {
+ public DescriptionParserFactory()
+ {
+ super(SSLAcceptorFactory.TYPE);
+ }
+
+ @Override
+ public AcceptorDescriptionParser create(String description) throws ProductCreationException
+ {
+ return this;
+ }
+
+ @Override
+ public String getAcceptorDescription(Element acceptorConfig)
+ {
+ String listenAddr = acceptorConfig.getAttribute("listenAddr"); //$NON-NLS-1$
+ String port = acceptorConfig.getAttribute("port"); //$NON-NLS-1$
+ return (listenAddr == null ? "" : listenAddr) + (port == null ? "" : ":" + port); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
}

Back to the top