Class Connector
- java.lang.Object
-
- sk.ipesoft.d2000.d2japi.connector.Connector
-
- All Implemented Interfaces:
D2Connector
,D2SessionFactory
public class Connector extends java.lang.Object implements D2Connector
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close connection to D2000.static D2Connector
createConnector(java.lang.String connectionString, java.lang.String certificatePath, D2ConnectorEventsListener eventsListener)
Create new instance of connector with TLS connectionstatic D2Connector
createConnector(java.lang.String connectionString, D2ConnectorEventsListener eventsListener)
Create a new instance of connector.Convertor
createDictionaryConvertor(int languageIndex)
Translator
createDictionaryTranslator(int languageIndex)
ObjectInfoCache
createObjectInfoCache(int cacheTimeMilliseconds)
java.util.concurrent.Future<D2Session>
createSession(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener)
Create new session object, connect it to D2000 and authorize it with valid D2000 user account.java.util.concurrent.Future<D2Session>
createSession(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener, java.util.Set<SharedResourceType> interestSet)
Create new session object, connect it to D2000 and authorize it with valid D2000 user account.java.util.concurrent.Future<CreateSessionResponse>
createSessionWithSpnego(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener, java.util.Set<SharedResourceType> interestSet)
Create new session object, connect it to D2000 and authorize it with valid D2000 user account.UnivalConvertor
createUnivalConvertor()
java.util.TimeZone
getApplicationTimeZone()
java.util.concurrent.Executor
getConnectionExecutor()
java.lang.String
getConnectionName()
long
getCurrentServerTimeMilliseconds()
ObjectInfoCache
getDefaultObjectInfoCache()
UnivalConvertor
getDefaultUnivalConvertor()
SharedResourcesCache
getSharedResourcesCache()
D2StructureDefinitionResolver
getStructureDefinitionResolver()
long
getTotalBytesRead()
Get number of bytes read from stream.long
getTotalBytesSent()
Get number of bytes sent into stream.boolean
isClosed()
Gettrue
afterD2SessionFactory.close()
has been called.boolean
isConnected()
void
registerStructureClasses(java.util.List<? extends java.lang.Class<?>> types)
void
setAutonomousWatchdog(boolean value)
Activate autonomous watchdog.java.lang.String
toString()
-
Methods inherited from interface sk.ipesoft.d2000.d2japi.D2SessionFactory
createSessionWithSpnego
-
-
-
-
Method Detail
-
createConnector
public static D2Connector createConnector(java.lang.String connectionString, D2ConnectorEventsListener eventsListener) throws ConnectorException
Create a new instance of connector.- Parameters:
connectionString
- where to connecteventsListener
- listener for connector events- Returns:
- new instance
- Throws:
ConnectorException
- when unable to connect
-
createConnector
public static D2Connector createConnector(java.lang.String connectionString, java.lang.String certificatePath, D2ConnectorEventsListener eventsListener) throws ConnectorException
Create new instance of connector with TLS connection- Parameters:
connectionString
- where to connectcertificatePath
- path to certificate used in TLSeventsListener
- listener for connector events- Returns:
- new instance
- Throws:
ConnectorException
- when unable to connect
-
close
public void close()
Description copied from interface:D2SessionFactory
Close connection to D2000.- Specified by:
close
in interfaceD2SessionFactory
-
createDictionaryConvertor
public Convertor createDictionaryConvertor(int languageIndex)
-
createDictionaryTranslator
public Translator createDictionaryTranslator(int languageIndex)
-
createObjectInfoCache
public ObjectInfoCache createObjectInfoCache(int cacheTimeMilliseconds)
-
createSession
public java.util.concurrent.Future<D2Session> createSession(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener)
Description copied from interface:D2SessionFactory
Create new session object, connect it to D2000 and authorize it with valid D2000 user account. Get the session asynchronously via returnedFuture
object.Note: Do not use in combination with SPNEGO authentication mechanism if you intend to obtain result from returned future.
Operation is executed in background thread and goes through following steps:
- Create new instance.
- Connect session to the D2000 kernel.
- Logon to the D2000 kernel with provided user account.
- Future result may throw
ExecutionException
withcause
: ConnectSessionException
- when kernel refused connection of the sessionLoginFailedException
- when kernel refused to logon with provided user account
- Specified by:
createSession
in interfaceD2SessionFactory
- Parameters:
sessionParams
- authentication informationeventsListener
- instance of event listener object to receive asynchronous events from D2000 session- Returns:
- upcoming session object in form of future
-
createSession
public java.util.concurrent.Future<D2Session> createSession(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener, java.util.Set<SharedResourceType> interestSet)
Description copied from interface:D2SessionFactory
Create new session object, connect it to D2000 and authorize it with valid D2000 user account. Get the session asynchronously via returnedFuture
object.Note: Do not use in combination with SPNEGO authentication mechanism if you intend to obtain result from returned future.
Operation is executed in background thread and goes through following steps:
- Create new instance.
- Report current state of shared resources to the
sharedResourcesListener
. - Connect session to the D2000 kernel.
- Logon to the D2000 kernel with provided user account.
- Future result may throw
ExecutionException
withcause
: ConnectSessionException
- when kernel refused connection of the sessionLoginFailedException
- when kernel refused to logon with provided user account
- Specified by:
createSession
in interfaceD2SessionFactory
- Parameters:
sessionParams
- authentication informationeventsListener
- instance of event listener object to receive asynchronous events from D2000 sessioninterestSet
- interesting shared resource types- Returns:
- upcoming session object in form of future
-
createUnivalConvertor
public UnivalConvertor createUnivalConvertor()
-
getApplicationTimeZone
public java.util.TimeZone getApplicationTimeZone()
-
setAutonomousWatchdog
public void setAutonomousWatchdog(boolean value)
Description copied from interface:D2Connector
Activate autonomous watchdog. Watchdog ensures that a message is send to d2connector.exe at least every 5 seconds.- Specified by:
setAutonomousWatchdog
in interfaceD2Connector
- Parameters:
value
-true
to activate orfalse
to deactivate.
-
getConnectionExecutor
public java.util.concurrent.Executor getConnectionExecutor()
-
getConnectionName
public java.lang.String getConnectionName()
-
getCurrentServerTimeMilliseconds
public long getCurrentServerTimeMilliseconds()
-
getDefaultObjectInfoCache
public ObjectInfoCache getDefaultObjectInfoCache()
-
getDefaultUnivalConvertor
public UnivalConvertor getDefaultUnivalConvertor()
-
getSharedResourcesCache
public SharedResourcesCache getSharedResourcesCache()
-
getStructureDefinitionResolver
public D2StructureDefinitionResolver getStructureDefinitionResolver()
-
getTotalBytesRead
public long getTotalBytesRead()
Description copied from interface:D2Connector
Get number of bytes read from stream. Note that actual number of bytes received from socket may differ when TLS is used.- Specified by:
getTotalBytesRead
in interfaceD2Connector
- Returns:
-
getTotalBytesSent
public long getTotalBytesSent()
Description copied from interface:D2Connector
Get number of bytes sent into stream. Note that actual number of bytes sent by socket may differ when TLS is used.- Specified by:
getTotalBytesSent
in interfaceD2Connector
- Returns:
-
isClosed
public boolean isClosed()
Description copied from interface:D2SessionFactory
Gettrue
afterD2SessionFactory.close()
has been called. Indicates that no new session can be created and all created sessions has been terminated.- Specified by:
isClosed
in interfaceD2SessionFactory
- Returns:
true
when closed;
-
isConnected
public boolean isConnected()
-
registerStructureClasses
public void registerStructureClasses(java.util.List<? extends java.lang.Class<?>> types)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createSessionWithSpnego
public java.util.concurrent.Future<CreateSessionResponse> createSessionWithSpnego(D2SessionParameters sessionParams, D2SessionEventsListener eventsListener, java.util.Set<SharedResourceType> interestSet)
Description copied from interface:D2SessionFactory
Create new session object, connect it to D2000 and authorize it with valid D2000 user account.Note: You should prefer
D2SessionFactory.createSession(sk.ipesoft.d2000.d2japi.D2SessionParameters, sk.ipesoft.d2000.d2japi.D2SessionEventsListener, java.util.Set)
when you don't use SPNEGO or when you obtain new session througheventsListener
.Note 2: Keep implementation of
SpnegoHandler.handleTokenFromServer(byte[], sk.ipesoft.d2000.d2japi.SpnegoHandler.ResponseHandler)
blank, because you will obtain SPNEGO response via returned future.Operation is executed in background thread and goes through following steps:
- Create new instance.
- Report current state of shared resources to the
sharedResourcesListener
. - Connect session to the D2000 kernel.
- Logon to the D2000 kernel with provided user account.
- Future result may throw
ExecutionException
withcause
: ConnectSessionException
- when kernel refused connection of the sessionLoginFailedException
- when kernel refused to logon with provided user account
- Specified by:
createSessionWithSpnego
in interfaceD2SessionFactory
- Parameters:
sessionParams
- authentication informationeventsListener
- instance of event listener object to receive asynchronous events from D2000 sessioninterestSet
- interesting shared resource types- Returns:
- upcoming session object in form of future
-
-