diff options
author | Joe George <joe@zeroc.com> | 2015-12-23 14:48:40 -0500 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2015-12-24 10:01:11 -0500 |
commit | e84da5f580821cae8dab292e19cc1296c07a8ed5 (patch) | |
tree | 1e8783c55c7dccd5adda2b87b47b8a7c118a1147 /java/src | |
parent | Fixes related to EnableSharedFromThis (diff) | |
download | ice-e84da5f580821cae8dab292e19cc1296c07a8ed5.tar.bz2 ice-e84da5f580821cae8dab292e19cc1296c07a8ed5.tar.xz ice-e84da5f580821cae8dab292e19cc1296c07a8ed5.zip |
ICE-6898 - "Delegate" functions for ACM callbacks
- Add delegate local interfaces CloseCallback and HeartbeatCallback and
remove ConnectionCallback.
- Replace setCallback by setCloseCallback and setHeartbeatCallback
Diffstat (limited to 'java/src')
6 files changed, 93 insertions, 102 deletions
diff --git a/java/src/Glacier2/src/main/java/Glacier2/Application.java b/java/src/Glacier2/src/main/java/Glacier2/Application.java index 400b57b28b6..b26028bee01 100644 --- a/java/src/Glacier2/src/main/java/Glacier2/Application.java +++ b/java/src/Glacier2/src/main/java/Glacier2/Application.java @@ -233,15 +233,9 @@ public abstract class Application extends Ice.Application return _adapter; } - private class ConnectionCallbackI implements Ice.ConnectionCallback + private class CloseCallbackI implements Ice.CloseCallback { @Override - public void heartbeat(Ice.Connection con) - { - - } - - @Override public void closed(Ice.Connection con) { sessionDestroyed(); @@ -346,7 +340,7 @@ public abstract class Application extends Ice.Application connection.setACM(new Ice.IntOptional(acmTimeout), null, new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); - connection.setCallback(new ConnectionCallbackI()); + connection.setCloseCallback(new CloseCallbackI()); } _category = _router.getCategoryForClient(); status.value = runWithSession(argHolder.value); diff --git a/java/src/Glacier2/src/main/java/Glacier2/SessionHelper.java b/java/src/Glacier2/src/main/java/Glacier2/SessionHelper.java index 83adf1fc6e1..1d936f45b31 100644 --- a/java/src/Glacier2/src/main/java/Glacier2/SessionHelper.java +++ b/java/src/Glacier2/src/main/java/Glacier2/SessionHelper.java @@ -327,19 +327,14 @@ public class SessionHelper connection.setACM(new Ice.IntOptional(acmTimeout), null, new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); - connection.setCallback(new Ice.ConnectionCallback() - { - @Override - public void heartbeat(Ice.Connection con) - { - } - - @Override - public void closed(Ice.Connection con) - { - destroy(); - } - }); + connection.setCloseCallback(new Ice.CloseCallback() + { + @Override + public void closed(Ice.Connection con) + { + destroy(); + } + }); } _shutdownHook = new Thread("Shutdown hook") diff --git a/java/src/Ice/src/main/java/Ice/CommunicatorI.java b/java/src/Ice/src/main/java/Ice/CommunicatorI.java index de854848e34..18ec854f19d 100644 --- a/java/src/Ice/src/main/java/Ice/CommunicatorI.java +++ b/java/src/Ice/src/main/java/Ice/CommunicatorI.java @@ -122,11 +122,11 @@ public final class CommunicatorI implements Communicator return _instance.objectAdapterFactory().createObjectAdapter(name, router); } - @Override + @Override @SuppressWarnings("deprecation") public void addObjectFactory(ObjectFactory factory, String id) { _instance.servantFactoryManager().add(factory, id); } - @Override + @Override @SuppressWarnings("deprecation") public ObjectFactory findObjectFactory(String id) { return _instance.servantFactoryManager().findObjectFactory(id); } @@ -271,9 +271,9 @@ public final class CommunicatorI implements Communicator // This callback object receives the results of all invocations // of Connection.begin_flushBatchRequests. // - IceInternal.CommunicatorFlushBatch result = new IceInternal.CommunicatorFlushBatch(this, - _instance, - __flushBatchRequests_name, + IceInternal.CommunicatorFlushBatch result = new IceInternal.CommunicatorFlushBatch(this, + _instance, + __flushBatchRequests_name, cb); connectionFactory.flushAsyncBatchRequests(result); @@ -332,7 +332,7 @@ public final class CommunicatorI implements Communicator { return _instance.findAdminFacet(facet); } - + @Override public java.util.Map<String, Ice.Object> findAllAdminFacets() diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java index d33ae1d3c20..b126bf2a858 100644 --- a/java/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java @@ -482,36 +482,39 @@ public final class ConnectionI extends IceInternal.EventHandler } @Override - synchronized public void setCallback(final ConnectionCallback callback) + synchronized public void setCloseCallback(final CloseCallback callback) { - synchronized(this) + if(_state >= StateClosed) { - if(_state >= StateClosed) + if(callback != null) { - if(callback != null) + _threadPool.dispatch(new IceInternal.DispatchWorkItem(this) { - _threadPool.dispatch(new IceInternal.DispatchWorkItem(this) + @Override + public void run() { - @Override - public void run() + try { - try - { - callback.closed(ConnectionI.this); - } - catch(Exception ex) - { - _logger.error("connection callback exception:\n" + ex + '\n' + _desc); - } + callback.closed(ConnectionI.this); } - }); - } - } - else - { - _callback = callback; + catch(Exception ex) + { + _logger.error("connection callback exception:\n" + ex + '\n' + _desc); + } + } + }); } } + else + { + _closeCallback = callback; + } + } + + @Override + synchronized public void setHeartbeatCallback(final HeartbeatCallback callback) + { + _heartbeatCallback = callback; } @Override @@ -1243,7 +1246,8 @@ public final class ConnectionI extends IceInternal.EventHandler // promoting a new leader and unecessary thread creation, especially if // this is called on shutdown). // - if(_startCallback == null && _sendStreams.isEmpty() && _asyncRequests.isEmpty() && _callback == null) + if(_startCallback == null && _sendStreams.isEmpty() && _asyncRequests.isEmpty() && + _closeCallback == null && _heartbeatCallback == null) { finish(close); return; @@ -1378,19 +1382,21 @@ public final class ConnectionI extends IceInternal.EventHandler _readStream.clear(); _readStream.getBuffer().clear(); - if(_callback != null) + if(_closeCallback != null) { try { - _callback.closed(this); + _closeCallback.closed(this); } catch(Exception ex) { _logger.error("connection callback exception:\n" + ex + '\n' + _desc); } - _callback = null; + _closeCallback = null; } + _heartbeatCallback = null; + // // This must be done last as this will cause waitUntilFinished() to // return (and communicator objects such as the timer might be destroyed @@ -2342,7 +2348,7 @@ public final class ConnectionI extends IceInternal.EventHandler IceInternal.ServantManager servantManager; ObjectAdapter adapter; IceInternal.OutgoingAsyncBase outAsync; - ConnectionCallback heartbeatCallback; + HeartbeatCallback heartbeatCallback; int messageDispatchCount; } @@ -2482,9 +2488,9 @@ public final class ConnectionI extends IceInternal.EventHandler case IceInternal.Protocol.validateConnectionMsg: { IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); - if(_callback != null) + if(_heartbeatCallback != null) { - info.heartbeatCallback = _callback; + info.heartbeatCallback = _heartbeatCallback; ++info.messageDispatchCount; } break; @@ -3001,7 +3007,8 @@ public final class ConnectionI extends IceInternal.EventHandler private Ice.ConnectionInfo _info; - private ConnectionCallback _callback; + private CloseCallback _closeCallback; + private HeartbeatCallback _heartbeatCallback; private static Ice.Instrumentation.ConnectionState connectionStateMap[] = { Ice.Instrumentation.ConnectionState.ConnectionStateValidating, // StateNotInitialized diff --git a/java/src/Ice/src/main/java/IceInternal/ValueFactoryManager.java b/java/src/Ice/src/main/java/IceInternal/ValueFactoryManager.java index f685d088b9a..c0bf96148c9 100644 --- a/java/src/Ice/src/main/java/IceInternal/ValueFactoryManager.java +++ b/java/src/Ice/src/main/java/IceInternal/ValueFactoryManager.java @@ -9,6 +9,7 @@ package IceInternal; +@SuppressWarnings("deprecation") public final class ValueFactoryManager { public synchronized void diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java index abbeae1f98c..83120e71740 100644 --- a/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java @@ -224,17 +224,11 @@ public class SessionKeeper null, new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); - _session.ice_getConnection().setCallback( - new Ice.ConnectionCallback() + _session.ice_getConnection().setCloseCallback( + new Ice.CloseCallback() { @Override public void - heartbeat(Ice.Connection con) - { - } - - @Override - public void closed(Ice.Connection con) { try @@ -437,7 +431,7 @@ public class SessionKeeper _adapter = null; } - _session.ice_getConnection().setCallback(null); + _session.ice_getConnection().setCloseCallback(null); if(destroySession) { @@ -1190,16 +1184,16 @@ public class SessionKeeper { Ice.LocatorPrx prx = Ice.LocatorPrxHelper.uncheckedCast( communicator.stringToProxy( - communicator.identityToString(locator.ice_getIdentity()) + + communicator.identityToString(locator.ice_getIdentity()) + ":" + e.toString())); - + if(_directDiscoveryEndpointModel.indexOf(prx) == -1) { _directDiscoveryEndpointModel.addElement(prx); } } - if(_directDiscoveryEndpointModel.size() > 0 && + if(_directDiscoveryEndpointModel.size() > 0 && _directDiscoveryEndpointList.getSelectedIndex() == -1) { _directDiscoveryEndpointList.setSelectedIndex(0); @@ -1231,7 +1225,7 @@ public class SessionKeeper final String intf = properties.getProperty("IceGridAdmin.Discovery.Interface"); String lookupEndpoints = properties.getProperty("IceGridAdmin.Discovery.Lookup"); String address; - if(properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0 && + if(properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0 && properties.getPropertyAsInt("Ice.PreferIPv6Address") <= 0) { address = "239.255.0.1"; @@ -1257,9 +1251,9 @@ public class SessionKeeper try { final LookupPrx lookupPrx = LookupPrxHelper.uncheckedCast( - communicator.stringToProxy("IceLocatorDiscovery/Lookup -d:" + + communicator.stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints).ice_collocationOptimized(false).ice_router(null)); - + new Thread(new Runnable() { @Override @@ -1268,15 +1262,15 @@ public class SessionKeeper synchronized(SessionKeeper.this) { // - // If search is in progress when refresh is hit, cancel the + // If search is in progress when refresh is hit, cancel the // finish task we will schedule a new one with this new // search. - // + // if(_discoveryFinishTask != null) { _discoveryFinishTask.cancel(); } - + if(properties.getProperty("IceGridAdmin.Discovery.Reply.Endpoints").isEmpty()) { StringBuilder s = new StringBuilder(); @@ -1287,7 +1281,7 @@ public class SessionKeeper } properties.setProperty("IceGridAdmin.Discovery.Reply.Endpoints", s.toString()); } - + try { if(_discoveryAdapter == null) @@ -1295,11 +1289,11 @@ public class SessionKeeper _discoveryAdapter = communicator.createObjectAdapter( "IceGridAdmin.Discovery.Reply"); _discoveryAdapter.activate(); - _discoveryReplyPrx = + _discoveryReplyPrx = LookupReplyPrxHelper.uncheckedCast( _discoveryAdapter.addWithUUID(_discoveryLookupReply).ice_datagram()); } - + lookupPrx.findLocator("", _discoveryReplyPrx); } catch(final Ice.LocalException ex) @@ -1318,7 +1312,7 @@ public class SessionKeeper } }); } - + // // We schedule a timer task to destroy the discovery adapter after 2 // seconds, the user doesn't need to wait, discovered proxies are @@ -1360,7 +1354,7 @@ public class SessionKeeper _directInstanceName = new JLabel(); _routedInstanceName = new JLabel(); - + // Connection type panel { FormLayout layout = new FormLayout("pref", "pref"); @@ -1420,7 +1414,7 @@ public class SessionKeeper } } }); - + _directDiscoveryEndpointList.addListSelectionListener(new ListSelectionListener() { @Override @@ -1429,7 +1423,7 @@ public class SessionKeeper validatePanel(); } }); - + ButtonGroup group = new ButtonGroup(); _directDiscoveryDiscoveredEndpoint = new JRadioButton(new AbstractAction("Discovered Endpoints") { @@ -1465,7 +1459,7 @@ public class SessionKeeper builder.append(_discoveryStatus, _discoveryRefresh); discoveryStatus = builder.getPanel(); } - + _directDiscoveryManualEndpoint = new JRadioButton(new AbstractAction("Manual Endpoint") { @Override @@ -1479,7 +1473,7 @@ public class SessionKeeper } }); group.add(_directDiscoveryManualEndpoint); - + { FormLayout layout = new FormLayout("pref:grow", "pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); @@ -2166,7 +2160,7 @@ public class SessionKeeper } break; } - + case DirectMasterStep: { _cardLayout.show(_cardPanel, WizardStep.DirectDiscoveryChooseStep.toString()); @@ -2184,20 +2178,20 @@ public class SessionKeeper { _cardLayout.show(_cardPanel, WizardStep.DirectEndpointStep.toString()); _wizardSteps.push(WizardStep.DirectEndpointStep); - } - else + } + else { Ice.LocatorPrx locator = _directDiscoveryEndpointList.getSelectedValue(); _directInstanceName.setText(locator.ice_getIdentity().category); _directCustomEndpointValue.setText(locator.ice_getEndpoints()[0].toString()); _directCustomEndpoints.setSelected(true); - + _cardLayout.show(_cardPanel, WizardStep.DirectCustomEnpointStep.toString()); _wizardSteps.push(WizardStep.DirectCustomEnpointStep); } break; } - + case DirectEndpointStep: { if(_directDefaultEndpoints.isSelected()) @@ -2237,7 +2231,7 @@ public class SessionKeeper } else { - _cardLayout.show(_cardPanel, + _cardLayout.show(_cardPanel, WizardStep.DirectUsernamePasswordCredentialsStep.toString()); _wizardSteps.push(WizardStep.DirectUsernamePasswordCredentialsStep); } @@ -2256,7 +2250,7 @@ public class SessionKeeper } break; } - + case RoutedDefaultEndpointStep: { if(_routedDefaultEndpointSSL.isSelected()) @@ -2266,7 +2260,7 @@ public class SessionKeeper } else { - _cardLayout.show(_cardPanel, + _cardLayout.show(_cardPanel, WizardStep.RoutedUsernamePasswordCredentialsStep.toString()); _wizardSteps.push(WizardStep.RoutedUsernamePasswordCredentialsStep); } @@ -2285,7 +2279,7 @@ public class SessionKeeper } break; } - + case DirectCustomEnpointStep: { try @@ -2305,7 +2299,7 @@ public class SessionKeeper } else { - _cardLayout.show(_cardPanel, + _cardLayout.show(_cardPanel, WizardStep.DirectUsernamePasswordCredentialsStep.toString()); _wizardSteps.push(WizardStep.DirectUsernamePasswordCredentialsStep); } @@ -2362,7 +2356,7 @@ public class SessionKeeper } else { - _cardLayout.show(_cardPanel, + _cardLayout.show(_cardPanel, WizardStep.RoutedUsernamePasswordCredentialsStep.toString()); _wizardSteps.push(WizardStep.RoutedUsernamePasswordCredentialsStep); } @@ -2400,7 +2394,7 @@ public class SessionKeeper } break; } - + case X509CertificateStep: { if(_x509CertificateYesButton.isSelected()) @@ -2461,7 +2455,7 @@ public class SessionKeeper } break; } - + default: { break; @@ -2691,7 +2685,7 @@ public class SessionKeeper { if(_directDiscoveryManualEndpoint.isSelected()) { - _directDiscoveryManualEndpoint.requestFocusInWindow(); + _directDiscoveryManualEndpoint.requestFocusInWindow(); } else { @@ -2699,7 +2693,7 @@ public class SessionKeeper } break; } - + case DirectEndpointStep: { if(_directDefaultEndpoints.isSelected()) @@ -2791,7 +2785,7 @@ public class SessionKeeper _routedUsername.requestFocusInWindow(); break; } - + default: { break; @@ -2923,7 +2917,7 @@ public class SessionKeeper validated = _routedUsername.getText() != null && _routedUsername.getText().length() > 0; break; } - + case DirectMasterStep: case RoutedEndpointStep: case DirectEndpointStep: @@ -3242,7 +3236,7 @@ public class SessionKeeper private JRadioButton _directDiscoveryDiscoveredEndpoint; private JLabel _discoveryStatus; private JButton _discoveryRefresh; - + private java.util.TimerTask _discoveryFinishTask; private Ice.ObjectAdapter _discoveryAdapter; private LookupReplyPrx _discoveryReplyPrx; @@ -5594,7 +5588,7 @@ public class SessionKeeper private static AuthDialog _authDialog; private final Coordinator _coordinator; - + private Session _session; private boolean _connectedToMaster = false; private String _replicaName = ""; |