Package com.exedio.cope.misc
Class ConnectToken
java.lang.Object
com.exedio.cope.misc.ConnectToken
- All Implemented Interfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
int
getID()
getModel()
getName()
static ConnectProperties
getProperties
(Model model) static List<ConnectToken>
Returns the collection of openConnectToken
s on the model.boolean
static ConnectToken
issue
(Model model, ConnectProperties properties, String tokenName) Deprecated.static ConnectToken
Connects the model to the database described in the properties, if the model is not already connected.static ConnectToken
issueIfConnected
(Model model, String tokenName) Issues a ConnectToken, if the model is already connected.static ConnectProperties
removeProperties
(Model model) Deprecated.UseremovePropertiesVoid
instead.static void
removePropertiesVoid
(Model model) boolean
returnIt()
Deprecated.UsereturnStrictly()
insteadboolean
Return false, if token was already returned.returnOnFailureOf
(Consumer<ConnectToken> target) Callstarget
.boolean
static void
setProperties
(Model model, ConnectProperties properties) Sets the connect properties for the given model.static void
setProperties
(Model model, Supplier<ConnectProperties> properties) Sets the connect properties for the given model.toString()
boolean
Returns 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:
close
in 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.UseremovePropertiesVoid
instead. 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 openConnectToken
s on the model.Returns an unmodifiable snapshot of the actual data, so iterating over the collection on a live server cannot cause
ConcurrentModificationException
s. -
returnIt
Deprecated.UsereturnStrictly()
instead -
issue
@Deprecated public static ConnectToken issue(Model model, ConnectProperties properties, String tokenName) Deprecated.Useissue(Model, String)
instead. Parameterproperties
is ignored.- Parameters:
properties
- is ignored
-
issue(Model, String)
instead.