Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocol.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceMeasurementWrapper.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/CommitManager.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java130
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java47
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionCancelIndication.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java256
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase1Indication.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase2Indication.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase3Indication.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java92
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionProtocol.java24
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOUserTransaction.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOXATransaction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCommitContext.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java84
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java19
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionStrategy.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java17
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java183
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionCancelRequest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase1Request.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase2Request.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase3Request.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java106
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPChannel.java2
-rw-r--r--plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPConnector.java53
-rw-r--r--plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPAcceptor.java3
-rw-r--r--plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java5
-rw-r--r--plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/Net4jTransportServlet.java4
-rw-r--r--plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSCreateDestinationRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java2
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java2
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java2
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java30
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java68
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java2
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java23
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java3
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java18
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java47
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java3
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java196
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla241463_Test.java22
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java37
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java19
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java24
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java3
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerItemProvider.java3
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java20
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningActionDelegate.java20
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java126
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java119
-rw-r--r--plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/DelegatingMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/IllegalMonitorNestingException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorAlreadyBegunException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorCanceledException.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalRemoteException.java)15
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorNotBegunException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorTest.java (renamed from plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitorUtil.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/MonitoredJob.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/OMMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/OMMonitorHandler.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/OMSubMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/SynchonizedSubProgressMonitor.java119
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/TotalWorkExceededException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/impl/EclipseMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/impl/LegacyMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/impl/MON.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/impl/Monitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/monitor/impl/NullMonitor.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java)0
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IErrorHandler.java20
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ResultSynchronizer.java7
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/EclipseMonitor.java67
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IMonitor.java34
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/Monitor.java80
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java7
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NestedMonitor.java58
-rw-r--r--plugins/org.eclipse.net4j/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java266
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java778
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java2
-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.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java59
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferState.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBuffer.java29
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelException.java42
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelOutputStream.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannel.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/IChannelMultiplexer.java29
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java32
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java71
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java190
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java84
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledIndication.java41
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledRequest.java43
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressIndication.java43
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressRequest.java51
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java39
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java16
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java38
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java47
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java115
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java254
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java199
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java48
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java132
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalReactor.java31
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/acceptor/Acceptor.java)6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/channel/Channel.java)54
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java360
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ClientProtocolFactory.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ClientProtocolFactory.java)3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java402
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannel.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/Protocol.java)104
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ServerProtocolFactory.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ServerProtocolFactory.java)3
246 files changed, 4240 insertions, 2350 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocol.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocol.java
index b7a9a49cc5..151a3b08b1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocol.java
@@ -10,13 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo.common;
-import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.signal.ISignalProtocol;
/**
* @author Eike Stepper
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface CDOProtocol<INFRA_STRUCTURE> extends IProtocol<INFRA_STRUCTURE>
+public interface CDOProtocol<INFRA_STRUCTURE> extends ISignalProtocol<INFRA_STRUCTURE>
{
public CDOProtocolSession getSession();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
index 174940d1a4..9d438df9c7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.List;
import java.util.Set;
@@ -54,12 +55,12 @@ public interface IClassMapping
/**
* @since 2.0
*/
- public void writeRevision(IDBStoreAccessor accessor, CDORevision revision);
+ public void writeRevision(IDBStoreAccessor accessor, CDORevision revision, IMonitor monitor);
/**
* @since 2.0
*/
- public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised);
+ public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised, IMonitor monitor);
/**
* @since 2.0
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java
index 08baa72678..6b1ffe79bc 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.emf.cdo.server.internal.db.jdbc.AbstractJDBCDelegate;
import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -82,7 +83,7 @@ public interface IJDBCDelegate
/**
* Do a commit on the JDBC connection.
*/
- public void commit();
+ public void commit(IMonitor monitor);
/**
* Do a rollback on the JDBC connection.
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index d09ffbf406..49168e084c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -30,6 +30,7 @@ import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.ArrayList;
import java.util.HashSet;
@@ -318,36 +319,61 @@ public abstract class ClassMapping implements IClassMapping
return cdoFeature;
}
- public void writeRevision(IDBStoreAccessor accessor, CDORevision revision)
+ public void writeRevision(IDBStoreAccessor accessor, CDORevision revision, IMonitor monitor)
{
- if (revision.getVersion() > 1 && hasFullRevisionInfo())
+ try
{
- writeRevisedRow(accessor, (InternalCDORevision)revision);
- }
+ // TODO Better monitoring
+ monitor.begin(10);
+ if (revision.getVersion() > 1 && hasFullRevisionInfo())
+ {
+ writeRevisedRow(accessor, (InternalCDORevision)revision);
+ }
- if (revision.isResourceFolder() || revision.isResource())
- {
- checkDuplicateResources(accessor, revision);
- }
+ monitor.worked(1);
- // Write attribute table always (even without modeled attributes!)
- writeAttributes(accessor, (InternalCDORevision)revision);
+ if (revision.isResourceFolder() || revision.isResource())
+ {
+ checkDuplicateResources(accessor, revision);
+ }
- // Write reference tables only if they exist
- if (referenceMappings != null)
+ monitor.worked(1);
+
+ // Write attribute table always (even without modeled attributes!)
+ writeAttributes(accessor, (InternalCDORevision)revision);
+
+ monitor.worked(1);
+
+ // Write reference tables only if they exist
+ if (referenceMappings != null)
+ {
+ writeReferences(accessor, (InternalCDORevision)revision);
+ }
+
+ monitor.worked(7);
+ }
+ finally
{
- writeReferences(accessor, (InternalCDORevision)revision);
+ monitor.done();
}
}
protected abstract void checkDuplicateResources(IDBStoreAccessor accessor, CDORevision revision)
throws IllegalStateException;
- public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised)
+ public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised, IMonitor monitor)
{
- if (hasFullRevisionInfo())
+ try
+ {
+ monitor.begin(1);
+ if (hasFullRevisionInfo())
+ {
+ writeRevisedRow(accessor, id, revised);
+ }
+ }
+ finally
{
- writeRevisedRow(accessor, id, revised);
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index e62ca28e1c..4d0be9ff92 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -48,6 +48,7 @@ import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBRowHandler;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.collection.CloseableIterator;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.sql.PreparedStatement;
@@ -341,9 +342,9 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
{
}
- public final void commit()
+ public final void commit(IMonitor monitor)
{
- jdbcDelegate.commit();
+ jdbcDelegate.commit(monitor);
}
@Override
@@ -353,9 +354,9 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
}
@Override
- protected final void writePackages(CDOPackage[] cdoPackages)
+ protected final void writePackages(CDOPackage[] cdoPackages, IMonitor monitor)
{
- new PackageWriter(cdoPackages)
+ new PackageWriter(cdoPackages, monitor)
{
@Override
protected void writePackage(InternalCDOPackage cdoPackage)
@@ -463,21 +464,29 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
}
@Override
- protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created)
+ protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created, IMonitor monitor)
{
throw new UnsupportedOperationException();
}
@Override
- protected void writeRevisions(CDORevision[] revisions)
+ protected void writeRevisions(CDORevision[] revisions, IMonitor monitor)
{
- for (CDORevision revision : revisions)
+ try
{
- writeRevision(revision);
+ monitor.begin(revisions.length);
+ for (CDORevision revision : revisions)
+ {
+ writeRevision(revision, monitor.fork(1));
+ }
+ }
+ finally
+ {
+ monitor.done();
}
}
- protected void writeRevision(CDORevision revision)
+ protected void writeRevision(CDORevision revision, IMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -486,23 +495,30 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
CDOClass cdoClass = revision.getCDOClass();
IClassMapping mapping = getStore().getMappingStrategy().getClassMapping(cdoClass);
- mapping.writeRevision(this, revision);
+ mapping.writeRevision(this, revision, monitor);
}
@Override
- protected void detachObjects(CDOID[] detachedObjects, long revised)
+ protected void detachObjects(CDOID[] detachedObjects, long revised, IMonitor monitor)
{
- for (CDOID id : detachedObjects)
+ try
+ {
+ monitor.begin(detachedObjects.length);
+ for (CDOID id : detachedObjects)
+ {
+ detachObject(id, revised, monitor.fork(1));
+ }
+ }
+ finally
{
- detachObject(id, revised);
+ monitor.done();
}
}
/**
- * @param revised
* @since 2.0
*/
- protected void detachObject(CDOID id, long revised)
+ protected void detachObject(CDOID id, long revised, IMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -511,7 +527,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
CDOClass cdoClass = getObjectType(id);
IClassMapping mapping = getStore().getMappingStrategy().getClassMapping(cdoClass);
- mapping.detachObject(this, id, revised);
+ mapping.detachObject(this, id, revised, monitor);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
index f8bb6f75fb..4ce56be454 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
/**
* @author Eike Stepper
@@ -38,14 +39,25 @@ public class HorizontalClassMapping extends ClassMapping
}
@Override
- public void writeRevision(IDBStoreAccessor accessor, CDORevision revision)
+ public void writeRevision(IDBStoreAccessor accessor, CDORevision revision, IMonitor monitor)
{
- super.writeRevision(accessor, revision);
- if (revision.getVersion() == 1)
+ try
{
- CDOID id = revision.getID();
- CDOClass type = revision.getCDOClass();
- getMappingStrategy().getObjectTypeCache().putObjectType(accessor, id, type);
+ monitor.begin(5);
+ super.writeRevision(accessor, revision, monitor.fork(4));
+ if (revision.getVersion() == 1)
+ {
+ CDOID id = revision.getID();
+ CDOClass type = revision.getCDOClass();
+ getMappingStrategy().getObjectTypeCache().putObjectType(accessor, id, type);
+ }
+
+ // TODO Better monitoring
+ monitor.worked(1);
+ }
+ finally
+ {
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
index e16e620af9..35e19fe404 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.Collections;
import java.util.List;
@@ -88,11 +89,11 @@ public class NoClassMapping implements IClassMapping
return null;
}
- public void writeRevision(IDBStoreAccessor accessor, CDORevision revision)
+ public void writeRevision(IDBStoreAccessor accessor, CDORevision revision, IMonitor monitor)
{
}
- public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised)
+ public void detachObject(IDBStoreAccessor accessor, CDOID id, long revised, IMonitor monitor)
{
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java
index 92fa3ef85c..1fe58010a9 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java
@@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+
import java.util.ArrayList;
import java.util.List;
@@ -60,15 +62,27 @@ public class VerticalClassMapping extends ClassMapping
}
@Override
- public void writeRevision(IDBStoreAccessor accessor, CDORevision revision)
+ public void writeRevision(IDBStoreAccessor accessor, CDORevision revision, IMonitor monitor)
{
- super.writeRevision(accessor, revision);
if (superMappings != null)
{
- for (IClassMapping superMapping : superMappings)
+ try
{
- superMapping.writeRevision(accessor, revision);
+ monitor.begin(1 + superMappings.size());
+ super.writeRevision(accessor, revision, monitor.fork(1));
+ for (IClassMapping superMapping : superMappings)
+ {
+ superMapping.writeRevision(accessor, revision, monitor.fork(1));
+ }
}
+ finally
+ {
+ monitor.done();
+ }
+ }
+ else
+ {
+ super.writeRevision(accessor, revision, monitor);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java
index 0e8130fd74..dd85aae797 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java
@@ -26,6 +26,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.util.collection.MoveableList;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -57,7 +58,7 @@ public abstract class AbstractJDBCDelegate implements IJDBCDelegate
return connection;
}
- public final void commit()
+ public final void commit(IMonitor monitor)
{
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceMeasurementWrapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceMeasurementWrapper.java
index c785eb02a3..ca926a90da 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceMeasurementWrapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceMeasurementWrapper.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.server.db.IReferenceMapping;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.sql.Connection;
@@ -47,9 +48,9 @@ public class JDBCPerformanceMeasurementWrapper implements IJDBCDelegate
this.delegate = delegate;
}
- public void commit()
+ public void commit(IMonitor monitor)
{
- delegate.commit();
+ delegate.commit(monitor);
}
public Connection getConnection()
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index c4cf79d6ff..6ce25cb5df 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -37,6 +37,7 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.CloseableIterator;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.hibernate.Criteria;
@@ -337,20 +338,20 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
/**
* Is handled through {@link #endHibernateSession()}.
*/
- public void commit()
+ public void commit(IMonitor monitor)
{
commitRollbackHibernateSession();
HibernateThreadContext.setCommitContext(null);
}
@Override
- public void write(CommitContext context)
+ public void write(CommitContext context, IMonitor monitor)
{
List<InternalCDORevision> adjustRevisions = new ArrayList<InternalCDORevision>();
HibernateThreadContext.setCommitContext(context);
if (context.getNewPackages().length > 0)
{
- writePackages(context.getNewPackages());
+ writePackages(context.getNewPackages(), monitor);
}
try
{
@@ -450,7 +451,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
}
@Override
- protected void detachObjects(CDOID[] detachedObjects, long revised)
+ protected void detachObjects(CDOID[] detachedObjects, long revised, IMonitor monitor)
{
// TODO: implement HibernateStoreAccessor.detachObjects(detachedObjects)
throw new UnsupportedOperationException();
@@ -465,7 +466,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
}
@Override
- protected void writePackages(CDOPackage[] cdoPackages)
+ protected void writePackages(CDOPackage[] cdoPackages, IMonitor monitor)
{
if (cdoPackages != null && cdoPackages.length != 0)
{
@@ -477,13 +478,13 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
}
@Override
- protected void writeRevisions(CDORevision[] revisions)
+ protected void writeRevisions(CDORevision[] revisions, IMonitor monitor)
{
// Don't do anything it is done at commit
}
@Override
- protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created)
+ protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created, IMonitor monitor)
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/CommitManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/CommitManager.java
index 0c06e1deb9..c9749c65e8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/CommitManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/CommitManager.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.server.IRepositoryElement;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -37,7 +38,7 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
private transient ExecutorService executors;
@ExcludeFromDump
- private transient Map<Transaction, TransactionCommitContextEntry> commitContextMap = new ConcurrentHashMap<Transaction, TransactionCommitContextEntry>();
+ private transient Map<Transaction, TransactionCommitContextEntry> contextEntries = new ConcurrentHashMap<Transaction, TransactionCommitContextEntry>();
public CommitManager()
{
@@ -71,16 +72,15 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
/**
* Create a future to execute commitContext in a different thread.
*/
- public void preCommit(InternalCommitContext commitContext)
+ public void preCommit(InternalCommitContext commitContext, IMonitor monitor)
{
- TransactionCommitContextEntry contextEntry = new TransactionCommitContextEntry();
+ TransactionCommitContextEntry contextEntry = new TransactionCommitContextEntry(monitor);
contextEntry.setContext(commitContext);
Future<Object> future = getExecutors().submit(contextEntry.createCallable());
-
contextEntry.setFuture(future);
- commitContextMap.put(commitContext.getTransaction(), contextEntry);
+ contextEntries.put(commitContext.getTransaction(), contextEntry);
}
/**
@@ -88,12 +88,12 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
*/
public void remove(InternalCommitContext commitContext)
{
- commitContextMap.remove(commitContext.getTransaction());
+ contextEntries.remove(commitContext.getTransaction());
}
public void rollback(InternalCommitContext commitContext)
{
- TransactionCommitContextEntry contextEntry = commitContextMap.get(commitContext.getTransaction());
+ TransactionCommitContextEntry contextEntry = contextEntries.get(commitContext.getTransaction());
if (contextEntry != null)
{
contextEntry.getFuture().cancel(true);
@@ -106,13 +106,13 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
*/
public void waitForTermination(Transaction transaction) throws InterruptedException, ExecutionException
{
- TransactionCommitContextEntry contextEntry = commitContextMap.get(transaction);
+ TransactionCommitContextEntry contextEntry = contextEntries.get(transaction);
contextEntry.getFuture().get();
}
public InternalCommitContext get(Transaction transaction)
{
- TransactionCommitContextEntry contextEntry = commitContextMap.get(transaction);
+ TransactionCommitContextEntry contextEntry = contextEntries.get(transaction);
if (contextEntry != null)
{
return contextEntry.getContext();
@@ -130,18 +130,20 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
private Future<Object> future;
- public TransactionCommitContextEntry()
+ private IMonitor monitor;
+
+ public TransactionCommitContextEntry(IMonitor monitor)
{
+ this.monitor = monitor;
}
public Callable<Object> createCallable()
{
return new Callable<Object>()
{
-
public Object call() throws Exception
{
- context.write();
+ context.write(monitor);
return null;
}
};
@@ -166,6 +168,5 @@ public class CommitManager extends Lifecycle implements IRepositoryElement
{
this.future = future;
}
-
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index b29c8048d6..0a655438f9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -29,6 +29,7 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.CloseableIterator;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.ArrayList;
import java.util.Collection;
@@ -141,18 +142,18 @@ public class MEMStoreAccessor extends StoreAccessor
/**
* @since 2.0
*/
- public void commit()
+ public void commit(IMonitor monitor)
{
// Do nothing
}
@Override
- public void write(CommitContext context)
+ public void write(CommitContext context, IMonitor monitor)
{
MEMStore store = getStore();
synchronized (store)
{
- super.write(context);
+ super.write(context, monitor);
}
}
@@ -170,13 +171,13 @@ public class MEMStoreAccessor extends StoreAccessor
}
@Override
- protected void writePackages(CDOPackage[] cdoPackages)
+ protected void writePackages(CDOPackage[] cdoPackages, IMonitor monitor)
{
// Do nothing
}
@Override
- protected void writeRevisions(CDORevision[] revisions)
+ protected void writeRevisions(CDORevision[] revisions, IMonitor monitor)
{
for (CDORevision revision : revisions)
{
@@ -190,8 +191,11 @@ public class MEMStoreAccessor extends StoreAccessor
getStore().addRevision(revision);
}
+ /**
+ * @since 2.0
+ */
@Override
- protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created)
+ protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created, IMonitor monitor)
{
for (CDORevisionDelta revisionDelta : revisionDeltas)
{
@@ -212,7 +216,7 @@ public class MEMStoreAccessor extends StoreAccessor
}
@Override
- protected void detachObjects(CDOID[] detachedObjects, long revised)
+ protected void detachObjects(CDOID[] detachedObjects, long revised, IMonitor monitor)
{
for (CDOID id : detachedObjects)
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index 411a6904e9..9e2f62330d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -270,7 +270,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
IChannel channel = protocol.getChannel();
if (LifecycleUtil.isActive(channel))
{
- new CommitNotificationRequest(channel, timeStamp, dirtyIDs, detachedObjects, newDeltas).send();
+ new CommitNotificationRequest(channel, timeStamp, dirtyIDs, detachedObjects, newDeltas).sendAsync();
}
else
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
index 51725a143f..ab1995278d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.util.ArrayList;
@@ -125,7 +126,7 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
/**
* @since 2.0
*/
- public void write(CommitContext context)
+ public void write(CommitContext context, IMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -135,22 +136,22 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
commitContexts.add(context);
long timeStamp = context.getTimeStamp();
- writePackages(context.getNewPackages());
- addIDMappings(context);
+ writePackages(context.getNewPackages(), monitor.fork(1));
+ addIDMappings(context, monitor.fork(1));
context.applyIDMappings();
- writeRevisions(context.getNewObjects());
+ writeRevisions(context.getNewObjects(), monitor.fork(1));
if (store.getRepository().isSupportingRevisionDeltas())
{
- writeRevisionDeltas(context.getDirtyObjectDeltas(), timeStamp);
+ writeRevisionDeltas(context.getDirtyObjectDeltas(), timeStamp, monitor.fork(1));
}
else
{
- writeRevisions(context.getDirtyObjects());
+ writeRevisions(context.getDirtyObjects(), monitor.fork(1));
}
- detachObjects(context.getDetachedObjects(), timeStamp - 1);
+ detachObjects(context.getDetachedObjects(), timeStamp - 1, monitor.fork(1));
}
/**
@@ -180,38 +181,54 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
/**
* @since 2.0
*/
- protected void addIDMappings(IStoreAccessor.CommitContext context)
+ protected void addIDMappings(IStoreAccessor.CommitContext context, IMonitor monitor)
{
- if (store instanceof LongIDStore)
+ try
{
- LongIDStore longIDStore = (LongIDStore)getStore();
- for (CDORevision revision : context.getNewObjects())
+ if (store instanceof LongIDStore)
{
- CDOIDTemp oldID = (CDOIDTemp)revision.getID();
- CDOID newID = longIDStore.getNextCDOID();
- if (CDOIDUtil.isNull(newID) || newID.isTemporary())
+ LongIDStore longIDStore = (LongIDStore)getStore();
+ CDORevision[] newObjects = context.getNewObjects();
+ monitor.begin(newObjects.length);
+ for (CDORevision revision : newObjects)
{
- throw new IllegalStateException("newID=" + newID);
+ CDOIDTemp oldID = (CDOIDTemp)revision.getID();
+ CDOID newID = longIDStore.getNextCDOID();
+ if (CDOIDUtil.isNull(newID) || newID.isTemporary())
+ {
+ throw new IllegalStateException("newID=" + newID);
+ }
+
+ context.addIDMapping(oldID, newID);
+ monitor.worked(1);
}
-
- context.addIDMapping(oldID, newID);
}
}
+ finally
+ {
+ monitor.done();
+ }
}
- protected abstract void writePackages(CDOPackage[] cdoPackages);
+ /**
+ * @since 2.0
+ */
+ protected abstract void writePackages(CDOPackage[] cdoPackages, IMonitor monitor);
- protected abstract void writeRevisions(CDORevision[] revisions);
+ /**
+ * @since 2.0
+ */
+ protected abstract void writeRevisions(CDORevision[] revisions, IMonitor monitor);
/**
* @since 2.0
*/
- protected abstract void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created);
+ protected abstract void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas, long created, IMonitor monitor);
/**
* @since 2.0
*/
- protected abstract void detachObjects(CDOID[] detachedObjects, long revised);
+ protected abstract void detachObjects(CDOID[] detachedObjects, long revised, IMonitor monitor);
/**
* @since 2.0
@@ -243,9 +260,12 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
{
private CDOPackage[] cdoPackages;
- public PackageWriter(CDOPackage[] cdoPackages)
+ private IMonitor monitor;
+
+ public PackageWriter(CDOPackage[] cdoPackages, IMonitor monitor)
{
this.cdoPackages = cdoPackages;
+ this.monitor = monitor;
}
public CDOPackage[] getCDOPackages()
@@ -253,34 +273,74 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
return cdoPackages;
}
+ public IMonitor getMonitor()
+ {
+ return monitor;
+ }
+
public void run()
{
- for (CDOPackage cdoPackage : cdoPackages)
+ try
{
- runPackage(cdoPackage);
+ monitor.begin(cdoPackages.length);
+ for (CDOPackage cdoPackage : cdoPackages)
+ {
+ runPackage(cdoPackage, monitor.fork(1));
+ }
+ }
+ finally
+ {
+ monitor.done();
}
}
- protected void runPackage(CDOPackage cdoPackage)
+ protected void runPackage(CDOPackage cdoPackage, IMonitor monitor)
{
- writePackage((InternalCDOPackage)cdoPackage);
- for (CDOClass cdoClass : cdoPackage.getClasses())
+ try
+ {
+ CDOClass[] classes = cdoPackage.getClasses();
+ monitor.begin(1 + cdoPackages.length);
+
+ writePackage((InternalCDOPackage)cdoPackage);
+ monitor.worked(1);
+
+ for (CDOClass cdoClass : classes)
+ {
+ runClass((InternalCDOClass)cdoClass, monitor.fork(1));
+ }
+ }
+ finally
{
- runClass((InternalCDOClass)cdoClass);
+ monitor.done();
}
}
- protected void runClass(InternalCDOClass cdoClass)
+ protected void runClass(InternalCDOClass cdoClass, IMonitor signalMonitor)
{
- writeClass(cdoClass);
- for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
+ try
{
- writeSuperType(cdoClass, superType);
- }
+ List<CDOClassProxy> superTypeProxies = cdoClass.getSuperTypeProxies();
+ CDOFeature[] features = cdoClass.getFeatures();
+ monitor.begin(1 + superTypeProxies.size() + features.length);
- for (CDOFeature feature : cdoClass.getFeatures())
+ writeClass(cdoClass);
+ monitor.worked(1);
+
+ for (CDOClassProxy superType : superTypeProxies)
+ {
+ writeSuperType(cdoClass, superType);
+ monitor.worked(1);
+ }
+
+ for (CDOFeature feature : features)
+ {
+ writeFeature((InternalCDOFeature)feature);
+ monitor.worked(1);
+ }
+ }
+ finally
{
- writeFeature((InternalCDOFeature)feature);
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
index 86be82671a..d0cde0d5df 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
@@ -22,6 +22,8 @@ import org.eclipse.emf.cdo.internal.server.TransactionCommitContextImpl.Transact
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+
import java.text.MessageFormat;
import java.util.List;
@@ -100,9 +102,9 @@ public class Transaction extends View implements ITransaction
public void preCommit();
- public void write();
+ public void write(IMonitor monitor);
- public void commit();
+ public void commit(IMonitor monitor);
public void postCommit(boolean success);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
index 0227cb3a2a..9b47388bce 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
@@ -36,6 +36,7 @@ import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.concurrent.RWLockManager;
import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.util.ArrayList;
@@ -222,12 +223,14 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
return autoReleaseLocksEnabled;
}
- public void commit()
+ public void commit(IMonitor monitor)
{
+ monitor.begin(5);
+
try
{
- accessor.commit();
- updateInfraStructure();
+ accessor.commit(monitor.fork(4));
+ updateInfraStructure(monitor.fork(1));
}
catch (RuntimeException ex)
{
@@ -237,13 +240,19 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
{
handleException(ex);
}
+ finally
+ {
+ monitor.done();
+ }
}
/**
* @since 2.0
*/
- public void write()
+ public void write(IMonitor monitor)
{
+ monitor.begin(10);
+
try
{
// Could throw an exception
@@ -251,15 +260,23 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
dirtyObjects = new CDORevision[dirtyObjectDeltas.length];
adjustMetaRanges();
+ monitor.worked(1);
+
adjustTimeStamps();
+ monitor.worked(1);
Repository repository = (Repository)transaction.getRepository();
computeDirtyObjects(!repository.isSupportingRevisionDeltas());
lockObjects();
+ monitor.worked(1);
repository.notifyWriteAccessHandlers(transaction, this);
+ monitor.worked(1);
+
detachObjects();
- accessor.write(this);
+ monitor.worked(1);
+
+ accessor.write(this, monitor.fork(5));
}
catch (RuntimeException ex)
{
@@ -269,9 +286,9 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
{
handleException(ex);
}
- catch (Error ex)
+ finally
{
- handleException(ex);
+ monitor.done();
}
}
@@ -455,13 +472,21 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
}
}
- private void updateInfraStructure()
+ private void updateInfraStructure(IMonitor monitor)
{
+ monitor.begin(4);
+
try
{
addNewPackages();
+ monitor.worked(1);
+
addRevisions(newObjects);
+ monitor.worked(1);
+
addRevisions(dirtyObjects);
+ monitor.worked(1);
+
revisedDetachObjects();
unlockObjects();
@@ -469,12 +494,18 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
{
((Repository)transaction.getRepository()).getLockManager().unlock(transaction);
}
+
+ monitor.worked(1);
}
catch (RuntimeException ex)
{
// TODO Rethink this case
OM.LOG.error("FATAL: Memory infrastructure corrupted after successful commit operation of the store");
}
+ finally
+ {
+ monitor.done();
+ }
}
private void addNewPackages()
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
index 18b367155d..4f17fef60b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java
@@ -3,9 +3,10 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.server.IRepositoryProvider;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionCancelIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionCancelIndication.java
index 53e5e14df6..bf70ba1921 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionCancelIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionCancelIndication.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.common.CDODataInput;
import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
-import java.io.IOException;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
/**
* @author Simon McDuff
@@ -27,13 +27,13 @@ public class CommitTransactionCancelIndication extends CommitTransactionIndicati
}
@Override
- protected void indicating(CDODataInput in) throws IOException
+ protected void indicating(CDODataInput in, IMonitor monitor) throws Exception
{
indicationTransaction(in);
}
@Override
- protected void responding(CDODataOutput out) throws IOException
+ protected void responding(CDODataOutput out, IMonitor monitor) throws Exception
{
String exceptionMessage = null;
try
@@ -57,7 +57,7 @@ public class CommitTransactionCancelIndication extends CommitTransactionIndicati
}
@Override
- protected void indicationTransaction(CDODataInput in) throws IOException
+ protected void indicationTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index 55046fd7c2..0af5140cb3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -17,18 +17,37 @@ import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.model.CDOPackage;
+import org.eclipse.emf.cdo.common.model.CDOPackageManager;
+import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.internal.common.CDODataInputImpl;
+import org.eclipse.emf.cdo.internal.common.CDODataOutputImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl;
+import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.internal.server.Session;
+import org.eclipse.emf.cdo.internal.server.SessionManager;
import org.eclipse.emf.cdo.internal.server.Transaction;
import org.eclipse.emf.cdo.internal.server.Transaction.InternalCommitContext;
import org.eclipse.emf.cdo.internal.server.TransactionCommitContextImpl.TransactionPackageManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
import org.eclipse.net4j.util.WrappedException;
+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.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -39,13 +58,15 @@ import java.util.Map.Entry;
/**
* @author Eike Stepper
*/
-public class CommitTransactionIndication extends CDOServerIndication
+public class CommitTransactionIndication extends IndicationWithMonitoring
{
private static final ContextTracer PROTOCOL_TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
CommitTransactionIndication.class);
protected InternalCommitContext commitContext;
+ private int halfWork;
+
public CommitTransactionIndication(CDOServerProtocol protocol)
{
super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION);
@@ -57,18 +78,130 @@ public class CommitTransactionIndication extends CDOServerIndication
}
@Override
+ public CDOServerProtocol getProtocol()
+ {
+ return (CDOServerProtocol)super.getProtocol();
+ }
+
+ protected Session getSession()
+ {
+ return getProtocol().getSession();
+ }
+
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return getSession();
+ }
+
+ protected CDOIDProvider getIDProvider()
+ {
+ return getSession();
+ }
+
+ protected CDOIDObjectFactory getIDFactory()
+ {
+ return getStore().getCDOIDObjectFactory();
+ }
+
+ protected SessionManager getSessionManager()
+ {
+ return getSession().getSessionManager();
+ }
+
+ protected Repository getRepository()
+ {
+ Repository repository = (Repository)getSessionManager().getRepository();
+ if (!repository.isActive())
+ {
+ throw new IllegalStateException("Repository has been deactivated");
+ }
+
+ return repository;
+ }
+
+ protected RevisionManager getRevisionManager()
+ {
+ return getRepository().getRevisionManager();
+ }
+
protected TransactionPackageManager getPackageManager()
{
return commitContext.getPackageManager();
}
+ protected IStore getStore()
+ {
+ IStore store = getRepository().getStore();
+ if (!LifecycleUtil.isActive(store))
+ {
+ throw new IllegalStateException("Store has been deactivated");
+ }
+
+ return store;
+ }
+
@Override
- protected void indicating(CDODataInput in) throws IOException
+ protected final void indicating(ExtendedDataInputStream in, IMonitor monitor) throws Exception
+ {
+ indicating(new CDODataInputImpl(in)
+ {
+ @Override
+ protected CDORevisionResolver getRevisionResolver()
+ {
+ return CommitTransactionIndication.this.getRevisionManager();
+ }
+
+ @Override
+ protected CDOPackageManager getPackageManager()
+ {
+ return CommitTransactionIndication.this.getPackageManager();
+ }
+
+ @Override
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return CommitTransactionIndication.this.getPackageURICompressor();
+ }
+
+ @Override
+ protected CDOIDObjectFactory getIDFactory()
+ {
+ return CommitTransactionIndication.this.getIDFactory();
+ }
+
+ @Override
+ protected CDOListFactory getListFactory()
+ {
+ return CDOListImpl.FACTORY;
+ }
+ }, monitor);
+ }
+
+ @Override
+ protected final void responding(ExtendedDataOutputStream out, IMonitor monitor) throws Exception
+ {
+ responding(new CDODataOutputImpl(out)
+ {
+ @Override
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return CommitTransactionIndication.this.getPackageURICompressor();
+ }
+
+ public CDOIDProvider getIDProvider()
+ {
+ return CommitTransactionIndication.this.getIDProvider();
+ }
+ }, monitor);
+ }
+
+ protected void indicating(CDODataInput in, IMonitor monitor) throws Exception
{
try
{
- indicatingCommit(in);
- indicatingCommit();
+ monitor.begin(2);
+ indicatingCommit(in, monitor.fork(1));
+ indicatingCommit(monitor.fork(1));
}
catch (IOException ex)
{
@@ -79,10 +212,13 @@ public class CommitTransactionIndication extends CDOServerIndication
OM.LOG.error(ex);
throw WrappedException.wrap(ex);
}
+ finally
+ {
+ monitor.done();
+ }
}
- @Override
- protected void responding(CDODataOutput out) throws IOException
+ protected void responding(CDODataOutput out, IMonitor monitor) throws Exception
{
boolean success = false;
@@ -102,13 +238,13 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- protected void indicationTransaction(CDODataInput in) throws IOException
+ protected void indicationTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = getTransaction(viewID).createCommitContext();
}
- protected void indicatingCommit(CDODataInput in) throws IOException
+ protected void indicatingCommit(CDODataInput in, IMonitor monitor) throws Exception
{
// Create transaction context
indicationTransaction(in);
@@ -129,57 +265,83 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL_TRACER.format("Reading {0} new packages", newPackages.length);
}
- for (int i = 0; i < newPackages.length; i++)
- {
- InternalCDOPackage newPackage = (InternalCDOPackage)in.readCDOPackage();
- newPackage.setEcore(in.readString());
- newPackages[i] = newPackage;
- packageManager.addPackage(newPackage);
- }
+ halfWork = newPackages.length + newObjects.length + dirtyObjectDeltas.length + detachedObjects.length;
+ monitor.begin(2 * halfWork);
- // New objects
- if (PROTOCOL_TRACER.isEnabled())
+ try
{
- PROTOCOL_TRACER.format("Reading {0} new objects", newObjects.length);
- }
+ for (int i = 0; i < newPackages.length; i++)
+ {
+ InternalCDOPackage newPackage = (InternalCDOPackage)in.readCDOPackage();
+ newPackage.setEcore(in.readString());
+ newPackages[i] = newPackage;
+ packageManager.addPackage(newPackage);
+ monitor.worked(1);
+ }
- for (int i = 0; i < newObjects.length; i++)
- {
- newObjects[i] = in.readCDORevision();
- }
+ // New objects
+ if (PROTOCOL_TRACER.isEnabled())
+ {
+ PROTOCOL_TRACER.format("Reading {0} new objects", newObjects.length);
+ }
- // Dirty objects
- if (PROTOCOL_TRACER.isEnabled())
- {
- PROTOCOL_TRACER.format("Reading {0} dirty object deltas", dirtyObjectDeltas.length);
- }
+ for (int i = 0; i < newObjects.length; i++)
+ {
+ newObjects[i] = in.readCDORevision();
+ monitor.worked(1);
+ }
- for (int i = 0; i < dirtyObjectDeltas.length; i++)
- {
- dirtyObjectDeltas[i] = in.readCDORevisionDelta();
- }
+ // Dirty objects
+ if (PROTOCOL_TRACER.isEnabled())
+ {
+ PROTOCOL_TRACER.format("Reading {0} dirty object deltas", dirtyObjectDeltas.length);
+ }
+
+ for (int i = 0; i < dirtyObjectDeltas.length; i++)
+ {
+ dirtyObjectDeltas[i] = in.readCDORevisionDelta();
+ monitor.worked(1);
+ }
- for (int i = 0; i < detachedObjects.length; i++)
+ for (int i = 0; i < detachedObjects.length; i++)
+ {
+ detachedObjects[i] = in.readCDOID();
+ monitor.worked(1);
+ }
+
+ commitContext.setNewPackages(newPackages);
+ commitContext.setNewObjects(newObjects);
+ commitContext.setDirtyObjectDeltas(dirtyObjectDeltas);
+ commitContext.setDetachedObjects(detachedObjects);
+ }
+ finally
{
- detachedObjects[i] = in.readCDOID();
+ monitor.done();
}
-
- commitContext.setNewPackages(newPackages);
- commitContext.setNewObjects(newObjects);
- commitContext.setDirtyObjectDeltas(dirtyObjectDeltas);
- commitContext.setDetachedObjects(detachedObjects);
}
- protected void indicatingCommit()
+ protected void indicatingCommit(IMonitor monitor)
{
- commitContext.write();
- if (commitContext.getRollbackMessage() == null)
+ monitor.begin(2);
+ try
+ {
+ commitContext.write(monitor.fork(1));
+ if (commitContext.getRollbackMessage() == null)
+ {
+ commitContext.commit(monitor.fork(1));
+ }
+ else
+ {
+ monitor.worked(1);
+ }
+ }
+ finally
{
- commitContext.commit();
+ monitor.done();
}
}
- protected boolean respondingException(CDODataOutput out, String rollbackMessage) throws IOException
+ protected boolean respondingException(CDODataOutput out, String rollbackMessage) throws Exception
{
boolean success = rollbackMessage == null;
out.writeBoolean(success);
@@ -191,12 +353,12 @@ public class CommitTransactionIndication extends CDOServerIndication
return success;
}
- protected void respondingTimestamp(CDODataOutput out) throws IOException
+ protected void respondingTimestamp(CDODataOutput out) throws Exception
{
out.writeLong(commitContext.getTimeStamp());
}
- protected void respondingMappingNewPackages(CDODataOutput out) throws IOException
+ protected void respondingMappingNewPackages(CDODataOutput out) throws Exception
{
// Meta ID ranges
List<CDOIDMetaRange> metaRanges = commitContext.getMetaIDRanges();
@@ -206,7 +368,7 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- protected void respondingMappingNewObjects(CDODataOutput out) throws IOException
+ protected void respondingMappingNewObjects(CDODataOutput out) throws Exception
{
// ID mappings
Map<CDOIDTemp, CDOID> idMappings = commitContext.getIDMappings();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase1Indication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase1Indication.java
index 34be0e01f5..57cee57ccb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase1Indication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase1Indication.java
@@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
-import java.io.IOException;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
/**
* @author Simon McDuff
@@ -28,14 +28,14 @@ public class CommitTransactionPhase1Indication extends CommitTransactionIndicati
}
@Override
- protected void indicatingCommit()
+ protected void indicatingCommit(IMonitor monitor)
{
// Register transactionContext
- getRepository().getCommitManager().preCommit(commitContext);
+ getRepository().getCommitManager().preCommit(commitContext, monitor);
}
@Override
- protected void responding(CDODataOutput out) throws IOException
+ protected void responding(CDODataOutput out, IMonitor monitor) throws Exception
{
String exceptionMessage = null;
@@ -62,7 +62,7 @@ public class CommitTransactionPhase1Indication extends CommitTransactionIndicati
}
@Override
- protected void indicationTransaction(CDODataInput in) throws IOException
+ protected void indicationTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = new XATransactionCommitContext(getTransaction(viewID));
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase2Indication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase2Indication.java
index 828c3f53cd..9495a30f08 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase2Indication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase2Indication.java
@@ -19,9 +19,9 @@ import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext.CommitState;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
-import java.io.IOException;
import java.util.concurrent.ExecutionException;
/**
@@ -38,10 +38,10 @@ public class CommitTransactionPhase2Indication extends CommitTransactionIndicati
}
@Override
- protected void indicating(CDODataInput in) throws IOException
+ protected void indicating(CDODataInput in, IMonitor monitor) throws Exception
{
indicationTransaction(in);
- XATransactionCommitContext xaTransactionContext = (XATransactionCommitContext)commitContext;
+ XATransactionCommitContext xaContextContext = (XATransactionCommitContext)commitContext;
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -53,15 +53,15 @@ public class CommitTransactionPhase2Indication extends CommitTransactionIndicati
{
CDOIDTemp oldID = (CDOIDTemp)in.readCDOID();
CDOID newID = in.readCDOID();
- xaTransactionContext.addIDMapping(oldID, newID);
+ xaContextContext.addIDMapping(oldID, newID);
}
// Mapping information from others CDOTransactions was added. Notify the commit process to continue.
- xaTransactionContext.getState().set(CommitState.APPLY_ID_MAPPING_DONE);
+ xaContextContext.getState().set(CommitState.APPLY_ID_MAPPING_DONE);
}
@Override
- protected void responding(CDODataOutput out) throws IOException
+ protected void responding(CDODataOutput out, IMonitor monitor) throws Exception
{
String exceptionMessage = null;
@@ -88,7 +88,7 @@ public class CommitTransactionPhase2Indication extends CommitTransactionIndicati
}
@Override
- protected void indicationTransaction(CDODataInput in) throws IOException
+ protected void indicationTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase3Indication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase3Indication.java
index 4740310cb6..dcf322e112 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase3Indication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionPhase3Indication.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.common.CDODataInput;
import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
-import java.io.IOException;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
/**
* @author Simon McDuff
@@ -27,15 +27,15 @@ public class CommitTransactionPhase3Indication extends CommitTransactionIndicati
}
@Override
- protected void indicating(CDODataInput in) throws IOException
+ protected void indicating(CDODataInput in, IMonitor monitor) throws Exception
{
indicationTransaction(in);
}
@Override
- protected void responding(CDODataOutput out) throws IOException
+ protected void responding(CDODataOutput out, IMonitor monitor) throws Exception
{
- commitContext.commit();
+ commitContext.commit(monitor);
boolean success = respondingException(out, commitContext.getRollbackMessage());
if (success)
{
@@ -46,7 +46,7 @@ public class CommitTransactionPhase3Indication extends CommitTransactionIndicati
}
@Override
- protected void indicationTransaction(CDODataInput in) throws IOException
+ protected void indicationTransaction(CDODataInput in) throws Exception
{
int viewID = in.readInt();
commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
index 359dc97e13..57dc19e390 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.net4j.util.collection.CloseableIterator;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import java.util.Collection;
import java.util.Map;
@@ -215,7 +216,7 @@ public interface IStoreAccessor extends IQueryHandler
*
* @since 2.0
*/
- public void write(CommitContext context);
+ public void write(CommitContext context, IMonitor monitor);
/**
* It will flush to the backend and make available the data for others.
@@ -225,7 +226,7 @@ public interface IStoreAccessor extends IQueryHandler
*
* @since 2.0
*/
- public void commit();
+ public void commit(IMonitor monitor);
/**
* <b>Note</b> : {@link IStoreAccessor#write(CommitContext)} and {@link IStoreAccessor#rollback()} could be called
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
index d563c69373..e1e3083d14 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AuditTest.java
@@ -18,7 +18,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.net4j.signal.SignalRemoteException;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.emf.common.util.URI;
@@ -349,7 +349,7 @@ public class AuditTest extends AbstractCDOTest
session.openAudit(timeStampPriorToRepoCreation);
fail("SignalRemoteException expected");
}
- catch (SignalRemoteException eexpected)
+ catch (RemoteException eexpected)
{
// Success
}
@@ -384,7 +384,7 @@ public class AuditTest extends AbstractCDOTest
audit.setTimeStamp(timeStampPriorToRepoCreation);
fail("SignalRemoteException expected");
}
- catch (SignalRemoteException expected)
+ catch (RemoteException expected)
{
// Success
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
index 4e3e761101..abc07a6db7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
@@ -455,6 +455,8 @@ public class LockingManagerTest extends AbstractCDOTest
CDOObject cdoCompany = CDOUtil.getCDOObject(company);
cdoCompany.cdoReadLock().lock();
session.close();
+
+ sleep(100);
assertEquals(false, repo.getLockManager().hasLock(RWLockManager.LockType.READ, view, cdoCompany.cdoID()));
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
index 6d5351440a..20f865eb06 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_241464_Test.java
@@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Customer;
-import org.eclipse.net4j.signal.SignalRemoteException;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
/**
@@ -44,7 +44,7 @@ public class Bugzilla_241464_Test extends AbstractCDOTest
}
CDOSession session = openModel1Session();
- session.getFailOverStrategy().setDefaultTimeout(2000L);
+ session.getProtocol().setTimeout(2000L);
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getResource("/test1");
@@ -57,7 +57,7 @@ public class Bugzilla_241464_Test extends AbstractCDOTest
System.out.println(customer.getName());
fail("SignalRemoteException expected");
}
- catch (SignalRemoteException success)
+ catch (RemoteException success)
{
}
finally
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
index f64794cdd6..1575e10ff8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
@@ -66,7 +66,7 @@ public class Bugzilla_246442_Test extends AbstractCDOTest
}
CDOSession session = openSession();
- session.getFailOverStrategy().setDefaultTimeout(2000L);
+ session.getProtocol().setTimeout(2000L);
CDOTransaction transaction = session.openTransaction();
transaction.getObject(lookupObject);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java
index e3cf7740d8..ddf992a4df 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/logic/TestLogic.java
@@ -41,6 +41,7 @@ import org.eclipse.emf.internal.cdo.CDOSessionImpl;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.tests.AbstractOMTest;
+import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
@@ -224,8 +225,8 @@ public abstract class TestLogic extends AbstractOMTest
transactionCommitContext.setNewObjects(getNewObjects());
transactionCommitContext.setDirtyObjectDeltas(getDirtyObjectDeltas());
transactionCommitContext.setDetachedObjects(getDetachedObjects());
- transactionCommitContext.write();
- transactionCommitContext.commit();
+ transactionCommitContext.write(new Monitor());
+ transactionCommitContext.commit(new Monitor());
transactionCommitContext.postCommit(true);
return transaction;
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java
index cd120f46da..e4439662ea 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -29,7 +30,7 @@ public final class CloseSessionAction extends SessionAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getSession().close();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java
index f4d86dca2e..85f20a5ea6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -29,7 +30,7 @@ public final class CloseViewAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getView().close();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java
index e960f7da6b..80c8dd4510 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -30,7 +31,7 @@ public final class CommitTransactionAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getTransaction().commit();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
index f71a77d0f1..35509eca7f 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.ui.IWorkbenchPage;
@@ -49,7 +50,7 @@ public final class CreateResourceAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getTransaction().getOrCreateResource(resourcePath);
CDOEditor.open(getPage(), getView(), resourcePath);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java
index ab3e3c4383..8b8f816707 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchPage;
@@ -70,7 +71,7 @@ public class ExportResourceAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOView view = getView();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
index e01e7fd4ce..55807f5c48 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchPage;
@@ -74,7 +75,7 @@ public class ImportResourceAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOTransaction transaction = getTransaction();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java
index 2481c21c10..85fa72b88a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import java.util.ArrayList;
@@ -85,7 +86,7 @@ public class ImportRootsAction extends EditingDomainAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
EList<EObject> targetContents = targetResource.getContents();
List<Resource> resources = getSourceResources();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java
index 95208cbc87..d98b116833 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.ui.IWorkbenchPage;
@@ -46,7 +47,7 @@ public final class LoadResourceAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOEditor.open(getPage(), getView(), resourcePath);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java
index c591936c53..9c0346d9cc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.dialogs.PackageManagerDialog;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -38,7 +39,7 @@ public class ManagePackagesAction extends SessionAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java
index 9b2a6dad99..4a3b8a88e9 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -49,7 +50,7 @@ public final class OpenAuditAction extends AbstractOpenViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getSession().openAudit(new ResourceSetImpl(), timeStamp);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
index d457a0b0e9..838e013f9d 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPage;
@@ -33,7 +34,7 @@ public final class OpenResourceEditorAction extends ResourceNodeAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOView view = getResourceNode().cdoView();
String resourcePath = getResourceNode().getPath();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
index 6bb117e6f5..8a536c9513 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.internal.cdo.CDOSessionFactory;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
@@ -64,7 +65,7 @@ public final class OpenSessionAction extends LongRunningAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOSession session = null;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java
index ff7729e30c..8625b6658e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -30,7 +31,7 @@ public final class OpenTransactionAction extends AbstractOpenViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getSession().openTransaction();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
index 1e77c62159..3a99545de0 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -32,7 +33,7 @@ public final class OpenViewAction extends AbstractOpenViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getSession().openView(new ResourceSetImpl());
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java
index 03e7be5e00..b3481f0777 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -30,7 +31,7 @@ public final class OpenViewEditorAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
CDOEditor.open(getPage(), getView(), null);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
index 6ff8cf0c9a..6eda8da588 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
@@ -52,7 +53,7 @@ public abstract class RegisterPackagesAction extends SessionAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
errors = 0;
CDOPackageRegistry packageRegistry = getSession().getPackageRegistry();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
index cbabbc30f7..a780cdc785 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPage;
@@ -65,7 +66,7 @@ public class ReloadObjectsAction extends EditingDomainAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
if (!objects.isEmpty())
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java
index ab9c6dff45..1571d6855c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -30,7 +31,7 @@ public final class ReloadViewAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
if (getView().reload() != 0)
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
index 96538c45f9..9f3fc8832c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPage;
/**
@@ -43,7 +44,7 @@ public final class RollbackTransactionAction extends ViewAction
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
getTransaction().rollback();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 9df82e344a..aff21f8c3a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -87,6 +87,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
@@ -95,6 +96,7 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -139,6 +141,7 @@ import org.eclipse.ui.views.properties.PropertySheetPage;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -1552,72 +1555,80 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
public void doSave(IProgressMonitor progressMonitor)
{
+ Display.getCurrent().syncExec(null);
// Save only resources that have actually changed.
//
final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
- // Do the work within an operation because this is a long running activity
- // that modifies the workbench.
- //
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation()
+ IRunnableWithProgress operation = new IRunnableWithProgress()
{
- // This is the method that gets invoked when the operation runs.
- //
- @Override
- public void execute(IProgressMonitor monitor)
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
- // Save the resources to the file system.
- //
boolean first = true;
- for (Resource resource : CDOUtil.getResources(editingDomain.getResourceSet()))
+ EList<Resource> resources = CDOUtil.getResources(editingDomain.getResourceSet());
+ monitor.beginTask("", resources.size());
+ try
{
- if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
- && !editingDomain.isReadOnly(resource))
+ for (Resource resource : resources)
{
- try
- {
- savedResources.add(resource);
- resource.save(saveOptions);
- }
- catch (final TransactionException exception)
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
+ && !editingDomain.isReadOnly(resource))
{
- OM.LOG.error(exception);
- final Shell shell = getSite().getShell();
- shell.getDisplay().syncExec(new Runnable()
+ try
{
- public void run()
+ savedResources.add(resource);
+ saveOptions.put(CDOResource.OPTION_SAVE_PROGRESS_MONITOR, new SubProgressMonitor(monitor, 1));
+ resource.save(saveOptions);
+ }
+ catch (final TransactionException exception)
+ {
+ OM.LOG.error(exception);
+ final Shell shell = getSite().getShell();
+ shell.getDisplay().syncExec(new Runnable()
{
- CDOTransaction transaction = (CDOTransaction)view;
- String title = "Transaction Error";
- String message = "An error occured while committing the tranasaction (see Error Log for details)";
- RollbackTransactionDialog dialog = new RollbackTransactionDialog(getEditorSite().getPage(), title,
- message, transaction);
- if (dialog.open() == RollbackTransactionDialog.OK)
+ public void run()
{
- transaction.rollback();
+ CDOTransaction transaction = (CDOTransaction)view;
+ String title = "Transaction Error";
+ String message = "An error occured while committing the tranasaction (see Error Log for details)";
+ RollbackTransactionDialog dialog = new RollbackTransactionDialog(getEditorSite().getPage(), title,
+ message, transaction);
+ if (dialog.open() == RollbackTransactionDialog.OK)
+ {
+ transaction.rollback();
+ }
}
- }
- });
+ });
+ }
+ catch (Exception exception)
+ {
+ OM.LOG.error(exception);
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+
+ first = false;
}
- catch (Exception exception)
+ else
{
- OM.LOG.error(exception);
- resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ monitor.worked(1);
}
-
- first = false;
}
}
+ finally
+ {
+ monitor.done();
+ }
}
};
updateProblemIndication = false;
+
try
{
// This runs the options, and shows progress.
//
- new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+ new ProgressMonitorDialog(getSite().getShell()).run(true, true, operation);
// Refresh the necessary state.
//
@@ -1629,6 +1640,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
//
PluginDelegator.INSTANCE.log(exception);
}
+
updateProblemIndication = true;
updateProblemIndication();
}
@@ -1961,7 +1973,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@SuppressWarnings("unchecked")
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
List<EObject> children = new ArrayList<EObject>();
for (int i = 0; i < instances; i++)
@@ -2314,7 +2326,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
Resource resource = null;
IStructuredSelection ssel = (IStructuredSelection)editorSelection;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
index 24fd32fd7b..d239a79b30 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
@@ -14,7 +14,6 @@ package org.eclipse.emf.cdo;
import org.eclipse.emf.cdo.common.CDOProtocolSession;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -27,7 +26,10 @@ import java.util.Collection;
*/
public interface CDOSession extends CDOProtocolSession, IContainer<CDOView>
{
- public IFailOverStrategy getFailOverStrategy();
+ /**
+ * @since 2.0
+ */
+ public CDOSessionProtocol getProtocol();
public boolean isOpen();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionProtocol.java
new file mode 100644
index 0000000000..4ad77fbdcd
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionProtocol.java
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.emf.cdo;
+
+import org.eclipse.emf.cdo.common.CDOProtocolSession;
+
+import org.eclipse.net4j.signal.ISignalProtocol;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface CDOSessionProtocol extends ISignalProtocol<CDOProtocolSession>
+{
+ public CDOSession getSession();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOUserTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOUserTransaction.java
index 348bd076cb..28ae080fe7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOUserTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOUserTransaction.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo;
import org.eclipse.net4j.util.transaction.TransactionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* Only deal with transaction process.
*
@@ -22,6 +24,8 @@ public interface CDOUserTransaction
{
public void commit() throws TransactionException;
+ public void commit(IProgressMonitor progressMonitor) throws TransactionException;
+
public void rollback();
public void rollback(CDOSavepoint savepoint);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOXATransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOXATransaction.java
index 4272cea08c..1daa7b6ceb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOXATransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOXATransaction.java
@@ -23,14 +23,13 @@ public interface CDOXATransaction extends CDOUserTransaction
/**
* see {@link CDOXATransaction#isAllowRequestFromTransactionEnabled()}
*/
-
public void setAllowRequestFromTransactionEnabled(boolean allRequest);
/**
* Allow request that come from contains {@link CDOTransaction}. Default value is true.
* <p>
* If the value is true, cdoTransaction.commit() will call xaTransaction.commit and all {@link CDOXATransaction} part
- * of XATransaction will be committed.
+ * of xaTransaction will be committed.
* <p>
* If the value is false, the user will receive an exception by calling cdoTransaction.commit(). The user can only
* commit from {@link CDOXATransaction}.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java
index b726f15440..929c05f7b2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java
@@ -16,6 +16,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* <!-- begin-user-doc --> A representation of the model object '<em><b>CDO Resource</b></em>'.
*
@@ -41,6 +43,12 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
public interface CDOResource extends CDOResourceNode, Resource
{
/**
+ * @ADDED
+ * @since 2.0
+ */
+ public static final String OPTION_SAVE_PROGRESS_MONITOR = IProgressMonitor.class.getName();
+
+ /**
* Returns the value of the '<em><b>Resource Set</b></em>' attribute. <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Resource Set</em>' attribute isn't clear, there really should be more of a description
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index d9b638a37b..e39b44c9f6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -47,6 +47,8 @@ import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.core.runtime.IProgressMonitor;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -674,7 +676,8 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
if (view instanceof CDOTransaction)
{
CDOTransaction transaction = (CDOTransaction)view;
- transaction.commit();
+ IProgressMonitor progressMonitor = (IProgressMonitor)options.get(CDOResource.OPTION_SAVE_PROGRESS_MONITOR);
+ transaction.commit(progressMonitor);
setModified(false);
}
else
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
index 8f056c539e..c4e3a32109 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
@@ -82,8 +82,7 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit
try
{
CDOSessionImpl session = getSession();
- SetAuditRequest request = new SetAuditRequest(session.getProtocol(), getViewID(), timeStamp, invalidObjects);
- return session.getFailOverStrategy().send(request);
+ return new SetAuditRequest(session.getProtocol(), getViewID(), timeStamp, invalidObjects).send();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCommitContext.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCommitContext.java
index 48c2a10e9b..22153102a5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCommitContext.java
@@ -44,7 +44,7 @@ public interface CDOCommitContext
public Map<CDOID, CDOObject> getDirtyObjects();
- public Map<CDOID, CDOObject> getDetachedObjects();
-
public Map<CDOID, CDORevisionDelta> getRevisionDeltas();
+
+ public Map<CDOID, CDOObject> getDetachedObjects();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
index c53929e9fe..fd43c7b4dd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
@@ -29,7 +29,6 @@ import org.eclipse.emf.internal.cdo.protocol.LoadRevisionByTimeRequest;
import org.eclipse.emf.internal.cdo.protocol.LoadRevisionByVersionRequest;
import org.eclipse.emf.internal.cdo.protocol.LoadRevisionRequest;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.om.trace.PerfTracer;
import java.util.Collection;
@@ -79,11 +78,8 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
try
{
CDOClientProtocol protocol = session.getProtocol();
- LoadChunkRequest request = new LoadChunkRequest(protocol, (InternalCDORevision)revision, feature, accessIndex,
- fetchIndex, fromIndex, toIndex);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- return failOverStrategy.send(request);
+ return new LoadChunkRequest(protocol, (InternalCDORevision)revision, feature, accessIndex, fetchIndex, fromIndex,
+ toIndex).send();
}
catch (RuntimeException ex)
{
@@ -144,8 +140,7 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
try
{
LOADING.start(request);
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- return failOverStrategy.send(request);
+ return request.send();
}
catch (RuntimeException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
index def45867fc..a68674fae3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
@@ -143,9 +143,9 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
session = new CDOSessionImpl();
session.setConnector(connector);
session.setRepositoryName(repositoryName);
- session.setFailOverStrategy(failOverStrategy);
session.setPackageRegistry(packageRegistry);
session.getRevisionManager().setCache(revisionCache);
+ session.getProtocol().setFailOverStrategy(failOverStrategy);
if (activateOnOpen)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
index 3d2cbcd35c..55b801c7f0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
@@ -104,7 +104,7 @@ public class CDOSessionFactory extends Factory
}
session.setRepositoryName(repositoryName);
- session.setFailOverStrategy(failOverStrategy);
+ session.getProtocol().setFailOverStrategy(failOverStrategy);
return session;
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 8dc6b67c1f..c4a76804a3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -55,9 +55,6 @@ import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.failover.IFailOverEvent;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
-import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
@@ -65,7 +62,6 @@ import org.eclipse.net4j.util.concurrent.QueueRunner;
import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.event.Event;
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.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -107,21 +103,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
private CDOCollectionLoadingPolicy collectionLoadingPolicy;
- private IFailOverStrategy failOverStrategy;
-
- @ExcludeFromDump
- private IListener failOverStrategyListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof IFailOverEvent)
- {
- IFailOverEvent e = (IFailOverEvent)event;
- handleFailOver(e.getOldChannel(), e.getNewChannel(), e.getNewConnector());
- }
- }
- };
-
private IConnector connector;
private CDOClientProtocol protocol;
@@ -235,30 +216,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
collectionLoadingPolicy = policy;
}
- public synchronized IFailOverStrategy getFailOverStrategy()
- {
- if (failOverStrategy == null)
- {
- failOverStrategy = new NOOPFailOverStrategy();
- }
-
- return failOverStrategy;
- }
-
- public synchronized void setFailOverStrategy(IFailOverStrategy strategy)
- {
- if (failOverStrategy != null)
- {
- failOverStrategy.removeListener(failOverStrategyListener);
- }
-
- failOverStrategy = strategy;
- if (failOverStrategy != null)
- {
- failOverStrategy.addListener(failOverStrategyListener);
- }
- }
-
public IConnector getConnector()
{
return connector;
@@ -327,8 +284,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
{
try
{
- RepositoryTimeRequest request = new RepositoryTimeRequest(protocol);
- return getFailOverStrategy().send(request);
+ return new RepositoryTimeRequest(protocol).send();
}
catch (Exception ex)
{
@@ -448,9 +404,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
{
try
{
- ViewsChangedRequest request = new ViewsChangedRequest(protocol, view.getViewID(),
- CDOProtocolConstants.VIEW_CLOSED, CDOProtocolView.UNSPECIFIED_DATE);
- getFailOverStrategy().send(request);
+ new ViewsChangedRequest(protocol, view.getViewID(), CDOProtocolConstants.VIEW_CLOSED,
+ CDOProtocolView.UNSPECIFIED_DATE).send();
}
catch (Exception ex)
{
@@ -473,8 +428,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
timeStamp = ((CDOAudit)view).getTimeStamp();
}
- ViewsChangedRequest request = new ViewsChangedRequest(protocol, id, kind, timeStamp);
- getFailOverStrategy().send(request);
+ new ViewsChangedRequest(protocol, id, kind, timeStamp).send();
}
catch (Exception ex)
{
@@ -855,17 +809,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
fireElementAddedEvent(view);
}
- protected void handleFailOver(IChannel oldChannel, IChannel newChannel, IConnector newConnector)
- {
- // TODO: implement CDOSessionImpl.handleFailOver(oldChannel, newChannel, newConnector)
- throw new UnsupportedOperationException();
-
- // EventUtil.removeListener(oldChannel, channelListener);
- // EventUtil.addListener(newChannel, channelListener);
- // channel = newChannel;
- // connector = newConnector;
- }
-
@Override
protected void doBeforeActivate() throws Exception
{
@@ -886,8 +829,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
packageRegistry.setSession(this);
IChannel channel = protocol.open(connector);
- OpenSessionRequest request = new OpenSessionRequest(protocol, repositoryName, passiveUpdateEnabled);
- OpenSessionResult result = getFailOverStrategy().send(request);
+ OpenSessionResult result = new OpenSessionRequest(protocol, repositoryName, passiveUpdateEnabled).send();
sessionID = result.getSessionID();
repositoryUUID = result.getRepositoryUUID();
@@ -958,8 +900,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
missingLibraries.removeAll(existingLibraries);
if (!missingLibraries.isEmpty())
{
- LoadLibrariesRequest request = new LoadLibrariesRequest(protocol, missingLibraries, cacheFolder);
- getFailOverStrategy().send(request);
+ new LoadLibrariesRequest(protocol, missingLibraries, cacheFolder).send();
}
}
@@ -1053,9 +994,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
{
if (!allRevisions.isEmpty())
{
- SetPassiveUpdateRequest request = new SetPassiveUpdateRequest(protocol, this, allRevisions,
- collectionLoadingPolicy.getInitialChunkSize(), passiveUpdateEnabled);
- getFailOverStrategy().send(request);
+ new SetPassiveUpdateRequest(protocol, this, allRevisions, collectionLoadingPolicy.getInitialChunkSize(),
+ passiveUpdateEnabled).send();
}
}
catch (Exception ex)
@@ -1071,7 +1011,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
public Collection<CDOTimeStampContext> refresh()
{
// If passive update is turned on we don`t need to refresh.
- // We do not throw an exception since the client could turn that feature on or off without affecting their code.
+ // We do not throw an exception since the client could turn
+ // that feature on or off without affecting their code.
checkActive();
if (!isPassiveUpdateEnabled())
{
@@ -1081,9 +1022,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
{
if (!allRevisions.isEmpty())
{
- SyncRevisionRequest request = new SyncRevisionRequest(protocol, this, allRevisions, collectionLoadingPolicy
- .getInitialChunkSize());
- return getFailOverStrategy().send(request);
+ return new SyncRevisionRequest(protocol, this, allRevisions, collectionLoadingPolicy.getInitialChunkSize())
+ .send();
}
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
index c7827440df..c394715380 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
@@ -24,12 +24,9 @@ import org.eclipse.emf.cdo.internal.common.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
import org.eclipse.emf.internal.cdo.protocol.LoadPackageRequest;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
-
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -155,12 +152,7 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
try
{
- CDOClientProtocol protocol = session.getProtocol();
- LoadPackageRequest request = new LoadPackageRequest(protocol, cdoPackage, false);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- failOverStrategy.send(request);
-
+ new LoadPackageRequest(session.getProtocol(), cdoPackage, false).send();
if (!cdoPackage.isDynamic())
{
OM.LOG.info("Dynamic package created for " + cdoPackage.getPackageURI());
@@ -183,11 +175,7 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
{
try
{
- CDOClientProtocol protocol = session.getProtocol();
- LoadPackageRequest request = new LoadPackageRequest(protocol, cdoPackage, true);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- String ecore = failOverStrategy.send(request);
+ String ecore = new LoadPackageRequest(session.getProtocol(), cdoPackage, true).send();
((InternalCDOPackage)cdoPackage).setEcore(ecore);
}
catch (RuntimeException ex)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java
index d6cd19ec3e..42c067b746 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java
@@ -16,10 +16,12 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionRequest;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.transaction.TransactionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* @author Simon McDuff
* @since 2.0
@@ -34,7 +36,7 @@ public class CDOSingleTransactionStrategy implements CDOTransactionStrategy
{
}
- public void commit(InternalCDOTransaction transaction) throws Exception
+ public void commit(InternalCDOTransaction transaction, IProgressMonitor progressMonitor) throws Exception
{
CDOCommitContext commitContext = transaction.createCommitContext();
if (TRACER.isEnabled())
@@ -51,8 +53,7 @@ public class CDOSingleTransactionStrategy implements CDOTransactionStrategy
TRACER.format("Sending commit request");
}
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- CommitTransactionResult result = failOverStrategy.send(request, transaction.getCommitTimeout());
+ CommitTransactionResult result = request.send(new EclipseMonitor(progressMonitor));
String rollbackMessage = result.getRollbackMessage();
if (rollbackMessage != null)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index efedeeaea0..54ced2b903 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -26,13 +26,11 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.emf.cdo.util.InvalidObjectException;
import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
import org.eclipse.emf.internal.cdo.protocol.VerifyRevisionRequest;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.RevisionAdjuster;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.fsm.FiniteStateMachine;
import org.eclipse.net4j.util.fsm.ITransition;
@@ -310,11 +308,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
try
{
CDOSessionImpl session = (CDOSessionImpl)view.getSession();
- CDOClientProtocol protocol = session.getProtocol();
- VerifyRevisionRequest request = new VerifyRevisionRequest(protocol, revisions);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- revisions = failOverStrategy.send(request);
+ revisions = new VerifyRevisionRequest(session.getProtocol(), revisions).send();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 456e9f9f56..813b2a2c91 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -57,6 +57,9 @@ import org.eclipse.net4j.util.transaction.TransactionException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -457,13 +460,20 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return new CDOCommitContextImpl();
}
- public void commit() throws TransactionException
+ /**
+ * @since 2.0
+ */
+ public void commit(IProgressMonitor progressMonitor) throws TransactionException
{
checkOpen();
+ if (progressMonitor == null)
+ {
+ progressMonitor = new NullProgressMonitor();
+ }
try
{
- getTransactionStrategy().commit(this);
+ getTransactionStrategy().commit(this, progressMonitor);
}
catch (TransactionException ex)
{
@@ -475,6 +485,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
+ public void commit() throws TransactionException
+ {
+ commit(null);
+ }
+
/**
* @since 2.0
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionStrategy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionStrategy.java
index c6ef9c08a1..0bbc6aa52a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionStrategy.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionStrategy.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOSavepoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* @author Simon McDuff
* @since 2.0
@@ -24,7 +26,7 @@ public interface CDOTransactionStrategy
public void unsetTarget(InternalCDOTransaction transaction);
- public void commit(InternalCDOTransaction transaction) throws Exception;
+ public void commit(InternalCDOTransaction transaction, IProgressMonitor progressMonitor) throws Exception;
public void rollback(InternalCDOTransaction transaction, CDOSavepoint savepoint);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 5ef26067d5..c9ae5eec98 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -58,7 +58,7 @@ import org.eclipse.emf.internal.cdo.query.CDOQueryImpl;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
-import org.eclipse.net4j.signal.SignalRemoteException;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.WrappedException;
@@ -234,10 +234,9 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
try
{
- LockObjectsRequest request = new LockObjectsRequest(getSession().getProtocol(), this, objects, timeout, lockType);
- getSession().getFailOverStrategy().send(request);
+ new LockObjectsRequest(getSession().getProtocol(), this, objects, timeout, lockType).send();
}
- catch (SignalRemoteException ex)
+ catch (RemoteException ex)
{
if (ex.getCause() instanceof RuntimeException)
{
@@ -271,8 +270,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
try
{
- UnlockObjectsRequest request = new UnlockObjectsRequest(getSession().getProtocol(), this, objects, lockType);
- getSession().getFailOverStrategy().send(request);
+ new UnlockObjectsRequest(getSession().getProtocol(), this, objects, lockType).send();
}
catch (Exception ex)
{
@@ -296,8 +294,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
try
{
- ObjectLockedRequest request = new ObjectLockedRequest(getSession().getProtocol(), this, object, lockType);
- return getSession().getFailOverStrategy().send(request);
+ return new ObjectLockedRequest(getSession().getProtocol(), this, object, lockType).send();
}
catch (Exception ex)
{
@@ -1513,9 +1510,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
try
{
- ChangeSubscriptionRequest request = new ChangeSubscriptionRequest(getSession().getProtocol(), getViewID(),
- cdoIDs, subscribeMode, clear);
- session.getFailOverStrategy().send(request);
+ new ChangeSubscriptionRequest(getSession().getProtocol(), getViewID(), cdoIDs, subscribeMode, clear).send();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java
index c5ce4a925e..13fd393013 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java
@@ -27,6 +27,8 @@ import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.core.runtime.IProgressMonitor;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -40,6 +42,8 @@ public class CDOXATransactionCommitContext implements Callable<Object>, CDOIDPro
{
private CDOXATransactionImpl transactionManager;
+ private IProgressMonitor progressMonitor;
+
private CDOXAState state;
private CommitTransactionResult result;
@@ -61,6 +65,11 @@ public class CDOXATransactionCommitContext implements Callable<Object>, CDOIDPro
return transactionManager;
}
+ public void setProgressMonitor(IProgressMonitor progressMonitor)
+ {
+ this.progressMonitor = progressMonitor;
+ }
+
public CDOXAState getState()
{
return state;
@@ -123,7 +132,7 @@ public class CDOXATransactionCommitContext implements Callable<Object>, CDOIDPro
public Object call() throws Exception
{
- state.handle(this);
+ state.handle(this, progressMonitor);
return true;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java
index 410bd965ee..6d7fa51d3c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java
@@ -18,20 +18,25 @@ import org.eclipse.emf.cdo.CDOXATransaction;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionCancelRequest;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionPhase1Request;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionPhase2Request;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionPhase3Request;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
+import org.eclipse.net4j.util.om.monitor.SynchonizedSubProgressMonitor;
import org.eclipse.net4j.util.transaction.TransactionException;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -75,7 +80,7 @@ import java.util.concurrent.Future;
*/
public class CDOXATransactionImpl implements CDOXATransaction
{
- private List<InternalCDOTransaction> views = new ArrayList<InternalCDOTransaction>();
+ private List<InternalCDOTransaction> transactions = new ArrayList<InternalCDOTransaction>();
private boolean allRequestEnabled = true;
@@ -175,18 +180,32 @@ public class CDOXATransactionImpl implements CDOXATransaction
return activeContext.get(transaction);
}
- private void send(Collection<CDOXATransactionCommitContext> xaTransactions) throws InterruptedException,
- ExecutionException
+ private void send(Collection<CDOXATransactionCommitContext> xaContexts, final IProgressMonitor progressMonitor)
+ throws InterruptedException, ExecutionException
{
- List<Future<Object>> futures = new ArrayList<Future<Object>>();
- for (CDOXATransactionCommitContext xaTransaction : xaTransactions)
+ progressMonitor.beginTask("", xaContexts.size());
+
+ try
{
- futures.add(executorService.submit(xaTransaction));
- }
+ List<Future<Object>> futures = new ArrayList<Future<Object>>();
+ for (CDOXATransactionCommitContext xaContext : xaContexts)
+ {
+ xaContext.setProgressMonitor(new SynchonizedSubProgressMonitor(progressMonitor, 1));
+ futures.add(executorService.submit(xaContext));
+ }
- for (Future<Object> future : futures)
+ for (Future<Object> future : futures)
+ {
+ future.get();
+ }
+ }
+ finally
{
- future.get();
+ progressMonitor.done();
+ for (CDOXATransactionCommitContext xaContext : xaContexts)
+ {
+ xaContext.setProgressMonitor(null);
+ }
}
}
@@ -212,26 +231,30 @@ public class CDOXATransactionImpl implements CDOXATransaction
public void commit() throws TransactionException
{
+ commit(new NullProgressMonitor());
+ }
+
+ public void commit(IProgressMonitor progressMonitor) throws TransactionException
+ {
+ CheckUtil.checkArg(progressMonitor, "progressMonitor");
+ progressMonitor.beginTask("Committing XA transaction", 3);
int phase = 0;
- try
- {
- CDOXAState defaultState = CDOXAPhase1State.INSTANCE;
- /*
- * if (transactions.size() == 1) { defaultState = CDOXAALLPhaseState.INSTANCE; }
- */
- for (InternalCDOTransaction transaction : views)
- {
- CDOXATransactionCommitContext xaTransaction = new CDOXATransactionCommitContext(this, transaction
- .createCommitContext());
- xaTransaction.setState(defaultState);
- activeContext.put(transaction, xaTransaction);
- }
+ for (InternalCDOTransaction transaction : transactions)
+ {
+ CDOCommitContext context = transaction.createCommitContext();
+ CDOXATransactionCommitContext xaContext = new CDOXATransactionCommitContext(this, context);
+ xaContext.setState(CDOXAPhase1State.INSTANCE);
+ activeContext.put(transaction, xaContext);
+ }
+ try
+ {
// We need to complete 3 phases
- for (phase = 0; phase < 3; phase++)
+ while (phase < 3)
{
- send(activeContext.values());
+ send(activeContext.values(), new SubProgressMonitor(progressMonitor, 1));
+ ++phase;
}
}
catch (Exception ex)
@@ -246,7 +269,7 @@ public class CDOXATransactionImpl implements CDOXATransaction
try
{
- send(activeContext.values());
+ send(activeContext.values(), new SubProgressMonitor(progressMonitor, 2 - phase));
}
catch (InterruptedException ignore)
{
@@ -261,6 +284,7 @@ public class CDOXATransactionImpl implements CDOXATransaction
finally
{
cleanUp();
+ progressMonitor.done();
}
}
@@ -325,10 +349,10 @@ public class CDOXATransactionImpl implements CDOXATransaction
private List<CDOSavepoint> getListSavepoints()
{
- synchronized (views)
+ synchronized (transactions)
{
List<CDOSavepoint> savepoints = new ArrayList<CDOSavepoint>();
- for (InternalCDOTransaction transaction : views)
+ for (InternalCDOTransaction transaction : transactions)
{
savepoints.add(transaction.getLastSavepoint());
}
@@ -348,17 +372,17 @@ public class CDOXATransactionImpl implements CDOXATransaction
public void setTarget(InternalCDOTransaction transaction)
{
- synchronized (views)
+ synchronized (transactions)
{
- views.add(transaction);
+ transactions.add(transaction);
}
}
public void unsetTarget(InternalCDOTransaction transaction)
{
- synchronized (views)
+ synchronized (transactions)
{
- views.remove(transaction);
+ transactions.remove(transaction);
}
}
@@ -370,10 +394,10 @@ public class CDOXATransactionImpl implements CDOXATransaction
}
}
- public void commit(InternalCDOTransaction transactionCommit) throws Exception
+ public void commit(InternalCDOTransaction transactionCommit, IProgressMonitor progressMonitor) throws Exception
{
checkAccess();
- CDOXATransactionImpl.this.commit();
+ CDOXATransactionImpl.this.commit(progressMonitor);
}
public void rollback(InternalCDOTransaction transaction, CDOSavepoint savepoint)
@@ -397,9 +421,9 @@ public class CDOXATransactionImpl implements CDOXATransaction
public static final CDOXAState DONE = new CDOXAState()
{
@Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
+ protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
- // Do nothing
+ progressMonitor.done();
}
};
@@ -411,7 +435,8 @@ public class CDOXATransactionImpl implements CDOXATransaction
}
}
- protected abstract void handle(CDOXATransactionCommitContext xaTransaction) throws Exception;
+ protected abstract void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor)
+ throws Exception;
};
/**
@@ -422,24 +447,19 @@ public class CDOXATransactionImpl implements CDOXATransaction
public static final CDOXAPhase1State INSTANCE = new CDOXAPhase1State();
@Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
+ protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
- xaTransaction.preCommit();
-
- InternalCDOTransaction transaction = xaTransaction.getTransaction();
- CDOSessionImpl session = (CDOSessionImpl)xaTransaction.getTransaction().getSession();
+ xaContext.preCommit();
+ CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession();
// Phase 1
{
- CDOClientProtocol protocol = session.getProtocol();
- CommitTransactionPhase1Request requestPhase1 = new CommitTransactionPhase1Request(protocol, xaTransaction);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- CommitTransactionResult result = failOverStrategy.send(requestPhase1, transaction.getCommitTimeout());
+ CommitTransactionResult result = new CommitTransactionPhase1Request(session.getProtocol(), xaContext)
+ .send(new EclipseMonitor(progressMonitor));
check_result(result);
- xaTransaction.setResult(result);
- xaTransaction.setState(CDOXAPhase2State.INSTANCE);
+ xaContext.setResult(result);
+ xaContext.setState(CDOXAPhase2State.INSTANCE);
}
}
};
@@ -456,21 +476,16 @@ public class CDOXATransactionImpl implements CDOXATransaction
}
@Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
+ protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
- InternalCDOTransaction transaction = xaTransaction.getTransaction();
- CDOSessionImpl session = (CDOSessionImpl)xaTransaction.getTransaction().getSession();
+ CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession();
// Phase 2
{
- CDOClientProtocol protocol = session.getProtocol();
- CommitTransactionPhase2Request requestPhase2 = new CommitTransactionPhase2Request(protocol, xaTransaction);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- CommitTransactionResult result = failOverStrategy.send(requestPhase2, transaction.getCommitTimeout());
+ CommitTransactionResult result = new CommitTransactionPhase2Request(session.getProtocol(), xaContext)
+ .send(new EclipseMonitor(progressMonitor));
check_result(result);
-
- xaTransaction.setState(CDOXAPhase3State.INSTANCE);
+ xaContext.setState(CDOXAPhase3State.INSTANCE);
}
}
};
@@ -487,22 +502,17 @@ public class CDOXATransactionImpl implements CDOXATransaction
}
@Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
+ protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
- InternalCDOTransaction transaction = xaTransaction.getTransaction();
- CDOSessionImpl session = (CDOSessionImpl)xaTransaction.getTransaction().getSession();
+ CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession();
// Phase 2
{
- CDOClientProtocol protocol = session.getProtocol();
- CommitTransactionPhase3Request requestPhase3 = new CommitTransactionPhase3Request(protocol, xaTransaction);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- CommitTransactionResult result = failOverStrategy.send(requestPhase3, transaction.getCommitTimeout());
+ CommitTransactionResult result = new CommitTransactionPhase3Request(session.getProtocol(), xaContext)
+ .send(new EclipseMonitor(progressMonitor));
check_result(result);
-
- xaTransaction.postCommit(xaTransaction.getResult());
- xaTransaction.setState(null);
+ xaContext.postCommit(xaContext.getResult());
+ xaContext.setState(null);
}
}
};
@@ -519,18 +529,14 @@ public class CDOXATransactionImpl implements CDOXATransaction
}
@Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
+ protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
- InternalCDOTransaction transaction = xaTransaction.getTransaction();
- CDOSessionImpl session = (CDOSessionImpl)xaTransaction.getTransaction().getSession();
+ CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession();
// Phase 2
{
- CDOClientProtocol protocol = session.getProtocol();
- CommitTransactionCancelRequest requestCancel = new CommitTransactionCancelRequest(protocol, xaTransaction);
-
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- CommitTransactionResult result = failOverStrategy.send(requestCancel, transaction.getCommitTimeout());
+ CommitTransactionResult result = new CommitTransactionCancelRequest(session.getProtocol(), xaContext)
+ .send(new EclipseMonitor(progressMonitor));
check_result(result);
}
}
@@ -539,27 +545,12 @@ public class CDOXATransactionImpl implements CDOXATransaction
/**
* @author Simon McDuff
*/
- public static class CDOXAALLPhaseState extends CDOXAState
+ public class CDOXAInternalAdapter implements Adapter
{
- public static final CDOXAALLPhaseState INSTANCE = new CDOXAALLPhaseState();
-
- public CDOXAALLPhaseState()
+ public CDOXAInternalAdapter()
{
}
- @Override
- protected void handle(CDOXATransactionCommitContext xaTransaction) throws Exception
- {
- CDOTransactionStrategy.DEFAULT.commit(xaTransaction.getTransaction());
- xaTransaction.setState(null);
- }
- }
-
- /**
- * @author Simon McDuff
- */
- public class CDOXAInternalAdapter implements Adapter
- {
public CDOXATransactionImpl getCDOXA()
{
return CDOXATransactionImpl.this;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
index 2c0763f76c..1ee8fc9f22 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOSessionProtocol;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.internal.common.CDOProtocolImpl;
@@ -19,7 +20,7 @@ import org.eclipse.net4j.signal.SignalReactor;
/**
* @author Eike Stepper
*/
-public class CDOClientProtocol extends CDOProtocolImpl
+public class CDOClientProtocol extends CDOProtocolImpl implements CDOSessionProtocol
{
public CDOClientProtocol()
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java
index 1ecf69f19c..71df8ff530 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java
@@ -12,9 +12,10 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
-import org.eclipse.net4j.protocol.ClientProtocolFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.spi.net4j.ClientProtocolFactory;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionCancelRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionCancelRequest.java
index 2fd09134af..c98e8c4031 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionCancelRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionCancelRequest.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.internal.cdo.CDOXATransactionCommitContext;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+
import java.io.IOException;
/**
@@ -30,19 +32,19 @@ import java.io.IOException;
*/
public class CommitTransactionCancelRequest extends CommitTransactionRequest
{
- public CommitTransactionCancelRequest(CDOClientProtocol protocol, CDOXATransactionCommitContext xaTransaction)
+ public CommitTransactionCancelRequest(CDOClientProtocol protocol, CDOXATransactionCommitContext xaContext)
{
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_CANCEL, xaTransaction);
+ super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_CANCEL, xaContext);
}
@Override
- protected void requesting(CDODataOutput out) throws IOException
+ protected void requesting(CDODataOutput out, IMonitor monitor) throws IOException
{
requestingTransactionInfo(out);
}
@Override
- protected CommitTransactionResult confirming(CDODataInput in) throws IOException
+ protected CommitTransactionResult confirming(CDODataInput in, IMonitor monitor) throws IOException
{
return confirmingCheckError(in);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase1Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase1Request.java
index f9c06ccf09..97feac39a7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase1Request.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase1Request.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.internal.cdo.CDOXATransactionCommitContext;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+
import java.io.IOException;
/**
@@ -29,13 +31,19 @@ import java.io.IOException;
*/
public class CommitTransactionPhase1Request extends CommitTransactionRequest
{
- public CommitTransactionPhase1Request(CDOClientProtocol protocol, final CDOXATransactionCommitContext xaTransaction)
+ public CommitTransactionPhase1Request(CDOClientProtocol protocol, CDOXATransactionCommitContext xaContext)
{
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE1, xaTransaction);
+ super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE1, xaContext);
+ }
+
+ @Override
+ protected CDOIDProvider getIDProvider()
+ {
+ return (CDOIDProvider)commitContext;
}
@Override
- protected CommitTransactionResult confirming(CDODataInput in) throws IOException
+ protected CommitTransactionResult confirming(CDODataInput in, IMonitor monitor) throws IOException
{
CommitTransactionResult result = confirmingCheckError(in);
if (result != null)
@@ -47,10 +55,4 @@ public class CommitTransactionPhase1Request extends CommitTransactionRequest
confirmingIdMapping(in, result);
return result;
}
-
- @Override
- protected CDOIDProvider getIDProvider()
- {
- return (CDOIDProvider)commitContext;
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase2Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase2Request.java
index c9bb55ac0f..a9142cb5c7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase2Request.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase2Request.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.internal.cdo.CDOXATransactionCommitContext;
import org.eclipse.emf.internal.cdo.InternalCDOTransaction;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.common.util.URI;
@@ -32,7 +33,7 @@ import java.util.Map.Entry;
/**
* <p>
- * Phase 2 consist of sending the mapping of temporary CDOID/final CDOID from other CDOTransaction.
+ * Phase 2 consist of sending the mapping of temporary/persistent CDOID from other CDOTransaction.
* <p>
* It will return confirmation only when the commit is ready to flush to disk.
*
@@ -43,9 +44,9 @@ public class CommitTransactionPhase2Request extends CommitTransactionRequest
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL,
CommitTransactionPhase1Request.class);
- public CommitTransactionPhase2Request(CDOClientProtocol protocol, final CDOXATransactionCommitContext xaTransaction)
+ public CommitTransactionPhase2Request(CDOClientProtocol protocol, CDOXATransactionCommitContext xaContext)
{
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE2, xaTransaction);
+ super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE2, xaContext);
}
@Override
@@ -55,14 +56,14 @@ public class CommitTransactionPhase2Request extends CommitTransactionRequest
}
@Override
- protected void requesting(CDODataOutput out) throws IOException
+ protected void requesting(CDODataOutput out, IMonitor monitor) throws IOException
{
requestingTransactionInfo(out);
requestingIdMapping(out);
}
@Override
- protected CommitTransactionResult confirming(CDODataInput in) throws IOException
+ protected CommitTransactionResult confirming(CDODataInput in, IMonitor monitor) throws IOException
{
return confirmingCheckError(in);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase3Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase3Request.java
index 0ad4319de5..68c7e8e373 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase3Request.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionPhase3Request.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.internal.cdo.CDOXATransactionCommitContext;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+
import java.io.IOException;
/**
@@ -30,19 +32,19 @@ import java.io.IOException;
*/
public class CommitTransactionPhase3Request extends CommitTransactionRequest
{
- public CommitTransactionPhase3Request(CDOClientProtocol protocol, final CDOXATransactionCommitContext xaTransaction)
+ public CommitTransactionPhase3Request(CDOClientProtocol protocol, CDOXATransactionCommitContext xaContext)
{
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE3, xaTransaction);
+ super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE3, xaContext);
}
@Override
- protected void requesting(CDODataOutput out) throws IOException
+ protected void requesting(CDODataOutput out, IMonitor monitor) throws IOException
{
requestingTransactionInfo(out);
}
@Override
- protected CommitTransactionResult confirming(CDODataInput in) throws IOException
+ protected CommitTransactionResult confirming(CDODataInput in, IMonitor monitor) throws IOException
{
CommitTransactionResult result = confirmingCheckError(in);
if (result != null)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 45e51ae26e..35731b1e08 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -19,19 +19,33 @@ import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackage;
+import org.eclipse.emf.cdo.common.model.CDOPackageManager;
+import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.CDODataInputImpl;
+import org.eclipse.emf.cdo.internal.common.CDODataOutputImpl;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.emf.internal.cdo.CDOCommitContext;
+import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.revision.CDOListReferenceProxyImpl;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -42,7 +56,7 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class CommitTransactionRequest extends CDOClientRequest<CommitTransactionResult>
+public class CommitTransactionRequest extends RequestWithMonitoring<CommitTransactionResult>
{
private static final ContextTracer PROTOCOL_TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
CommitTransactionRequest.class);
@@ -66,20 +80,104 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
}
@Override
+ public CDOClientProtocol getProtocol()
+ {
+ return (CDOClientProtocol)super.getProtocol();
+ }
+
+ protected CDOSessionImpl getSession()
+ {
+ return (CDOSessionImpl)getProtocol().getInfraStructure();
+ }
+
+ protected CDORevisionManagerImpl getRevisionManager()
+ {
+ return getSession().getRevisionManager();
+ }
+
+ protected CDOSessionPackageManagerImpl getPackageManager()
+ {
+ return getSession().getPackageManager();
+ }
+
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return getSession();
+ }
+
protected CDOIDProvider getIDProvider()
{
return commitContext.getTransaction();
}
+ protected CDOIDObjectFactory getIDFactory()
+ {
+ return getSession();
+ }
+
@Override
- protected void requesting(CDODataOutput out) throws IOException
+ protected final void requesting(ExtendedDataOutputStream out, IMonitor monitor) throws Exception
+ {
+ requesting(new CDODataOutputImpl(out)
+ {
+ @Override
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return CommitTransactionRequest.this.getPackageURICompressor();
+ }
+
+ public CDOIDProvider getIDProvider()
+ {
+ return CommitTransactionRequest.this.getIDProvider();
+ }
+ }, monitor);
+ }
+
+ @Override
+ protected final CommitTransactionResult confirming(ExtendedDataInputStream in, IMonitor monitor)
+ throws Exception
+ {
+ return confirming(new CDODataInputImpl(in)
+ {
+ @Override
+ protected CDORevisionResolver getRevisionResolver()
+ {
+ return CommitTransactionRequest.this.getRevisionManager();
+ }
+
+ @Override
+ protected CDOPackageManager getPackageManager()
+ {
+ return CommitTransactionRequest.this.getPackageManager();
+ }
+
+ @Override
+ protected CDOPackageURICompressor getPackageURICompressor()
+ {
+ return CommitTransactionRequest.this.getPackageURICompressor();
+ }
+
+ @Override
+ protected CDOIDObjectFactory getIDFactory()
+ {
+ return CommitTransactionRequest.this.getIDFactory();
+ }
+
+ @Override
+ protected CDOListFactory getListFactory()
+ {
+ return CDOListReferenceProxyImpl.FACTORY;
+ }
+ }, monitor);
+ }
+
+ protected void requesting(CDODataOutput out, IMonitor monitor) throws IOException
{
requestingTransactionInfo(out);
requestingCommit(out);
}
- @Override
- protected CommitTransactionResult confirming(CDODataInput in) throws IOException
+ protected CommitTransactionResult confirming(CDODataInput in, IMonitor monitor) throws IOException
{
CommitTransactionResult result = confirmingCheckError(in);
if (result != null)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java
index b805278193..ebbf106aca 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java
@@ -77,8 +77,7 @@ public abstract class CDOAbstractQueryIteratorImpl<T> extends AbstractQueryResul
try
{
CDOSessionImpl session = (CDOSessionImpl)getView().getSession();
- QueryCancelRequest request = new QueryCancelRequest(session.getProtocol(), getQueryID());
- session.getFailOverStrategy().send(request);
+ new QueryCancelRequest(session.getProtocol(), getQueryID()).send();
}
catch (Exception ignore)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
index a332e96812..c0f2d78b5f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
@@ -81,8 +81,7 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery
try
{
CDOSessionImpl session = view.getSession();
- QueryRequest request = new QueryRequest(session.getProtocol(), view.getViewID(), queryResult);
- session.getFailOverStrategy().send(request);
+ new QueryRequest(session.getProtocol(), view.getViewID(), queryResult).send();
}
catch (Exception exception)
{
@@ -103,8 +102,7 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery
try
{
CDOSessionImpl session = view.getSession();
- QueryRequest request = new QueryRequest(session.getProtocol(), view.getViewID(), queryResult);
- session.getFailOverStrategy().send(request);
+ new QueryRequest(session.getProtocol(), view.getViewID(), queryResult).send();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java
index 5900a276d6..fc17e743d9 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java
@@ -168,7 +168,7 @@ public class Collaboration extends MembershipContainer implements ICollaboration
try
{
SignalProtocol<?> protocol = (SignalProtocol<?>)receiver.getSession().getProtocol();
- new MessageNotification(protocol, collaborationID, facilityType, message).send();
+ new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java
index 059715ddaa..72c83fdbb8 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java
index b35096fd6c..00b9baf30f 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java
index 9ee37805cb..d1f5c5dc33 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java
index 5fa4471000..5a7205fae0 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java
index 89c5d8a5ab..647f4b5004 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java
index f4e8e13411..46d1abe2c9 100644
--- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
index 46f14a5e04..ea11e24792 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
@@ -181,7 +181,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
{
invitations.remove(buddy);
BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationInitiatedNotification(protocol, collaborationID, invitations, null).send();
+ new CollaborationInitiatedNotification(protocol, collaborationID, invitations, null).sendAsync();
}
catch (Exception ex)
{
@@ -219,7 +219,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
try
{
BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
- new BuddyRemovedNotification(protocol, userID).send();
+ new BuddyRemovedNotification(protocol, userID).sendAsync();
}
catch (Exception ex)
{
@@ -245,7 +245,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
if (!ObjectUtil.equals(session.getSelf(), e.getBuddy()))
{
BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
- new BuddyStateNotification(protocol, e.getBuddy().getUserID(), e.getNewState()).send();
+ new BuddyStateNotification(protocol, e.getBuddy().getUserID(), e.getNewState()).sendAsync();
}
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
index afd49db81c..00884493eb 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
@@ -70,7 +70,7 @@ public class BuddiesServerProtocol extends SignalProtocol<ServerSession>
/**
* @author Eike Stepper
*/
- public static class Factory extends org.eclipse.net4j.protocol.ServerProtocolFactory
+ public static class Factory extends org.eclipse.spi.net4j.ServerProtocolFactory
{
public Factory()
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
index f792389afe..a578ee725c 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
index befbea90cc..e7d00cdfca 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
index 6de49f2858..993df21249 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
index 3a284838be..e9823797cd 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
@@ -20,7 +20,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index a3b09836f7..610e1fc633 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
@@ -23,7 +23,6 @@ import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
@@ -68,7 +67,7 @@ public class InstallFacilityIndication extends IndicationWithResponse
try
{
BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new FacilityInstalledNotification(protocol, collaborationID, facilityType).send();
+ new FacilityInstalledNotification(protocol, collaborationID, facilityType).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
index b3cef41f52..88962315a5 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
@@ -79,7 +79,7 @@ public class InviteBuddiesIndication extends Indication
try
{
BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationInitiatedNotification(protocol, collaborationID, set, facilityTypes).send();
+ new CollaborationInitiatedNotification(protocol, collaborationID, set, facilityTypes).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
index 15d9e48038..05febd8171 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
index 22a8ff383b..53b1a9373a 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
@@ -90,7 +90,7 @@ public class OpenSessionIndication extends IndicationWithResponse
{
try
{
- new BuddyAddedNotification(protocol, account.getUserID()).send();
+ new BuddyAddedNotification(protocol, account.getUserID()).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
index 60dc41cd9b..2e1493c6d8 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
@@ -44,7 +44,7 @@ public class ServerCollaborationLeftIndication extends CollaborationLeftIndicati
try
{
BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationLeftNotification(protocol, collaboration.getID(), buddy.getUserID()).send();
+ new CollaborationLeftNotification(protocol, collaboration.getID(), buddy.getUserID()).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java
index 6ea5f78426..841df06b7e 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java
@@ -23,6 +23,7 @@ import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.net4j.util.ui.views.IElementFilter;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ITreeSelection;
@@ -220,8 +221,11 @@ public abstract class AbstractItemProvider extends ContainerItemProvider<IContai
this.object = object;
}
+ /**
+ * @since 2.0
+ */
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
LifecycleUtil.deactivateNoisy(object);
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
index 1b74a92e22..4fa630fd05 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java
@@ -14,7 +14,7 @@ import org.eclipse.net4j.buddies.spi.common.ClientFacilityFactory;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol;
import org.eclipse.net4j.internal.buddies.protocol.OpenSessionRequest;
-import org.eclipse.net4j.signal.SignalActor;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IPluginContainer;
@@ -50,6 +50,6 @@ public final class BuddiesUtil
public static IBuddySession openSession(IConnector connector, String userID, String password)
{
- return openSession(connector, userID, password, SignalActor.NO_TIMEOUT);
+ return openSession(connector, userID, password, RequestWithConfirmation.NO_TIMEOUT);
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
index 59bf9a9322..df01a18f50 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
@@ -97,7 +97,7 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
try
{
BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new MessageNotification(protocol, collaborationID, facilityType, message).send();
+ new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync();
}
catch (Exception ex)
{
@@ -135,7 +135,7 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
try
{
BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new InviteBuddiesNotification(protocol, getID(), invitations).send();
+ new InviteBuddiesNotification(protocol, getID(), invitations).sendAsync();
}
catch (Exception ex)
{
@@ -149,7 +149,7 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
try
{
BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new CollaborationLeftNotification(protocol, getID(), session.getSelf().getUserID()).send();
+ new CollaborationLeftNotification(protocol, getID(), session.getSelf().getUserID()).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
index 0ca3a32001..f1a5d07d4c 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java
@@ -96,7 +96,7 @@ public class ClientSession extends BuddyContainer implements IBuddySession, ILis
{
try
{
- new BuddyStateNotification(protocol, self.getUserID(), ((IBuddyStateEvent)event).getNewState()).send();
+ new BuddyStateNotification(protocol, self.getUserID(), ((IBuddyStateEvent)event).getNewState()).sendAsync();
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
index 625a70b4c9..80883fb362 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
@@ -16,7 +16,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
index 546d79cffd..d1800859d8 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
@@ -16,7 +16,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
index 0ca03820a8..5822eb8cd8 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
index 8503cd680e..9a268edb4a 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
index a4c3d52983..31d017d0fc 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
index d72368426b..41aa2a07b0 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/client/EchoRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
* @since 2.0
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
index 29ba22315f..26a1ae4b4d 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoIndication.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
* @since 2.0
diff --git a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
index 71c84cdd07..54e468761b 100644
--- a/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
+++ b/plugins/org.eclipse.net4j.examples/src/org/eclipse/net4j/examples/echo/server/EchoServerProtocol.java
@@ -11,11 +11,12 @@
package org.eclipse.net4j.examples.echo.server;
import org.eclipse.net4j.examples.echo.EchoProtocol;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
/**
* @author Eike Stepper
* @since 2.0
diff --git a/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPChannel.java b/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPChannel.java
index 93530788ce..173b74c7a3 100644
--- a/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPChannel.java
+++ b/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPChannel.java
@@ -12,7 +12,7 @@ package org.eclipse.net4j.http.internal.common;
import org.eclipse.net4j.http.internal.common.HTTPConnector.ChannelOperation;
-import org.eclipse.internal.net4j.channel.Channel;
+import org.eclipse.spi.net4j.Channel;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPConnector.java b/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPConnector.java
index 2e69be1291..de751c57fb 100644
--- a/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPConnector.java
+++ b/plugins/org.eclipse.net4j.http.common/src/org/eclipse/net4j/http/internal/common/HTTPConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.http.internal.common;
import org.eclipse.net4j.buffer.IBuffer;
+import org.eclipse.net4j.channel.ChannelException;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.http.common.IHTTPConnector;
import org.eclipse.net4j.http.internal.common.bundle.OM;
@@ -20,8 +21,7 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.INegotiationContext;
-import org.eclipse.internal.net4j.connector.Connector;
-
+import org.eclipse.spi.net4j.Connector;
import org.eclipse.spi.net4j.InternalChannel;
import java.io.IOException;
@@ -107,7 +107,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
TRACER.format("Multiplexing {0} (count={1})", buffer.formatContent(true), outputOperationCount);
}
- outputOperations.add(new BufferChannelOperation(httpChannel.getIndex(), outputOperationCount, buffer));
+ outputOperations.add(new BufferChannelOperation(httpChannel.getID(), outputOperationCount, buffer));
}
/**
@@ -188,18 +188,17 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
}
@Override
- protected void registerChannelWithPeer(short channelIndex, long timeout, IProtocol<?> protocol)
- throws ConnectorException
+ protected void registerChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol) throws ChannelException
{
- ChannelOperation operation = new OpenChannelOperation(channelIndex, protocol.getType());
+ ChannelOperation operation = new OpenChannelOperation(channelID, protocol.getType());
outputOperations.add(operation);
- HTTPChannel channel = (HTTPChannel)getChannel(channelIndex);
+ HTTPChannel channel = (HTTPChannel)getChannel(channelID);
channel.waitForOpenAck(timeout);
}
@Override
- protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ConnectorException
+ protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ChannelException
{
HTTPChannel httpChannel = (HTTPChannel)channel;
if (!httpChannel.isInverseRemoved())
@@ -224,34 +223,34 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
*/
public abstract class ChannelOperation
{
- private short channelIndex;
+ private short channelID;
private long operationCount;
- public ChannelOperation(short channelIndex, long operationCount)
+ public ChannelOperation(short channelID, long operationCount)
{
- this.channelIndex = channelIndex;
+ this.channelID = channelID;
this.operationCount = operationCount;
}
public ChannelOperation(ExtendedDataInputStream in) throws IOException
{
- channelIndex = in.readShort();
+ channelID = in.readShort();
operationCount = in.readLong();
}
public void write(ExtendedDataOutputStream out) throws IOException
{
out.writeByte(getOperation());
- out.writeShort(channelIndex);
+ out.writeShort(channelID);
out.writeLong(operationCount);
}
public abstract byte getOperation();
- public short getChannelIndex()
+ public short getChannelID()
{
- return channelIndex;
+ return channelID;
}
public long getOperationCount()
@@ -261,7 +260,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
public void execute()
{
- HTTPChannel channel = (HTTPChannel)getChannel(getChannelIndex());
+ HTTPChannel channel = (HTTPChannel)getChannel(getChannelID());
long operationCount = getOperationCount();
synchronized (channel)
{
@@ -322,9 +321,9 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
private String protocolID;
- public OpenChannelOperation(short channelIndex, String protocolID)
+ public OpenChannelOperation(short channelID, String protocolID)
{
- super(channelIndex, 0);
+ super(channelID, 0);
this.protocolID = protocolID;
}
@@ -355,7 +354,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
@Override
public void execute()
{
- HTTPChannel channel = (HTTPChannel)inverseOpenChannel(getChannelIndex(), protocolID);
+ HTTPChannel channel = (HTTPChannel)inverseOpenChannel(getChannelID(), protocolID);
if (channel == null)
{
throw new ConnectorException("Could not open channel");
@@ -368,7 +367,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
@Override
public void doEexecute(HTTPChannel channel)
{
- ChannelOperation operation = new OpenAckChannelOperation(getChannelIndex(), true);
+ ChannelOperation operation = new OpenAckChannelOperation(getChannelID(), true);
outputOperations.add(operation);
}
}
@@ -380,9 +379,9 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
private boolean success;
- public OpenAckChannelOperation(short channelIndex, boolean success)
+ public OpenAckChannelOperation(short channelID, boolean success)
{
- super(channelIndex, 0);
+ super(channelID, 0);
this.success = success;
}
@@ -419,7 +418,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
public CloseChannelOperation(HTTPChannel channel)
{
- super(channel.getIndex(), channel.getOutputOperationCount());
+ super(channel.getID(), channel.getOutputOperationCount());
channel.increaseOutputOperationCount();
}
@@ -438,7 +437,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
public void doEexecute(HTTPChannel channel)
{
channel.setInverseRemoved();
- inverseCloseChannel(channel.getIndex());
+ inverseCloseChannel(channel.getID());
}
}
@@ -449,9 +448,9 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
private IBuffer buffer;
- public BufferChannelOperation(short channelIndex, long operationCount, IBuffer buffer)
+ public BufferChannelOperation(short channelID, long operationCount, IBuffer buffer)
{
- super(channelIndex, operationCount);
+ super(channelID, operationCount);
this.buffer = buffer;
}
@@ -465,7 +464,7 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
}
buffer = getConfig().getBufferProvider().provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(getChannelIndex());
+ ByteBuffer byteBuffer = buffer.startPutting(getChannelID());
for (int i = 0; i < length; i++)
{
byte b = in.readByte();
diff --git a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPAcceptor.java b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPAcceptor.java
index fa7eea43dc..b8b8b6e0f0 100644
--- a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPAcceptor.java
+++ b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPAcceptor.java
@@ -23,8 +23,7 @@ import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.IRandomizer;
-import org.eclipse.internal.net4j.acceptor.Acceptor;
-
+import org.eclipse.spi.net4j.Acceptor;
import org.eclipse.spi.net4j.InternalConnector;
import java.io.IOException;
diff --git a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
index d88028108d..8480260996 100644
--- a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
+++ b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.http.internal.server;
-import org.eclipse.net4j.connector.ConnectorException;
+import org.eclipse.net4j.channel.ChannelException;
import org.eclipse.net4j.http.internal.common.HTTPConnector;
import org.eclipse.net4j.protocol.IProtocol;
@@ -67,8 +67,7 @@ public class HTTPServerConnector extends HTTPConnector
}
@Override
- protected void registerChannelWithPeer(short channelIndex, long timeout, IProtocol<?> protocol)
- throws ConnectorException
+ protected void registerChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol) throws ChannelException
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/Net4jTransportServlet.java b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/Net4jTransportServlet.java
index 3ed588c979..4eb77b4202 100644
--- a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/Net4jTransportServlet.java
+++ b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/Net4jTransportServlet.java
@@ -149,7 +149,7 @@ public class Net4jTransportServlet extends HttpServlet implements INet4jTranspor
for (IChannel channel : connector.getChannels())
{
writer.write(" ");
- writer.write(String.valueOf(channel.getIndex()));
+ writer.write(String.valueOf(channel.getID()));
writer.write(": ");
IBufferHandler receiveHandler = channel.getReceiveHandler();
if (receiveHandler instanceof IProtocol)
@@ -168,7 +168,7 @@ public class Net4jTransportServlet extends HttpServlet implements INet4jTranspor
}
writer.write(" (");
- writer.write(String.valueOf(channel.getIndex()));
+ writer.write(String.valueOf(channel.getID()));
writer.write(")\n");
}
}
diff --git a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSCreateDestinationRequest.java b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSCreateDestinationRequest.java
index e704cdb4c6..8c8a923805 100644
--- a/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSCreateDestinationRequest.java
+++ b/plugins/org.eclipse.net4j.jms.admin/src/org/eclipse/net4j/jms/internal/admin/protocol/JMSCreateDestinationRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java
index 49f1c4396e..2f494563ec 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java
@@ -99,7 +99,7 @@ public class ServerConsumer implements IServerConsumer
messages.put(messageID, message);
}
- new JMSServerMessageRequest(getProtocol(), session.getID(), id, message).send();
+ new JMSServerMessageRequest(getProtocol(), session.getID(), id, message).sendAsync();
transaction.messageSent(message, id);
return true;
}
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
index f1011d9651..c31533efd3 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.jms.internal.server.bundle.OM;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
index 4d6d8978e7..baacbe7160 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java
@@ -19,7 +19,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
index 2ee2109c91..9e601cb9f2 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java
@@ -20,7 +20,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
index b0eb83f187..4cfaa75c29 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
index c1a99f0c8f..2cf9eec4af 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
index 1074a114f7..9d1ff1ed09 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
index 6dec319c5c..f6b382c8d1 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java
@@ -19,7 +19,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
index b9a82217f4..bf665e8b1d 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java
index 4e7bba4bef..3061283b45 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java
@@ -16,7 +16,6 @@ import org.eclipse.net4j.jms.JMSProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java
index 3fe1af89d2..d5cbb3686a 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java
@@ -11,9 +11,10 @@
package org.eclipse.net4j.jms.internal.server.protocol;
import org.eclipse.net4j.jms.JMSProtocolConstants;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java
index 91283ccc59..622e8e50bb 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java
index f85e05eb0c..c285ffe9cb 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java
@@ -11,9 +11,10 @@
package org.eclipse.net4j.jms.internal.server.protocol.admin;
import org.eclipse.net4j.jms.JMSAdminProtocolConstants;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java
index 8631eb8397..b19eb39310 100644
--- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java
+++ b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java
@@ -18,7 +18,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java
index 227890c2b1..7b5d299fcc 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java
@@ -387,7 +387,7 @@ public class SessionImpl extends QueueWorker<MessageConsumerImpl> implements Ses
{
try
{
- new JMSAcknowledgeRequest(connection.getProtocol(), id).send();
+ new JMSAcknowledgeRequest(connection.getProtocol(), id).sendAsync();
return true;
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java
index cbb306c22f..d468d61614 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.jms.JMSProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java
index bb432e88fc..21bf532af4 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java
index 914a7020d5..2104b47502 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java
index d7f6ca5a59..71a37aa512 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java
index 9e1b2ff4fa..fe7c7c8147 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.jms.JMSProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java
index 7c101ccaea..b12f251546 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java
index 4dcb0f59f3..a35ef9d89b 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java
index 3b020e4d66..27b39b2c7e 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java
index 29a614bc0f..b9d8354c6a 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java
index e22fd63751..3ed0b4f932 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
index 9f6d2f83e5..c1edd453f3 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java
@@ -17,7 +17,6 @@ import org.eclipse.net4j.jms.JMSProtocolConstants;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java
index fed2491c89..ddbb48b603 100644
--- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java
+++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
index 9322b8eec1..157ea770e0 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
@@ -13,7 +13,7 @@ package org.eclipse.net4j.internal.jvm;
import org.eclipse.net4j.jvm.IJVMAcceptor;
import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.internal.net4j.acceptor.Acceptor;
+import org.eclipse.spi.net4j.Acceptor;
import java.text.MessageFormat;
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
index 172033fad5..6a060e6c84 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.internal.jvm;
import org.eclipse.net4j.buffer.IBuffer;
+import org.eclipse.net4j.channel.ChannelException;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.connector.ConnectorState;
import org.eclipse.net4j.internal.jvm.bundle.OM;
@@ -19,8 +20,7 @@ import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.INegotiationContext;
-import org.eclipse.internal.net4j.connector.Connector;
-
+import org.eclipse.spi.net4j.Connector;
import org.eclipse.spi.net4j.InternalChannel;
import java.util.Queue;
@@ -81,14 +81,14 @@ public abstract class JVMConnector extends Connector implements IJVMConnector
public void multiplexChannel(InternalChannel localChannel)
{
- short channelIndex = localChannel.getIndex();
- InternalChannel peerChannel = peer.getChannel(channelIndex);
+ short channelID = localChannel.getID();
+ InternalChannel peerChannel = peer.getChannel(channelID);
if (peerChannel == null)
{
throw new IllegalStateException("peerChannel == null"); //$NON-NLS-1$
}
- Queue<IBuffer> localQueue = (localChannel).getSendQueue();
+ Queue<IBuffer> localQueue = localChannel.getSendQueue();
IBuffer buffer = localQueue.poll();
if (TRACER.isEnabled())
{
@@ -106,42 +106,42 @@ public abstract class JVMConnector extends Connector implements IJVMConnector
}
@Override
- protected void registerChannelWithPeer(short channelIndex, long timeoutIgnored, IProtocol<?> protocol)
- throws ConnectorException
+ protected void registerChannelWithPeer(short channelID, long timeoutIgnored, IProtocol<?> protocol)
+ throws ChannelException
{
try
{
String protocolID = protocol == null ? null : protocol.getType();
- InternalChannel channel = getPeer().inverseOpenChannel(channelIndex, protocolID);
+ InternalChannel channel = getPeer().inverseOpenChannel(channelID, protocolID);
if (channel == null)
{
- throw new ConnectorException("Failed to register channel with peer");
+ throw new ChannelException("Failed to register channel with peer");
}
}
- catch (ConnectorException ex)
+ catch (ChannelException ex)
{
throw ex;
}
catch (Exception ex)
{
- throw new ConnectorException(ex);
+ throw new ChannelException(ex);
}
}
@Override
- protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ConnectorException
+ protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ChannelException
{
try
{
- getPeer().inverseCloseChannel(channel.getIndex());
+ getPeer().inverseCloseChannel(channel.getID());
}
- catch (ConnectorException ex)
+ catch (ChannelException ex)
{
throw ex;
}
catch (Exception ex)
{
- throw new ConnectorException(ex);
+ throw new ChannelException(ex);
}
}
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
index d254342565..c7d8b83a78 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
@@ -24,8 +24,8 @@ import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.net4j.util.security.INegotiationContext.Receiver;
import org.eclipse.internal.net4j.buffer.BufferUtil;
-import org.eclipse.internal.net4j.channel.Channel;
+import org.eclipse.spi.net4j.Channel;
import org.eclipse.spi.net4j.InternalChannel;
import java.nio.ByteBuffer;
@@ -46,8 +46,6 @@ public class ControlChannel extends Channel
public static final byte OPCODE_DEREGISTRATION = 4;
- public static final byte OPCODE_DEREGISTRATION_ACK = 5;
-
public static final byte SUCCESS = 1;
public static final byte FAILURE = 0;
@@ -58,7 +56,7 @@ public class ControlChannel extends Channel
public ControlChannel(TCPConnector connector)
{
- setChannelIndex(CONTROL_CHANNEL_INDEX);
+ setID(CONTROL_CHANNEL_INDEX);
setMultiplexer(connector);
setReceiveExecutor(connector.getConfig().getReceiveExecutor());
setUserID(connector.getUserID());
@@ -69,20 +67,20 @@ public class ControlChannel extends Channel
return (TCPConnector)getMultiplexer();
}
- public boolean registerChannel(short channelIndex, long timeout, IProtocol<?> protocol)
+ public boolean registerChannel(short channelID, long timeout, IProtocol<?> protocol)
{
if (TRACER.isEnabled())
{
- TRACER.format("Registering channel {0} with protocol {1}", channelIndex, protocol);
+ TRACER.format("Registering channel {0} with protocol {1}", channelID, protocol);
}
- assertValidChannelIndex(channelIndex);
- ISynchronizer<Boolean> acknowledgement = acknowledgements.correlate(channelIndex);
+ assertValidChannelID(channelID);
+ ISynchronizer<Boolean> acknowledgement = acknowledgements.correlate(channelID);
IBuffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_INDEX);
byteBuffer.put(OPCODE_REGISTRATION);
- byteBuffer.putShort(channelIndex);
+ byteBuffer.putShort(channelID);
BufferUtil.putUTF8(byteBuffer, protocol == null ? null : protocol.getType());
handleBuffer(buffer);
@@ -95,29 +93,19 @@ public class ControlChannel extends Channel
return acknowledged;
}
- public boolean deregisterChannel(short channelIndex, long timeout)
+ public void deregisterChannel(short channelID, long timeout)
{
if (TRACER.isEnabled())
{
- TRACER.format("Deregistering channel {0}", channelIndex);
+ TRACER.format("Deregistering channel {0}", channelID);
}
- assertValidChannelIndex(channelIndex);
- ISynchronizer<Boolean> acknowledgement = acknowledgements.correlate(channelIndex);
-
+ assertValidChannelID(channelID);
IBuffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_INDEX);
byteBuffer.put(OPCODE_DEREGISTRATION);
- byteBuffer.putShort(channelIndex);
+ byteBuffer.putShort(channelID);
handleBuffer(buffer);
-
- Boolean acknowledged = acknowledgement.get(timeout);
- if (acknowledged == null)
- {
- throw new TimeoutRuntimeException("Deregistration timeout after " + timeout + " milliseconds");
- }
-
- return acknowledged;
}
@Override
@@ -147,15 +135,15 @@ public class ControlChannel extends Channel
case OPCODE_REGISTRATION:
{
assertConnected();
- short channelIndex = byteBuffer.getShort();
- assertValidChannelIndex(channelIndex);
+ short channelID = byteBuffer.getShort();
+ assertValidChannelID(channelID);
boolean success = true;
try
{
byte[] handlerFactoryUTF8 = BufferUtil.getByteArray(byteBuffer);
String protocolID = BufferUtil.fromUTF8(handlerFactoryUTF8);
- InternalChannel channel = getConnector().inverseOpenChannel(channelIndex, protocolID);
+ InternalChannel channel = getConnector().inverseOpenChannel(channelID, protocolID);
if (channel == null)
{
throw new ConnectorException("Could not open channel");
@@ -167,41 +155,37 @@ public class ControlChannel extends Channel
success = false;
}
- sendStatus(OPCODE_REGISTRATION_ACK, channelIndex, success);
+ sendStatus(OPCODE_REGISTRATION_ACK, channelID, success);
break;
}
case OPCODE_DEREGISTRATION:
{
assertConnected();
- boolean success = true;
- short channelIndex = byteBuffer.getShort();
- if (channelIndex == CONTROL_CHANNEL_INDEX)
+ short channelID = byteBuffer.getShort();
+ if (channelID == CONTROL_CHANNEL_INDEX)
{
throw new ImplementationError();
}
try
{
- getConnector().inverseCloseChannel(channelIndex);
+ getConnector().inverseCloseChannel(channelID);
}
catch (Exception ex)
{
OM.LOG.error(ex);
- success = false;
}
- sendStatus(OPCODE_DEREGISTRATION_ACK, channelIndex, success);
break;
}
case OPCODE_REGISTRATION_ACK:
- case OPCODE_DEREGISTRATION_ACK:
{
assertConnected();
- short channelIndex = byteBuffer.getShort();
+ short channelID = byteBuffer.getShort();
boolean success = byteBuffer.get() == SUCCESS;
- acknowledgements.put(channelIndex, success);
+ acknowledgements.put(channelID, success);
break;
}
@@ -225,15 +209,15 @@ public class ControlChannel extends Channel
@Override
protected void doDeactivate() throws Exception
{
- finishDeactivate(true);
+ // Do nothing
}
- private void sendStatus(byte opcode, short channelIndex, boolean status)
+ private void sendStatus(byte opcode, short channelID, boolean status)
{
IBuffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_INDEX);
byteBuffer.put(opcode);
- byteBuffer.putShort(channelIndex);
+ byteBuffer.putShort(channelID);
byteBuffer.put(status ? SUCCESS : FAILURE);
handleBuffer(buffer);
}
@@ -255,11 +239,11 @@ public class ControlChannel extends Channel
}
}
- private void assertValidChannelIndex(short channelIndex)
+ private void assertValidChannelID(short channelID)
{
- if (channelIndex <= CONTROL_CHANNEL_INDEX)
+ if (channelID <= CONTROL_CHANNEL_INDEX)
{
- throw new IllegalArgumentException("channelIndex <= CONTROL_CHANNEL_ID"); //$NON-NLS-1$
+ throw new IllegalArgumentException("channelID <= CONTROL_CHANNEL_ID"); //$NON-NLS-1$
}
}
}
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
index 2edb683b9a..2ebea8b1fe 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPAcceptor.java
@@ -18,7 +18,7 @@ import org.eclipse.net4j.util.concurrent.Worker;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.internal.net4j.acceptor.Acceptor;
+import org.eclipse.spi.net4j.Acceptor;
import java.io.IOException;
import java.net.InetAddress;
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
index 873b3cfce9..ffdb6c41e6 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.internal.tcp;
import org.eclipse.net4j.buffer.IBuffer;
+import org.eclipse.net4j.channel.ChannelException;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.connector.ConnectorState;
@@ -27,8 +28,7 @@ import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.net4j.util.security.NegotiationContext;
import org.eclipse.net4j.util.security.NegotiationException;
-import org.eclipse.internal.net4j.connector.Connector;
-
+import org.eclipse.spi.net4j.Connector;
import org.eclipse.spi.net4j.InternalChannel;
import java.io.IOException;
@@ -171,9 +171,9 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
ByteBuffer byteBuffer = inputBuffer.startGetting(socketChannel);
if (byteBuffer != null)
{
- short channelIndex = inputBuffer.getChannelIndex();
- InternalChannel channel = channelIndex == ControlChannel.CONTROL_CHANNEL_INDEX ? controlChannel
- : getChannel(channelIndex);
+ short channelID = inputBuffer.getChannelID();
+ InternalChannel channel = channelID == ControlChannel.CONTROL_CHANNEL_INDEX ? controlChannel
+ : getChannel(channelID);
if (channel != null)
{
channel.handleBufferFromMultiplexer(inputBuffer);
@@ -282,14 +282,13 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
}
@Override
- protected void registerChannelWithPeer(short channelIndex, long timeout, IProtocol<?> protocol)
- throws ConnectorException
+ protected void registerChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol) throws ChannelException
{
try
{
- if (!controlChannel.registerChannel(channelIndex, timeout, protocol))
+ if (!controlChannel.registerChannel(channelID, timeout, protocol))
{
- throw new ConnectorException("Failed to register channel with peer"); //$NON-NLS-1$
+ throw new ChannelException("Failed to register channel with peer"); //$NON-NLS-1$
}
}
catch (RuntimeException ex)
@@ -303,13 +302,13 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
}
@Override
- protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ConnectorException
+ protected void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ChannelException
{
if (channel != null && channel.getClass() != ControlChannel.class)
{
if (controlChannel != null && isConnected())
{
- controlChannel.deregisterChannel(channel.getIndex(), getChannelTimeout());
+ controlChannel.deregisterChannel(channel.getID(), getChannelTimeout());
}
}
}
@@ -365,7 +364,7 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
{
if (selectionKey == null)
{
- throw new IllegalStateException("selectionKey == null");
+ throw new IllegalStateException("No selection key for connector " + this);
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
index a6399bccb1..4f660f2693 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
@@ -12,7 +12,6 @@ package org.eclipse.net4j.tests;
import org.eclipse.net4j.tests.bugzilla.Bugzilla241463_Test;
import org.eclipse.net4j.util.tests.ExtendedIOTest;
-import org.eclipse.net4j.util.tests.MonitorTest;
import org.eclipse.net4j.util.tests.MultiMapTest;
import org.eclipse.net4j.util.tests.ReferenceValueMapTest;
import org.eclipse.net4j.util.tests.SecurityTest;
@@ -30,7 +29,6 @@ public class AllTests
public static Test suite()
{
TestSuite suite = new TestSuite("Tests for Net4j");
- suite.addTestSuite(MonitorTest.class);
suite.addTestSuite(MultiMapTest.class);
suite.addTestSuite(SortedFileMapTest.class);
suite.addTestSuite(SynchronizingCorrelatorTest.class);
@@ -44,6 +42,7 @@ public class AllTests
suite.addTestSuite(TransportTest.JVM.class);
suite.addTestSuite(TransportTest.TCP.class);
suite.addTestSuite(SignalTest.class);
+ suite.addTestSuite(SignalMonitorTest.class);
suite.addTestSuite(ExceptionTest.class);
suite.addTestSuite(SecurityTest.class);
return suite;
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
index 4b7b75dc43..141ac05052 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
@@ -25,6 +25,7 @@ import org.eclipse.spi.net4j.InternalConnector;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -59,10 +60,10 @@ public abstract class ChannelTest extends AbstractProtocolTest
assertActive(channel);
InternalConnector serverConnector = (InternalConnector)getAcceptor().getAcceptedConnectors()[0];
- List<IChannel> serverChannels = serverConnector.getChannels();
+ Collection<IChannel> serverChannels = serverConnector.getChannels();
assertEquals(1, serverChannels.size());
- IChannel serverChannel = serverChannels.get(0);
+ IChannel serverChannel = serverChannels.iterator().next();
serverChannel.addListener(deactivationListener);
assertActive(serverChannel);
@@ -72,9 +73,10 @@ public abstract class ChannelTest extends AbstractProtocolTest
protocol.close();
assertInactive(protocol);
- assertEquals(0, serverConnector.getChannels().size());
assertInactive(channel);
- assertInactive(protocol);
+
+ sleep(50);
+ assertEquals(0, serverConnector.getChannels().size());
assertInactive(serverChannel);
assertInactive(serverProtocol);
@@ -90,10 +92,10 @@ public abstract class ChannelTest extends AbstractProtocolTest
}
}
- public void testSingleThreadNoData1000() throws Exception
+ public void testSingleThreadNoData100() throws Exception
{
disableConsole();
- for (int i = 0; i < 1000; i++)
+ for (int i = 0; i < 100; i++)
{
IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i);
testSingleThreadNoData();
@@ -113,10 +115,10 @@ public abstract class ChannelTest extends AbstractProtocolTest
assertInactive(protocol);
}
- public void testSingleThreadTinyData1000() throws Exception
+ public void testSingleThreadTinyData100() throws Exception
{
disableConsole();
- for (int i = 0; i < 1000; i++)
+ for (int i = 0; i < 100; i++)
{
IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i);
testSingleThreadTinyData();
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java
index d374140a68..d6bed26415 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java
@@ -10,9 +10,10 @@
**************************************************************************/
package org.eclipse.net4j.tests;
-import org.eclipse.net4j.protocol.ClientProtocolFactory;
import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.spi.net4j.ClientProtocolFactory;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
index 88027ba7a9..e6fa3476a5 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
@@ -11,8 +11,7 @@
package org.eclipse.net4j.tests;
import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.SignalRemoteException;
-import org.eclipse.net4j.tests.signal.ExceptionIndication;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.tests.signal.ExceptionRequest;
import org.eclipse.net4j.tests.signal.TestSignalProtocol;
import org.eclipse.net4j.util.io.IOUtil;
@@ -28,17 +27,27 @@ public class ExceptionTest extends AbstractProtocolTest
{
}
+ public void testExceptionInIRequesting() throws Exception
+ {
+ exceptionInPhase(1);
+ }
+
public void testExceptionInIndicating() throws Exception
{
- run(true);
+ exceptionInPhase(2);
}
public void testExceptionInResponding() throws Exception
{
- run(false);
+ exceptionInPhase(3);
}
- private void run(boolean exceptionInIndicating) throws Exception
+ public void testExceptionInConfirming() throws Exception
+ {
+ exceptionInPhase(4);
+ }
+
+ private void exceptionInPhase(int phase) throws Exception
{
IConnector connector = startTransport();
TestSignalProtocol protocol = new TestSignalProtocol(connector);
@@ -46,15 +55,31 @@ public class ExceptionTest extends AbstractProtocolTest
try
{
- new ExceptionRequest(protocol, exceptionInIndicating).send();
- fail("SignalRemoteException expected");
+ new ExceptionRequest(protocol, phase).send();
+ fail("Exception expected");
}
- catch (SignalRemoteException success)
+ catch (Exception ex)
{
- IOUtil.print(success);
- ClassNotFoundException cnfe = (ClassNotFoundException)success.getCause();
+ IOUtil.print(ex);
+ ClassNotFoundException cnfe = null;
+ if (phase == 2 || phase == 3)
+ {
+ if (ex instanceof RemoteException)
+ {
+ cnfe = (ClassNotFoundException)ex.getCause();
+ }
+ else
+ {
+ fail("RemoteException expected");
+ }
+ }
+ else
+ {
+ cnfe = (ClassNotFoundException)ex;
+ }
+
AlreadyBoundException abe = (AlreadyBoundException)cnfe.getCause();
- assertEquals(ExceptionIndication.SIMULATED_EXCEPTION, abe.getMessage());
+ assertEquals(TestSignalProtocol.SIMULATED_EXCEPTION, abe.getMessage());
}
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java
index 0f8b0d2861..9c22ac0fb6 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java
@@ -10,9 +10,10 @@
**************************************************************************/
package org.eclipse.net4j.tests;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
import java.util.concurrent.CountDownLatch;
/**
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java
new file mode 100644
index 0000000000..88ee40d1af
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java
@@ -0,0 +1,196 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.tests;
+
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+import org.eclipse.net4j.util.om.monitor.Monitor;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class SignalMonitorTest extends AbstractTransportTest
+{
+ public static final String PROTOCOL_TYPE = "protocol";
+
+ public static final short SIGNAL_ID = 1;
+
+ @Override
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = super.createContainer();
+ container.registerFactory(new ServerProtocolFactory(PROTOCOL_TYPE)
+ {
+ public Object create(String description) throws ProductCreationException
+ {
+ return new SignalProtocol<Object>()
+ {
+ public String getType()
+ {
+ return PROTOCOL_TYPE;
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case SIGNAL_ID:
+ return new IndicationWithMonitoring(this, SIGNAL_ID)
+ {
+ @Override
+ protected void indicating(ExtendedDataInputStream in, IMonitor monitor) throws Exception
+ {
+ monitor.begin(101);
+
+ try
+ {
+ in.readBoolean();
+ monitor.worked(1);
+
+ for (int i = 0; i < 100; i++)
+ {
+ // if (i == 60)
+ // {
+ // Thread.sleep(5000);
+ // }
+
+ Thread.sleep(100);
+ monitor.worked(1);
+ }
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out, IMonitor monitor) throws Exception
+ {
+ monitor.begin(1);
+
+ try
+ {
+ out.writeBoolean(true);
+ monitor.worked(1);
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+
+ default:
+ return null;
+ }
+ }
+ };
+ }
+ });
+
+ return container;
+ }
+
+ public void testMonitorProgress() throws Exception
+ {
+ startTransport();
+ SignalProtocol<Object> protocol = new ClientProtocol();
+ protocol.open(getConnector());
+
+ RequestWithMonitoring<Boolean> request = new RequestWithMonitoring<Boolean>(protocol, SIGNAL_ID)
+ {
+ @Override
+ protected void requesting(ExtendedDataOutputStream out, IMonitor monitor) throws Exception
+ {
+ monitor.begin(1);
+
+ try
+ {
+ out.writeBoolean(true);
+ monitor.worked(1);
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in, IMonitor monitor) throws Exception
+ {
+ monitor.begin(1);
+
+ try
+ {
+ boolean result = in.readBoolean();
+ monitor.worked(1);
+ return result;
+ }
+ finally
+ {
+ monitor.done();
+ }
+
+ }
+ };
+
+ request.send(4000L, new TestMonitor());
+ protocol.close();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class ClientProtocol extends SignalProtocol<Object>
+ {
+ public String getType()
+ {
+ return PROTOCOL_TYPE;
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class TestMonitor extends Monitor
+ {
+ @Override
+ public void begin(int totalWork)
+ {
+ super.begin(totalWork);
+ System.out.println("totalWork: " + getTotalWork());
+ }
+
+ @Override
+ public void worked(int work)
+ {
+ super.worked(work);
+ System.out.println("work: " + getWork());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index 9607845ac6..b7e4359287 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -84,7 +84,7 @@ public class SignalTest extends AbstractProtocolTest
for (int i = 0; i < 10000; i++)
{
msg("Loop " + i);
- new AsyncRequest(protocol, data).send();
+ new AsyncRequest(protocol, data).sendAsync();
String result = new StringRequest(protocol, data).send();
assertEquals(data, result);
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
index 49d3ac5891..50bfa70090 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
@@ -11,9 +11,10 @@
package org.eclipse.net4j.tests;
import org.eclipse.net4j.buffer.IBuffer;
-import org.eclipse.net4j.protocol.Protocol;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.spi.net4j.Protocol;
+
import java.util.concurrent.CountDownLatch;
/**
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
index 24e4a308e4..3489808e27 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
@@ -65,7 +65,7 @@ public abstract class TransportTest extends AbstractProtocolTest
for (int i = 0; i < 3; i++)
{
IBuffer buffer = provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getIndex());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getID());
byteBuffer.putInt(1970);
channel.sendBuffer(buffer);
}
@@ -83,7 +83,7 @@ public abstract class TransportTest extends AbstractProtocolTest
for (int i = 0; i < COUNT; i++)
{
IBuffer buffer = provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getIndex());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getID());
byteBuffer.putInt(1970);
channel.sendBuffer(buffer);
sleep(50);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla241463_Test.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla241463_Test.java
index ac71a86745..e32067666a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla241463_Test.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla241463_Test.java
@@ -11,7 +11,6 @@
package org.eclipse.net4j.tests.bugzilla;
import org.eclipse.net4j.TransportInjector;
-import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.internal.tcp.TCPAcceptor;
import org.eclipse.net4j.internal.tcp.TCPAcceptorFactory;
@@ -23,10 +22,8 @@ import org.eclipse.net4j.tcp.ITCPAcceptor;
import org.eclipse.net4j.tests.AbstractTransportTest;
import org.eclipse.net4j.tests.signal.TestSignalProtocol;
import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.ManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.security.RandomizerFactory;
import org.eclipse.internal.net4j.ExecutorServiceFactory;
@@ -69,25 +66,10 @@ public class Bugzilla241463_Test extends AbstractTransportTest
try
{
new TestSignalProtocol(connector);
- fail("TimeoutRuntimeException expected");
+ fail("Exception expected");
}
- catch (ConnectorException expected)
+ catch (Exception expected)
{
- if (expected.getCause().getClass() != TimeoutRuntimeException.class)
- {
- fail("TimeoutRuntimeException expected");
- }
-
- // Success
- }
- catch (TimeoutRuntimeException expected)
- {
- // Success
- }
- catch (Throwable wrongException)
- {
- IOUtil.print(wrongException);
- fail("TimeoutRuntimeException expected");
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
index cea34a3d22..dca22b1a78 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
index 0eca61f29e..df901d949f 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
index f1dab4ed81..c96e548593 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
index 2f0c780b28..e1dfbf67ff 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
index 9344cd0b2b..fbfc501f51 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
@@ -14,62 +14,41 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import java.rmi.AlreadyBoundException;
-
/**
* @author Eike Stepper
*/
public class ExceptionIndication extends IndicationWithResponse
{
- public static final String SIMULATED_EXCEPTION = "Simulated exception";
-
- private boolean exceptionInIndicating;
+ private int phase;
public ExceptionIndication(TestSignalProtocol protocol)
{
super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
}
- public boolean isExceptionInIndicating()
+ public int getPhase()
{
- return exceptionInIndicating;
+ return phase;
}
@Override
protected void indicating(ExtendedDataInputStream in) throws Exception
{
- exceptionInIndicating = in.readBoolean();
- if (exceptionInIndicating)
+ phase = in.readInt();
+ if (phase == 2)
{
- throwException();
+ ((TestSignalProtocol)getProtocol()).throwException();
}
}
@Override
protected void responding(ExtendedDataOutputStream out) throws Exception
{
- if (!exceptionInIndicating)
+ if (phase == 3)
{
- throwException();
+ ((TestSignalProtocol)getProtocol()).throwException();
}
out.writeBoolean(true);
}
-
- private void throwException() throws Exception
- {
- try
- {
- throwNestedException();
- }
- catch (Exception ex)
- {
- throw new ClassNotFoundException(SIMULATED_EXCEPTION, ex);
- }
- }
-
- private void throwNestedException() throws Exception
- {
- throw new AlreadyBoundException(SIMULATED_EXCEPTION);
- }
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
index 00ccbe6940..dd125f02b2 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
@@ -14,29 +14,38 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
public class ExceptionRequest extends RequestWithConfirmation<Boolean>
{
- private boolean exceptionInIndicating;
+ private int phase;
- public ExceptionRequest(TestSignalProtocol protocol, boolean exceptionInIndicating)
+ public ExceptionRequest(TestSignalProtocol protocol, int phase)
{
super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
- this.exceptionInIndicating = exceptionInIndicating;
+ this.phase = phase;
}
@Override
protected void requesting(ExtendedDataOutputStream out) throws Exception
{
- out.writeBoolean(exceptionInIndicating);
+ out.writeInt(phase);
+ if (phase == 1)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException();
+ }
+
}
@Override
protected Boolean confirming(ExtendedDataInputStream in) throws Exception
{
+ if (phase == 4)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException();
+ }
+
return in.readBoolean();
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
index 25f71c2ea0..5fae4d6097 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
index 863088446a..69ddcdf31a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
index 4597bde668..62b59f5dec 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
index 36b728f732..26b18a0634 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
index a496bfea30..784c2e2260 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
@@ -14,7 +14,6 @@ import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
index 81c68b66df..385fdd1fb1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
index 679f97e1d9..b8e7743eaf 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
@@ -11,11 +11,14 @@
package org.eclipse.net4j.tests.signal;
import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+import java.rmi.AlreadyBoundException;
+
/**
* @author Eike Stepper
*/
@@ -35,6 +38,8 @@ public class TestSignalProtocol extends SignalProtocol<Object>
public static final short SIGNAL_EXCEPTION = 6;
+ public static final String SIMULATED_EXCEPTION = "Simulated exception";
+
public TestSignalProtocol(IConnector connector)
{
open(connector);
@@ -77,6 +82,23 @@ public class TestSignalProtocol extends SignalProtocol<Object>
}
}
+ public void throwException() throws Exception
+ {
+ try
+ {
+ throwNestedException();
+ }
+ catch (Exception ex)
+ {
+ throw new ClassNotFoundException(SIMULATED_EXCEPTION, ex);
+ }
+ }
+
+ public void throwNestedException() throws Exception
+ {
+ throw new AlreadyBoundException(SIMULATED_EXCEPTION);
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java
index 31705f95b0..2a8b3a4dc9 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.net4j.util.ui.views.IElementFilter;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.graphics.Image;
@@ -87,7 +88,7 @@ public class Net4jItemProvider extends ContainerItemProvider<IContainer<Object>>
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
LifecycleUtil.deactivateNoisy(object);
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerItemProvider.java
index b1a10e380a..995478b69c 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jContainerItemProvider.java
@@ -18,6 +18,7 @@ import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.net4j.util.ui.views.IElementFilter;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.graphics.Image;
@@ -64,7 +65,7 @@ public class Net4jContainerItemProvider extends ContainerItemProvider<IContainer
}
@Override
- protected void doRun() throws Exception
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
for (Iterator<?> it = selection.iterator(); it.hasNext();)
{
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
index d213e310d1..0c00651b33 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
@@ -11,11 +11,12 @@
package org.eclipse.net4j.util.ui.actions;
import org.eclipse.net4j.util.internal.ui.bundle.OM;
-import org.eclipse.net4j.util.om.monitor.MonitorUtil;
-import org.eclipse.net4j.util.om.monitor.MonitoredJob;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
@@ -153,20 +154,20 @@ public abstract class LongRunningAction extends SafeAction
preRun();
if (totalWork != 0)
{
- new MonitoredJob(getBundleID(), getText())
+ new Job(getText())
{
@Override
- protected void run() throws Exception
+ protected IStatus run(IProgressMonitor progressMonitor)
{
try
{
- MonitorUtil.begin(totalWork);
- doRun();
+ doRun(progressMonitor);
+ return Status.OK_STATUS;
}
catch (Exception ex)
{
OM.LOG.error(ex);
- throw ex;
+ return new Status(IStatus.ERROR, OM.BUNDLE_ID, ex.getMessage(), ex);
}
}
}.schedule();
@@ -182,7 +183,10 @@ public abstract class LongRunningAction extends SafeAction
return OM.BUNDLE_ID;
}
- protected abstract void doRun() throws Exception;
+ /**
+ * @since 2.0
+ */
+ protected abstract void doRun(IProgressMonitor progressMonitor) throws Exception;
protected final void checkCancelation(IProgressMonitor monitor)
{
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningActionDelegate.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningActionDelegate.java
index c90808d42b..5be0135d3b 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningActionDelegate.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningActionDelegate.java
@@ -11,11 +11,12 @@
package org.eclipse.net4j.util.ui.actions;
import org.eclipse.net4j.util.internal.ui.bundle.OM;
-import org.eclipse.net4j.util.om.monitor.MonitorUtil;
-import org.eclipse.net4j.util.om.monitor.MonitoredJob;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
/**
* @author Eike Stepper
@@ -50,20 +51,20 @@ public abstract class LongRunningActionDelegate extends SafeActionDelegate
preRun();
if (totalWork != 0)
{
- new MonitoredJob(getBundleID(), getText())
+ new Job(getText())
{
@Override
- protected void run() throws Exception
+ protected IStatus run(IProgressMonitor progressMonitor)
{
try
{
- MonitorUtil.begin(totalWork);
- doRun();
+ doRun(progressMonitor);
+ return Status.OK_STATUS;
}
catch (Exception ex)
{
OM.LOG.error(ex);
- throw ex;
+ return new Status(IStatus.ERROR, OM.BUNDLE_ID, ex.getMessage(), ex);
}
}
}.schedule();
@@ -79,7 +80,10 @@ public abstract class LongRunningActionDelegate extends SafeActionDelegate
return OM.BUNDLE_ID;
}
- protected abstract void doRun() throws Exception;
+ /**
+ * @since 2.0
+ */
+ protected abstract void doRun(IProgressMonitor progressMonitor) throws Exception;
protected final void checkCancelation(IProgressMonitor monitor)
{
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java
deleted file mode 100644
index c8381ddf0b..0000000000
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorDialog.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.util.ui.widgets;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.om.monitor.MonitorUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * @author Eike Stepper
- */
-public class MonitorDialog extends ProgressMonitorDialog
-{
- public static final int DEFAULT_SHELL_STYLE = SWT.SHELL_TRIM;
-
- private String title;
-
- private IDialogSettings settings;
-
- private MonitorLogDialog log;
-
- public MonitorDialog(Shell parentShell, int shellStyle, String title, IDialogSettings settings)
- {
- super(parentShell);
- setShellStyle(shellStyle);
- this.title = title;
- this.settings = settings;
- }
-
- public MonitorDialog(Shell parentShell, String title, IDialogSettings settings)
- {
- this(parentShell, DEFAULT_SHELL_STYLE, title, settings);
- }
-
- public void run(boolean fork, boolean cancelable, final Runnable runnable)
- {
- try
- {
- log = new MonitorLogDialog(getShell(), getShellStyle(), "Log of " + title, "See the log for details.", settings);
- log.setEmphasizePrefix("Woven class ", "Mixed in ", "Reversioned ");
-
- super.run(fork, cancelable, new IRunnableWithProgress()
- {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
- {
- MonitorUtil.Eclipse.startMonitoring(monitor, log);
- try
- {
- runnable.run();
- }
- catch (RuntimeException ex)
- {
- log.append(ex);
- throw ex;
- }
- finally
- {
- MonitorUtil.Eclipse.stopMonitoring();
- }
- }
- });
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- @Override
- protected void finishedRun()
- {
- super.finishedRun();
- if (log != null)
- {
- log.open();
- }
- }
-
- @Override
- @Deprecated
- public final void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
- throws InvocationTargetException, InterruptedException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void configureShell(Shell newShell)
- {
- super.configureShell(newShell);
- newShell.setText(title);
- }
-
- @Override
- protected IDialogSettings getDialogBoundsSettings()
- {
- if (settings == null)
- {
- return null;
- }
-
- IDialogSettings section = settings.getSection(title);
- if (section == null)
- {
- section = settings.addNewSection(title);
- }
-
- return section;
- }
-}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java
deleted file mode 100644
index 2837e5bf11..0000000000
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/MonitorLogDialog.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.util.ui.widgets;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitorHandler;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.TextStyle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Eike Stepper
- */
-public class MonitorLogDialog extends LogDialog implements OMMonitorHandler
-{
- private String[] emphasizePrefix;
-
- private TextStyle taskStyle;
-
- private TextStyle normalStyle;
-
- private TextStyle emphasizedStyle;
-
- private TextStyle problemStyle;
-
- public MonitorLogDialog(Shell parentShell, int shellStyle, String title, String message, IDialogSettings settings)
- {
- super(parentShell, shellStyle, title, message, settings);
- Display display = Display.getCurrent();
- taskStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLACK), null);
- normalStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_DARK_GRAY), null);
- emphasizedStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_BLUE), null);
- problemStyle = new TextStyle(null, display.getSystemColor(SWT.COLOR_RED), null);
- }
-
- public MonitorLogDialog(Shell parentShell, String title, String message, IDialogSettings settings)
- {
- this(parentShell, DEFAULT_SHELL_STYLE, title, message, settings);
- }
-
- public String[] getEmphasizePrefix()
- {
- return emphasizePrefix;
- }
-
- public void setEmphasizePrefix(String... emphasizePrefix)
- {
- this.emphasizePrefix = emphasizePrefix;
- }
-
- public TextStyle getNormalStyle()
- {
- return normalStyle;
- }
-
- public TextStyle getTaskStyle()
- {
- return taskStyle;
- }
-
- public TextStyle getProblemStyle()
- {
- return problemStyle;
- }
-
- public TextStyle getEmphasizedStyle()
- {
- return emphasizedStyle;
- }
-
- public void handleTask(String task, int level)
- {
- setTextStyle(taskStyle);
- append(task);
- append("\n");
- }
-
- public void handleMessage(String msg, int level)
- {
- boolean emphasized = false;
- if (emphasizePrefix != null)
- {
- for (String prefix : emphasizePrefix)
- {
- if (msg.startsWith(prefix))
- {
- setTextStyle(emphasizedStyle);
- emphasized = true;
- break;
- }
- }
- }
-
- if (!emphasized)
- {
- setTextStyle(normalStyle);
- }
-
- append(msg);
- append("\n");
- }
-
- @Override
- public void append(Throwable t)
- {
- setTextStyle(problemStyle);
- super.append(t);
- }
-}
diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
index 8c6e9c65a3..debdc8a8e2 100644
--- a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
@@ -18,7 +18,6 @@ Export-Package: org.eclipse.net4j.internal.util.bundle;version="2.0.0";x-friends
org.eclipse.net4j.internal.util.container;version="2.0.0";x-internal:=true,
org.eclipse.net4j.internal.util.factory;version="2.0.0";x-internal:=true,
org.eclipse.net4j.internal.util.om;version="2.0.0";x-internal:=true,
- org.eclipse.net4j.internal.util.om.monitor;version="2.0.0";x-internal:=true,
org.eclipse.net4j.internal.util.om.pref;version="2.0.0";x-internal:=true,
org.eclipse.net4j.util;version="2.0.0",
org.eclipse.net4j.util.cache;version="2.0.0",
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java b/plugins/org.eclipse.net4j.util/monitor/DelegatingMonitor.java
index 18d7e0c996..18d7e0c996 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/DelegatingMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java b/plugins/org.eclipse.net4j.util/monitor/IllegalMonitorNestingException.java
index 92dbda2735..92dbda2735 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/IllegalMonitorNestingException.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java b/plugins/org.eclipse.net4j.util/monitor/MonitorAlreadyBegunException.java
index 19f44dea46..19f44dea46 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorAlreadyBegunException.java
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalRemoteException.java b/plugins/org.eclipse.net4j.util/monitor/MonitorCanceledException.java
index 3fa69c6429..92f3224f61 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalRemoteException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorCanceledException.java
@@ -8,31 +8,30 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.signal;
+package org.eclipse.net4j.util.om.monitor;
/**
* @author Eike Stepper
- * @since 2.0
*/
-public class SignalRemoteException extends RuntimeException
+public class MonitorCanceledException extends MonitorException
{
private static final long serialVersionUID = 1L;
- public SignalRemoteException()
+ public MonitorCanceledException()
{
}
- public SignalRemoteException(String message)
+ public MonitorCanceledException(String s)
{
- super(message);
+ super(s);
}
- public SignalRemoteException(Throwable cause)
+ public MonitorCanceledException(Throwable cause)
{
super(cause);
}
- public SignalRemoteException(String message, Throwable cause)
+ public MonitorCanceledException(String message, Throwable cause)
{
super(message, cause);
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java b/plugins/org.eclipse.net4j.util/monitor/MonitorException.java
index c39fb00426..c39fb00426 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorException.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java b/plugins/org.eclipse.net4j.util/monitor/MonitorNotBegunException.java
index e4d31e6269..e4d31e6269 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorNotBegunException.java
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java b/plugins/org.eclipse.net4j.util/monitor/MonitorTest.java
index 8bcab480bd..8bcab480bd 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorTest.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java b/plugins/org.eclipse.net4j.util/monitor/MonitorUtil.java
index b139567a18..b139567a18 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitorUtil.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java b/plugins/org.eclipse.net4j.util/monitor/MonitoredJob.java
index abf85017fc..abf85017fc 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java
+++ b/plugins/org.eclipse.net4j.util/monitor/MonitoredJob.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java b/plugins/org.eclipse.net4j.util/monitor/OMMonitor.java
index 3ba918ecec..3ba918ecec 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/OMMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java b/plugins/org.eclipse.net4j.util/monitor/OMMonitorHandler.java
index 6f7be296ea..6f7be296ea 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java
+++ b/plugins/org.eclipse.net4j.util/monitor/OMMonitorHandler.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java b/plugins/org.eclipse.net4j.util/monitor/OMSubMonitor.java
index 08c0e10d58..08c0e10d58 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/OMSubMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/monitor/SynchonizedSubProgressMonitor.java b/plugins/org.eclipse.net4j.util/monitor/SynchonizedSubProgressMonitor.java
new file mode 100644
index 0000000000..ca3ebfa454
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/monitor/SynchonizedSubProgressMonitor.java
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util.om.monitor;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+/**
+ * A sub progress monitor that synchronizes all methods on the parent monitor instance.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public final class SynchonizedSubProgressMonitor extends SubProgressMonitor
+{
+ public SynchonizedSubProgressMonitor(IProgressMonitor monitor, int ticks)
+ {
+ super(monitor, ticks);
+ }
+
+ @Override
+ public void beginTask(String name, int totalWork)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.beginTask(name, totalWork);
+ }
+ }
+
+ @Override
+ public void clearBlocked()
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.clearBlocked();
+ }
+ }
+
+ @Override
+ public void done()
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.done();
+ }
+ }
+
+ @Override
+ public void internalWorked(double work)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.internalWorked(work);
+ }
+ }
+
+ @Override
+ public boolean isCanceled()
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ return super.isCanceled();
+ }
+ }
+
+ @Override
+ public void setBlocked(IStatus reason)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.setBlocked(reason);
+ }
+ }
+
+ @Override
+ public void setCanceled(boolean b)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.setCanceled(b);
+ }
+ }
+
+ @Override
+ public void setTaskName(String name)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.setTaskName(name);
+ }
+ }
+
+ @Override
+ public void subTask(String name)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.subTask(name);
+ }
+ }
+
+ @Override
+ public void worked(int work)
+ {
+ synchronized (getWrappedProgressMonitor())
+ {
+ super.worked(work);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java b/plugins/org.eclipse.net4j.util/monitor/TotalWorkExceededException.java
index 6fbdeeb10d..6fbdeeb10d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java
+++ b/plugins/org.eclipse.net4j.util/monitor/TotalWorkExceededException.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java b/plugins/org.eclipse.net4j.util/monitor/impl/EclipseMonitor.java
index 03f8cafb62..03f8cafb62 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/impl/EclipseMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java b/plugins/org.eclipse.net4j.util/monitor/impl/LegacyMonitor.java
index cb5e8ddb18..cb5e8ddb18 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/impl/LegacyMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java b/plugins/org.eclipse.net4j.util/monitor/impl/MON.java
index 430a74572e..430a74572e 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java
+++ b/plugins/org.eclipse.net4j.util/monitor/impl/MON.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java b/plugins/org.eclipse.net4j.util/monitor/impl/Monitor.java
index b59bbd6a0b..b59bbd6a0b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/impl/Monitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java b/plugins/org.eclipse.net4j.util/monitor/impl/NullMonitor.java
index 1390d8f36d..1390d8f36d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java
+++ b/plugins/org.eclipse.net4j.util/monitor/impl/NullMonitor.java
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IErrorHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IErrorHandler.java
new file mode 100644
index 0000000000..8503f023e5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IErrorHandler.java
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface IErrorHandler
+{
+ public void handleError(Throwable t);
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ResultSynchronizer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ResultSynchronizer.java
index ee321f527d..1241733eb2 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ResultSynchronizer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ResultSynchronizer.java
@@ -10,8 +10,6 @@
**************************************************************************/
package org.eclipse.net4j.util.concurrent;
-import org.eclipse.net4j.util.om.monitor.MonitorUtil;
-
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -47,11 +45,6 @@ public final class ResultSynchronizer<RESULT> implements ISynchronizer<RESULT>
return null;
}
- if (MonitorUtil.isCanceled())
- {
- return null;
- }
-
consumerLock.wait(Math.min(remaining, 100L));
}
catch (InterruptedException ex)
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/EclipseMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/EclipseMonitor.java
new file mode 100644
index 0000000000..ef63dd5480
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/EclipseMonitor.java
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util.om.monitor;
+
+import org.eclipse.net4j.util.StringUtil;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class EclipseMonitor extends Monitor
+{
+ private IProgressMonitor progressMonitor;
+
+ private String taskName;
+
+ public EclipseMonitor(IProgressMonitor progressMonitor, String taskName)
+ {
+ this.progressMonitor = progressMonitor;
+ this.taskName = taskName;
+ }
+
+ public EclipseMonitor(IProgressMonitor progressMonitor)
+ {
+ this(progressMonitor, StringUtil.EMPTY);
+ }
+
+ public String getTaskName()
+ {
+ return taskName;
+ }
+
+ @Override
+ public boolean isCanceled()
+ {
+ if (super.isCanceled())
+ {
+ return true;
+ }
+
+ return progressMonitor.isCanceled();
+ }
+
+ @Override
+ public synchronized void begin(int totalWork) throws MonitorCanceledException
+ {
+ super.begin(totalWork);
+ progressMonitor.beginTask(taskName, totalWork);
+ }
+
+ @Override
+ public synchronized void worked(int work) throws MonitorCanceledException
+ {
+ super.worked(work);
+ progressMonitor.worked(work);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IMonitor.java
new file mode 100644
index 0000000000..6fb5c298cb
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IMonitor.java
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util.om.monitor;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface IMonitor
+{
+ public boolean isCanceled();
+
+ public void checkCanceled() throws MonitorCanceledException;
+
+ public void begin(int totalWork) throws MonitorCanceledException;
+
+ public void worked(int work) throws MonitorCanceledException;
+
+ public void done();
+
+ public int getTotalWork();
+
+ public int getWork();
+
+ public IMonitor fork(int work);
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/Monitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/Monitor.java
new file mode 100644
index 0000000000..4dab08d9ab
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/Monitor.java
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util.om.monitor;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class Monitor implements IMonitor
+{
+ private int totalWork;
+
+ private int work;
+
+ private boolean canceled;
+
+ public Monitor()
+ {
+ }
+
+ public synchronized void cancel()
+ {
+ canceled = true;
+ }
+
+ public synchronized void checkCanceled() throws MonitorCanceledException
+ {
+ if (isCanceled())
+ {
+ throw new MonitorCanceledException();
+ }
+ }
+
+ public synchronized void begin(int totalWork) throws MonitorCanceledException
+ {
+ this.totalWork = totalWork;
+ }
+
+ public synchronized void worked(int work) throws MonitorCanceledException
+ {
+ this.work += work;
+ }
+
+ public synchronized IMonitor fork(int work)
+ {
+ return new NestedMonitor(this, work);
+ }
+
+ public synchronized void done()
+ {
+ int rest = totalWork - work;
+ if (rest > 0)
+ {
+ worked(rest);
+ }
+ }
+
+ public synchronized int getTotalWork()
+ {
+ return totalWork;
+ }
+
+ public synchronized int getWork()
+ {
+ return work;
+ }
+
+ public synchronized boolean isCanceled()
+ {
+ return canceled;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java
index 92f3224f61..f675834e13 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java
@@ -12,8 +12,9 @@ package org.eclipse.net4j.util.om.monitor;
/**
* @author Eike Stepper
+ * @since 2.0
*/
-public class MonitorCanceledException extends MonitorException
+public class MonitorCanceledException extends RuntimeException
{
private static final long serialVersionUID = 1L;
@@ -21,9 +22,9 @@ public class MonitorCanceledException extends MonitorException
{
}
- public MonitorCanceledException(String s)
+ public MonitorCanceledException(String message)
{
- super(s);
+ super(message);
}
public MonitorCanceledException(Throwable cause)
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NestedMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NestedMonitor.java
new file mode 100644
index 0000000000..5e9dd9ee64
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NestedMonitor.java
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.util.om.monitor;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class NestedMonitor extends Monitor
+{
+ private IMonitor parent;
+
+ private int parentWork;
+
+ private float propagateWork;
+
+ public NestedMonitor(IMonitor parent, int parentWork)
+ {
+ this.parent = parent;
+ this.parentWork = parentWork;
+ }
+
+ public IMonitor getParent()
+ {
+ return parent;
+ }
+
+ public int getParentWork()
+ {
+ return parentWork;
+ }
+
+ @Override
+ public synchronized void worked(int work) throws MonitorCanceledException
+ {
+ super.worked(work);
+ float ratio = getWork();
+ ratio /= getTotalWork();
+ propagateWork += ratio;
+
+ int parentTicks = (int)Math.floor(propagateWork * getParentWork());
+ if (parentTicks > 0)
+ {
+ parent.worked(parentTicks);
+ float rest = parentTicks;
+ rest /= getParentWork();
+ propagateWork -= rest;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
index e5c660af87..35b21c8595 100644
--- a/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j/META-INF/MANIFEST.MF
@@ -19,14 +19,6 @@ Export-Package: org.eclipse.internal.net4j;version="2.0.0";
org.eclipse.net4j.http.common,
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests",
- org.eclipse.internal.net4j.acceptor;version="2.0.0";
- x-friends:="org.eclipse.net4j.http.server,
- org.eclipse.net4j.jvm,
- org.eclipse.net4j.tcp,
- org.eclipse.net4j.http,
- org.eclipse.net4j.http.common,
- org.eclipse.net4j.http.tests,
- org.eclipse.net4j.tests",
org.eclipse.internal.net4j.buffer;version="2.0.0";
x-friends:="org.eclipse.net4j.http.server,
org.eclipse.net4j.jvm,
@@ -36,22 +28,6 @@ Export-Package: org.eclipse.internal.net4j;version="2.0.0";
org.eclipse.net4j.http.tests,
org.eclipse.net4j.tests",
org.eclipse.internal.net4j.bundle;version="2.0.0";x-internal:=true,
- org.eclipse.internal.net4j.channel;version="2.0.0";
- x-friends:="org.eclipse.net4j.http,
- org.eclipse.net4j.http.common,
- org.eclipse.net4j.http.server,
- org.eclipse.net4j.tcp,
- org.eclipse.net4j.http.tests,
- org.eclipse.net4j.tests,
- org.eclipse.net4j.jvm",
- org.eclipse.internal.net4j.connector;version="2.0.0";
- x-friends:="org.eclipse.net4j.http,
- org.eclipse.net4j.http.common,
- org.eclipse.net4j.http.server,
- org.eclipse.net4j.jvm,
- org.eclipse.net4j.tcp,
- org.eclipse.net4j.http.tests,
- org.eclipse.net4j.tests",
org.eclipse.net4j;version="2.0.0",
org.eclipse.net4j.acceptor;version="2.0.0",
org.eclipse.net4j.buffer;version="2.0.0",
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
index 90effe2563..5e1a1f0f3e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
@@ -14,6 +14,7 @@ import org.eclipse.net4j.buffer.BufferState;
import org.eclipse.net4j.buffer.IBuffer;
import org.eclipse.net4j.buffer.IBufferProvider;
import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.IErrorHandler;
import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -36,9 +37,11 @@ public class Buffer implements InternalBuffer
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_BUFFER, Buffer.class);
+ private IErrorHandler errorHandler;
+
private IBufferProvider bufferProvider;
- private short channelIndex;
+ private short channelID;
private boolean eos;
@@ -72,14 +75,14 @@ public class Buffer implements InternalBuffer
this.bufferProvider = bufferProvider;
}
- public short getChannelIndex()
+ public short getChannelID()
{
if (state == BufferState.INITIAL || state == BufferState.READING_HEADER)
{
throw new IllegalStateException("state == " + state); //$NON-NLS-1$
}
- return channelIndex;
+ return channelID;
}
public short getCapacity()
@@ -107,6 +110,7 @@ public class Buffer implements InternalBuffer
*/
public void release()
{
+ errorHandler = null;
if (bufferProvider != null)
{
bufferProvider.retainBuffer(this);
@@ -117,7 +121,7 @@ public class Buffer implements InternalBuffer
{
byteBuffer.clear();
state = BufferState.INITIAL;
- channelIndex = NO_CHANNEL;
+ channelID = NO_CHANNEL;
eos = false;
}
@@ -129,21 +133,50 @@ public class Buffer implements InternalBuffer
public ByteBuffer startGetting(SocketChannel socketChannel) throws IOException
{
- if (state != BufferState.INITIAL && state != BufferState.READING_HEADER && state != BufferState.READING_BODY)
+ try
{
- throw new IllegalStateException("state == " + state); //$NON-NLS-1$
- }
+ if (state != BufferState.INITIAL && state != BufferState.READING_HEADER && state != BufferState.READING_BODY)
+ {
+ throw new IllegalStateException("state == " + state); //$NON-NLS-1$
+ }
- if (state == BufferState.INITIAL)
- {
- byteBuffer.limit(IBuffer.HEADER_SIZE);
- state = BufferState.READING_HEADER;
- }
+ if (state == BufferState.INITIAL)
+ {
+ byteBuffer.limit(IBuffer.HEADER_SIZE);
+ state = BufferState.READING_HEADER;
+ }
- if (state == BufferState.READING_HEADER)
- {
- int num = socketChannel.read(byteBuffer);
- if (num == -1)
+ if (state == BufferState.READING_HEADER)
+ {
+ int num = socketChannel.read(byteBuffer);
+ if (num == -1)
+ {
+ throw new ClosedChannelException();
+ }
+
+ if (byteBuffer.hasRemaining())
+ {
+ return null;
+ }
+
+ byteBuffer.flip();
+ channelID = byteBuffer.getShort();
+ short payloadSize = byteBuffer.getShort();
+ if (payloadSize < 0)
+ {
+ eos = true;
+ payloadSize = (short)-payloadSize;
+ }
+
+ payloadSize -= EOS_OFFSET;
+
+ byteBuffer.clear();
+ byteBuffer.limit(payloadSize);
+ state = BufferState.READING_BODY;
+ }
+
+ // state == State.READING_BODY
+ if (socketChannel.read(byteBuffer) == -1)
{
throw new ClosedChannelException();
}
@@ -153,67 +186,69 @@ public class Buffer implements InternalBuffer
return null;
}
- byteBuffer.flip();
- channelIndex = byteBuffer.getShort();
- short payloadSize = byteBuffer.getShort();
- if (payloadSize < 0)
+ if (TRACER.isEnabled())
{
- eos = true;
- payloadSize = (short)-payloadSize;
+ TRACER.trace("Read " + byteBuffer.limit() + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ + (eos ? " (EOS)" : "") + StringUtil.NL + formatContent(false)); //$NON-NLS-1$ //$NON-NLS-2$
}
- payloadSize -= EOS_OFFSET;
-
- byteBuffer.clear();
- byteBuffer.limit(payloadSize);
- state = BufferState.READING_BODY;
+ byteBuffer.flip();
+ state = BufferState.GETTING;
+ return byteBuffer;
}
-
- // state == State.READING_BODY
- if (socketChannel.read(byteBuffer) == -1)
+ catch (IOException ex)
{
- throw new ClosedChannelException();
+ handleError(ex);
+ throw ex;
}
-
- if (byteBuffer.hasRemaining())
+ catch (RuntimeException ex)
{
- return null;
+ handleError(ex);
+ throw ex;
}
-
- if (TRACER.isEnabled())
+ catch (Error ex)
{
- TRACER.trace("Read " + byteBuffer.limit() + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
- + (eos ? " (EOS)" : "") + StringUtil.NL + formatContent(false)); //$NON-NLS-1$ //$NON-NLS-2$
+ handleError(ex);
+ throw ex;
}
-
- byteBuffer.flip();
- state = BufferState.GETTING;
- return byteBuffer;
}
- public ByteBuffer startPutting(short channelIndex)
+ public ByteBuffer startPutting(short channelID)
{
- if (state == BufferState.PUTTING)
+ try
{
- if (channelIndex != this.channelIndex)
+ if (state == BufferState.PUTTING)
+ {
+ if (channelID != this.channelID)
+ {
+ throw new IllegalArgumentException("channelID != this.channelID"); //$NON-NLS-1$
+ }
+ }
+ else if (state != BufferState.INITIAL)
{
- throw new IllegalArgumentException("channelIndex != this.channelIndex"); //$NON-NLS-1$
+ throw new IllegalStateException("state: " + state); //$NON-NLS-1$
}
+ else
+ {
+ state = BufferState.PUTTING;
+ this.channelID = channelID;
+
+ byteBuffer.clear();
+ byteBuffer.position(IBuffer.HEADER_SIZE);
+ }
+
+ return byteBuffer;
}
- else if (state != BufferState.INITIAL)
+ catch (RuntimeException ex)
{
- throw new IllegalStateException("state: " + state); //$NON-NLS-1$
+ handleError(ex);
+ throw ex;
}
- else
+ catch (Error ex)
{
- state = BufferState.PUTTING;
- this.channelIndex = channelIndex;
-
- byteBuffer.clear();
- byteBuffer.position(IBuffer.HEADER_SIZE);
+ handleError(ex);
+ throw ex;
}
-
- return byteBuffer;
}
/**
@@ -221,62 +256,93 @@ public class Buffer implements InternalBuffer
*/
public boolean write(SocketChannel socketChannel) throws IOException
{
- if (state != BufferState.PUTTING && state != BufferState.WRITING)
+ try
{
- throw new IllegalStateException("state == " + state); //$NON-NLS-1$
- }
+ if (state != BufferState.PUTTING && state != BufferState.WRITING)
+ {
+ throw new IllegalStateException("state == " + state); //$NON-NLS-1$
+ }
- if (state == BufferState.PUTTING)
- {
- if (channelIndex == NO_CHANNEL)
+ if (state == BufferState.PUTTING)
{
- throw new IllegalStateException("channelIndex == NO_CHANNEL"); //$NON-NLS-1$
+ if (channelID == NO_CHANNEL)
+ {
+ throw new IllegalStateException("channelID == NO_CHANNEL"); //$NON-NLS-1$
+ }
+
+ int payloadSize = byteBuffer.position() - IBuffer.HEADER_SIZE + EOS_OFFSET;
+ if (eos)
+ {
+ payloadSize = -payloadSize;
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Writing " + (Math.abs(payloadSize) - 1) + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
+ + (eos ? " (EOS)" : "") + StringUtil.NL + formatContent(false)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ byteBuffer.flip();
+ byteBuffer.putShort(channelID);
+ byteBuffer.putShort((short)payloadSize);
+ byteBuffer.position(0);
+ state = BufferState.WRITING;
}
- int payloadSize = byteBuffer.position() - IBuffer.HEADER_SIZE + EOS_OFFSET;
- if (eos)
+ int numBytes = socketChannel.write(byteBuffer);
+ if (numBytes == -1)
{
- payloadSize = -payloadSize;
+ throw new IOException("Channel closed"); //$NON-NLS-1$
}
- if (TRACER.isEnabled())
+ if (byteBuffer.hasRemaining())
{
- TRACER.trace("Writing " + (Math.abs(payloadSize) - 1) + " bytes" //$NON-NLS-1$ //$NON-NLS-2$
- + (eos ? " (EOS)" : "") + StringUtil.NL + formatContent(false)); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
}
- byteBuffer.flip();
- byteBuffer.putShort(channelIndex);
- byteBuffer.putShort((short)payloadSize);
- byteBuffer.position(0);
- state = BufferState.WRITING;
+ clear();
+ return true;
}
-
- int numBytes = socketChannel.write(byteBuffer);
- if (numBytes == -1)
+ catch (IOException ex)
{
- throw new IOException("Channel closed"); //$NON-NLS-1$
+ handleError(ex);
+ throw ex;
}
-
- if (byteBuffer.hasRemaining())
+ catch (RuntimeException ex)
{
- return false;
+ handleError(ex);
+ throw ex;
+ }
+ catch (Error ex)
+ {
+ handleError(ex);
+ throw ex;
}
-
- clear();
- return true;
}
public void flip()
{
- if (state != BufferState.PUTTING)
+ try
{
- throw new IllegalStateException("state == " + state); //$NON-NLS-1$
- }
+ if (state != BufferState.PUTTING)
+ {
+ throw new IllegalStateException("state == " + state); //$NON-NLS-1$
+ }
- byteBuffer.flip();
- byteBuffer.position(IBuffer.HEADER_SIZE);
- state = BufferState.GETTING;
+ byteBuffer.flip();
+ byteBuffer.position(IBuffer.HEADER_SIZE);
+ state = BufferState.GETTING;
+ }
+ catch (RuntimeException ex)
+ {
+ handleError(ex);
+ throw ex;
+ }
+ catch (Error ex)
+ {
+ handleError(ex);
+ throw ex;
+ }
}
@Override
@@ -319,4 +385,24 @@ public class Buffer implements InternalBuffer
byteBuffer.limit(oldLimit);
}
}
+
+ public IErrorHandler getErrorHandler()
+ {
+ return errorHandler;
+ }
+
+ public void setErrorHandler(IErrorHandler errorHandler)
+ {
+ this.errorHandler = errorHandler;
+ }
+
+ private void handleError(Throwable t)
+ {
+ OM.LOG.error(t);
+ if (errorHandler != null)
+ {
+ errorHandler.handleError(t);
+ release();
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java
deleted file mode 100644
index ef929e6122..0000000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.internal.net4j.connector;
-
-import org.eclipse.net4j.ITransportConfig;
-import org.eclipse.net4j.buffer.IBuffer;
-import org.eclipse.net4j.channel.IChannel;
-import org.eclipse.net4j.channel.IChannelMultiplexer;
-import org.eclipse.net4j.connector.ConnectorException;
-import org.eclipse.net4j.connector.ConnectorState;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.connector.IConnectorStateEvent;
-import org.eclipse.net4j.protocol.ClientProtocolFactory;
-import org.eclipse.net4j.protocol.IProtocol;
-import org.eclipse.net4j.protocol.IProtocolProvider;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
-import org.eclipse.net4j.util.container.Container;
-import org.eclipse.net4j.util.event.Event;
-import org.eclipse.net4j.util.event.INotifier;
-import org.eclipse.net4j.util.factory.FactoryKey;
-import org.eclipse.net4j.util.factory.IFactoryKey;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.monitor.MonitorUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.security.INegotiationContext;
-import org.eclipse.net4j.util.security.INegotiator;
-import org.eclipse.net4j.util.security.NegotiationException;
-
-import org.eclipse.internal.net4j.TransportConfig;
-import org.eclipse.internal.net4j.bundle.OM;
-import org.eclipse.internal.net4j.channel.Channel;
-
-import org.eclipse.spi.net4j.InternalChannel;
-import org.eclipse.spi.net4j.InternalConnector;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public abstract class Connector extends Container<IChannel> implements InternalConnector
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONNECTOR, Connector.class);
-
- private String userID;
-
- private ITransportConfig config;
-
- private long channelTimeout = IChannelMultiplexer.DEFAULT_CHANNEL_TIMEOUT;
-
- private transient ConnectorState connectorState = ConnectorState.DISCONNECTED;
-
- private transient InternalChannel[] channels = {};
-
- @ExcludeFromDump
- private transient Object channelsLock = new Object();
-
- @ExcludeFromDump
- private transient CountDownLatch finishedConnecting;
-
- @ExcludeFromDump
- private transient CountDownLatch finishedNegotiating;
-
- @ExcludeFromDump
- private transient INegotiationContext negotiationContext;
-
- @ExcludeFromDump
- private transient NegotiationException negotiationException;
-
- public Connector()
- {
- }
-
- public synchronized ITransportConfig getConfig()
- {
- if (config == null)
- {
- config = new TransportConfig();
- }
-
- return config;
- }
-
- public synchronized void setConfig(ITransportConfig config)
- {
- checkInactive();
- this.config = config;
- }
-
- public INegotiator getNegotiator()
- {
- return getConfig().getNegotiator();
- }
-
- public void setNegotiator(INegotiator negotiator)
- {
- getConfig().setNegotiator(negotiator);
- }
-
- public INegotiationContext getNegotiationContext()
- {
- return negotiationContext;
- }
-
- public long getChannelTimeout()
- {
- if (channelTimeout == IChannelMultiplexer.DEFAULT_CHANNEL_TIMEOUT)
- {
- return OM.BUNDLE.getDebugSupport().getDebugOption("channel.timeout", 10000);
- }
-
- return channelTimeout;
- }
-
- public void setChannelTimeout(long channelTimeout)
- {
- this.channelTimeout = channelTimeout;
- }
-
- public boolean isClient()
- {
- return getLocation() == Location.CLIENT;
- }
-
- public boolean isServer()
- {
- return getLocation() == Location.SERVER;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public void setUserID(String userID)
- {
- checkState(getState() != ConnectorState.CONNECTED, "Connector is already connected");
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting userID {0} for {1}", userID, this);
- }
-
- this.userID = userID;
- }
-
- public ConnectorState getState()
- {
- return connectorState;
- }
-
- public void setState(ConnectorState newState) throws ConnectorException
- {
- ConnectorState oldState = getState();
- if (newState != oldState)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting state {0} (was {1}) for {2}", newState, oldState.toString().toLowerCase(), this);
- }
-
- connectorState = newState;
- switch (newState)
- {
- case DISCONNECTED:
- if (finishedConnecting != null)
- {
- finishedConnecting.countDown();
- finishedConnecting = null;
- }
-
- if (finishedNegotiating != null)
- {
- finishedNegotiating.countDown();
- finishedNegotiating = null;
- }
- break;
-
- case CONNECTING:
- finishedConnecting = new CountDownLatch(1);
- finishedNegotiating = new CountDownLatch(1);
- // The concrete implementation must advance state to NEGOTIATING or CONNECTED
- break;
-
- case NEGOTIATING:
- finishedConnecting.countDown();
- negotiationContext = createNegotiationContext();
- getNegotiator().negotiate(negotiationContext);
- break;
-
- case CONNECTED:
- negotiationContext = null;
- deferredActivate();
- finishedConnecting.countDown();
- finishedNegotiating.countDown();
- break;
- }
-
- fireEvent(new ConnectorStateEvent(this, oldState, newState));
- }
- }
-
- public boolean isDisconnected()
- {
- return connectorState == ConnectorState.DISCONNECTED;
- }
-
- public boolean isConnecting()
- {
- return connectorState == ConnectorState.CONNECTING;
- }
-
- public boolean isNegotiating()
- {
- return connectorState == ConnectorState.NEGOTIATING;
- }
-
- public boolean isConnected()
- {
- if (negotiationException != null)
- {
- throw new ConnectorException("Connector negotiation failed", negotiationException);
- }
-
- return connectorState == ConnectorState.CONNECTED;
- }
-
- public void connectAsync() throws ConnectorException
- {
- try
- {
- activate();
- }
- catch (ConnectorException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new ConnectorException(ex);
- }
- }
-
- public boolean waitForConnection(long timeout) throws ConnectorException
- {
- final long MAX_POLL_INTERVAL = 100L;
- boolean withTimeout = timeout != NO_TIMEOUT;
-
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Waiting for connection...");
- }
-
- for (;;)
- {
- long t = MAX_POLL_INTERVAL;
- if (withTimeout)
- {
- t = Math.min(MAX_POLL_INTERVAL, timeout);
- timeout -= MAX_POLL_INTERVAL;
- }
-
- if (t <= 0)
- {
- break;
- }
-
- if (finishedNegotiating == null)
- {
- break;
- }
-
- if (finishedNegotiating.await(t, TimeUnit.MILLISECONDS))
- {
- break;
- }
-
- if (MonitorUtil.isCanceled())
- {
- break;
- }
- }
-
- return isConnected();
- }
- catch (InterruptedException ex)
- {
- return false;
- }
- }
-
- public boolean connect(long timeout) throws ConnectorException
- {
- connectAsync();
- return waitForConnection(timeout);
- }
-
- public boolean connect() throws ConnectorException
- {
- return connect(NO_TIMEOUT);
- }
-
- public ConnectorException disconnect()
- {
- Exception ex = deactivate();
- if (ex == null)
- {
- return null;
- }
-
- if (ex instanceof ConnectorException)
- {
- return (ConnectorException)ex;
- }
-
- return new ConnectorException(ex);
- }
-
- public final List<IChannel> getChannels()
- {
- List<IChannel> result = new ArrayList<IChannel>(0);
- synchronized (channelsLock)
- {
- for (int i = 0; i < channels.length; i++)
- {
- IChannel channel = channels[i];
- if (LifecycleUtil.isActive(channel))
- {
- result.add(channel);
- }
- }
- }
-
- return result;
- }
-
- @Override
- public boolean isEmpty()
- {
- return getElements().length == 0;
- }
-
- public IChannel[] getElements()
- {
- List<IChannel> list = getChannels();
- return list.toArray(new IChannel[list.size()]);
- }
-
- public InternalChannel openChannel() throws ConnectorException
- {
- return openChannel((IProtocol<?>)null);
- }
-
- public InternalChannel openChannel(String protocolID, Object infraStructure) throws ConnectorException
- {
- IProtocol<?> protocol = createProtocol(protocolID, infraStructure);
- if (protocol == null)
- {
- throw new IllegalArgumentException("Unknown protocolID: " + protocolID);
- }
-
- return openChannel(protocol);
- }
-
- public InternalChannel openChannel(IProtocol<?> protocol) throws ConnectorException
- {
- long openChannelTimeout = getChannelTimeout();
- long start = System.currentTimeMillis();
- if (!waitForConnection(openChannelTimeout))
- {
- throw new ConnectorException("Connector not connected");
- }
-
- final long elapsed = System.currentTimeMillis() - start;
- InternalChannel channel = createChannel();
- initChannel(channel, protocol);
- addChannelWithoutIndex(channel);
-
- try
- {
- try
- {
- registerChannelWithPeer(channel.getIndex(), openChannelTimeout - elapsed, protocol);
- }
- catch (TimeoutRuntimeException ex)
- {
- // Adjust the message for the complete timeout time
- throw new TimeoutRuntimeException("Registration timeout after " + openChannelTimeout + " milliseconds");
- }
- }
- catch (ConnectorException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new ConnectorException(ex);
- }
-
- return channel;
- }
-
- public InternalChannel inverseOpenChannel(short channelIndex, String protocolID)
- {
- IProtocol<?> protocol = createProtocol(protocolID, null);
-
- InternalChannel channel = createChannel();
- initChannel(channel, protocol);
- channel.setChannelIndex(channelIndex);
- addChannelWithIndex(channel);
- return channel;
- }
-
- public final InternalChannel getChannel(short channelIndex)
- {
- int index = getChannelsArrayIndex(channelIndex);
- synchronized (channelsLock)
- {
- if (channels == null || index >= channels.length)
- {
- return null;
- }
-
- return channels[index];
- }
- }
-
- protected InternalChannel createChannel()
- {
- return new Channel();
- }
-
- private void initChannel(InternalChannel channel, IProtocol<?> protocol)
- {
- channel.setMultiplexer(this);
- channel.setReceiveExecutor(getConfig().getReceiveExecutor());
- channel.setUserID(getUserID());
- if (protocol != null)
- {
- protocol.setChannel(channel);
- LifecycleUtil.activate(protocol);
- if (TRACER.isEnabled())
- {
- String protocolType = protocol == null ? null : protocol.getType();
- TRACER.format("Opening channel with protocol {0}", protocolType);
- }
-
- channel.setReceiveHandler(protocol);
- }
- else
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Opening channel without protocol");
- }
- }
- }
-
- private void addChannelWithIndex(InternalChannel channel)
- {
- short channelIndex = channel.getIndex();
- int index = getChannelsArrayIndex(channelIndex);
- synchronized (channelsLock)
- {
- if (index >= channels.length)
- {
- InternalChannel[] newChannels = new InternalChannel[index + 1];
- System.arraycopy(channels, 0, newChannels, 0, channels.length);
- channels = newChannels;
- }
-
- channels[index] = channel;
- }
-
- LifecycleUtil.activate(channel);
- fireElementAddedEvent(channel);
- }
-
- private void addChannelWithoutIndex(InternalChannel channel)
- {
- final short INCREMENT = (short)(isClient() ? 1 : -1);
- short channelIndex = INCREMENT;
- synchronized (channelsLock)
- {
- for (;;)
- {
- int index = getChannelsArrayIndex(channelIndex);
- if (index >= channels.length)
- {
- channel.setChannelIndex(channelIndex);
- addChannelWithIndex(channel);
- return;
- }
-
- if (channels[index] == null)
- {
- channel.setChannelIndex(channelIndex);
- channels[index] = channel;
-
- LifecycleUtil.activate(channel);
- fireElementAddedEvent(channel);
- return;
- }
-
- channelIndex += INCREMENT;
- }
- }
- }
-
- public void closeChannel(InternalChannel channel) throws ConnectorException
- {
- InternalChannel internalChannel = channel;
- deregisterChannelFromPeer(internalChannel, getChannelTimeout());
- removeChannel(internalChannel, false);
- }
-
- public void inverseCloseChannel(short channelIndex) throws ConnectorException
- {
- InternalChannel channel = getChannel(channelIndex);
- if (channel != null && channel.isActive())
- {
- removeChannel(channel, true);
- }
- }
-
- private void removeChannel(InternalChannel channel, boolean inverse)
- {
- try
- {
- short channelIndex = channel.getIndex();
- int index = getChannelsArrayIndex(channelIndex);
- synchronized (channelsLock)
- {
- if (index < channels.length)
- {
- if (channels[index] != channel)
- {
- throw new IllegalStateException("Wrong channel: " + channels[index]);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Removing " + channel);
- }
-
- if (index == channels.length - 1)
- {
- --index;
- while (index > 0 && channels[index] == null)
- {
- --index;
- }
-
- if (index == 0)
- {
- channels = new InternalChannel[0];
- }
- else
- {
- InternalChannel[] newChannels = new InternalChannel[index + 1];
- System.arraycopy(channels, 0, newChannels, 0, newChannels.length);
- channels = newChannels;
- }
- }
- else
- {
- channels[index] = null;
- }
- }
- }
-
- channel.finishDeactivate(inverse);
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- throw ex;
- }
- }
-
- private int getChannelsArrayIndex(short channelIndex)
- {
- if (channelIndex < 0)
- {
- return ~channelIndex << 1;
- }
-
- return (channelIndex << 1) - 1;
- }
-
- public short getBufferCapacity()
- {
- return getConfig().getBufferProvider().getBufferCapacity();
- }
-
- public IBuffer provideBuffer()
- {
- return getConfig().getBufferProvider().provideBuffer();
- }
-
- public void retainBuffer(IBuffer buffer)
- {
- getConfig().getBufferProvider().retainBuffer(buffer);
- }
-
- protected void leaveConnecting()
- {
- if (getNegotiator() == null)
- {
- setState(ConnectorState.CONNECTED);
- }
- else
- {
- setState(ConnectorState.NEGOTIATING);
- }
- }
-
- protected abstract INegotiationContext createNegotiationContext();
-
- protected NegotiationException getNegotiationException()
- {
- return negotiationException;
- }
-
- protected void setNegotiationException(NegotiationException negotiationException)
- {
- this.negotiationException = negotiationException;
- }
-
- @SuppressWarnings("unchecked")
- protected <INFRA_STRUCTURE> IProtocol<INFRA_STRUCTURE> createProtocol(String type, INFRA_STRUCTURE infraStructure)
- {
- if (StringUtil.isEmpty(type))
- {
- return null;
- }
-
- IProtocolProvider protocolProvider = getConfig().getProtocolProvider();
- if (protocolProvider == null)
- {
- throw new ConnectorException("No protocol provider configured");
- }
-
- IProtocol<INFRA_STRUCTURE> protocol = (IProtocol<INFRA_STRUCTURE>)protocolProvider.getProtocol(type);
- if (protocol == null)
- {
- throw new ConnectorException("Invalid protocol factory: " + type);
- }
-
- protocol.setBufferProvider(getConfig().getBufferProvider());
- protocol.setExecutorService(getConfig().getReceiveExecutor());
- if (infraStructure != null)
- {
- protocol.setInfraStructure(infraStructure);
- }
-
- return protocol;
- }
-
- protected IFactoryKey createProtocolFactoryKey(String type)
- {
- switch (getLocation())
- {
- case SERVER:
- return new FactoryKey(ServerProtocolFactory.PRODUCT_GROUP, type);
- case CLIENT:
- return new FactoryKey(ClientProtocolFactory.PRODUCT_GROUP, type);
- default:
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected boolean isDeferredActivation()
- {
- return true;
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- if (getConfig().getBufferProvider() == null)
- {
- throw new IllegalStateException("getConfig().getBufferProvider() == null");
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- setState(ConnectorState.CONNECTING);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- setState(ConnectorState.DISCONNECTED);
- synchronized (channelsLock)
- {
- for (short i = 0; i < channels.length; i++)
- {
- InternalChannel channel = channels[i];
- if (channel != null)
- {
- LifecycleUtil.deactivate(channel);
- }
- }
-
- channels = new InternalChannel[0];
- }
-
- super.doDeactivate();
- }
-
- protected abstract void registerChannelWithPeer(short channelIndex, long timeout, IProtocol<?> protocol)
- throws ConnectorException;
-
- protected abstract void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ConnectorException;
-
- /**
- * @author Eike Stepper
- */
- private static class ConnectorStateEvent extends Event implements IConnectorStateEvent
- {
- private static final long serialVersionUID = 1L;
-
- private ConnectorState oldState;
-
- private ConnectorState newState;
-
- public ConnectorStateEvent(INotifier notifier, ConnectorState oldState, ConnectorState newState)
- {
- super(notifier);
- this.oldState = oldState;
- this.newState = newState;
- }
-
- public IConnector getConnector()
- {
- return (IConnector)getSource();
- }
-
- public ConnectorState getOldState()
- {
- return oldState;
- }
-
- public ConnectorState getNewState()
- {
- return newState;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("ConnectorStateEvent[source={0}, oldState={1}, newState={2}]", getSource(),
- getOldState(), getNewState());
- }
- }
-}
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 c5c855d7a6..74dc4ae96f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
@@ -10,13 +10,14 @@
**************************************************************************/
package org.eclipse.net4j;
-import org.eclipse.net4j.protocol.ClientProtocolFactory;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.protocol.IProtocolProvider;
-import org.eclipse.net4j.protocol.ServerProtocolFactory;
import org.eclipse.net4j.util.concurrent.NonBlockingLongCounter;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.spi.net4j.ClientProtocolFactory;
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
/**
* @author Eike Stepper
* @since 2.0
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 7af26c36ba..03ddadabd4 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
@@ -16,10 +16,10 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.INegotiator;
import org.eclipse.net4j.util.security.NegotiatorFactory;
-import org.eclipse.internal.net4j.acceptor.Acceptor;
import org.eclipse.internal.net4j.bundle.OM;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.spi.net4j.Acceptor;
import org.eclipse.spi.net4j.AcceptorFactory;
import org.w3c.dom.Document;
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 9d47f78c0c..eccc93ce52 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
@@ -13,7 +13,7 @@ package org.eclipse.net4j.acceptor;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.internal.net4j.acceptor.Acceptor;
+import org.eclipse.spi.net4j.Acceptor;
/**
* Accepts incoming connection requests from {@link Location#CLIENT client} {@link IConnector connectors} and creates
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 28732ed7ca..8079445eb8 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
@@ -42,6 +42,8 @@ public class BufferInputStream extends InputStream implements IBufferHandler
private RuntimeException exception;
+ private long stopTimeMillis;
+
public BufferInputStream()
{
}
@@ -59,6 +61,14 @@ public class BufferInputStream extends InputStream implements IBufferHandler
/**
* @since 2.0
*/
+ public void restartTimeout()
+ {
+ stopTimeMillis = System.currentTimeMillis() + getMillisBeforeTimeout();
+ }
+
+ /**
+ * @since 2.0
+ */
public RuntimeException getException()
{
return exception;
@@ -129,11 +139,10 @@ public class BufferInputStream extends InputStream implements IBufferHandler
protected boolean ensureBuffer() throws IOException
{
final long check = getMillisInterruptCheck();
- final long timeout = getMillisBeforeTimeout();
try
{
- if (timeout == NO_TIMEOUT)
+ if (getMillisBeforeTimeout() == NO_TIMEOUT)
{
while (currentBuffer == null)
{
@@ -153,8 +162,7 @@ public class BufferInputStream extends InputStream implements IBufferHandler
}
else
{
- // TODO Consider something faster than currentTimeMillis(), maybe less accurate?
- final long stop = System.currentTimeMillis() + timeout;
+ restartTimeout();
while (currentBuffer == null)
{
if (exception != null)
@@ -168,7 +176,13 @@ public class BufferInputStream extends InputStream implements IBufferHandler
return false;
}
- final long remaining = stop - System.currentTimeMillis();
+ long remaining;
+ synchronized (this)
+ {
+ remaining = stopTimeMillis;
+ }
+
+ remaining -= System.currentTimeMillis();
if (remaining <= 0)
{
return false;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
index c7710aea49..01203a8aea 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
@@ -11,6 +11,9 @@
package org.eclipse.net4j.buffer;
import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.IErrorHandler;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -29,15 +32,33 @@ public class BufferOutputStream extends OutputStream
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_BUFFER_STREAM, BufferOutputStream.class);
- private IBufferHandler bufferHandler;
-
private IBufferProvider bufferProvider;
+ private IBufferHandler bufferHandler;
+
private IBuffer currentBuffer;
- private short channelIndex;
+ private short channelID;
+
+ private RuntimeException exception;
+
+ @ExcludeFromDump
+ private transient IErrorHandler writeErrorHandler = new IErrorHandler()
+ {
+ public void handleError(Throwable t)
+ {
+ if (t instanceof RuntimeException)
+ {
+ setException((RuntimeException)t);
+ }
+ else
+ {
+ setException(new IORuntimeException(t));
+ }
+ }
+ };
- public BufferOutputStream(IBufferHandler bufferHandler, IBufferProvider bufferProvider, short channelIndex)
+ public BufferOutputStream(IBufferHandler bufferHandler, IBufferProvider bufferProvider, short channelID)
{
if (bufferHandler == null)
{
@@ -51,12 +72,28 @@ public class BufferOutputStream extends OutputStream
this.bufferHandler = bufferHandler;
this.bufferProvider = bufferProvider;
- this.channelIndex = channelIndex;
+ this.channelID = channelID;
+ }
+
+ public BufferOutputStream(IBufferHandler bufferHandler, short channelID)
+ {
+ this(bufferHandler, extractBufferProvider(bufferHandler), channelID);
}
- public BufferOutputStream(IBufferHandler bufferHandler, short channelIndex)
+ /**
+ * @since 2.0
+ */
+ public RuntimeException getException()
{
- this(bufferHandler, extractBufferProvider(bufferHandler), channelIndex);
+ return exception;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void setException(RuntimeException exception)
+ {
+ this.exception = exception;
}
@SuppressWarnings("deprecation")
@@ -123,10 +160,16 @@ public class BufferOutputStream extends OutputStream
protected void ensureBuffer()
{
+ if (exception != null)
+ {
+ throw exception;
+ }
+
if (currentBuffer == null)
{
currentBuffer = bufferProvider.provideBuffer();
- currentBuffer.startPutting(channelIndex);
+ currentBuffer.setErrorHandler(writeErrorHandler);
+ currentBuffer.startPutting(channelID);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferState.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferState.java
index 5db9105c80..74682509e7 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferState.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferState.java
@@ -35,8 +35,8 @@ public enum BufferState
* <p>
* A transition to {@link #PUTTING} can be triggered by calling {@link IBuffer#startPutting(short)} once. If the
* buffer is intended to be passed to an {@link org.eclipse.net4j.channel.IChannel IChannel} later the
- * {@link org.eclipse.net4j.channel.IChannel#getChannelIndex() channel index} of that Channel has to be passed because
- * it is part of the buffer's header. A {@link ByteBuffer} is returned that can be used for putting data.
+ * {@link org.eclipse.net4j.channel.IChannel#getChannelID() channel index} of that Channel has to be passed because it
+ * is part of the buffer's header. A {@link ByteBuffer} is returned that can be used for putting data.
* <p>
* A transition to {@link #GETTING} can be triggered by calling {@link IBuffer#startGetting(SocketChannel)} repeatedly
* until it finally returns a {@link ByteBuffer} that can be used for getting data.
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBuffer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBuffer.java
index 3e6cad36e3..bc4c878abb 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBuffer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBuffer.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.buffer;
import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.util.IErrorHandler;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -51,7 +52,7 @@ import java.nio.channels.SocketChannel;
* An example for <b>putting</b> values into a buffer and writing it to a {@link SocketChannel}:
* <p>
* <pre style="background-color:#ffffc8; border-width:1px; border-style:solid; padding:.5em;"> // Obtain a fresh buffer
- * Buffer buffer = bufferProvider.getBuffer(); // Start filling the buffer for channelIndex 4711 ByteBuffer byteBuffer =
+ * Buffer buffer = bufferProvider.getBuffer(); // Start filling the buffer for channelID 4711 ByteBuffer byteBuffer =
* buffer.startPutting(4711); byteBuffer.putDouble(15.47); // Write the contents of the Buffer to a // SocketChannel
* without blocking while (!buffer.write(socketChannel)) { // Do something else } </pre> An example for reading a buffer
* from a {@link SocketChannel} and <b>getting</b> values from it:
@@ -72,8 +73,8 @@ import java.nio.channels.SocketChannel;
public interface IBuffer
{
/**
- * Possible argument value of {@link #startPutting(short)} and possible return value of {@link #getChannelIndex()}
- * that indicates that this buffer is not intended to be passed to a {@link SocketChannel}.
+ * Possible argument value of {@link #startPutting(short)} and possible return value of {@link #getChannelID()} that
+ * indicates that this buffer is not intended to be passed to a {@link SocketChannel}.
*/
public static final short NO_CHANNEL = Short.MIN_VALUE;
@@ -102,8 +103,10 @@ public interface IBuffer
/**
* Returns the channel index value stored in the header of this buffer.
+ *
+ * @since 2.0
*/
- public short getChannelIndex();
+ public short getChannelID();
/**
* Returns the capacity of this buffer.
@@ -191,16 +194,16 @@ public interface IBuffer
* {@link ByteBuffer#capacity()}
* </ul>
*
- * @param channelIndex
+ * @param channelID
* The index of an {@link IChannel} that this buffer is intended to be passed to later or {@link #NO_CHANNEL}
* .
* @return A {@link ByteBuffer} that can be used for putting data.
* @throws IllegalStateException
* If the state of this buffer is not {@link BufferState#INITIAL INITIAL} ({@link BufferState#PUTTING
- * PUTTING} is allowed but meaningless if and only if the given <code>channelIndex</code> is equal to the
- * existing <code>channelIndex</code> of this buffer).
+ * PUTTING} is allowed but meaningless if and only if the given <code>channelID</code> is equal to the
+ * existing <code>channelID</code> of this buffer).
*/
- public ByteBuffer startPutting(short channelIndex) throws IllegalStateException;
+ public ByteBuffer startPutting(short channelID) throws IllegalStateException;
/**
* Tries to write the data of this buffer to a {@link SocketChannel}.
@@ -259,4 +262,14 @@ public interface IBuffer
public void clear();
public String formatContent(boolean showHeader);
+
+ /**
+ * @since 2.0
+ */
+ public IErrorHandler getErrorHandler();
+
+ /**
+ * @since 2.0
+ */
+ public void setErrorHandler(IErrorHandler errorHandler);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelException.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelException.java
new file mode 100644
index 0000000000..b666688d2a
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelException.java
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.channel;
+
+/**
+ * Thrown by an {@link IChannel} to indicate channel management problems.
+ *
+ * @see IChannelMultiplexer
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class ChannelException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public ChannelException()
+ {
+ }
+
+ public ChannelException(String message)
+ {
+ super(message);
+ }
+
+ public ChannelException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ChannelException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelOutputStream.java
index 236807c0a4..68a0257a41 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/channel/ChannelOutputStream.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.channel;
import org.eclipse.net4j.buffer.BufferOutputStream;
+import org.eclipse.net4j.buffer.IBuffer;
import org.eclipse.net4j.buffer.IBufferProvider;
/**
@@ -20,11 +21,11 @@ public class ChannelOutputStream extends BufferOutputStream
{
public ChannelOutputStream(IChannel channel)
{
- super(channel, channel.getIndex());
+ super(channel, channel.getID());
}
public ChannelOutputStream(IChannel channel, IBufferProvider bufferProvider)
{
- super(channel, bufferProvider, channel.getIndex());
+ super(channel, bufferProvider, channel == null ? IBuffer.NO_CHANNEL : channel.getID());
}
}
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 4d6a3494d7..1118f9ec1e 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
@@ -42,9 +42,9 @@ import org.eclipse.net4j.util.security.IUserAware;
* An example for opening a channel on an {@link IConnector} and sending an {@link IBuffer}:
* <p>
* <pre style="background-color:#ffffc8; border-width:1px; border-style:solid; padding:.5em;"> // Open a channel
- * IChannel channel = connector.openChannel(); short channelIndex = channel.getIndex(); // Fill a buffer Buffer buffer =
- * bufferProvider.getBuffer(); ByteBuffer byteBuffer = buffer.startPutting(channelIndex); byteBuffer.putDouble(15.47);
- * // Let the channel send the buffer without blocking channel.sendBuffer(buffer); </pre>
+ * IChannel channel = connector.openChannel(); short channelID = channel.getIndex(); // Fill a buffer Buffer buffer =
+ * bufferProvider.getBuffer(); ByteBuffer byteBuffer = buffer.startPutting(channelID); byteBuffer.putDouble(15.47); //
+ * Let the channel send the buffer without blocking channel.sendBuffer(buffer); </pre>
* <p>
* An example for receiving {@link IBuffer}s from channels on an {@link IConnector}:
* <p>
@@ -63,12 +63,12 @@ import org.eclipse.net4j.util.security.IUserAware;
public interface IChannel extends ILocationAware, IUserAware, IBufferHandler, INotifier
{
/**
- * Returns the index of this channel within the array of channels returned from the
- * {@link IChannelMultiplexer#getChannels() getChannels()} method of the multiplexer of this channel.
+ * Returns the ID of this channel. The ID is unique at any time among all channels of the associated
+ * {@link IChannelMultiplexer multiplexer}.
*
* @since 2.0
*/
- public short getIndex();
+ public short getID();
/**
* Returns the multiplexer this channel is associated with. This channel multiplexer can be used, for example, to open
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 ba4f9750c0..332c00f1b6 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
@@ -12,14 +12,13 @@ package org.eclipse.net4j.channel;
import org.eclipse.net4j.ILocationAware;
import org.eclipse.net4j.buffer.IBufferHandler;
-import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import java.util.List;
+import java.util.Collection;
/**
* @author Eike Stepper
@@ -37,18 +36,7 @@ public interface IChannelMultiplexer extends ILocationAware, IContainer<IChannel
*
* @since 2.0
*/
- public static final long DEFAULT_CHANNEL_TIMEOUT = -1L;
-
- /**
- * Returns a list of currently open channels. Note that the resulting list does not contain <code>null</code> values.
- * Generally the {@link IChannel#getIndex() index} of a channel <b>must not</b> be used as an index into this list.
- * Each call to this method creates a new copy of the internal channels array, so it can safely be modified bz the
- * caller.
- * <p>
- *
- * @since 2.0
- */
- public List<IChannel> getChannels();
+ public static final long DEFAULT_CHANNEL_TIMEOUT = -1;
/**
* Synchronous request to open a new {@link IChannel} with an undefined channel protocol. Since the peer connector
@@ -61,7 +49,7 @@ public interface IChannelMultiplexer extends ILocationAware, IContainer<IChannel
* @see #openChannel(IProtocol)
* @since 2.0
*/
- public IChannel openChannel() throws ConnectorException;
+ public IChannel openChannel() throws ChannelException;
/**
* Synchronous request to open a new {@link IChannel} with a channel protocol defined by a given protocol identifier.
@@ -73,7 +61,7 @@ public interface IChannelMultiplexer extends ILocationAware, IContainer<IChannel
* @see #openChannel(IProtocol)
* @since 2.0
*/
- public IChannel openChannel(String protocolID, Object infraStructure) throws ConnectorException;
+ public IChannel openChannel(String protocolID, Object infraStructure) throws ChannelException;
/**
* Synchronous request to open a new {@link IChannel} with the given channel protocol . The peer connector will lookup
@@ -85,7 +73,14 @@ public interface IChannelMultiplexer extends ILocationAware, IContainer<IChannel
* @see #openChannel(String, Object)
* @since 2.0
*/
- public IChannel openChannel(IProtocol<?> protocol) throws ConnectorException;
+ public IChannel openChannel(IProtocol<?> protocol) throws ChannelException;
+
+ /**
+ * Returns a collection of currently open channels.
+ *
+ * @since 2.0
+ */
+ public Collection<IChannel> getChannels();
/**
* @since 2.0
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
new file mode 100644
index 0000000000..1f68c894d2
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ISignalProtocol.java
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.buffer.BufferInputStream;
+import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface ISignalProtocol<INFRA_STRUCTURE> extends IProtocol<INFRA_STRUCTURE>
+{
+ public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
+
+ public long getTimeout();
+
+ public void setTimeout(long timeout);
+
+ public IFailOverStrategy getFailOverStrategy();
+
+ public void setFailOverStrategy(IFailOverStrategy failOverStrategy);
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
index 7e7e9aacc6..3c98db4064 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
@@ -12,79 +12,48 @@ 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.WrappedException;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.io.InputStream;
/**
* @author Eike Stepper
*/
public abstract class Indication extends SignalReactor
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, Indication.class);
-
/**
* @since 2.0
*/
- public Indication(SignalProtocol<?> protocol, short signalID)
+ public Indication(SignalProtocol<?> protocol, short id, String name)
{
- super(protocol, signalID);
+ super(protocol, id, name);
}
- @Override
- protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
+ /**
+ * @since 2.0
+ */
+ public Indication(SignalProtocol<?> protocol, short signalID)
{
- if (TRACER.isEnabled())
- {
- TRACER.trace("================ Indicating " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
- }
-
- InputStream wrappedInputStream = wrapInputStream(in);
-
- try
- {
- indicating(ExtendedDataInputStream.wrap(wrappedInputStream));
- }
- catch (Error ex)
- {
- OM.LOG.error(ex);
- sendExceptionSignal(ex);
- throw ex;
- }
- catch (Exception ex)
- {
- ex = WrappedException.unwrap(ex);
- OM.LOG.error(ex);
- sendExceptionSignal(ex);
- throw ex;
- }
- finally
- {
- finishInputStream(wrappedInputStream);
- }
+ super(protocol, signalID);
}
- protected abstract void indicating(ExtendedDataInputStream in) throws Exception;
-
/**
* @since 2.0
*/
- protected String getMessage(Throwable t)
+ public Indication(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ @Override
+ protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- return StringUtil.formatException(t);
+ doInput(in);
}
- void sendExceptionSignal(Throwable t) throws Exception
+ @Override
+ void doExtendedInput(ExtendedDataInputStream in) throws Exception
{
- SignalProtocol<?> protocol = getProtocol();
- int correlationID = -getCorrelationID();
- String message = getMessage(t);
- new RemoteExceptionRequest(protocol, correlationID, message, t).send();
+ indicating(in);
}
+
+ protected abstract void indicating(ExtendedDataInputStream in) throws Exception;
}
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
new file mode 100644
index 0000000000..0381fb5f22
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
@@ -0,0 +1,190 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.buffer.BufferInputStream;
+import org.eclipse.net4j.buffer.BufferOutputStream;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+import org.eclipse.net4j.util.om.monitor.Monitor;
+import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class IndicationWithMonitoring extends IndicationWithResponse
+{
+ private Monitor monitor;
+
+ private long lastMonitorAccess;
+
+ /**
+ * @since 2.0
+ */
+ public IndicationWithMonitoring(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public IndicationWithMonitoring(SignalProtocol<?> protocol, short signalID)
+ {
+ super(protocol, signalID);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public IndicationWithMonitoring(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ @Override
+ protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
+ {
+ try
+ {
+ super.execute(in, out);
+ }
+ finally
+ {
+ monitor = null;
+ }
+ }
+
+ @Override
+ protected final void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ final long monitorProgressInterval = in.readLong();
+ ExecutorService executorService = getMonitoringExecutorService();
+ if (executorService != null)
+ {
+ monitor = new LastAccessMonitor();
+ setLastMonitorAccess();
+ executorService.execute(new Runnable()
+ {
+ public void run()
+ {
+ while (monitor != null)
+ {
+ if (System.currentTimeMillis() - lastMonitorAccess > monitorProgressInterval)
+ {
+ setMonitorCanceled();
+ break;
+ }
+
+ sendProgress(monitor.getTotalWork(), monitor.getWork());
+ ConcurrencyUtil.sleep(monitorProgressInterval);
+ }
+ }
+
+ private void sendProgress(int totalWork, int work)
+ {
+ try
+ {
+ new MonitorProgressRequest(getProtocol(), -getCorrelationID(), totalWork, work).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ });
+ }
+
+ indicating(in, monitor.fork(getIndicatingWorkPercent()));
+ }
+
+ @Override
+ protected final void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ responding(out, monitor.fork(getRespondingWorkPercent()));
+ }
+
+ protected abstract void indicating(ExtendedDataInputStream in, IMonitor monitor) throws Exception;
+
+ protected abstract void responding(ExtendedDataOutputStream out, IMonitor monitor) throws Exception;
+
+ /**
+ * @since 2.0
+ */
+ protected ExecutorService getMonitoringExecutorService()
+ {
+ return getProtocol().getExecutorService();
+ }
+
+ protected int getIndicatingWorkPercent()
+ {
+ return 50;
+ }
+
+ protected int getRespondingWorkPercent()
+ {
+ return 50;
+ }
+
+ void setMonitorCanceled()
+ {
+ if (monitor != null)
+ {
+ monitor.cancel();
+ }
+ }
+
+ void setLastMonitorAccess()
+ {
+ lastMonitorAccess = System.currentTimeMillis();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class LastAccessMonitor extends Monitor
+ {
+ @Override
+ public synchronized void begin(int totalWork)
+ {
+ setLastMonitorAccess();
+ super.begin(totalWork);
+ }
+
+ @Override
+ public synchronized void checkCanceled() throws MonitorCanceledException
+ {
+ setLastMonitorAccess();
+ super.checkCanceled();
+ }
+
+ @Override
+ public synchronized boolean isCanceled()
+ {
+ setLastMonitorAccess();
+ return super.isCanceled();
+ }
+
+ @Override
+ public synchronized void worked(int work)
+ {
+ setLastMonitorAccess();
+ super.worked(work);
+ }
+ }
+}
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 5c16fb3c29..76661e8aab 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
@@ -12,21 +12,22 @@ 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.WrappedException;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.io.OutputStream;
/**
* @author Eike Stepper
*/
-public abstract class IndicationWithResponse extends Indication
+public abstract class IndicationWithResponse extends SignalReactor
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, IndicationWithResponse.class);
+ /**
+ * @since 2.0
+ */
+ public IndicationWithResponse(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
/**
* @since 2.0
@@ -36,47 +37,70 @@ public abstract class IndicationWithResponse extends Indication
super(protocol, signalID);
}
+ /**
+ * @since 2.0
+ */
+ public IndicationWithResponse(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected String getExceptionMessage(Throwable t)
+ {
+ return StringUtil.formatException(t);
+ }
+
@Override
protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- super.execute(in, out);
- if (TRACER.isEnabled())
- {
- TRACER.trace("================ Responding " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
- }
-
- OutputStream wrappedOutputStream = wrapOutputStream(out);
+ boolean responding = false;
try
{
- responding(ExtendedDataOutputStream.wrap(wrappedOutputStream));
+ doInput(in);
+ responding = true;
+ doOutput(out);
}
catch (Error ex)
{
- OM.LOG.error(ex);
- sendExceptionSignal(ex);
+ sendExceptionSignal(ex, responding);
throw ex;
}
catch (Exception ex)
{
- ex = WrappedException.unwrap(ex);
- OM.LOG.error(ex);
- sendExceptionSignal(ex);
+ sendExceptionSignal(ex, responding);
throw ex;
}
- finally
- {
- finishOutputStream(wrappedOutputStream);
- }
-
- // End response
- out.flushWithEOS();
}
+ protected abstract void indicating(ExtendedDataInputStream in) throws Exception;
+
/**
* <b>Important Note:</b> The response must not be empty, i.e. the stream must be used at least to write a
* <code>boolean</code>. Otherwise synchronization problems will result!
- * @throws Exception TODO
*/
protected abstract void responding(ExtendedDataOutputStream out) throws Exception;
+
+ @Override
+ void doExtendedInput(ExtendedDataInputStream in) throws Exception
+ {
+ indicating(in);
+ }
+
+ @Override
+ void doExtendedOutput(ExtendedDataOutputStream out) throws Exception
+ {
+ responding(out);
+ }
+
+ void sendExceptionSignal(Throwable t, boolean responding) throws Exception
+ {
+ SignalProtocol<?> protocol = getProtocol();
+ int correlationID = -getCorrelationID();
+ String message = getExceptionMessage(t);
+ new RemoteExceptionRequest(protocol, correlationID, responding, message, t).sendAsync();
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledIndication.java
new file mode 100644
index 0000000000..68f50becd6
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledIndication.java
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+/**
+ * @author Eike Stepper
+ */
+class MonitorCanceledIndication extends Indication
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, MonitorCanceledIndication.class);
+
+ public MonitorCanceledIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, SignalProtocol.SIGNAL_MONITOR_CANCELED);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ int correlationID = in.readInt();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Canceling monitor of signal {0}", correlationID);
+ }
+
+ getProtocol().handleMonitorCanceled(correlationID);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledRequest.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledRequest.java
new file mode 100644
index 0000000000..075c43909c
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorCanceledRequest.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+/**
+ * @author Eike Stepper
+ */
+class MonitorCanceledRequest extends Request
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, MonitorCanceledRequest.class);
+
+ private int correlationID;
+
+ public MonitorCanceledRequest(SignalProtocol<?> protocol, int correlationID)
+ {
+ super(protocol, SignalProtocol.SIGNAL_MONITOR_CANCELED);
+ this.correlationID = correlationID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Canceling monitor of signal {0}", correlationID);
+ }
+
+ out.writeInt(correlationID);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressIndication.java
new file mode 100644
index 0000000000..dbfa9c2412
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressIndication.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+/**
+ * @author Eike Stepper
+ */
+class MonitorProgressIndication extends Indication
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, MonitorProgressIndication.class);
+
+ public MonitorProgressIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, SignalProtocol.SIGNAL_MONITOR_PROGRESS);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ int correlationID = in.readInt();
+ int totalWork = in.readInt();
+ int work = in.readInt();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Progress of signal {0}: totalWork={1}, work={2}", correlationID, totalWork, work);
+ }
+
+ getProtocol().handleMonitorProgress(correlationID, totalWork, work);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressRequest.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressRequest.java
new file mode 100644
index 0000000000..503a82df3e
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/MonitorProgressRequest.java
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+/**
+ * @author Eike Stepper
+ */
+class MonitorProgressRequest extends Request
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, MonitorProgressRequest.class);
+
+ private int correlationID;
+
+ private int totalWork;
+
+ private int work;
+
+ public MonitorProgressRequest(SignalProtocol<?> protocol, int correlationID, int totalWork, int work)
+ {
+ super(protocol, SignalProtocol.SIGNAL_MONITOR_PROGRESS);
+ this.correlationID = correlationID;
+ this.totalWork = totalWork;
+ this.work = work;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Progress of signal {0}: totalWork={1}, work={2}", correlationID, totalWork, work);
+ }
+
+ out.writeInt(correlationID);
+ out.writeInt(totalWork);
+ out.writeInt(work);
+ }
+}
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
new file mode 100644
index 0000000000..76495612d3
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteException.java
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class RemoteException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ private boolean whileResponding;
+
+ public RemoteException(Throwable cause, boolean whileResponding)
+ {
+ super(cause);
+ this.whileResponding = whileResponding;
+ }
+
+ public RemoteException(String message, boolean whileResponding)
+ {
+ super(message);
+ this.whileResponding = whileResponding;
+ }
+
+ public boolean whileResponding()
+ {
+ return 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 de18a1b3bb..82218548bf 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
@@ -11,6 +11,7 @@
package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.OM;
@@ -19,6 +20,10 @@ import org.eclipse.internal.net4j.bundle.OM;
*/
class RemoteExceptionIndication extends Indication
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionIndication.class);
+
+ private Throwable t;
+
public RemoteExceptionIndication(SignalProtocol<?> protocol)
{
super(protocol, SignalProtocol.SIGNAL_REMOTE_EXCEPTION);
@@ -28,8 +33,13 @@ class RemoteExceptionIndication extends Indication
protected void indicating(ExtendedDataInputStream in) throws Exception
{
int correlationID = in.readInt();
+ boolean responding = in.readBoolean();
String message = in.readString();
- Throwable t;
+ if (TRACER.isEnabled())
+ {
+ String msg = RemoteExceptionRequest.getFirstLine(message);
+ TRACER.format("Reading remote exception for signal {0}: {1}", correlationID, msg);
+ }
try
{
@@ -37,9 +47,9 @@ class RemoteExceptionIndication extends Indication
}
catch (Throwable couldNotLoadExceptionClass)
{
- t = new SignalRemoteException(message);
+ t = new RemoteException(message, responding);
}
- getProtocol().stopSignal(correlationID, t);
+ getProtocol().handleRemoteException(correlationID, t, responding);
}
}
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 8dd6f083f0..9190517da4 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
@@ -11,31 +11,67 @@
package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
/**
* @author Eike Stepper
*/
class RemoteExceptionRequest extends Request
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionRequest.class);
+
private int correlationID;
+ private boolean responding;
+
private String message;
private Throwable t;
- public RemoteExceptionRequest(SignalProtocol<?> protocol, int correlationID, String message, Throwable t)
+ public RemoteExceptionRequest(SignalProtocol<?> protocol, int correlationID, boolean responding, String message,
+ Throwable t)
{
super(protocol, SignalProtocol.SIGNAL_REMOTE_EXCEPTION);
this.correlationID = correlationID;
this.message = message;
this.t = t;
+ this.responding = responding;
}
@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);
+ }
+
out.writeInt(correlationID);
+ out.writeBoolean(responding);
out.writeString(message);
out.writeObject(t);
}
+
+ public 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/Request.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
index e79a162163..dcc3d3c75d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
@@ -12,20 +12,20 @@ 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.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.io.OutputStream;
/**
* @author Eike Stepper
*/
public abstract class Request extends SignalActor
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, Request.class);
+ /**
+ * @since 2.0
+ */
+ public Request(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
/**
* @since 2.0
@@ -35,18 +35,33 @@ public abstract class Request extends SignalActor
super(protocol, signalID);
}
+ /**
+ * @since 2.0
+ */
+ public Request(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void sendAsync() throws Exception
+ {
+ getProtocol().startSignal(this, getProtocol().getTimeout());
+
+ }
+
@Override
protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
- if (TRACER.isEnabled())
- {
- TRACER.trace("================ Requesting " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
- }
-
- OutputStream wrappedOutputStream = wrapOutputStream(out);
- requesting(ExtendedDataOutputStream.wrap(wrappedOutputStream));
- finishOutputStream(wrappedOutputStream);
- out.flushWithEOS();
+ doOutput(out);
+ }
+
+ @Override
+ void doExtendedOutput(ExtendedDataOutputStream out) throws Exception
+ {
+ requesting(out);
}
protected abstract void requesting(ExtendedDataOutputStream out) throws Exception;
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 a5d47735ce..26d0798200 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
@@ -12,20 +12,27 @@ 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.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.io.InputStream;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
/**
* @author Eike Stepper
*/
-public abstract class RequestWithConfirmation<RESULT> extends Request
+public abstract class RequestWithConfirmation<RESULT> extends SignalActor
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RequestWithConfirmation.class);
+ private RESULT result;
+
+ /**
+ * @since 2.0
+ */
+ public RequestWithConfirmation(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
/**
* @since 2.0
@@ -35,56 +42,84 @@ public abstract class RequestWithConfirmation<RESULT> extends Request
super(protocol, signalID);
}
- @Override
- @SuppressWarnings("unchecked")
- public RESULT send() throws Exception, SignalRemoteException
+ /**
+ * @since 2.0
+ */
+ public RequestWithConfirmation(SignalProtocol<?> protocol, Enum<?> literal)
{
- return (RESULT)super.send();
+ super(protocol, literal);
}
- @Override
- @SuppressWarnings("unchecked")
- public RESULT send(long timeout) throws Exception, SignalRemoteException
+ /**
+ * @since 2.0
+ */
+ public Future<RESULT> sendAsync()
{
- return (RESULT)super.send(timeout);
+ ExecutorService executorService = getAsyncExecutorService();
+ return executorService.submit(new Callable<RESULT>()
+ {
+ public RESULT call() throws Exception
+ {
+ return send();
+ }
+ });
}
- @Override
- protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
+ /**
+ * @since 2.0
+ */
+ public RESULT send() throws Exception, RemoteException
{
- super.execute(in, out);
- if (TRACER.isEnabled())
- {
- TRACER.trace("================ Confirming " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
- }
+ return send(getProtocol().getTimeout());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public RESULT send(long timeout) throws Exception, RemoteException
+ {
+ result = null;
+ getProtocol().startSignal(this, timeout);
+ return result;
+ }
- InputStream wrappedInputStream = wrapInputStream(in);
- RESULT result = confirming(ExtendedDataInputStream.wrap(wrappedInputStream));
- finishInputStream(wrappedInputStream);
- setResult(result);
+ /**
+ * @since 2.0
+ */
+ protected ExecutorService getAsyncExecutorService()
+ {
+ return getProtocol().getExecutorService();
}
+ @Override
+ protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
+ {
+ doOutput(out);
+ doInput(in);
+ }
+
+ protected abstract void requesting(ExtendedDataOutputStream out) throws Exception;
+
/**
* <b>Important Note:</b> The confirmation must not be empty, i.e. the stream must be used at least to read a
* <code>boolean</code>. Otherwise synchronization problems will result!
- *
- * @throws Exception
- * TODO
*/
protected abstract RESULT confirming(ExtendedDataInputStream in) throws Exception;
- void setRemoteException(Throwable t)
+ @Override
+ void doExtendedOutput(ExtendedDataOutputStream out) throws Exception
{
- SignalRemoteException remoteException;
- if (t instanceof SignalRemoteException)
- {
- remoteException = (SignalRemoteException)t;
- }
- else
- {
- remoteException = new SignalRemoteException(t);
- }
+ requesting(out);
+ }
- getBufferInputStream().setException(remoteException);
+ @Override
+ void doExtendedInput(ExtendedDataInputStream in) throws Exception
+ {
+ result = confirming(in);
+ }
+
+ void setRemoteException(Throwable t, boolean responding)
+ {
+ getBufferInputStream().setException(new RemoteException(t, 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
new file mode 100644
index 0000000000..deafa7bc06
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
@@ -0,0 +1,254 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.signal;
+
+import org.eclipse.net4j.buffer.BufferInputStream;
+import org.eclipse.net4j.buffer.BufferOutputStream;
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.IMonitor;
+import org.eclipse.net4j.util.om.monitor.Monitor;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmation<RESULT>
+{
+ /**
+ * @since 2.0
+ */
+ public static final long DEFAULT_CANCELATION_POLL_INTERVAL = 100L;
+
+ /**
+ * @since 2.0
+ */
+ public static final long DEFAULT_MONITOR_PROGRESS_INTERVAL = 2000;
+
+ private IMonitor mainMonitor;
+
+ private IMonitor remoteMonitor;
+
+ /**
+ * @since 2.0
+ */
+ public RequestWithMonitoring(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public RequestWithMonitoring(SignalProtocol<?> protocol, short signalID)
+ {
+ super(protocol, signalID);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public RequestWithMonitoring(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ @Override
+ public Future<RESULT> sendAsync()
+ {
+ return sendAsync(null);
+ }
+
+ @Override
+ public RESULT send() throws Exception, RemoteException
+ {
+ return send(null);
+ }
+
+ @Override
+ public RESULT send(long timeout) throws Exception, RemoteException
+ {
+ return send(timeout, null);
+ }
+
+ public Future<RESULT> sendAsync(IMonitor monitor)
+ {
+ initMainMonitor(monitor);
+ return super.sendAsync();
+ }
+
+ public RESULT send(IMonitor monitor) throws Exception, RemoteException
+ {
+ initMainMonitor(monitor);
+ return super.send();
+ }
+
+ public RESULT send(long timeout, IMonitor monitor) throws Exception, RemoteException
+ {
+ initMainMonitor(monitor);
+ return super.send(timeout);
+ }
+
+ @Override
+ protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
+ {
+ try
+ {
+ super.execute(in, out);
+ }
+ finally
+ {
+ remoteMonitor.done();
+ remoteMonitor = null;
+
+ mainMonitor.done();
+ mainMonitor = null;
+ }
+ }
+
+ @Override
+ protected final void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ int remoteWork = 100 - getRequestingWorkPercent() - getConfirmingWorkPercent();
+ if (remoteWork < 0)
+ {
+ throw new ImplementationError("Remote work must not be negative: " + remoteWork);
+ }
+
+ mainMonitor.begin(100);
+ remoteMonitor = mainMonitor.fork(remoteWork);
+
+ ExecutorService executorService = getCancelationExecutorService();
+ if (executorService != null)
+ {
+ executorService.execute(new Runnable()
+ {
+ public void run()
+ {
+ while (mainMonitor != null)
+ {
+ ConcurrencyUtil.sleep(getCancelationPollInterval());
+ if (mainMonitor != null && mainMonitor.isCanceled())
+ {
+ try
+ {
+ new MonitorCanceledRequest(getProtocol(), getCorrelationID()).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+
+ return;
+ }
+ }
+ }
+ });
+ }
+
+ out.writeLong(getMonitorProgressInterval());
+ requesting(out, mainMonitor.fork(getRequestingWorkPercent()));
+ }
+
+ @Override
+ protected final RESULT confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return confirming(in, mainMonitor.fork(getConfirmingWorkPercent()));
+ }
+
+ protected abstract void requesting(ExtendedDataOutputStream out, IMonitor monitor) throws Exception;
+
+ /**
+ * <b>Important Note:</b> The confirmation must not be empty, i.e. the stream must be used at least to read a
+ * <code>boolean</code>. Otherwise synchronization problems will result!
+ */
+ protected abstract RESULT confirming(ExtendedDataInputStream in, IMonitor monitor) throws Exception;
+
+ /**
+ * @since 2.0
+ */
+ protected ExecutorService getCancelationExecutorService()
+ {
+ return getProtocol().getExecutorService();
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected long getCancelationPollInterval()
+ {
+ return DEFAULT_CANCELATION_POLL_INTERVAL;
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected long getMonitorProgressInterval()
+ {
+ return DEFAULT_MONITOR_PROGRESS_INTERVAL;
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected int getRequestingWorkPercent()
+ {
+ return 25;
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected int getConfirmingWorkPercent()
+ {
+ return 25;
+ }
+
+ void setMonitorProgress(int totalWork, int work)
+ {
+ getBufferInputStream().restartTimeout();
+ if (remoteMonitor != null)
+ {
+ if (remoteMonitor.getTotalWork() == 0)
+ {
+ remoteMonitor.begin(totalWork);
+ remoteMonitor.worked(work);
+ }
+ else
+ {
+ float oldRatio = remoteMonitor.getWork();
+ oldRatio /= remoteMonitor.getTotalWork();
+
+ float newRatio = work;
+ newRatio /= totalWork;
+
+ float newWork = newRatio - oldRatio;
+ newWork *= remoteMonitor.getTotalWork();
+ if (newWork >= 1.0)
+ {
+ remoteMonitor.worked((int)newWork);
+ }
+ }
+ }
+ }
+
+ private void initMainMonitor(IMonitor monitor)
+ {
+ mainMonitor = monitor == null ? new Monitor() : monitor;
+ }
+}
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 9567f6bfa3..be91752cca 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
@@ -12,6 +12,9 @@ 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.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -21,6 +24,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.text.MessageFormat;
import java.util.concurrent.TimeoutException;
/**
@@ -28,11 +32,18 @@ import java.util.concurrent.TimeoutException;
*/
public abstract class Signal implements Runnable
{
+ /**
+ * @since 2.0
+ */
+ public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
+
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, Signal.class);
private SignalProtocol<?> protocol;
- private short signalID;
+ private short id;
+
+ private String name;
private int correlationID;
@@ -48,10 +59,29 @@ public abstract class Signal implements Runnable
*
* @since 2.0
*/
- protected Signal(SignalProtocol<?> protocol, short signalID)
+ public Signal(SignalProtocol<?> protocol, short id, String name)
{
this.protocol = protocol;
- this.signalID = signalID;
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @since 2.0
+ * @see #Signal(SignalProtocol, short, String)
+ */
+ public Signal(SignalProtocol<?> protocol, short id)
+ {
+ this(protocol, id, null);
+ }
+
+ /**
+ * @since 2.0
+ * @see #Signal(SignalProtocol, short, String)
+ */
+ public Signal(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ this(protocol, (short)literal.ordinal(), literal.name());
}
public SignalProtocol<?> getProtocol()
@@ -60,20 +90,71 @@ public abstract class Signal implements Runnable
}
/**
- * Returns the short integer ID of this signal.
+ * Returns the short integer ID of this signal that is unique among all signals of the associated
+ * {@link #getProtocol() protocol}.
*
* @since 2.0
*/
- public final short getSignalID()
+ public final short getID()
{
- return signalID;
+ return id;
}
- protected final int getCorrelationID()
+ /**
+ * @since 2.0
+ */
+ public String getName()
+ {
+ if (name == null)
+ {
+ // Needs no synchronization because any thread would set the same value.
+ name = ReflectUtil.getSimpleClassName(this);
+ }
+
+ return name;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public final int getCorrelationID()
{
return correlationID;
}
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("Signal[protocol={0}, id={1}, name={2}, correlation={3}]", getProtocol().getType(),
+ getID(), getName(), getCorrelationID());
+ }
+
+ public final void run()
+ {
+ String threadName = null;
+ try
+ {
+ if (OM.SET_SIGNAL_THREAD_NAME)
+ {
+ threadName = getClass().getSimpleName();
+ Thread.currentThread().setName(threadName);
+ }
+
+ runSync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ finally
+ {
+ if (threadName != null)
+ {
+ Thread.currentThread().setName(threadName + "(FINISHED)");
+ }
+ }
+ }
+
protected final BufferInputStream getBufferInputStream()
{
return bufferInputStream;
@@ -173,33 +254,9 @@ public abstract class Signal implements Runnable
}
}
- public final void run()
- {
- String threadName = null;
- try
- {
- if (OM.SET_SIGNAL_THREAD_NAME)
- {
- threadName = getClass().getSimpleName();
- Thread.currentThread().setName(threadName);
- }
-
- runSync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- finally
- {
- if (threadName != null)
- {
- Thread.currentThread().setName(threadName + "(FINISHED)");
- }
- }
- }
+ protected abstract void execute(BufferInputStream in, BufferOutputStream out) throws Exception;
- protected void runSync() throws Exception
+ void runSync() throws Exception
{
try
{
@@ -224,8 +281,6 @@ public abstract class Signal implements Runnable
}
}
- protected abstract void execute(BufferInputStream in, BufferOutputStream out) throws Exception;
-
void setCorrelationID(int correlationID)
{
this.correlationID = correlationID;
@@ -240,4 +295,78 @@ public abstract class Signal implements Runnable
{
bufferOutputStream = outputStream;
}
+
+ void doOutput(BufferOutputStream out) throws Exception
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("================ {0}: {1}", getOutputMeaning(), this); //$NON-NLS-1$
+ }
+
+ OutputStream wrappedOutputStream = wrapOutputStream(out);
+ ExtendedDataOutputStream extended = ExtendedDataOutputStream.wrap(wrappedOutputStream);
+
+ try
+ {
+ doExtendedOutput(extended);
+ }
+ catch (Error ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
+ finally
+ {
+ finishOutputStream(wrappedOutputStream);
+ }
+
+ out.flushWithEOS();
+ }
+
+ void doInput(BufferInputStream in) throws Exception
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("================ {0}: {1}", getInputMeaning(), this); //$NON-NLS-1$
+ }
+
+ InputStream wrappedInputStream = wrapInputStream(in);
+ ExtendedDataInputStream extended = ExtendedDataInputStream.wrap(wrappedInputStream);
+
+ try
+ {
+ doExtendedInput(extended);
+ }
+ catch (Error ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
+ finally
+ {
+ finishInputStream(wrappedInputStream);
+ }
+ }
+
+ void doExtendedOutput(ExtendedDataOutputStream out) throws Exception
+ {
+ }
+
+ void doExtendedInput(ExtendedDataInputStream in) throws Exception
+ {
+ }
+
+ abstract String getOutputMeaning();
+
+ abstract String getInputMeaning();
}
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 7e30b589ae..a46333efd9 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
@@ -10,57 +10,47 @@
**************************************************************************/
package org.eclipse.net4j.signal;
-import org.eclipse.net4j.buffer.BufferInputStream;
-import org.eclipse.net4j.util.ReflectUtil;
-
-import java.text.MessageFormat;
-
/**
* @author Eike Stepper
*/
public abstract class SignalActor extends Signal
{
- public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
-
- private boolean terminated;
-
- private Object result;
-
/**
* @since 2.0
*/
- public SignalActor(SignalProtocol<?> protocol, short signalID)
+ public SignalActor(SignalProtocol<?> protocol, short id, String name)
{
- super(protocol, signalID);
+ super(protocol, id, name);
setCorrelationID(protocol.getNextCorrelationID());
}
- public Object send() throws Exception, SignalRemoteException
+ /**
+ * @since 2.0
+ */
+ public SignalActor(SignalProtocol<?> protocol, short id)
{
- return send(NO_TIMEOUT);
+ super(protocol, id);
+ setCorrelationID(protocol.getNextCorrelationID());
}
- public Object send(long timeout) throws Exception, SignalRemoteException
+ /**
+ * @since 2.0
+ */
+ public SignalActor(SignalProtocol<?> protocol, Enum<?> literal)
{
- if (terminated)
- {
- throw new IllegalStateException("Terminated"); //$NON-NLS-1$
- }
-
- getProtocol().startSignal(this, timeout);
- terminated = true;
- return result;
+ super(protocol, literal);
+ setCorrelationID(protocol.getNextCorrelationID());
}
@Override
- public String toString()
+ String getInputMeaning()
{
- return MessageFormat.format("{0}[{1}, {2}, correlation={3} {4}]", ReflectUtil.getSimpleName(getClass()),
- getSignalID(), getProtocol(), getCorrelationID(), terminated ? "SENT" : "UNSENT");
+ return "Confirming";
}
- protected void setResult(Object result)
+ @Override
+ String getOutputMeaning()
{
- this.result = result;
+ return "Requesting";
}
}
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 5c2fb306f4..a19c91d30f 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
@@ -16,7 +16,8 @@ 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.protocol.Protocol;
+import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.io.IStreamWrapper;
import org.eclipse.net4j.util.io.StreamWrapperChain;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -24,27 +25,37 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.OM;
import org.eclipse.spi.net4j.InternalConnector;
+import org.eclipse.spi.net4j.Protocol;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.text.MessageFormat;
+import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
/**
* @author Eike Stepper
*/
-public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE>
+public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> implements
+ ISignalProtocol<INFRA_STRUCTURE>
{
- public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
-
/**
* @since 2.0
*/
public static final short SIGNAL_REMOTE_EXCEPTION = -1;
+ /**
+ * @since 2.0
+ */
+ public static final short SIGNAL_MONITOR_CANCELED = -2;
+
+ /**
+ * @since 2.0
+ */
+ public static final short SIGNAL_MONITOR_PROGRESS = -3;
+
private static final int MIN_CORRELATION_ID = 1;
private static final int MAX_CORRELATION_ID = Integer.MAX_VALUE;
@@ -53,9 +64,13 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
private static final ContextTracer STREAM_TRACER = new ContextTracer(OM.DEBUG_BUFFER_STREAM, SignalProtocol.class);
+ private long timeout = NO_TIMEOUT;
+
private IStreamWrapper streamWrapper;
- private Map<Integer, Signal> signals = new ConcurrentHashMap<Integer, Signal>(0);
+ private IFailOverStrategy failOverStrategy;
+
+ private Map<Integer, Signal> signals = new HashMap<Integer, Signal>();
private int nextCorrelationID = MIN_CORRELATION_ID;
@@ -66,6 +81,22 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
/**
* @since 2.0
*/
+ public long getTimeout()
+ {
+ return timeout;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void setTimeout(long timeout)
+ {
+ this.timeout = timeout;
+ }
+
+ /**
+ * @since 2.0
+ */
public IChannel open(IConnector connector)
{
InternalConnector conn = (InternalConnector)connector;
@@ -107,6 +138,22 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
}
}
+ /**
+ * @since 2.0
+ */
+ public IFailOverStrategy getFailOverStrategy()
+ {
+ return failOverStrategy;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void setFailOverStrategy(IFailOverStrategy failOverStrategy)
+ {
+ this.failOverStrategy = failOverStrategy;
+ }
+
public boolean waitForSignals(long timeout)
{
synchronized (signals)
@@ -189,7 +236,7 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
signal = provideSignalReactor(signalID);
signal.setCorrelationID(-correlationID);
- signal.setBufferInputStream(new SignalInputStream(getInputStreamTimeout()));
+ signal.setBufferInputStream(new SignalInputStream(getTimeout()));
signal.setBufferOutputStream(new SignalOutputStream(-correlationID, signalID, false));
signals.put(-correlationID, signal);
getExecutorService().execute(signal);
@@ -218,11 +265,6 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
}
}
- public long getInputStreamTimeout()
- {
- return NO_TIMEOUT;
- }
-
@Override
public String toString()
{
@@ -245,18 +287,26 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
protected final SignalReactor provideSignalReactor(short signalID)
{
checkActive();
- if (signalID == SIGNAL_REMOTE_EXCEPTION)
+ switch (signalID)
{
+ case SIGNAL_REMOTE_EXCEPTION:
return new RemoteExceptionIndication(this);
- }
- SignalReactor signal = createSignalReactor(signalID);
- if (signal == null)
- {
- throw new IllegalArgumentException("Invalid signalID " + signalID);
- }
+ case SIGNAL_MONITOR_CANCELED:
+ return new MonitorCanceledIndication(this);
- return signal;
+ case SIGNAL_MONITOR_PROGRESS:
+ return new MonitorProgressIndication(this);
+
+ default:
+ SignalReactor signal = createSignalReactor(signalID);
+ if (signal == null)
+ {
+ throw new IllegalArgumentException("Invalid signalID " + signalID);
+ }
+
+ return signal;
+ }
}
/**
@@ -292,10 +342,10 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
throw new IllegalArgumentException("signalActor.getProtocol() != this"); //$NON-NLS-1$
}
- short signalID = signalActor.getSignalID();
+ short signalID = signalActor.getID();
int correlationID = signalActor.getCorrelationID();
- signalActor.setBufferInputStream(new SignalInputStream(timeout));
signalActor.setBufferOutputStream(new SignalOutputStream(correlationID, signalID, true));
+ signalActor.setBufferInputStream(new SignalInputStream(timeout));
synchronized (signals)
{
signals.put(correlationID, signalActor);
@@ -314,7 +364,7 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
}
}
- void stopSignal(int correlationID, Throwable t)
+ void handleRemoteException(int correlationID, Throwable t, boolean responding)
{
synchronized (signals)
{
@@ -322,13 +372,39 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
if (signal instanceof RequestWithConfirmation)
{
RequestWithConfirmation<?> request = (RequestWithConfirmation<?>)signal;
- request.setRemoteException(t);
+ request.setRemoteException(t, responding);
}
signals.notifyAll();
}
}
+ void handleMonitorProgress(int correlationID, int totalWork, int work)
+ {
+ synchronized (signals)
+ {
+ Signal signal = signals.get(correlationID);
+ if (signal instanceof RequestWithMonitoring)
+ {
+ RequestWithMonitoring<?> request = (RequestWithMonitoring<?>)signal;
+ request.setMonitorProgress(totalWork, work);
+ }
+ }
+ }
+
+ void handleMonitorCanceled(int correlationID)
+ {
+ synchronized (signals)
+ {
+ Signal signal = signals.get(correlationID);
+ if (signal instanceof IndicationWithMonitoring)
+ {
+ IndicationWithMonitoring indication = (IndicationWithMonitoring)signal;
+ indication.setMonitorCanceled();
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/
@@ -368,8 +444,14 @@ public abstract class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STR
public IBuffer provideBuffer()
{
+ IChannel channel = getChannel();
+ if (channel == null)
+ {
+ throw new IORuntimeException("No channel for protocol " + SignalProtocol.this);
+ }
+
IBuffer buffer = delegate.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(getChannel().getIndex());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getID());
if (STREAM_TRACER.isEnabled())
{
STREAM_TRACER.trace("Providing buffer for correlation " + correlationID); //$NON-NLS-1$
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 962af81478..ba62a6eb85 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
@@ -10,8 +10,6 @@
**************************************************************************/
package org.eclipse.net4j.signal;
-import org.eclipse.net4j.util.ReflectUtil;
-
/**
* @author Eike Stepper
*/
@@ -20,15 +18,36 @@ public abstract class SignalReactor extends Signal
/**
* @since 2.0
*/
- protected SignalReactor(SignalProtocol<?> protocol, short signalID)
+ public SignalReactor(SignalProtocol<?> protocol, short id, String name)
+ {
+ super(protocol, id, name);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public SignalReactor(SignalProtocol<?> protocol, short signalID)
{
super(protocol, signalID);
}
+ /**
+ * @since 2.0
+ */
+ public SignalReactor(SignalProtocol<?> protocol, Enum<?> literal)
+ {
+ super(protocol, literal);
+ }
+
+ @Override
+ String getInputMeaning()
+ {
+ return "Indicating";
+ }
+
@Override
- public String toString()
+ String getOutputMeaning()
{
- return ReflectUtil.getSimpleName(getClass()) + "[" + getSignalID() + ", " + getProtocol() + ", correlation=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + getCorrelationID() + "]"; //$NON-NLS-1$
+ return "Responding";
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java
index ff782e1d45..617202a41c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/AbstractFailOverStrategy.java
@@ -10,9 +10,8 @@
**************************************************************************/
package org.eclipse.net4j.signal.failover;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalActor;
-import org.eclipse.net4j.signal.SignalRemoteException;
import org.eclipse.net4j.util.event.Notifier;
/**
@@ -21,7 +20,7 @@ import org.eclipse.net4j.util.event.Notifier;
*/
public abstract class AbstractFailOverStrategy extends Notifier implements IFailOverStrategy
{
- private long defaultTimeout = SignalActor.NO_TIMEOUT;
+ private long defaultTimeout = RequestWithConfirmation.NO_TIMEOUT;
public AbstractFailOverStrategy()
{
@@ -37,7 +36,7 @@ public abstract class AbstractFailOverStrategy extends Notifier implements IFail
this.defaultTimeout = defaultTimeout;
}
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception, SignalRemoteException
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception, RemoteException
{
return send(request, defaultTimeout);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
index 242824fcc6..32b12ec620 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/FailOverStrategy.java
@@ -12,9 +12,9 @@ package org.eclipse.net4j.signal.failover;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalRemoteException;
import org.eclipse.net4j.util.CheckUtil;
import java.util.concurrent.TimeoutException;
@@ -28,8 +28,7 @@ public abstract class FailOverStrategy extends AbstractFailOverStrategy
{
}
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception,
- SignalRemoteException
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception, RemoteException
{
for (;;)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
index 245e57663a..62fc021bc6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/IFailOverStrategy.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.net4j.signal.failover;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalRemoteException;
import org.eclipse.net4j.util.event.INotifier;
/**
@@ -29,8 +29,7 @@ public interface IFailOverStrategy extends INotifier
*/
public void setDefaultTimeout(long defaultTimeout);
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception, SignalRemoteException;
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) throws Exception, RemoteException;
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception,
- SignalRemoteException;
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception, RemoteException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
index 689675c1aa..79b18c5cc5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/failover/NOOPFailOverStrategy.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.net4j.signal.failover;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalRemoteException;
import org.eclipse.net4j.util.event.IListener;
/**
@@ -23,8 +23,7 @@ public class NOOPFailOverStrategy extends AbstractFailOverStrategy
{
}
- public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception,
- SignalRemoteException
+ public <RESULT> RESULT send(RequestWithConfirmation<RESULT> request, long timeout) throws Exception, RemoteException
{
return request.send(timeout);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/acceptor/Acceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java
index 6d89a692b6..b63f3f2a10 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/acceptor/Acceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Acceptor.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.internal.net4j.acceptor;
+package org.eclipse.spi.net4j;
import org.eclipse.net4j.ITransportConfig;
import org.eclipse.net4j.connector.IConnector;
@@ -23,14 +23,12 @@ import org.eclipse.net4j.util.security.INegotiator;
import org.eclipse.internal.net4j.TransportConfig;
import org.eclipse.internal.net4j.bundle.OM;
-import org.eclipse.spi.net4j.InternalAcceptor;
-import org.eclipse.spi.net4j.InternalConnector;
-
import java.util.HashSet;
import java.util.Set;
/**
* @author Eike Stepper
+ * @since 2.0
*/
public abstract class Acceptor extends Container<IConnector> implements InternalAcceptor
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/channel/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
index 23cd94753b..4bb4f65100 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/channel/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Channel.java
@@ -8,25 +8,20 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.internal.net4j.channel;
+package org.eclipse.spi.net4j;
import org.eclipse.net4j.buffer.BufferState;
import org.eclipse.net4j.buffer.IBuffer;
import org.eclipse.net4j.buffer.IBufferHandler;
import org.eclipse.net4j.channel.IChannelMultiplexer;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.concurrent.IWorkSerializer;
import org.eclipse.net4j.util.concurrent.QueueWorkerWorkSerializer;
import org.eclipse.net4j.util.concurrent.SynchronousWorkSerializer;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.OM;
-import org.eclipse.spi.net4j.InternalChannel;
-import org.eclipse.spi.net4j.InternalChannelMultiplexer;
-
import java.text.MessageFormat;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -34,6 +29,7 @@ import java.util.concurrent.ExecutorService;
/**
* @author Eike Stepper
+ * @since 2.0
*/
public class Channel extends Lifecycle implements InternalChannel
{
@@ -43,7 +39,7 @@ public class Channel extends Lifecycle implements InternalChannel
private InternalChannelMultiplexer channelMultiplexer;
- private short channelIndex = IBuffer.NO_CHANNEL;
+ private short id = IBuffer.NO_CHANNEL;
private ExecutorService receiveExecutor;
@@ -56,9 +52,6 @@ public class Channel extends Lifecycle implements InternalChannel
private transient Queue<IBuffer> sendQueue;
- @ExcludeFromDump
- private transient boolean inverseClosed;
-
public Channel()
{
}
@@ -98,19 +91,15 @@ public class Channel extends Lifecycle implements InternalChannel
this.channelMultiplexer = (InternalChannelMultiplexer)channelMultiplexer;
}
- public short getIndex()
+ public short getID()
{
- return channelIndex;
+ return id;
}
- public void setChannelIndex(short channelIndex)
+ public void setID(short id)
{
- if (channelIndex == IBuffer.NO_CHANNEL)
- {
- throw new IllegalArgumentException("channelIndex == INVALID_CHANNEL_ID"); //$NON-NLS-1$
- }
-
- this.channelIndex = channelIndex;
+ checkArg(id != IBuffer.NO_CHANNEL, "id == IBuffer.NO_CHANNEL"); //$NON-NLS-1$
+ this.id = id;
}
public ExecutorService getReceiveExecutor()
@@ -154,7 +143,7 @@ public class Channel extends Lifecycle implements InternalChannel
if (TRACER.isEnabled())
{
- TRACER.format("Handling buffer from client: {0} --> {1}", buffer, this); //$NON-NLS-1$
+ TRACER.format("Handling buffer: {0} --> {1}", buffer, this); //$NON-NLS-1$
}
if (sendQueue == null)
@@ -214,14 +203,14 @@ public class Channel extends Lifecycle implements InternalChannel
@Override
public String toString()
{
- return MessageFormat.format("Channel[{0}, {1}]", channelIndex, getLocation()); //$NON-NLS-1$
+ return MessageFormat.format("Channel[{0}, {1}]", id, getLocation()); //$NON-NLS-1$
}
@Override
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- checkState(channelIndex != IBuffer.NO_CHANNEL, "channelIndex == NO_CHANNEL"); //$NON-NLS-1$
+ checkState(id != IBuffer.NO_CHANNEL, "channelID == NO_CHANNEL"); //$NON-NLS-1$
checkState(channelMultiplexer, "channelMultiplexer"); //$NON-NLS-1$
}
@@ -257,24 +246,7 @@ public class Channel extends Lifecycle implements InternalChannel
@Override
protected void doDeactivate() throws Exception
{
- if (!inverseClosed)
- {
- channelMultiplexer.closeChannel(this);
- }
-
- super.doDeactivate();
- }
-
- public void finishDeactivate(boolean inverse)
- {
- inverseClosed = inverse;
- if (inverse)
- {
- LifecycleUtil.deactivate(receiveHandler);
- deactivate();
- }
-
- receiveHandler = null;
+ channelMultiplexer.closeChannel(this);
if (receiveSerializer != null)
{
receiveSerializer.dispose();
@@ -286,6 +258,8 @@ public class Channel extends Lifecycle implements InternalChannel
sendQueue.clear();
sendQueue = null;
}
+
+ super.doDeactivate();
}
public void close()
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
new file mode 100644
index 0000000000..5a85aeeee5
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
@@ -0,0 +1,360 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.ITransportConfig;
+import org.eclipse.net4j.buffer.IBuffer;
+import org.eclipse.net4j.channel.ChannelException;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.channel.IChannelMultiplexer;
+import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.protocol.IProtocolProvider;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+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.LifecycleUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.security.INegotiationContext;
+
+import org.eclipse.internal.net4j.TransportConfig;
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class ChannelMultiplexer extends Container<IChannel> implements InternalChannelMultiplexer
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONNECTOR, ChannelMultiplexer.class);
+
+ private ITransportConfig config;
+
+ private long channelTimeout = IChannelMultiplexer.DEFAULT_CHANNEL_TIMEOUT;
+
+ @ExcludeFromDump
+ private transient ConcurrentMap<Short, IChannel> channels = new ConcurrentHashMap<Short, IChannel>();
+
+ @ExcludeFromDump
+ private transient Set<Short> channelIDs = new HashSet<Short>();
+
+ @ExcludeFromDump
+ private transient int lastChannelID;
+
+ public ChannelMultiplexer()
+ {
+ }
+
+ public synchronized ITransportConfig getConfig()
+ {
+ if (config == null)
+ {
+ config = new TransportConfig();
+ }
+
+ return config;
+ }
+
+ public synchronized void setConfig(ITransportConfig config)
+ {
+ checkInactive();
+ this.config = config;
+ }
+
+ public long getChannelTimeout()
+ {
+ if (channelTimeout == IChannelMultiplexer.DEFAULT_CHANNEL_TIMEOUT)
+ {
+ return OM.BUNDLE.getDebugSupport().getDebugOption("channel.timeout", 10000);
+ }
+
+ return channelTimeout;
+ }
+
+ public void setChannelTimeout(long channelTimeout)
+ {
+ this.channelTimeout = channelTimeout;
+ }
+
+ public final InternalChannel getChannel(short channelID)
+ {
+ return (InternalChannel)channels.get(channelID);
+ }
+
+ public final Collection<IChannel> getChannels()
+ {
+ return channels.values();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return channels.isEmpty();
+ }
+
+ public IChannel[] getElements()
+ {
+ List<IChannel> list = new ArrayList<IChannel>(getChannels());
+ return list.toArray(new IChannel[list.size()]);
+ }
+
+ public InternalChannel openChannel() throws ChannelException
+ {
+ return openChannel((IProtocol<?>)null);
+ }
+
+ public InternalChannel openChannel(String protocolID, Object infraStructure) throws ChannelException
+ {
+ IProtocol<?> protocol = createProtocol(protocolID, infraStructure);
+ if (protocol == null)
+ {
+ throw new IllegalArgumentException("Unknown protocolID: " + protocolID);
+ }
+
+ return openChannel(protocol);
+ }
+
+ public InternalChannel openChannel(IProtocol<?> protocol) throws ChannelException
+ {
+ InternalChannel channel = createChannel();
+ initChannel(channel, protocol);
+ channel.setID(getNextChannelID());
+ addChannel(channel);
+
+ try
+ {
+ try
+ {
+ registerChannelWithPeer(channel.getID(), getChannelTimeout(), protocol);
+ }
+ catch (TimeoutRuntimeException ex)
+ {
+ // Adjust the message for the complete timeout time
+ throw new TimeoutRuntimeException("Registration timeout after " + getChannelTimeout() + " milliseconds");
+ }
+ }
+ catch (ChannelException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new ChannelException(ex);
+ }
+
+ return channel;
+ }
+
+ public InternalChannel inverseOpenChannel(short channelID, String protocolID)
+ {
+ IProtocol<?> protocol = createProtocol(protocolID, null);
+
+ InternalChannel channel = createChannel();
+ initChannel(channel, protocol);
+ channel.setID(channelID);
+ addChannel(channel);
+ return channel;
+ }
+
+ public void closeChannel(InternalChannel channel) throws ChannelException
+ {
+ InternalChannel internalChannel = channel;
+ deregisterChannelFromPeer(internalChannel, getChannelTimeout());
+ removeChannel(internalChannel);
+ }
+
+ public void inverseCloseChannel(short channelID) throws ChannelException
+ {
+ InternalChannel channel = getChannel(channelID);
+ LifecycleUtil.deactivate(channel);
+ }
+
+ protected InternalChannel createChannel()
+ {
+ return new Channel();
+ }
+
+ protected void initChannel(InternalChannel channel, IProtocol<?> protocol)
+ {
+ channel.setMultiplexer(this);
+ channel.setReceiveExecutor(getConfig().getReceiveExecutor());
+ // channel.setUserID(getUserID());
+ if (protocol != null)
+ {
+ protocol.setChannel(channel);
+ LifecycleUtil.activate(protocol);
+ if (TRACER.isEnabled())
+ {
+ String protocolType = protocol == null ? null : protocol.getType();
+ TRACER.format("Opening channel with protocol {0}", protocolType);
+ }
+
+ channel.setReceiveHandler(protocol);
+ }
+ else
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Opening channel without protocol");
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <INFRA_STRUCTURE> IProtocol<INFRA_STRUCTURE> createProtocol(String type, INFRA_STRUCTURE infraStructure)
+ {
+ if (StringUtil.isEmpty(type))
+ {
+ return null;
+ }
+
+ IProtocolProvider protocolProvider = getConfig().getProtocolProvider();
+ if (protocolProvider == null)
+ {
+ throw new ChannelException("No protocol provider configured");
+ }
+
+ IProtocol<INFRA_STRUCTURE> protocol = (IProtocol<INFRA_STRUCTURE>)protocolProvider.getProtocol(type);
+ if (protocol == null)
+ {
+ throw new ChannelException("Invalid protocol factory: " + type);
+ }
+
+ protocol.setBufferProvider(getConfig().getBufferProvider());
+ protocol.setExecutorService(getConfig().getReceiveExecutor());
+ if (infraStructure != null)
+ {
+ protocol.setInfraStructure(infraStructure);
+ }
+
+ return protocol;
+ }
+
+ protected IFactoryKey createProtocolFactoryKey(String type)
+ {
+ switch (getLocation())
+ {
+ case SERVER:
+ return new FactoryKey(ServerProtocolFactory.PRODUCT_GROUP, type);
+ case CLIENT:
+ return new FactoryKey(ClientProtocolFactory.PRODUCT_GROUP, type);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected boolean isDeferredActivation()
+ {
+ return true;
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ synchronized (channelIDs)
+ {
+ for (IChannel channel : getChannels())
+ {
+ LifecycleUtil.deactivate(channel);
+ }
+
+ channels.clear();
+ }
+
+ super.doDeactivate();
+ }
+
+ protected abstract INegotiationContext createNegotiationContext();
+
+ protected abstract void registerChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol)
+ throws ChannelException;
+
+ protected abstract void deregisterChannelFromPeer(InternalChannel channel, long timeout) throws ChannelException;
+
+ private short getNextChannelID()
+ {
+ synchronized (channelIDs)
+ {
+ int start = lastChannelID;
+ int maxValue = Short.MAX_VALUE;
+ for (;;)
+ {
+ ++lastChannelID;
+ if (lastChannelID == start)
+ {
+ throw new ChannelException("Too many channels");
+ }
+
+ if (lastChannelID > maxValue)
+ {
+ lastChannelID = 1;
+ }
+
+ short id = (short)(isClient() ? lastChannelID : -lastChannelID);
+ if (channelIDs.add(id))
+ {
+ return id;
+ }
+ }
+ }
+ }
+
+ private void addChannel(InternalChannel channel)
+ {
+ short channelID = channel.getID();
+ if (channelID == IBuffer.CONTROL_CHANNEL || channelID == IBuffer.NO_CHANNEL)
+ {
+ throw new ChannelException("Invalid channel ID: " + channelID);
+ }
+
+ channels.put(channelID, channel);
+ LifecycleUtil.activate(channel);
+ fireElementAddedEvent(channel);
+ }
+
+ private void removeChannel(InternalChannel channel)
+ {
+ try
+ {
+ short channelID = channel.getID();
+ boolean removed;
+ synchronized (channelIDs)
+ {
+ removed = channels.remove(channelID) != null;
+ if (removed)
+ {
+ channelIDs.remove(channelID);
+ }
+ }
+
+ if (removed)
+ {
+ fireElementRemovedEvent(channel);
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ throw ex;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ClientProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ClientProtocolFactory.java
index 710578e224..aa926d8909 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ClientProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ClientProtocolFactory.java
@@ -8,12 +8,13 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.protocol;
+package org.eclipse.spi.net4j;
import org.eclipse.net4j.util.factory.Factory;
/**
* @author Eike Stepper
+ * @since 2.0
*/
public abstract class ClientProtocolFactory extends Factory
{
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
new file mode 100644
index 0000000000..acb145e4aa
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Connector.java
@@ -0,0 +1,402 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.ITransportConfig;
+import org.eclipse.net4j.buffer.IBuffer;
+import org.eclipse.net4j.connector.ConnectorException;
+import org.eclipse.net4j.connector.ConnectorState;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.connector.IConnectorStateEvent;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.INotifier;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.security.INegotiationContext;
+import org.eclipse.net4j.util.security.INegotiator;
+import org.eclipse.net4j.util.security.NegotiationException;
+
+import org.eclipse.internal.net4j.TransportConfig;
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.text.MessageFormat;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class Connector extends ChannelMultiplexer implements InternalConnector
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONNECTOR, Connector.class);
+
+ private String userID;
+
+ private ITransportConfig config;
+
+ private transient ConnectorState connectorState = ConnectorState.DISCONNECTED;
+
+ @ExcludeFromDump
+ private transient CountDownLatch finishedConnecting;
+
+ @ExcludeFromDump
+ private transient CountDownLatch finishedNegotiating;
+
+ @ExcludeFromDump
+ private transient INegotiationContext negotiationContext;
+
+ @ExcludeFromDump
+ private transient NegotiationException negotiationException;
+
+ public Connector()
+ {
+ }
+
+ @Override
+ public synchronized ITransportConfig getConfig()
+ {
+ if (config == null)
+ {
+ config = new TransportConfig();
+ }
+
+ return config;
+ }
+
+ @Override
+ public synchronized void setConfig(ITransportConfig config)
+ {
+ checkInactive();
+ this.config = config;
+ }
+
+ public INegotiator getNegotiator()
+ {
+ return getConfig().getNegotiator();
+ }
+
+ public void setNegotiator(INegotiator negotiator)
+ {
+ getConfig().setNegotiator(negotiator);
+ }
+
+ public INegotiationContext getNegotiationContext()
+ {
+ return negotiationContext;
+ }
+
+ public boolean isClient()
+ {
+ return getLocation() == Location.CLIENT;
+ }
+
+ public boolean isServer()
+ {
+ return getLocation() == Location.SERVER;
+ }
+
+ public String getUserID()
+ {
+ return userID;
+ }
+
+ public void setUserID(String userID)
+ {
+ checkState(getState() != ConnectorState.CONNECTED, "Connector is already connected");
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting userID {0} for {1}", userID, this);
+ }
+
+ this.userID = userID;
+ }
+
+ public ConnectorState getState()
+ {
+ return connectorState;
+ }
+
+ public void setState(ConnectorState newState) throws ConnectorException
+ {
+ ConnectorState oldState = getState();
+ if (newState != oldState)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting state {0} (was {1}) for {2}", newState, oldState.toString().toLowerCase(), this);
+ }
+
+ connectorState = newState;
+ switch (newState)
+ {
+ case DISCONNECTED:
+ if (finishedConnecting != null)
+ {
+ finishedConnecting.countDown();
+ finishedConnecting = null;
+ }
+
+ if (finishedNegotiating != null)
+ {
+ finishedNegotiating.countDown();
+ finishedNegotiating = null;
+ }
+ break;
+
+ case CONNECTING:
+ finishedConnecting = new CountDownLatch(1);
+ finishedNegotiating = new CountDownLatch(1);
+ // The concrete implementation must advance state to NEGOTIATING or CONNECTED
+ break;
+
+ case NEGOTIATING:
+ finishedConnecting.countDown();
+ negotiationContext = createNegotiationContext();
+ getNegotiator().negotiate(negotiationContext);
+ break;
+
+ case CONNECTED:
+ negotiationContext = null;
+ deferredActivate();
+ finishedConnecting.countDown();
+ finishedNegotiating.countDown();
+ break;
+ }
+
+ fireEvent(new ConnectorStateEvent(this, oldState, newState));
+ }
+ }
+
+ public boolean isDisconnected()
+ {
+ return connectorState == ConnectorState.DISCONNECTED;
+ }
+
+ public boolean isConnecting()
+ {
+ return connectorState == ConnectorState.CONNECTING;
+ }
+
+ public boolean isNegotiating()
+ {
+ return connectorState == ConnectorState.NEGOTIATING;
+ }
+
+ public boolean isConnected()
+ {
+ if (negotiationException != null)
+ {
+ throw new ConnectorException("Connector negotiation failed", negotiationException);
+ }
+
+ return connectorState == ConnectorState.CONNECTED;
+ }
+
+ public void connectAsync() throws ConnectorException
+ {
+ try
+ {
+ activate();
+ }
+ catch (ConnectorException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new ConnectorException(ex);
+ }
+ }
+
+ public boolean waitForConnection(long timeout) throws ConnectorException
+ {
+ final long MAX_POLL_INTERVAL = 100L;
+ boolean withTimeout = timeout != NO_TIMEOUT;
+
+ try
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Waiting for connection...");
+ }
+
+ for (;;)
+ {
+ long t = MAX_POLL_INTERVAL;
+ if (withTimeout)
+ {
+ t = Math.min(MAX_POLL_INTERVAL, timeout);
+ timeout -= MAX_POLL_INTERVAL;
+ }
+
+ if (t <= 0)
+ {
+ break;
+ }
+
+ if (finishedNegotiating == null)
+ {
+ break;
+ }
+
+ if (finishedNegotiating.await(t, TimeUnit.MILLISECONDS))
+ {
+ break;
+ }
+ }
+
+ return isConnected();
+ }
+ catch (InterruptedException ex)
+ {
+ return false;
+ }
+ }
+
+ public boolean connect(long timeout) throws ConnectorException
+ {
+ connectAsync();
+ return waitForConnection(timeout);
+ }
+
+ public boolean connect() throws ConnectorException
+ {
+ return connect(NO_TIMEOUT);
+ }
+
+ public ConnectorException disconnect()
+ {
+ Exception ex = deactivate();
+ if (ex == null)
+ {
+ return null;
+ }
+
+ if (ex instanceof ConnectorException)
+ {
+ return (ConnectorException)ex;
+ }
+
+ return new ConnectorException(ex);
+ }
+
+ public short getBufferCapacity()
+ {
+ return getConfig().getBufferProvider().getBufferCapacity();
+ }
+
+ public IBuffer provideBuffer()
+ {
+ return getConfig().getBufferProvider().provideBuffer();
+ }
+
+ public void retainBuffer(IBuffer buffer)
+ {
+ getConfig().getBufferProvider().retainBuffer(buffer);
+ }
+
+ protected void leaveConnecting()
+ {
+ if (getNegotiator() == null)
+ {
+ setState(ConnectorState.CONNECTED);
+ }
+ else
+ {
+ setState(ConnectorState.NEGOTIATING);
+ }
+ }
+
+ @Override
+ protected abstract INegotiationContext createNegotiationContext();
+
+ protected NegotiationException getNegotiationException()
+ {
+ return negotiationException;
+ }
+
+ protected void setNegotiationException(NegotiationException negotiationException)
+ {
+ this.negotiationException = negotiationException;
+ }
+
+ @Override
+ protected boolean isDeferredActivation()
+ {
+ return true;
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ if (getConfig().getBufferProvider() == null)
+ {
+ throw new IllegalStateException("getConfig().getBufferProvider() == null");
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ setState(ConnectorState.CONNECTING);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ setState(ConnectorState.DISCONNECTED);
+ super.doDeactivate();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static class ConnectorStateEvent extends Event implements IConnectorStateEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private ConnectorState oldState;
+
+ private ConnectorState newState;
+
+ public ConnectorStateEvent(INotifier notifier, ConnectorState oldState, ConnectorState newState)
+ {
+ super(notifier);
+ this.oldState = oldState;
+ this.newState = newState;
+ }
+
+ public IConnector getConnector()
+ {
+ return (IConnector)getSource();
+ }
+
+ public ConnectorState getOldState()
+ {
+ return oldState;
+ }
+
+ public ConnectorState getNewState()
+ {
+ return newState;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("ConnectorStateEvent[source={0}, oldState={1}, newState={2}]", getSource(),
+ getOldState(), getNewState());
+ }
+ }
+}
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 556a1cfda5..90f4039fa4 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
@@ -27,9 +27,12 @@ public interface InternalChannel extends IChannel, IBufferProvider, ILifecycle.I
/**
* @since 2.0
*/
- public void setUserID(String userID);
+ public void setID(short id);
- public void setChannelIndex(short channelIndex);
+ /**
+ * @since 2.0
+ */
+ public void setUserID(String userID);
public ExecutorService getReceiveExecutor();
@@ -43,9 +46,4 @@ public interface InternalChannel extends IChannel, IBufferProvider, ILifecycle.I
public void handleBufferFromMultiplexer(IBuffer buffer);
public Queue<IBuffer> getSendQueue();
-
- /**
- * @since 2.0
- */
- public void finishDeactivate(boolean inverse);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/Protocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java
index 69a8607a2a..3139624d60 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/Protocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/Protocol.java
@@ -8,31 +8,77 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.protocol;
+package org.eclipse.spi.net4j;
import org.eclipse.net4j.buffer.IBufferProvider;
import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import java.util.concurrent.ExecutorService;
/**
* @author Eike Stepper
+ * @since 2.0
*/
public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IProtocol<INFRA_STRUCTURE>
{
- private IChannel channel;
+ private ExecutorService executorService;
private IBufferProvider bufferProvider;
- private ExecutorService executorService;
-
private INFRA_STRUCTURE infraStructure;
+ private IChannel channel;
+
+ @ExcludeFromDump
+ private transient IListener channelListener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ handleChannelDeactivation();
+ };
+ };
+
public Protocol()
{
}
+ public ExecutorService getExecutorService()
+ {
+ return executorService;
+ }
+
+ public void setExecutorService(ExecutorService executorService)
+ {
+ this.executorService = executorService;
+ }
+
+ public IBufferProvider getBufferProvider()
+ {
+ return bufferProvider;
+ }
+
+ public void setBufferProvider(IBufferProvider bufferProvider)
+ {
+ this.bufferProvider = bufferProvider;
+ }
+
+ public INFRA_STRUCTURE getInfraStructure()
+ {
+ return infraStructure;
+ }
+
+ public void setInfraStructure(INFRA_STRUCTURE infraStructure)
+ {
+ this.infraStructure = infraStructure;
+ }
+
/**
* @since 2.0
*/
@@ -62,39 +108,29 @@ public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IPr
return channel;
}
- public void setChannel(IChannel channel)
- {
- this.channel = channel;
- }
-
- public IBufferProvider getBufferProvider()
- {
- return bufferProvider;
- }
-
- public void setBufferProvider(IBufferProvider bufferProvider)
- {
- this.bufferProvider = bufferProvider;
- }
-
- public ExecutorService getExecutorService()
+ public void setChannel(IChannel newChannel)
{
- return executorService;
+ if (channel != newChannel)
+ {
+ if (channel != null)
+ {
+ channel.removeListener(channelListener);
+ }
+
+ channel = newChannel;
+ if (channel != null)
+ {
+ channel.addListener(channelListener);
+ }
+ }
}
- public void setExecutorService(ExecutorService executorService)
- {
- this.executorService = executorService;
- }
-
- public INFRA_STRUCTURE getInfraStructure()
- {
- return infraStructure;
- }
-
- public void setInfraStructure(INFRA_STRUCTURE infraStructure)
+ /**
+ * @since 2.0
+ */
+ protected void handleChannelDeactivation()
{
- this.infraStructure = infraStructure;
+ deactivate();
}
@Override
@@ -109,7 +145,7 @@ public abstract class Protocol<INFRA_STRUCTURE> extends Lifecycle implements IPr
@Override
protected void doDeactivate() throws Exception
{
- channel = null;
+ setChannel(null);
super.doDeactivate();
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ServerProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ServerProtocolFactory.java
index e4fdb76ffb..b4a30d1078 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/protocol/ServerProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ServerProtocolFactory.java
@@ -8,12 +8,13 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.protocol;
+package org.eclipse.spi.net4j;
import org.eclipse.net4j.util.factory.Factory;
/**
* @author Eike Stepper
+ * @since 2.0
*/
public abstract class ServerProtocolFactory extends Factory
{

Back to the top