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 Object
implements ConnectionComponent.ConnectionAutomaton<CON>
This class implements a
ConnectionComponent.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
-
Constructor Summary
ConstructorDescriptionEmpty 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
Modifier and TypeMethodDescriptionvoid
close()
Closes the component's connection(s).Retrieves theConnectionStatus
property from the property.boolean
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
Opens the component with the given connection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
Methods inherited from interface org.refcodes.component.ConnectionOpenable
openUnchecked
-
Field Details
-
_connectionComponent
-
-
Constructor Details
-
ConnectionAutomatonImpl
public ConnectionAutomatonImpl()Empty constructor, suchLifecycleComponent.LifecycleAutomaton
cannot do much more than decline the variousLifecycleStatus
states for you. -
ConnectionAutomatonImpl
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 Details
-
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
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
Opens the component with the given connection.- Specified by:
open
in interfaceConnectionOpenable<CON>
- Parameters:
aConnection
- The connection used for opening the connection.- Throws:
IOException
- 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 interfaceConnectionStatusAccessor
- 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
Closes the component's connection(s). Throws aIOException
as upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).- Specified by:
close
in interfaceClosable
- Throws:
IOException
- thrown in case closing failed.
-