IOpenable

Interface that allows you to create components with explicit opening and closing.

Extends: IClosable

Description

The IOpenable interface allows you to create components with explicit opening and closing.

Important points

  • For components that perform opening on demand consider using IClosable interface instead.

Instance methods

isOpen

Checks if the component is opened.

public boolean isOpen()

  • returns: boolean - true if the component has been opened and false otherwise.

open

Opens the component.

void open(IContext context)

  • context: IContext - (optional) execution context to trace execution through call chain.

Examples

class MyPersistence implements IOpenable {
    private Object _client;
    ...
    public boolean isOpen() {
        return this._client != null;
    }
    
    public void open(IContext context) {
        if (this.isOpen()) {
            return;
        }
        ...
    }
    
    public void close(IContext context) {
        if (this._client != null) {
            this._client.close();
            this._client = null;
        }
    }
   
    ...
}

See also