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.ClosedPropertyNested 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.ConnectionStatusPropertyNested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
OpenedAccessor.OpenedMutator, OpenedAccessor.OpenedProperty -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEmpty 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
Modifier and TypeMethodDescriptionvoidclose()Closes the component's connection(s).Retrieves theConnectionStatusproperty from the property.booleanDetermines 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.voidOpens the component with the given connection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface org.refcodes.component.ConnectionOpenable
openUnchecked
-
Field Details
-
_connectionComponent
-
-
Constructor Details
-
ConnectionAutomatonImpl
public ConnectionAutomatonImpl()Empty constructor, suchLifecycleComponent.LifecycleAutomatoncannot do much more than decline the variousLifecycleStatusstates for you. -
ConnectionAutomatonImpl
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 Details
-
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
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
Opens the component with the given connection.- Specified by:
openin 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:
isOpenedin interfaceConnectionStatusAccessor- 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
Closes the component's connection(s). Throws aIOExceptionas 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:
closein interfaceClosable- Throws:
IOException- thrown in case closing failed.
-