Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j')
-rw-r--r--plugins/org.eclipse.net4j/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--plugins/org.eclipse.net4j/.settings/org.eclipse.jdt.ui.prefs2
-rw-r--r--plugins/org.eclipse.net4j/META-INF/MANIFEST.MF32
-rw-r--r--plugins/org.eclipse.net4j/plugin.properties10
-rw-r--r--plugins/org.eclipse.net4j/plugin.xml12
-rw-r--r--plugins/org.eclipse.net4j/pom.xml4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportInjector.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/acceptor/IAcceptor.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java17
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/IProtocol3.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java13
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java114
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java11
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java42
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java20
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java15
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java50
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalCounter.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalFinishedEvent.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java53
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java144
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/security/AuthenticationIndication.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java13
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java88
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelContainer.java132
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalAcceptor.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java20
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalConnector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java50
41 files changed, 754 insertions, 264 deletions
diff --git a/plugins/org.eclipse.net4j/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.net4j/.settings/org.eclipse.core.resources.prefs
index 5b0b47e0a4..99f26c0203 100644
--- a/plugins/org.eclipse.net4j/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.net4j/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,2 @@
-#Mon Jul 04 12:56:06 CEST 2011
eclipse.preferences.version=1
-
+encoding/<project>=UTF-8
diff --git a/plugins/org.eclipse.net4j/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j/.settings/org.eclipse.jdt.ui.prefs
index c993e80543..79e0b974b9 100644
--- a/plugins/org.eclipse.net4j/.settings/org.eclipse.jdt.ui.prefs
+++ b/plugins/org.eclipse.net4j/.settings/org.eclipse.jdt.ui.prefs
@@ -75,7 +75,7 @@ org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2021 Eike Stepper (Loehne, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2023 Eike Stepper (Loehne, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
diff --git a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
index 5432e2eab4..ddcd84eab7 100644
--- a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j;singleton:=true
-Bundle-Version: 4.12.0.qualifier
+Bundle-Version: 4.17.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -11,7 +11,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
-Export-Package: org.eclipse.internal.net4j;version="4.12.0";
+Export-Package: org.eclipse.internal.net4j;version="4.17.0";
x-friends:="org.eclipse.net4j.http.server,
org.eclipse.net4j.jvm,
org.eclipse.net4j.tcp,
@@ -21,7 +21,7 @@ Export-Package: org.eclipse.internal.net4j;version="4.12.0";
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests,
org.eclipse.net4j.trace",
- org.eclipse.internal.net4j.buffer;version="4.12.0";
+ org.eclipse.internal.net4j.buffer;version="4.17.0";
x-friends:="org.eclipse.net4j.http.server,
org.eclipse.net4j.jvm,
org.eclipse.net4j.tcp,
@@ -31,18 +31,18 @@ Export-Package: org.eclipse.internal.net4j;version="4.12.0";
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests,
org.eclipse.net4j.trace",
- org.eclipse.internal.net4j.bundle;version="4.12.0";x-internal:=true,
- org.eclipse.net4j;version="4.12.0",
- org.eclipse.net4j.acceptor;version="4.12.0",
- org.eclipse.net4j.buffer;version="4.12.0",
- org.eclipse.net4j.channel;version="4.12.0",
- org.eclipse.net4j.connector;version="4.12.0",
- org.eclipse.net4j.protocol;version="4.12.0",
- org.eclipse.net4j.signal;version="4.12.0",
- org.eclipse.net4j.signal.confirmation;version="4.12.0",
- org.eclipse.net4j.signal.heartbeat;version="4.12.0",
- org.eclipse.net4j.signal.security;version="4.12.0",
- org.eclipse.net4j.signal.wrapping;version="4.12.0",
- org.eclipse.spi.net4j;version="4.12.0"
+ org.eclipse.internal.net4j.bundle;version="4.17.0";x-internal:=true,
+ org.eclipse.net4j;version="4.17.0",
+ org.eclipse.net4j.acceptor;version="4.17.0",
+ org.eclipse.net4j.buffer;version="4.17.0",
+ org.eclipse.net4j.channel;version="4.17.0",
+ org.eclipse.net4j.connector;version="4.17.0",
+ org.eclipse.net4j.protocol;version="4.17.0",
+ org.eclipse.net4j.signal;version="4.17.0",
+ org.eclipse.net4j.signal.confirmation;version="4.17.0",
+ org.eclipse.net4j.signal.heartbeat;version="4.17.0",
+ org.eclipse.net4j.signal.security;version="4.17.0",
+ org.eclipse.net4j.signal.wrapping;version="4.17.0",
+ org.eclipse.spi.net4j;version="4.17.0"
Eclipse-BuddyPolicy: registered
Automatic-Module-Name: org.eclipse.net4j
diff --git a/plugins/org.eclipse.net4j/plugin.properties b/plugins/org.eclipse.net4j/plugin.properties
index 461e864e80..62d4a89f17 100644
--- a/plugins/org.eclipse.net4j/plugin.properties
+++ b/plugins/org.eclipse.net4j/plugin.properties
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2010, 2012, 2013 Eike Stepper (Loehne, Germany) and others.
+# Copyright (c) 2006-2010, 2012, 2013, 2022 Eike Stepper (Loehne, Germany) and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -9,3 +9,11 @@
pluginName = Net4j Signalling Platform
providerName = Eclipse Modeling Project
+
+productGroup.name = Net4j Buffer Providers
+productGroup.name.0 = Net4j Server Protocols
+productGroup.name.1 = Net4j Client Protocols
+productGroup.name.2 = Net4j Acceptor Description Parsers
+productGroup.name.3 = Net4j Acceptors
+productGroup.name.4 = Net4j Connectors
+productGroup.name.5 = Net4j Selectors
diff --git a/plugins/org.eclipse.net4j/plugin.xml b/plugins/org.eclipse.net4j/plugin.xml
index f489bc56fc..bae8172d95 100644
--- a/plugins/org.eclipse.net4j/plugin.xml
+++ b/plugins/org.eclipse.net4j/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
- Copyright (c) 2006-2009, 2012, 2016, 2018 Eike Stepper (Loehne, Germany) and others.
+ Copyright (c) 2006-2009, 2012, 2016, 2018, 2022 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
@@ -13,6 +13,16 @@
<plugin>
+ <extension point="org.eclipse.net4j.util.productGroups">
+ <productGroup id="org.eclipse.net4j.bufferProviders" name="%productGroup.name"/>
+ <productGroup id="org.eclipse.net4j.serverProtocols" name="%productGroup.name.0"/>
+ <productGroup id="org.eclipse.net4j.clientProtocols" name="%productGroup.name.1"/>
+ <productGroup id="org.eclipse.net4j.acceptorDescriptionParsers" name="%productGroup.name.2"/>
+ <productGroup id="org.eclipse.net4j.acceptors" name="%productGroup.name.3"/>
+ <productGroup id="org.eclipse.net4j.connectors" name="%productGroup.name.4"/>
+ <productGroup id="org.eclipse.net4j.selectors" name="%productGroup.name.5"/>
+ </extension>
+
<extension point="org.eclipse.net4j.util.factories">
<factory
class="org.eclipse.internal.net4j.buffer.BufferPoolFactory"
diff --git a/plugins/org.eclipse.net4j/pom.xml b/plugins/org.eclipse.net4j/pom.xml
index 9b143fd8f1..d47fef5909 100644
--- a/plugins/org.eclipse.net4j/pom.xml
+++ b/plugins/org.eclipse.net4j/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2017-2021 Eike Stepper (Loehne, Germany) and others.
+ Copyright (c) 2017-2023 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.net4j</artifactId>
- <version>4.12.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
index 43d6c7d37d..a3967ce85e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, 2010-2012, 2017, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2007, 2008, 2010-2012, 2017, 2019, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,7 +57,7 @@ public abstract class BufferProvider extends Notifier implements IBufferProvider
++providedBuffers;
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
fireEvent(new BufferProviderEvent.Provided(this, buffer), listeners);
}
@@ -69,7 +69,7 @@ public abstract class BufferProvider extends Notifier implements IBufferProvider
public final void retainBuffer(IBuffer buffer)
{
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
fireEvent(new BufferProviderEvent.Retaining(this, buffer), listeners);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
index faf5ca958b..a2a24079e8 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2019, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
index 6322a91a0b..b99a99631d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011-2013, 2015, 2016, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011-2013, 2015, 2016, 2019-2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import org.eclipse.net4j.channel.IChannelMultiplexer;
import org.eclipse.net4j.connector.IServerConnector;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.wrapping.StreamWrapperInjector;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.FactoryNotFoundException;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -107,7 +108,7 @@ public class TransportConfigurator implements IManagedContainerProvider
{
String type = acceptorConfig.getAttribute("type"); //$NON-NLS-1$
String description = acceptorConfig.getAttribute("description"); //$NON-NLS-1$
- if (description == null || description.isEmpty())
+ if (StringUtil.isEmpty(description))
{
try
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportInjector.java
index b0fd19736e..309715d26d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportInjector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportInjector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2018, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2018, 2019, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,7 +57,8 @@ public class TransportInjector implements IElementProcessor
protected void processAcceptor(IManagedContainer container, String factoryType, String description, InternalAcceptor acceptor)
{
ITransportConfig config = acceptor.getConfig();
- if (config.getBufferProvider() == null)
+
+ if (acceptor.needsBufferProvider() && config.getBufferProvider() == null)
{
config.setBufferProvider(getBufferProvider(container));
}
@@ -76,7 +77,8 @@ public class TransportInjector implements IElementProcessor
protected void processConnector(IManagedContainer container, String factoryType, String description, InternalConnector connector)
{
ITransportConfig config = connector.getConfig();
- if (config.getBufferProvider() == null)
+
+ if (connector.needsBufferProvider() && config.getBufferProvider() == null)
{
config.setBufferProvider(getBufferProvider(container));
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/acceptor/IAcceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/acceptor/IAcceptor.java
index 2e5c65d24b..d4d5bb28a7 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/acceptor/IAcceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/acceptor/IAcceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2012, 2015, 2016 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2007-2012, 2015, 2016, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
index bd994b51c1..3bc488caf3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2012, 2015, 2016, 2018-2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2012, 2015, 2016, 2018-2020, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -347,11 +347,14 @@ public class BufferInputStream extends InputStream implements IBufferHandler
remaining = stopTimeMillis;
}
+ // int forDebuggingOnly;
+ // remaining = Long.MAX_VALUE;
+
remaining -= System.currentTimeMillis();
if (remaining <= 0)
{
// Throw an exception so that caller can distinguish between end-of-stream and a timeout
- throw new IOTimeoutException();
+ throw new IOTimeoutException("Buffer read timeout expired after " + getMillisBeforeTimeout() + " milliseconds");
}
return Math.min(remaining, check);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java
index 99f60a03a9..d9b9176c08 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2012, 2015, 2016, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2007-2012, 2015, 2016, 2020, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -112,10 +112,25 @@ public interface IChannel extends ILocationAware, IUserAware, IBufferHandler, IN
public long getSentBuffers();
/**
+ * Returns the number of bytes that are sent to the {@link IChannelMultiplexer multiplexer} of this channel.
+ *
+ * @since 4.13
+ */
+ public long getSentBytes();
+
+ /**
* Returns the number of {@link IBuffer buffers} that are received from the {@link IChannelMultiplexer multiplexer} of this channel
* <b>and</b> are passed on to the {@link #getReceiveHandler() receive handler} of this channel.
*
* @since 4.10
*/
public long getReceivedBuffers();
+
+ /**
+ * Returns the number of bytes that are received from the {@link IChannelMultiplexer multiplexer} of this channel
+ * <b>and</b> are passed on to the {@link #getReceiveHandler() receive handler} of this channel.
+ *
+ * @since 4.13
+ */
+ public long getReceivedBytes();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java
index 65be487490..8f897dacde 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, 2011, 2012, 2015 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2007, 2008, 2011, 2012, 2015, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java
index 123a4171c6..223c7eb51d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2016, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/IProtocol3.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/IProtocol3.java
new file mode 100644
index 0000000000..489b55a469
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/IProtocol3.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2023 Eike Stepper (Loehne, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.protocol;
+
+/**
+ * A {@link IProtocol protocol} that is told when it is {@link #doWhenFullyConnected() fully connected}.
+ *
+ * @author Eike Stepper
+ * @since 4.17
+ */
+public interface IProtocol3<INFRA_STRUCTURE> extends IProtocol2<INFRA_STRUCTURE>
+{
+ public default void doWhenFullyConnected() throws Exception
+ {
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java
index ab1b7a2af2..fcc15ce1f7 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2012, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,4 +42,15 @@ public interface ISignalProtocol<INFRA_STRUCTURE> extends IProtocol<INFRA_STRUCT
public IChannel open(IConnector connector);
public void close();
+
+ /**
+ * @author Eike Stepper
+ * @since 4.13
+ */
+ public interface WithSignalCounters<INFRA_STRUCTURE> extends ISignalProtocol<INFRA_STRUCTURE>
+ {
+ public long getSentSignals();
+
+ public long getReceivedSignals();
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
index 92407040ec..9eb8538515 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2016 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2016, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,18 +10,10 @@
*/
package org.eclipse.net4j.signal;
-import org.eclipse.net4j.buffer.BufferInputStream;
-import org.eclipse.net4j.buffer.BufferOutputStream;
-import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.TimeoutMonitor;
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
/**
@@ -32,7 +24,7 @@ import java.util.concurrent.ExecutorService;
*/
public abstract class IndicationWithMonitoring extends IndicationWithResponse
{
- private ReportingMonitor monitor;
+ private OMMonitor monitor;
/**
* @since 2.0
@@ -59,29 +51,12 @@ public abstract class IndicationWithMonitoring extends IndicationWithResponse
}
@Override
- protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
- {
- try
- {
- super.execute(in, out);
- }
- finally
- {
- if (monitor != null)
- {
- monitor.done();
- monitor = null;
- }
- }
- }
-
- @Override
protected final void indicating(ExtendedDataInputStream in) throws Exception
{
int monitorProgressSeconds = in.readInt();
int monitorTimeoutSeconds = in.readInt();
- monitor = new ReportingMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
+ monitor = createMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
monitor.begin(OMMonitor.HUNDRED);
indicating(in, monitor.fork(getIndicatingWorkPercent()));
@@ -90,94 +65,33 @@ public abstract class IndicationWithMonitoring extends IndicationWithResponse
@Override
protected final void responding(ExtendedDataOutputStream out) throws Exception
{
- responding(out, monitor.fork(OMMonitor.HUNDRED - getIndicatingWorkPercent()));
+ responding(out, monitor.fork(getRespondingWorkPercent()));
}
protected abstract void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception;
protected abstract void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception;
- /**
- * @since 2.0
- */
- protected ExecutorService getMonitoringExecutorService()
- {
- return getProtocol().getExecutorService();
- }
-
protected int getIndicatingWorkPercent()
{
return 99;
}
- void setMonitorCanceled()
+ /**
+ * @since 4.13
+ */
+ protected final int getRespondingWorkPercent()
{
- monitor.cancel();
+ return (int)OMMonitor.HUNDRED - getIndicatingWorkPercent();
}
/**
- * @author Eike Stepper
+ * @since 2.0
+ * @deprecated As of 4.13 not used anymore.
*/
- private final class ReportingMonitor extends TimeoutMonitor
+ @Deprecated
+ protected ExecutorService getMonitoringExecutorService()
{
- private TimerTask sendProgressTask = new TimerTask()
- {
- @Override
- public void run()
- {
- try
- {
- sendProgress();
- }
- catch (Throwable ex)
- {
- OM.LOG.error("ReportingMonitorTask failed", ex);
- cancel();
- }
- }
- };
-
- public ReportingMonitor(int monitorProgressSeconds, int monitorTimeoutSeconds)
- {
- super(1000L * monitorTimeoutSeconds);
- long period = 1000L * monitorProgressSeconds;
- scheduleAtFixedRate(sendProgressTask, period, period);
- }
-
- @Override
- public void cancel(RuntimeException cancelException)
- {
- sendProgressTask.cancel();
- super.cancel(cancelException);
- }
-
- @Override
- public void done()
- {
- sendProgressTask.cancel();
- super.done();
- }
-
- private void sendProgress()
- {
- SignalProtocol<?> protocol = getProtocol();
-
- try
- {
- int correlationID = -getCorrelationID();
- double totalWork = getTotalWork();
- double work = getWork();
-
- new MonitorProgressRequest(protocol, correlationID, totalWork, work).sendAsync();
- }
- catch (Exception ex)
- {
- IChannel channel = protocol.getChannel();
- if (LifecycleUtil.isActive(channel))
- {
- OM.LOG.error(ex);
- }
- }
- }
+ return getProtocol().getExecutorService();
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
index c7efe86812..c91df6bcb2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2008, 2011, 2012, 2015 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2006-2008, 2011, 2012, 2015, 2021, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,6 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.buffer.BufferInputStream;
import org.eclipse.net4j.buffer.BufferOutputStream;
-import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -60,7 +59,7 @@ public abstract class IndicationWithResponse extends SignalReactor
*/
protected String getExceptionMessage(Throwable t)
{
- return StringUtil.formatException(t);
+ return t.getLocalizedMessage();
}
@Override
@@ -74,12 +73,7 @@ public abstract class IndicationWithResponse extends SignalReactor
responding = true;
doOutput(out);
}
- catch (Error ex)
- {
- sendExceptionSignal(ex, responding);
- throw ex;
- }
- catch (Exception ex)
+ catch (Exception | Error ex)
{
sendExceptionSignal(ex, responding);
throw ex;
@@ -111,7 +105,7 @@ public abstract class IndicationWithResponse extends SignalReactor
SignalProtocol<?> protocol = getProtocol();
int correlationID = -getCorrelationID();
String message = getExceptionMessage(t);
- final boolean closeChannel = closeChannelAfterException();
+ boolean closeChannel = closeChannelAfterException();
RemoteExceptionRequest request = new RemoteExceptionRequest(protocol, correlationID, responding, message, t)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java
index e1645e9f02..6b87b1e1b5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011-2014 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2011-2014, 2021, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,13 +16,13 @@ package org.eclipse.net4j.signal;
* @author Eike Stepper
* @since 2.0
*/
-public class RemoteException extends RuntimeException
+public class RemoteException extends org.eclipse.net4j.util.io.RemoteException
{
private static final long serialVersionUID = 1L;
- private boolean whileResponding;
+ private final boolean whileResponding;
- private transient RequestWithConfirmation<?> localRequest;
+ private final transient RequestWithConfirmation<?> localRequest;
private StackTraceElement[] localStackTrace;
@@ -31,7 +31,7 @@ public class RemoteException extends RuntimeException
*/
public RemoteException(Throwable remoteCause, RequestWithConfirmation<?> localRequest, boolean whileResponding)
{
- super(remoteCause);
+ super(remoteCause.getMessage(), remoteCause);
this.localRequest = localRequest;
this.whileResponding = whileResponding;
}
@@ -40,6 +40,7 @@ public class RemoteException extends RuntimeException
{
super(message);
this.whileResponding = whileResponding;
+ localRequest = null;
}
public boolean whileResponding()
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
index a5fcae9717..24f831377b 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2013 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2013, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,17 +12,12 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedIOUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
/**
* @author Eike Stepper
*/
class RemoteExceptionIndication extends Indication
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionIndication.class);
-
private Throwable t;
public RemoteExceptionIndication(SignalProtocol<?> protocol)
@@ -36,11 +31,6 @@ class RemoteExceptionIndication extends Indication
int correlationID = in.readInt();
boolean responding = in.readBoolean();
String message = in.readString();
- if (TRACER.isEnabled())
- {
- String msg = RemoteExceptionRequest.getFirstLine(message);
- TRACER.format("Reading remote exception for signal {0}: {1}", correlationID, msg); //$NON-NLS-1$
- }
try
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java
index 520df91f87..73568193bf 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2013, 2016 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2013, 2016, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,24 +12,19 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.io.ExtendedIOUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
/**
* @author Eike Stepper
*/
class RemoteExceptionRequest extends Request
{
- public static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionRequest.class);
-
- private int correlationID;
+ private final int correlationID;
- private boolean responding;
+ private final boolean responding;
- private String message;
+ private final String message;
- private Throwable t;
+ private final Throwable t;
public RemoteExceptionRequest(SignalProtocol<?> protocol, int correlationID, boolean responding, String message, Throwable t)
{
@@ -43,36 +38,9 @@ class RemoteExceptionRequest extends Request
@Override
protected void requesting(ExtendedDataOutputStream out) throws Exception
{
- if (TRACER.isEnabled())
- {
- String msg = getFirstLine(message);
- TRACER.format("Writing remote exception for signal {0}: {1}", correlationID, msg); //$NON-NLS-1$
- }
-
out.writeInt(correlationID);
out.writeBoolean(responding);
out.writeString(message);
out.writeByteArray(ExtendedIOUtil.serializeThrowable(t));
}
-
- static String getFirstLine(String message)
- {
- if (message == null)
- {
- return null;
- }
-
- int nl = message.indexOf('\n');
- if (nl == -1)
- {
- nl = message.length();
- }
-
- if (nl > 100)
- {
- nl = 100;
- }
-
- return message.substring(0, nl);
- }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
index b1b7e4f34b..0a6b0d72d4 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2008, 2011, 2012, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2006-2008, 2011, 2012, 2019, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -126,10 +126,26 @@ public abstract class RequestWithConfirmation<RESULT> extends SignalActor
result = confirming(in);
}
+ /**
+ * @since 4.15
+ */
+ protected void onRemoteException(RemoteException ex)
+ {
+ // Subclasses may override.
+ }
+
void setRemoteException(Throwable t, boolean responding)
{
RemoteException remoteException = getRemoteException(t, responding);
- getBufferInputStream().setException(remoteException);
+
+ try
+ {
+ onRemoteException(remoteException);
+ }
+ finally
+ {
+ getBufferInputStream().setException(remoteException);
+ }
}
private RemoteException getRemoteException(Throwable t, boolean responding)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
index f9316012f1..7ceb47d2e0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2014, 2016, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2014, 2016, 2019, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -124,14 +124,15 @@ public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmat
@Override
protected final void requesting(ExtendedDataOutputStream out) throws Exception
{
- double remoteWork = OMMonitor.HUNDRED - getRequestingWorkPercent() - getConfirmingWorkPercent();
- if (remoteWork < OMMonitor.ZERO)
+ double remoteWorkPercent = OMMonitor.HUNDRED - getRequestingWorkPercent() - getConfirmingWorkPercent();
+ if (remoteWorkPercent < OMMonitor.ZERO)
{
- throw new ImplementationError("Remote work must not be negative: " + remoteWork); //$NON-NLS-1$
+ throw new ImplementationError("Remote work must not be negative: " + remoteWorkPercent); //$NON-NLS-1$
}
mainMonitor.begin(OMMonitor.HUNDRED);
- OMMonitor subMonitor = mainMonitor.fork(remoteWork);
+ OMMonitor subMonitor = mainMonitor.fork(remoteWorkPercent);
+
synchronized (monitorLock)
{
remoteMonitor = subMonitor;
@@ -293,9 +294,11 @@ public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmat
}
}
+ @Override
void setMonitorProgress(double totalWork, double work)
{
- getBufferInputStream().restartTimeout();
+ super.setMonitorProgress(totalWork, work);
+
synchronized (monitorLock)
{
if (remoteMonitor != null)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
index 10162336a6..6662f489be 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2013, 2015, 2016, 2018-2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2006-2013, 2015, 2016, 2018-2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.buffer.BufferInputStream;
import org.eclipse.net4j.buffer.BufferOutputStream;
import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -43,6 +44,8 @@ public abstract class Signal implements Runnable
private static final boolean DISABLE_LOG_EXCEPTIONS = OMPlatform.INSTANCE.isProperty("org.eclipse.net4j.signal.Signal.disableLogExceptions");
+ private static final boolean SHORT_TO_STRING = OMPlatform.INSTANCE.isProperty("org.eclipse.net4j.signal.Signal.shortToString");
+
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, Signal.class);
private SignalProtocol<?> protocol;
@@ -63,6 +66,8 @@ public abstract class Signal implements Runnable
private Object currentStream;
+ long scheduled = -1L;
+
/**
* Both implementation classes of a logical signal must have the same signalID. The signalID of a user signals must be
* equal to or greater than zero.
@@ -139,8 +144,35 @@ public abstract class Signal implements Runnable
@Override
public String toString()
{
- return MessageFormat.format("Signal[protocol={0}, id={1}, name={2}, correlation={3}{4}]", getProtocol().getType(), //$NON-NLS-1$
- getID(), getName(), getCorrelationID(), getAdditionalInfo());
+ return toString(SHORT_TO_STRING);
+ }
+
+ /**
+ * @since 4.13
+ */
+ public String toString(boolean shortForm)
+ {
+ String name = getName();
+
+ String additionalInfo = getAdditionalInfo();
+ if (StringUtil.isEmpty(additionalInfo))
+ {
+ if (shortForm)
+ {
+ return name;
+ }
+
+ return MessageFormat.format("{0}[protocol={1}, correlation={2}]", name, getProtocol().getType(), //$NON-NLS-1$
+ getCorrelationID());
+ }
+
+ if (shortForm)
+ {
+ return MessageFormat.format("{0}[{1}]", name, additionalInfo); //$NON-NLS-1$
+ }
+
+ return MessageFormat.format("{0}[protocol={1}, correlation={2}, {3}]", name, getProtocol().getType(), //$NON-NLS-1$
+ getCorrelationID(), additionalInfo);
}
/**
@@ -359,11 +391,7 @@ public abstract class Signal implements Runnable
{
doExtendedOutput(extended);
}
- catch (Error ex)
- {
- throw ex;
- }
- catch (Exception ex)
+ catch (Exception | Error ex)
{
throw ex;
}
@@ -390,11 +418,7 @@ public abstract class Signal implements Runnable
{
doExtendedInput(extended);
}
- catch (Error ex)
- {
- throw ex;
- }
- catch (Exception ex)
+ catch (Exception | Error ex)
{
throw ex;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
index 0e8c29cbc1..b082f6102c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2006-2012, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -55,6 +55,11 @@ public abstract class SignalActor extends Signal
abstract void doExecute(BufferInputStream in, BufferOutputStream out) throws Exception;
+ void setMonitorProgress(double totalWork, double work)
+ {
+ getBufferInputStream().restartTimeout();
+ }
+
@Override
String getInputMeaning()
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalCounter.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalCounter.java
index 35640443d8..3d4f3559c9 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalCounter.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalCounter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012, 2015, 2016, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2010-2012, 2015, 2016, 2019, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -128,9 +128,10 @@ public final class SignalCounter implements IListener
{
if (event instanceof SignalFinishedEvent)
{
+ SignalFinishedEvent<?> e = (SignalFinishedEvent<?>)event;
+
synchronized (signals)
{
- SignalFinishedEvent<?> e = (SignalFinishedEvent<?>)event;
signals.add(e.getSignal().getClass());
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalFinishedEvent.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalFinishedEvent.java
index a454816747..1cd1a5558a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalFinishedEvent.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalFinishedEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2010-2012, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,15 +25,19 @@ public class SignalFinishedEvent<INFRA_STRUCTURE> extends Event
{
private static final long serialVersionUID = 1L;
- private Signal signal;
+ private final Signal signal;
- private Exception exception;
+ private final Exception exception;
+
+ private final long duration;
SignalFinishedEvent(ISignalProtocol<INFRA_STRUCTURE> source, Signal signal, Exception exception)
{
super(source);
this.signal = signal;
this.exception = exception;
+
+ duration = signal.scheduled == -1L ? -1L : System.currentTimeMillis() - signal.scheduled;
}
@Override
@@ -54,6 +58,14 @@ public class SignalFinishedEvent<INFRA_STRUCTURE> extends Event
return exception;
}
+ /**
+ * @since 4.13
+ */
+ public long getDuration()
+ {
+ return duration;
+ }
+
@Override
protected String formatAdditionalParameters()
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 9b040536a9..8c1ade7338 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -42,6 +42,7 @@ import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
/**
* The default implementation of a {@link ISignalProtocol signal protocol}.
@@ -52,7 +53,7 @@ import java.util.Map;
*
* @author Eike Stepper
*/
-public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> implements ISignalProtocol<INFRA_STRUCTURE>
+public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> implements ISignalProtocol.WithSignalCounters<INFRA_STRUCTURE>
{
/**
* @since 4.7
@@ -115,6 +116,10 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
private boolean failingOver;
+ private AtomicLong sentSignals = new AtomicLong();
+
+ private AtomicLong receivedSignals = new AtomicLong();
+
/**
* @since 2.0
*/
@@ -201,6 +206,21 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
}
/**
+ * @since 4.13
+ */
+ @Override
+ public long getSentSignals()
+ {
+ return sentSignals.get();
+ }
+
+ @Override
+ public long getReceivedSignals()
+ {
+ return receivedSignals.get();
+ }
+
+ /**
* @since 2.0
*/
@Override
@@ -571,10 +591,9 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
synchronized (signals)
{
Signal signal = signals.get(correlationID);
- if (signal instanceof RequestWithMonitoring<?>)
+ if (signal instanceof SignalActor)
{
- RequestWithMonitoring<?> request = (RequestWithMonitoring<?>)signal;
- request.setMonitorProgress(totalWork, work);
+ ((SignalActor)signal).setMonitorProgress(totalWork, work);
}
}
}
@@ -584,10 +603,9 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
synchronized (signals)
{
Signal signal = signals.get(-correlationID);
- if (signal instanceof IndicationWithMonitoring)
+ if (signal instanceof SignalReactor)
{
- IndicationWithMonitoring indication = (IndicationWithMonitoring)signal;
- indication.setMonitorCanceled();
+ ((SignalReactor)signal).setMonitorCanceled();
}
}
}
@@ -642,21 +660,30 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
private void fireSignalScheduledEvent(Signal signal)
{
+ signal.scheduled = System.currentTimeMillis();
+
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
- IEvent event = new SignalScheduledEvent<>(this, signal);
- fireEvent(event, listeners);
+ fireEvent(new SignalScheduledEvent<>(this, signal), listeners);
}
}
private void fireSignalFinishedEvent(Signal signal, Exception exception)
{
+ if (signal instanceof SignalActor)
+ {
+ sentSignals.incrementAndGet();
+ }
+ else if (signal instanceof SignalReactor)
+ {
+ receivedSignals.incrementAndGet();
+ }
+
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
- IEvent event = new SignalFinishedEvent<>(this, signal, exception);
- fireEvent(event, listeners);
+ fireEvent(new SignalFinishedEvent<>(this, signal, exception), listeners);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java
index 762e0071ec..11dd68596d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2009, 2011, 2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2006-2009, 2011, 2012, 2021, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,17 @@
*/
package org.eclipse.net4j.signal;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.util.RunnableWithException;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+import org.eclipse.net4j.util.om.monitor.TimeoutMonitor;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.util.TimerTask;
+
/**
* Represents the receiver side of a {@link Signal signal}.
*
@@ -17,6 +28,8 @@ package org.eclipse.net4j.signal;
*/
public abstract class SignalReactor extends Signal
{
+ private ReportingMonitor monitor;
+
/**
* @since 2.0
*/
@@ -41,6 +54,62 @@ public abstract class SignalReactor extends Signal
super(protocol, literal);
}
+ /**
+ * @since 4.13
+ */
+ protected final OMMonitor createMonitor(int monitorProgressSeconds, int monitorTimeoutSeconds)
+ {
+ if (monitor != null)
+ {
+ throw new IllegalStateException("Illegal attempt to create a second monitor");
+ }
+
+ monitor = new ReportingMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
+ return monitor;
+ }
+
+ /**
+ * @since 4.15
+ */
+ protected final void monitor(int monitorProgressSeconds, int monitorTimeoutSeconds, RunnableWithException runnable) throws Exception
+ {
+ OMMonitor monitor = createMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
+ monitor.begin();
+
+ Async async = monitor.forkAsync();
+
+ try
+ {
+ runnable.run();
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+ }
+ }
+
+ @Override
+ void runSync() throws Exception
+ {
+ try
+ {
+ super.runSync();
+ }
+ finally
+ {
+ if (monitor != null)
+ {
+ monitor.done();
+ }
+ }
+ }
+
+ void setMonitorCanceled()
+ {
+ monitor.cancel();
+ }
+
@Override
String getInputMeaning()
{
@@ -52,4 +121,77 @@ public abstract class SignalReactor extends Signal
{
return "Responding"; //$NON-NLS-1$
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ReportingMonitor extends TimeoutMonitor
+ {
+ private TimerTask sendProgressTask = new TimerTask()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ sendProgress();
+ }
+ catch (Throwable ex)
+ {
+ OM.LOG.error("ReportingMonitorTask failed", ex);
+ cancel();
+ }
+ }
+ };
+
+ public ReportingMonitor(int monitorProgressSeconds, int monitorTimeoutSeconds)
+ {
+ super(1000L * monitorTimeoutSeconds);
+ long period = 1000L * monitorProgressSeconds;
+ scheduleAtFixedRate(sendProgressTask, period, period);
+ }
+
+ @Override
+ public void cancel(RuntimeException cancelException)
+ {
+ sendProgressTask.cancel();
+ super.cancel(cancelException);
+ }
+
+ @Override
+ public void done()
+ {
+ try
+ {
+ sendProgressTask.cancel();
+ super.done();
+ }
+ finally
+ {
+ monitor = null;
+ }
+ }
+
+ private void sendProgress()
+ {
+ SignalProtocol<?> protocol = getProtocol();
+
+ try
+ {
+ int correlationID = -getCorrelationID();
+ double totalWork = getTotalWork();
+ double work = getWork();
+
+ new MonitorProgressRequest(protocol, correlationID, totalWork, work).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ IChannel channel = protocol.getChannel();
+ if (LifecycleUtil.isActive(channel))
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/security/AuthenticationIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/security/AuthenticationIndication.java
index 6454321c82..b260b75244 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/security/AuthenticationIndication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/security/AuthenticationIndication.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015-2017 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2013, 2015-2017, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java
index 3e42b7fe99..71c6b6bb82 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2015, 2016, 2019-2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,6 +68,12 @@ public abstract class Acceptor extends Container<IConnector> implements Internal
}
@Override
+ public boolean needsBufferProvider()
+ {
+ return true;
+ }
+
+ @Override
public synchronized ITransportConfig getConfig()
{
if (config == null)
@@ -191,9 +197,10 @@ public abstract class Acceptor extends Container<IConnector> implements Internal
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- if (getConfig().getBufferProvider() == null)
+
+ if (needsBufferProvider())
{
- throw new IllegalStateException("getConfig().getBufferProvider() == null"); //$NON-NLS-1$
+ checkState(getConfig().getBufferProvider(), "getConfig().getBufferProvider()"); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
index de4b221b7c..d1800f70db 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2013, 2015, 2016, 2018-2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2013, 2015, 2016, 2018-2021, 2023 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -66,8 +66,12 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
private transient long sentBuffers;
+ private transient long sentBytes;
+
private transient long receivedBuffers;
+ private transient long receivedBytes;
+
public Channel()
{
}
@@ -180,6 +184,15 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
}
/**
+ * @since 4.13
+ */
+ @Override
+ public final long getSentBytes()
+ {
+ return sentBytes;
+ }
+
+ /**
* @since 3.0
*/
@Override
@@ -188,6 +201,15 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
return receivedBuffers;
}
+ /**
+ * @since 4.13
+ */
+ @Override
+ public final long getReceivedBytes()
+ {
+ return receivedBytes;
+ }
+
@Override
public Queue<IBuffer> getSendQueue()
{
@@ -211,6 +233,8 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
@Override
public void handleBuffer(IBuffer buffer)
{
+ checkID();
+
BufferState state = buffer.getState();
if (state != BufferState.PUTTING)
{
@@ -256,7 +280,16 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
return;
}
- ++sentBuffers;
+ try
+ {
+ ++sentBuffers;
+ sentBytes += buffer.getPosition();
+ fireCountersChangedEvent();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.warn(ex);
+ }
if (sendQueue != null)
{
@@ -284,7 +317,17 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
TRACER.format("Handling buffer from multiplexer: {0} --> {1}", buffer, this); //$NON-NLS-1$
}
- ++receivedBuffers;
+ try
+ {
+ ++receivedBuffers;
+ receivedBytes += buffer.getLimit();
+ fireCountersChangedEvent();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.warn(ex);
+ }
+
receiveHandler.handleBuffer(buffer);
}
else
@@ -341,7 +384,7 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- checkState(id != IBuffer.NO_CHANNEL, "channelID == NO_CHANNEL"); //$NON-NLS-1$
+ checkID();
checkState(channelMultiplexer, "channelMultiplexer"); //$NON-NLS-1$
}
@@ -387,6 +430,20 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
return !isActive();
}
+ private void checkID()
+ {
+ checkState(id != IBuffer.NO_CHANNEL, "channelID == NO_CHANNEL"); //$NON-NLS-1$
+ }
+
+ private void fireCountersChangedEvent()
+ {
+ IListener[] listeners = getListeners();
+ if (listeners.length != 0)
+ {
+ fireEvent(new CountersChangedEventImpl(this), listeners);
+ }
+ }
+
/**
* @author Eike Stepper
* @since 4.1
@@ -509,7 +566,7 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
{
int queueSize = size.incrementAndGet();
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
fireEvent(new SendQueueEventImpl(Channel.this, Type.ENQUEUED, queueSize), listeners);
}
@@ -519,7 +576,7 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
{
int queueSize = size.decrementAndGet();
IListener[] listeners = getListeners();
- if (listeners != null)
+ if (listeners.length != 0)
{
fireEvent(new SendQueueEventImpl(Channel.this, Type.DEQUEUED, queueSize), listeners);
}
@@ -562,4 +619,23 @@ public class Channel extends Lifecycle implements InternalChannel, IExecutorServ
return queueSize;
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CountersChangedEventImpl extends Event implements CountersChangedEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private CountersChangedEventImpl(Channel channel)
+ {
+ super(channel);
+ }
+
+ @Override
+ public InternalChannel getSource()
+ {
+ return (InternalChannel)super.getSource();
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelContainer.java
new file mode 100644
index 0000000000..64c0bcf40f
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelContainer.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2021 Eike Stepper (Loehne, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.spi.net4j;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.buffer.IBufferHandler;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.SelfAttachingContainerListener;
+import org.eclipse.net4j.util.container.SetContainer;
+import org.eclipse.net4j.util.event.EventUtil;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.event.INotifier;
+
+import java.util.LinkedHashSet;
+
+/**
+ * @author Eike Stepper
+ * @since 4.13
+ */
+public class ChannelContainer extends SetContainer<IChannel>
+{
+ private final IContainer<?> delegate;
+
+ private final IListener delegateListener = new SelfAttachingContainerListener()
+ {
+ @Override
+ public void attach(Object element)
+ {
+ if (element instanceof IChannel)
+ {
+ addChannel((IChannel)element);
+ }
+
+ super.attach(element);
+ }
+
+ @Override
+ public void detach(Object element)
+ {
+ if (element instanceof IChannel)
+ {
+ IChannel channel = (IChannel)element;
+ removeChannel(channel);
+ }
+
+ super.detach(element);
+ }
+
+ @Override
+ protected boolean shouldDescend(Object element)
+ {
+ return element instanceof IManagedContainer || element instanceof IAcceptor || element instanceof IConnector;
+ }
+
+ @Override
+ protected void notifyOtherEvent(IEvent event)
+ {
+ INotifier source = event.getSource();
+ if (source instanceof IChannel)
+ {
+ notifyChannelEvent(event);
+ }
+ else if (source instanceof IProtocol)
+ {
+ notifyProtocolEvent(event);
+ }
+ }
+ };
+
+ public ChannelContainer(IContainer<?> delegate)
+ {
+ super(IChannel.class, new LinkedHashSet<IChannel>());
+ this.delegate = delegate;
+ }
+
+ protected void notifyChannelEvent(IEvent event)
+ {
+ }
+
+ protected void notifyProtocolEvent(IEvent event)
+ {
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ delegate.addListener(delegateListener);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ delegate.removeListener(delegateListener);
+ super.doDeactivate();
+ }
+
+ protected void addChannel(IChannel channel)
+ {
+ addElement(channel);
+
+ IBufferHandler receiveHandler = channel.getReceiveHandler();
+ if (receiveHandler instanceof IProtocol)
+ {
+ EventUtil.addUniqueListener(receiveHandler, delegateListener);
+ }
+ }
+
+ protected void removeChannel(IChannel channel)
+ {
+ removeElement(channel);
+
+ IBufferHandler receiveHandler = channel.getReceiveHandler();
+ if (receiveHandler instanceof IProtocol)
+ {
+ EventUtil.removeListener(receiveHandler, delegateListener);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
index 094a7a073e..3ca72bf0ee 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2012, 2015, 2016, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2012, 2015, 2016, 2019-2023 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@ import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.channel.IChannelMultiplexer;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.protocol.IProtocol2;
+import org.eclipse.net4j.protocol.IProtocol3;
import org.eclipse.net4j.protocol.IProtocolProvider;
import org.eclipse.net4j.protocol.ProtocolVersionException;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
@@ -28,6 +29,7 @@ import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.factory.FactoryKey;
import org.eclipse.net4j.util.factory.IFactoryKey;
+import org.eclipse.net4j.util.lifecycle.LifecycleException;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.registry.HashMapRegistry;
@@ -86,6 +88,12 @@ public abstract class ChannelMultiplexer extends Container<IChannel> implements
}
@Override
+ public boolean needsBufferProvider()
+ {
+ return true;
+ }
+
+ @Override
public synchronized ITransportConfig getConfig()
{
if (config == null)
@@ -199,13 +207,17 @@ public abstract class ChannelMultiplexer extends Container<IChannel> implements
String message = "Channel registration timeout after " + getOpenChannelTimeout() + " milliseconds";
throw new TimeoutRuntimeException(message, ex);
}
+
+ protocolConnected(protocol);
}
catch (ChannelException ex)
{
+ removeChannel(channel);
throw ex;
}
catch (Exception ex)
{
+ removeChannel(channel);
throw new ChannelException(ex);
}
@@ -238,6 +250,7 @@ public abstract class ChannelMultiplexer extends Container<IChannel> implements
channel.setID(channelID);
addChannel(channel);
+ protocolConnected(protocol);
return channel;
}
finally
@@ -459,4 +472,23 @@ public abstract class ChannelMultiplexer extends Container<IChannel> implements
throw ex;
}
}
+
+ private void protocolConnected(IProtocol<?> protocol)
+ {
+ if (protocol instanceof IProtocol3)
+ {
+ try
+ {
+ ((IProtocol3<?>)protocol).doWhenFullyConnected();
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new LifecycleException(ex);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java
index 25e0d9611d..04b4969dd0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2012, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2012, 2019, 2020, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -387,7 +387,11 @@ public abstract class Connector extends ChannelMultiplexer implements InternalCo
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- checkState(getConfig().getBufferProvider(), "getConfig().getBufferProvider()"); //$NON-NLS-1$
+
+ if (needsBufferProvider())
+ {
+ checkState(getConfig().getBufferProvider(), "getConfig().getBufferProvider()"); //$NON-NLS-1$
+ }
if (userID != null && getConfig().getNegotiator() == null)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalAcceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalAcceptor.java
index 3d24b1356a..deaf1cc316 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalAcceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalAcceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, 2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2011, 2012, 2021, 2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,4 +23,8 @@ import org.eclipse.net4j.util.security.INegotiatorAware;
*/
public interface InternalAcceptor extends IAcceptor, ITransportConfigAware, INegotiatorAware
{
+ /**
+ * @since 4.16
+ */
+ public boolean needsBufferProvider();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java
index 140a9781a6..8a2c129534 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2019-2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -86,4 +86,22 @@ public interface InternalChannel extends IChannel, IBufferProvider, ILifecycle
ENQUEUED, DEQUEUED
}
}
+
+ /**
+ * An {@link IEvent event} fired from a {@link InternalChannel channel} when one of its statistical counters changed.
+ *
+ * @see IChannel#getReceivedBuffers()
+ * @see IChannel#getReceivedBytes()
+ * @see IChannel#getSentBuffers()
+ * @see IChannel#getSentBytes()
+ * @author Eike Stepper
+ * @since 4.13
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface CountersChangedEvent extends IEvent
+ {
+ @Override
+ public InternalChannel getSource();
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
index ba8c764b92..274abb00f2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011, 2012, 2016, 2019, 2020 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2009, 2011, 2012, 2016, 2019-2022 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,6 +37,11 @@ public interface InternalChannelMultiplexer extends IChannelMultiplexer, IBuffer
public static final short RESERVED_CHANNEL = 0;
/**
+ * @since 4.16
+ */
+ public boolean needsBufferProvider();
+
+ /**
* Called by a {@link IChannel channel} each time a new {@link IBuffer buffer} is available for multiplexing. This or another buffer can be
* dequeued from the {@link InternalChannel#getSendQueue() send queue} of the channel.
*/
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalConnector.java
index 93ec88b57b..5329c76578 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalConnector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010-2012 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008, 2010-2012, 2021 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java
index 74a647d24d..c8c72df91d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2012, 2015, 2016, 2019 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2008-2012, 2015, 2016, 2019, 2021, 2023 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,10 +12,11 @@ package org.eclipse.spi.net4j;
import org.eclipse.net4j.buffer.IBufferProvider;
import org.eclipse.net4j.channel.IChannel;
-import org.eclipse.net4j.protocol.IProtocol2;
+import org.eclipse.net4j.protocol.IProtocol3;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.concurrent.IExecutorServiceProvider;
+import org.eclipse.net4j.util.event.Event;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
@@ -31,7 +32,7 @@ import java.util.concurrent.ExecutorService;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IProtocol2<INFRA_STRUCTURE>, IExecutorServiceProvider
+public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IProtocol3<INFRA_STRUCTURE>, IExecutorServiceProvider
{
private String type;
@@ -102,7 +103,12 @@ public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IPr
@Override
public void setInfraStructure(INFRA_STRUCTURE infraStructure)
{
- this.infraStructure = infraStructure;
+ if (this.infraStructure != infraStructure)
+ {
+ INFRA_STRUCTURE oldInfraStructure = this.infraStructure;
+ this.infraStructure = infraStructure;
+ fireEvent(new InfraStructureChangedEvent(oldInfraStructure, infraStructure));
+ }
}
/**
@@ -199,4 +205,40 @@ public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IPr
setChannel(null);
super.doDeactivate();
}
+
+ /**
+ * @author Eike Stepper
+ * @since 4.13
+ */
+ public final class InfraStructureChangedEvent extends Event
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final INFRA_STRUCTURE oldInfraStructure;
+
+ private final INFRA_STRUCTURE newInfraStructure;
+
+ private InfraStructureChangedEvent(INFRA_STRUCTURE oldInfraStructure, INFRA_STRUCTURE newInfraStructure)
+ {
+ super(Protocol.this);
+ this.oldInfraStructure = oldInfraStructure;
+ this.newInfraStructure = newInfraStructure;
+ }
+
+ @Override
+ public Protocol<INFRA_STRUCTURE> getSource()
+ {
+ return Protocol.this;
+ }
+
+ public final INFRA_STRUCTURE getOldInfraStructure()
+ {
+ return oldInfraStructure;
+ }
+
+ public final INFRA_STRUCTURE getNewInfraStructure()
+ {
+ return newInfraStructure;
+ }
+ }
}

Back to the top