Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-24 05:50:14 -0400
committerEike Stepper2006-10-24 05:50:14 -0400
commit73ab230d762acbe084c562c88ee5b699e860958b (patch)
tree910c912fdb8f6cb5914a99e032f98116716aa8da /plugins/org.eclipse.net4j
parent107521df821d72413751bd6c98ceb71a8a60334b (diff)
downloadcdo-73ab230d762acbe084c562c88ee5b699e860958b.tar.gz
cdo-73ab230d762acbe084c562c88ee5b699e860958b.tar.xz
cdo-73ab230d762acbe084c562c88ee5b699e860958b.zip
Introduced new lifecycle phase AboutToActivate
Diffstat (limited to 'plugins/org.eclipse.net4j')
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java9
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java27
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleListener.java2
8 files changed, 60 insertions, 16 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
index acaa90cc28..99fc973d30 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
@@ -451,6 +451,20 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return factory.createProtocol(channel);
}
+ protected void fireChannelAboutToOpen(Channel channel)
+ {
+ for (ChannelListener listener : channelListeners)
+ {
+ try
+ {
+ listener.notifyChannelOpened(channel);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
protected void fireChannelOpened(Channel channel)
{
for (ChannelListener listener : channelListeners)
@@ -497,9 +511,9 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
}
@Override
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
- super.onAccessBeforeActivate();
+ super.onAboutToActivate();
if (bufferProvider == null)
{
throw new IllegalStateException("bufferProvider == null");
@@ -551,6 +565,12 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
*/
private final class ChannelLifecycleListener implements LifecycleListener
{
+ public void notifyLifecycleAboutToActivate(LifecycleNotifier notifier)
+ {
+ ChannelImpl channel = (ChannelImpl)notifier;
+ fireChannelAboutToOpen(channel);
+ }
+
public void notifyLifecycleActivated(LifecycleNotifier notifier)
{
ChannelImpl channel = (ChannelImpl)notifier;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
index 8924e2e07b..6547bab0f6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
@@ -160,9 +160,9 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
}
@Override
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
- super.onAccessBeforeActivate();
+ super.onAboutToActivate();
if (channelID == BufferImpl.NO_CHANNEL)
{
throw new IllegalStateException("channelID == INVALID_CHANNEL_ID");
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
index 016fa432e5..3974062571 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
@@ -256,9 +256,9 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
}
@Override
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
- super.onAccessBeforeActivate();
+ super.onAboutToActivate();
if (selector == null)
{
selector = Net4jFactory.createTCPSelector();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
index 769ab52787..fd814b3664 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
@@ -59,9 +59,9 @@ public class ClientTCPConnectorImpl extends AbstractTCPConnector
}
@Override
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
- super.onAccessBeforeActivate();
+ super.onAboutToActivate();
if (host == null || host.length() == 0)
{
throw new IllegalArgumentException("host == null || host.length() == 0");
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
index 2a7e2bcf0c..5ab5a44316 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
@@ -178,6 +178,11 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
listeners.remove(listener);
}
+ public void notifyLifecycleAboutToActivate(LifecycleNotifier notifier)
+ {
+ // Do nothing
+ }
+
public void notifyLifecycleActivated(LifecycleNotifier notifier)
{
// Do nothing
@@ -276,9 +281,9 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
}
@Override
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
- super.onAccessBeforeActivate();
+ super.onAboutToActivate();
if (bufferProvider == null)
{
throw new IllegalStateException("bufferProvider == null");
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
index 617047eead..bea5c53386 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
@@ -150,6 +150,8 @@ public interface Connector
*/
public interface ChannelListener
{
+ public void notifyChannelAboutToOpen(Channel channel);
+
public void notifyChannelOpened(Channel channel);
public void notifyChannelClosing(Channel channel);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
index 3e37b306dd..a7597d094d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/AbstractLifecycle.java
@@ -40,17 +40,18 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
if (!active)
{
System.out.println(toString() + ": Activating");
- onAccessBeforeActivate();
- onActivate();
+ onAboutToActivate();
+ fireLifecycleAboutToActivate();
+
active = true;
+ onActivate();
+ fireLifecycleActivated();
if (DUMP_ON_ACTIVATE)
{
ReflectUtil.dump(this, toString() + ": DUMP ");
}
-
- fireLifecycleActivated();
- }
+}
}
public final synchronized Exception deactivate()
@@ -96,6 +97,20 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
}
+ protected void fireLifecycleAboutToActivate()
+ {
+ for (LifecycleListener listener : listeners)
+ {
+ try
+ {
+ listener.notifyLifecycleAboutToActivate(this);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
protected void fireLifecycleActivated()
{
for (LifecycleListener listener : listeners)
@@ -126,7 +141,7 @@ public abstract class AbstractLifecycle implements Lifecycle, LifecycleNotifier
}
}
- protected void onAccessBeforeActivate() throws Exception
+ protected void onAboutToActivate() throws Exception
{
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleListener.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleListener.java
index eaa3863ff6..fc735909e6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleListener.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/lifecycle/LifecycleListener.java
@@ -5,6 +5,8 @@ package org.eclipse.net4j.util.lifecycle;
*/
public interface LifecycleListener
{
+ public void notifyLifecycleAboutToActivate(LifecycleNotifier notifier);
+
public void notifyLifecycleActivated(LifecycleNotifier notifier);
public void notifyLifecycleDeactivating(LifecycleNotifier notifier);

Back to the top