Package org.refcodes.component
Class ConnectionAutomatonImpl<CON>
- java.lang.Object
-
- org.refcodes.component.ConnectionAutomatonImpl<CON>
-
- Type Parameters:
CON
- The type of the connection to be used.
- All Implemented Interfaces:
Closable
,Closable.CloseAutomaton
,ClosedAccessor
,ConnectionComponent<CON>
,ConnectionComponent.ConnectionAutomaton<CON>
,ConnectionOpenable<CON>
,ConnectionOpenable.ConnectionOpenAutomaton<CON>
,ConnectionStatusAccessor
,OpenedAccessor
public class ConnectionAutomatonImpl<CON> extends java.lang.Object implements ConnectionComponent.ConnectionAutomaton<CON>
This class implements aConnectionComponent.ConnectionAutomaton
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
Closable.CloseAutomaton, Closable.CloseBuilder<B extends Closable.CloseBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
ClosedAccessor.ClosedMutator, ClosedAccessor.ClosedProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionComponent
ConnectionComponent.ConnectionAutomaton<CON>, ConnectionComponent.ConnectionComponentBuilder<CON,B extends ConnectionComponent.ConnectionComponentBuilder<CON,B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionOpenable
ConnectionOpenable.ConnectionOpenAutomaton<CON>, ConnectionOpenable.ConnectionOpenBuilder<CON,B extends ConnectionOpenable.ConnectionOpenBuilder<CON,B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
ConnectionStatusAccessor.ConnectionStatusMutator, ConnectionStatusAccessor.ConnectionStatusProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
OpenedAccessor.OpenedMutator, OpenedAccessor.OpenedProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionComponent<CON>
_connectionComponent
-
Constructor Summary
Constructors Constructor Description ConnectionAutomatonImpl()
Empty constructor, suchLifeCycleComponent.LifeCycleAutomaton
cannot do much more than decline the variousLifeCycleStatus
states for you.ConnectionAutomatonImpl(ConnectionComponent<CON> aConnectionComponent)
This constructor uses aLifeCycleStatus
for wrapping it inside theConnectionAutomatonImpl
, making sure of obeying and guarding the correctLifeCycleStatus
's order ofLifeCycleStatus
states for you.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component's connection(s).ConnectionStatus
getConnectionStatus()
Retrieves theConnectionStatus
property from the property.boolean
isClosable()
Determines whether the component's connection(s) may get closed.boolean
isClosed()
Retrieves the is-closed status.boolean
isOpenable(CON aConnection)
Determines whether the given connection may get opened, if true then component may open a connection with the given connection via theConnectionOpenable.open(Object)
method.boolean
isOpened()
Retrieves the is-opened property from the opened property.void
open(CON aConnection)
Opens the component with the given connection.-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.component.ConnectionOpenable
openUnchecked
-
Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor
isConnectionOpened
-
-
-
-
Field Detail
-
_connectionComponent
protected ConnectionComponent<CON> _connectionComponent
-
-
Constructor Detail
-
ConnectionAutomatonImpl
public ConnectionAutomatonImpl()
Empty constructor, suchLifeCycleComponent.LifeCycleAutomaton
cannot do much more than decline the variousLifeCycleStatus
states for you.
-
ConnectionAutomatonImpl
public ConnectionAutomatonImpl(ConnectionComponent<CON> aConnectionComponent)
This constructor uses aLifeCycleStatus
for wrapping it inside theConnectionAutomatonImpl
, making sure of obeying and guarding the correctLifeCycleStatus
's order ofLifeCycleStatus
states for you.- Parameters:
aConnectionComponent
- The component to be guarded regarding the correct declination of theLifeCycleStatus
states.
-
-
Method Detail
-
getConnectionStatus
public ConnectionStatus getConnectionStatus()
Retrieves theConnectionStatus
property from the property. Determines in whichConnectionStatus
status a component is in.- Specified by:
getConnectionStatus
in interfaceConnectionStatusAccessor
- Returns:
- Returns the
ConnectionStatus
property stored by the property.
-
isOpenable
public boolean isOpenable(CON aConnection)
Determines whether the given connection may get opened, if true then component may open a connection with the given connection via theConnectionOpenable.open(Object)
method. Usually no physical connection is established; usually criteria describing the provided connection are evaluated; for example the connection is tested against a black list, a white list or against well-formedness or whether the specified protocols are supported (in case of a connection being a String URL beginning with "http://", "ftp://" or similar). --------------------------------------------------------------------- CAUTION: Even in case true is returned, the actual opening of a connection may fail (e.g. due to network failure or authentication issues). ---------------------------------------------------------------------- Specified by:
isOpenable
in interfaceConnectionOpenable.ConnectionOpenAutomaton<CON>
- Parameters:
aConnection
- The connection for which to determine whether it can be used to open a connection.- Returns:
- True if
ConnectionOpenable.open(Object)
is theoretically possible.
-
open
public void open(CON aConnection) throws OpenException
Opens the component with the given connection.- Specified by:
open
in interfaceConnectionOpenable<CON>
- Parameters:
aConnection
- The connection used for opening the connection.- Throws:
OpenException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
-
isOpened
public boolean isOpened()
Retrieves the is-opened property from the opened property. Determines whether the component's connection is opened. A component's connection is opened after being opened as ofOpenable.open()
orConnectionOpenable.open(Object)
.- Specified by:
isOpened
in interfaceOpenedAccessor
- Returns:
- True in case of being opened (returns the is-opened property stored by the opened property).
-
isClosable
public boolean isClosable()
Determines whether the component's connection(s) may get closed.- Specified by:
isClosable
in interfaceClosable.CloseAutomaton
- Returns:
- True if
Closable.close()
is possible.
-
isClosed
public boolean isClosed()
Retrieves the is-closed status. Determines whether the component's connection is closed. A component's connection is closed after being closed as ofClosable.close()
.- Specified by:
isClosed
in interfaceClosedAccessor
- Returns:
- True in case of being closed.
-
close
public void close()
Closes the component's connection(s). Throws aCloseException
as upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).
-
-