Package com.exedio.cope.misc
Class ConnectToken
java.lang.Object
com.exedio.cope.misc.ConnectToken
- All Implemented Interfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanintgetID()getModel()getName()static ConnectPropertiesgetProperties(Model model) static List<ConnectToken>Returns the collection of openConnectTokens on the model.booleanstatic ConnectTokenissue(Model model, ConnectProperties properties, String tokenName) Deprecated.static ConnectTokenConnects the model to the database described in the properties, if the model is not already connected.static ConnectTokenissueIfConnected(Model model, String tokenName) Issues a ConnectToken, if the model is already connected.static ConnectPropertiesremoveProperties(Model model) Deprecated.UseremovePropertiesVoidinstead.static voidremovePropertiesVoid(Model model) booleanreturnIt()Deprecated.UsereturnStrictly()insteadbooleanReturn false, if token was already returned.returnOnFailureOf(Consumer<ConnectToken> target) Callstarget.booleanstatic voidsetProperties(Model model, ConnectProperties properties) Sets the connect properties for the given model.static voidsetProperties(Model model, Supplier<ConnectProperties> properties) Sets the connect properties for the given model.toString()booleanReturns true, if this token was issued byissueIfConnected(Model, String).
-
Method Details
-
getModel
-
getID
public int getID() -
getIssueDate
-
getName
-
wasConditional
public boolean wasConditional()Returns true, if this token was issued byissueIfConnected(Model, String). Returns false, if this token was issued byissue(Model, ConnectProperties, String). -
didConnect
public boolean didConnect() -
isReturned
public boolean isReturned() -
returnStrictly
public boolean returnStrictly()- Throws:
IllegalArgumentException- if token was already returned. You may want to usereturnItConditionally()instead.
-
returnItConditionally
public boolean returnItConditionally()Return false, if token was already returned. You may want to usereturnStrictly()instead. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
returnOnFailureOf
-
toString
-
setProperties
Sets the connect properties for the given model. Enables usage ofissue(Model, String),issueIfConnected(Model, String),getTokens(Model). -
setProperties
Sets the connect properties for the given model. Enables usage ofissue(Model, String),issueIfConnected(Model, String),getTokens(Model). -
getProperties
-
removePropertiesVoid
- See Also:
-
removeProperties
Deprecated.UseremovePropertiesVoidinstead. This method may fail at computing the result if used together withsetProperties(Model, Supplier)and the supplier fails.- See Also:
-
issue
Connects the model to the database described in the properties, if the model is not already connected. Can be called multiple times, but only the first time takes effect.Usually you may want to use this method, if you want to connect this model from different servlets with equal properties in an undefined order.
-
issueIfConnected
Issues a ConnectToken, if the model is already connected. Otherwise the method returns null.Usually you may want to use this method, if you want to do something if the model is already connected, but in that case with a guarantee, that the model is not disconnected while doing those things.
Tokens returned by this method always do have
didConnect()==false.- See Also:
-
getTokens
Returns the collection of openConnectTokens on the model.Returns an unmodifiable snapshot of the actual data, so iterating over the collection on a live server cannot cause
ConcurrentModificationExceptions. -
returnIt
Deprecated.UsereturnStrictly()instead -
issue
@Deprecated public static ConnectToken issue(Model model, ConnectProperties properties, String tokenName) Deprecated.Useissue(Model, String)instead. Parameterpropertiesis ignored.- Parameters:
properties- is ignored
-
issue(Model, String)instead.