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.LifeCycleAutomatoncannot do much more than decline the variousLifeCycleStatusstates for you.ConnectionAutomatonImpl(ConnectionComponent<CON> aConnectionComponent)This constructor uses aLifeCycleStatusfor wrapping it inside theConnectionAutomatonImpl, making sure of obeying and guarding the correctLifeCycleStatus's order ofLifeCycleStatusstates for you.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the component's connection(s).ConnectionStatusgetConnectionStatus()Retrieves theConnectionStatusproperty from the property.booleanisClosable()Determines whether the component's connection(s) may get closed.booleanisClosed()Retrieves the is-closed status.booleanisOpenable(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.booleanisOpened()Retrieves the is-opened property from the opened property.voidopen(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.LifeCycleAutomatoncannot do much more than decline the variousLifeCycleStatusstates for you.
-
ConnectionAutomatonImpl
public ConnectionAutomatonImpl(ConnectionComponent<CON> aConnectionComponent)
This constructor uses aLifeCycleStatusfor wrapping it inside theConnectionAutomatonImpl, making sure of obeying and guarding the correctLifeCycleStatus's order ofLifeCycleStatusstates for you.- Parameters:
aConnectionComponent- The component to be guarded regarding the correct declination of theLifeCycleStatusstates.
-
-
Method Detail
-
getConnectionStatus
public ConnectionStatus getConnectionStatus()
Retrieves theConnectionStatusproperty from the property. Determines in whichConnectionStatusstatus a component is in.- Specified by:
getConnectionStatusin interfaceConnectionStatusAccessor- Returns:
- Returns the
ConnectionStatusproperty 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:
isOpenablein 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:
openin 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:
isOpenedin 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:
isClosablein 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:
isClosedin interfaceClosedAccessor- Returns:
- True in case of being closed.
-
close
public void close()
Closes the component's connection(s). Throws aCloseExceptionas upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).
-
-