Feature #2537

try-with-resources

Added by M. Goerlich almost 5 years ago. Updated over 3 years ago.

Status:ResolvedStart date:04/27/2016
Priority:LowDue date:
Assignee:J. Moringen% Done:

100%

Category:Java
Target version:rsb-0.17

Description

Sometimes it would be nice if the RSB resource holding classes like Listener, Informer, LocalServer and RemoteServer would implement the java.lang.AutoClosable interface to be usable in the try-with-resources constructs available since Java 7.

Same would go for pythons "with" statement, e.g. implementing enter() and exit() to activate and deactivate the object.

Associated revisions

Revision 6722af73
Added by J. Moringen over 3 years ago

Implement Closeable interface in rsb-java/src/main/java/rsb/[Abstract]Activatable.java

fixes #2537

  • rsb-java/src/main/java/rsb/Activatable.java (Activatable): extend
    Closeable
  • rsb-java/src/main/java/rsb/AbstractActivatable.java: new file;
    implement close() method because Activatable cannot

Revision 7f60f1c7
Added by J. Moringen over 3 years ago

Mention Closeable support in news.rst

refs #2537

  • news.rst (RSB 0.17): mention Closeable support in the Java
    implementation

Revision 646a4618
Added by J. Moringen over 3 years ago

Added helper Abstract* classes in src/main/java/**/Abstract*.java

refs #2537

  • rsb-java/src/main/java/rsb/eventprocessing/AbstractEventReceivingStrategy.java:
    new file; contains AbstractEventReceivingStrategy helper class
  • rsb-java/src/main/java/rsb/eventprocessing/SingleThreadEventReceivingStrategy.java:
    extend AbstractEventReceivingStrategy
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultOutRouteConfigurator.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultPushInRouteConfigurator.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/AbstractConnector.java: new
    file; contains AbstractConnector helper class
  • rsb-java/src/main/java/rsb/transport/inprocess/ConnectorBase.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/BusBase.java: extend
    AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/socket/SocketOutConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/SocketInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/MultiSpreadInPushConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/spread/SpreadInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadOutConnector.java:
    likewise

Revision 3de8f6af
Added by J. Moringen over 3 years ago

Added helper Abstract* classes in src/main/java/**/Abstract*.java

refs #2537

  • rsb-java/src/main/java/rsb/eventprocessing/AbstractEventReceivingStrategy.java:
    new file; contains AbstractEventReceivingStrategy helper class
  • rsb-java/src/main/java/rsb/eventprocessing/SingleThreadEventReceivingStrategy.java:
    extend AbstractEventReceivingStrategy
  • rsb-java/src/main/java/rsb/eventprocessing/UnorderedParallelEventReceivingStrategy.java:
    likewise
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultOutRouteConfigurator.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultPushInRouteConfigurator.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/AbstractConnector.java: new
    file; contains AbstractConnector helper class
  • rsb-java/src/main/java/rsb/transport/inprocess/ConnectorBase.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/BusBase.java: extend
    AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/socket/RefCountingBus.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/BusConnectionBase.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/SocketOutConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/SocketInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadReceiver.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/spread/SpreadWrapperImpl.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/RefCountingSpreadWrapper.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/MultiSpreadInPushConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/spread/SpreadInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadOutConnector.java:
    likewise

Revision d67c87d1
Added by J. Moringen over 3 years ago

Added helper Abstract* classes in src/main/java/**/Abstract*.java

refs #2537

  • rsb-java/src/main/java/rsb/eventprocessing/AbstractEventReceivingStrategy.java:
    new file; contains AbstractEventReceivingStrategy helper class
  • rsb-java/src/main/java/rsb/eventprocessing/SingleThreadEventReceivingStrategy.java:
    extend AbstractEventReceivingStrategy
  • rsb-java/src/main/java/rsb/eventprocessing/UnorderedParallelEventReceivingStrategy.java:
    likewise
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultOutRouteConfigurator.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultPushInRouteConfigurator.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/AbstractConnector.java: new
    file; contains AbstractConnector helper class
  • rsb-java/src/main/java/rsb/transport/inprocess/ConnectorBase.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/BusBase.java: extend
    AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/socket/RefCountingBus.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/BusConnectionBase.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/SocketOutConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/SocketInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadReceiver.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/spread/SpreadWrapperImpl.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/RefCountingSpreadWrapper.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/MultiSpreadInPushConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/spread/SpreadInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadOutConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/introspection/ProtocolHandler.java:
    implemented close method

Revision ad72bb06
Added by J. Moringen over 3 years ago

Added helper Abstract* classes in src/main/java/**/Abstract*.java

refs #2537

  • rsb-java/src/main/java/rsb/eventprocessing/AbstractEventReceivingStrategy.java:
    new file; contains AbstractEventReceivingStrategy helper class
  • rsb-java/src/main/java/rsb/eventprocessing/SingleThreadEventReceivingStrategy.java:
    extend AbstractEventReceivingStrategy
  • rsb-java/src/main/java/rsb/eventprocessing/UnorderedParallelEventReceivingStrategy.java:
    likewise
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultOutRouteConfigurator.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/eventprocessing/DefaultPushInRouteConfigurator.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/AbstractConnector.java: new
    file; contains AbstractConnector helper class
  • rsb-java/src/main/java/rsb/transport/inprocess/ConnectorBase.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/BusBase.java: extend
    AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/socket/RefCountingBus.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/BusConnectionBase.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/socket/SocketOutConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/socket/SocketInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadReceiver.java:
    extend AbstractActivatable
  • rsb-java/src/main/java/rsb/transport/spread/SpreadWrapperImpl.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/RefCountingSpreadWrapper.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/MultiSpreadInPushConnector.java:
    extend AbstractConnector
  • rsb-java/src/main/java/rsb/transport/spread/SpreadInPushConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/transport/spread/SpreadOutConnector.java:
    likewise
  • rsb-java/src/main/java/rsb/introspection/ProtocolHandler.java:
    implemented close method

History

#1 Updated by J. Wienke almost 5 years ago

For python this is already supported.

#2 Updated by J. Wienke over 4 years ago

After reading https://stackoverflow.com/questions/25190347/does-autocloseable-close-method-break-backward-compatibilty-rule-of-java it seems to be possible to implement the new java 7 AutoCloseable interface in a backwards-compatible fashion by implementing Closeable. Therefore we can extend our participants to implement Closeable and have immediate support fir try-with-resource blocks in java 7.

#3 Updated by J. Moringen over 4 years ago

  • Target version set to rsb-0.15

#4 Updated by J. Moringen about 4 years ago

  • Target version changed from rsb-0.15 to rsb-0.16

#5 Updated by J. Moringen almost 4 years ago

  • Target version changed from rsb-0.16 to rsb-0.17

#6 Updated by J. Moringen over 3 years ago

  • Status changed from New to In Progress
  • Assignee set to J. Moringen
  • % Done changed from 0 to 50

#7 Updated by J. Moringen over 3 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100

Also available in: Atom PDF