Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-05 04:38:53 -0400
committerEike Stepper2011-07-05 04:38:53 -0400
commitc1e7e8db43761c649da510e7dc1d208de7b541b0 (patch)
treef15133583d37b043471751bc490abc70012a6d48 /plugins
parent3d5a474fa73ee5b8f271672652a74af9cf8b94f6 (diff)
downloadcdo-c1e7e8db43761c649da510e7dc1d208de7b541b0.tar.gz
cdo-c1e7e8db43761c649da510e7dc1d208de7b541b0.tar.xz
cdo-c1e7e8db43761c649da510e7dc1d208de7b541b0.zip
[351147] Emit TimeoutChangedEvent from SignalProtocol
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351147
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java25
-rw-r--r--plugins/org.eclipse.net4j/META-INF/MANIFEST.MF28
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java52
3 files changed, 90 insertions, 15 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java
index b9f9348bba..dbb2746584 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java
@@ -25,9 +25,12 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.signal.ISignalProtocol;
import org.eclipse.net4j.signal.RemoteException;
+import org.eclipse.net4j.signal.SignalProtocol.TimeoutChangedEvent;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.ContainerEventAdapter;
import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogHandler;
import org.eclipse.net4j.util.om.log.OMLogger;
@@ -392,6 +395,28 @@ public class SessionTest extends AbstractCDOTest
}
}
+ public void testProtocolTimeoutChangedEvent() throws Exception
+ {
+ final boolean[] eventSent = { false };
+
+ org.eclipse.emf.cdo.net4j.CDOSession session = (org.eclipse.emf.cdo.net4j.CDOSession)openSession();
+ session.options().getProtocol().addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof TimeoutChangedEvent)
+ {
+ TimeoutChangedEvent e = (TimeoutChangedEvent)event;
+ System.out.println(e);
+ eventSent[0] = true;
+ }
+ }
+ });
+
+ session.options().getProtocol().setTimeout(20L * 1000L);
+ assertEquals(true, eventSent[0]);
+ }
+
public void testSetProtocolTimeout() throws Exception
{
IRepository repository = getRepository();
diff --git a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
index 7d01d7c014..13aaba9be3 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.0.0.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -11,7 +11,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.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.0.0";
+Export-Package: org.eclipse.internal.net4j;version="4.1.0";
x-friends:="org.eclipse.net4j.http.server,
org.eclipse.net4j.jvm,
org.eclipse.net4j.tcp,
@@ -20,7 +20,7 @@ Export-Package: org.eclipse.internal.net4j;version="4.0.0";
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests,
org.eclipse.net4j.defs",
- org.eclipse.internal.net4j.buffer;version="4.0.0";
+ org.eclipse.internal.net4j.buffer;version="4.1.0";
x-friends:="org.eclipse.net4j.http.server,
org.eclipse.net4j.jvm,
org.eclipse.net4j.tcp,
@@ -29,15 +29,15 @@ Export-Package: org.eclipse.internal.net4j;version="4.0.0";
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests,
org.eclipse.net4j.defs",
- org.eclipse.internal.net4j.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.net4j;version="4.0.0",
- org.eclipse.net4j.acceptor;version="4.0.0",
- org.eclipse.net4j.buffer;version="4.0.0",
- org.eclipse.net4j.channel;version="4.0.0",
- org.eclipse.net4j.connector;version="4.0.0",
- org.eclipse.net4j.protocol;version="4.0.0",
- org.eclipse.net4j.signal;version="4.0.0",
- org.eclipse.net4j.signal.heartbeat;version="4.0.0",
- org.eclipse.net4j.signal.wrapping;version="4.0.0",
- org.eclipse.spi.net4j;version="4.0.0"
+ org.eclipse.internal.net4j.bundle;version="4.1.0";x-internal:=true,
+ org.eclipse.net4j;version="4.1.0",
+ org.eclipse.net4j.acceptor;version="4.1.0",
+ org.eclipse.net4j.buffer;version="4.1.0",
+ org.eclipse.net4j.channel;version="4.1.0",
+ org.eclipse.net4j.connector;version="4.1.0",
+ org.eclipse.net4j.protocol;version="4.1.0",
+ org.eclipse.net4j.signal;version="4.1.0",
+ org.eclipse.net4j.signal.heartbeat;version="4.1.0",
+ org.eclipse.net4j.signal.wrapping;version="4.1.0",
+ org.eclipse.spi.net4j;version="4.1.0"
Eclipse-BuddyPolicy: registered
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 6a4a9d84ba..ab66e4d513 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
@@ -17,6 +17,7 @@ import org.eclipse.net4j.buffer.IBufferProvider;
import org.eclipse.net4j.channel.ChannelOutputStream;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.util.event.Event;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.io.IStreamWrapper;
@@ -97,7 +98,12 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
*/
public void setTimeout(long timeout)
{
- this.timeout = timeout;
+ long oldTimeout = this.timeout;
+ if (oldTimeout != timeout)
+ {
+ this.timeout = timeout;
+ fireEvent(new TimeoutChangedEvent(this, oldTimeout, timeout));
+ }
}
public IStreamWrapper getStreamWrapper()
@@ -455,6 +461,50 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
/**
* @author Eike Stepper
+ * @since 4.1
+ */
+ public static final class TimeoutChangedEvent extends Event
+ {
+ private static final long serialVersionUID = 1L;
+
+ private long oldTimeout;
+
+ private long newTimeout;
+
+ private TimeoutChangedEvent(ISignalProtocol<?> source, long oldTimeout, long newTimeout)
+ {
+ super(source);
+ this.oldTimeout = oldTimeout;
+ this.newTimeout = newTimeout;
+ }
+
+ @Override
+ public SignalProtocol<?> getSource()
+ {
+ return (SignalProtocol<?>)super.getSource();
+ }
+
+ public long getOldTimeout()
+ {
+ return oldTimeout;
+ }
+
+ public long getNewTimeout()
+ {
+ return newTimeout;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TimeoutChangedEvent [oldTimeout=" + oldTimeout + ", newTimeout=" + newTimeout + ", source=" + source
+ + "]";
+ }
+
+ }
+
+ /**
+ * @author Eike Stepper
*/
class SignalInputStream extends BufferInputStream
{

Back to the top