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 voidclose()Close connection to D2000.static D2ConnectorcreateConnector(java.lang.String connectionString, java.lang.String certificatePath, D2ConnectorEventsListener eventsListener)Create new instance of connector with TLS connectionstatic D2ConnectorcreateConnector(java.lang.String connectionString, D2ConnectorEventsListener eventsListener)Create a new instance of connector.ConvertorcreateDictionaryConvertor(int languageIndex)TranslatorcreateDictionaryTranslator(int languageIndex)ObjectInfoCachecreateObjectInfoCache(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 authorise it with valid D2000 user account.UnivalConvertorcreateUnivalConvertor()java.util.TimeZonegetApplicationTimeZone()java.util.concurrent.ExecutorgetConnectionExecutor()java.lang.StringgetConnectionName()longgetCurrentServerTimeMilliseconds()ObjectInfoCachegetDefaultObjectInfoCache()UnivalConvertorgetDefaultUnivalConvertor()SharedResourcesCachegetSharedResourcesCache()D2StructureDefinitionResolvergetStructureDefinitionResolver()longgetTotalBytesRead()Get number of bytes read from stream.longgetTotalBytesSent()Get number of bytes sent into stream.booleanisClosed()GettrueafterD2SessionFactory.close()has been called.booleanisConnected()voidregisterStructureClasses(java.util.List<? extends java.lang.Class<?>> types)voidsetAutonomousWatchdog(boolean value)Activate autonomous watchdog.java.lang.StringtoString()
-
-
-
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:D2SessionFactoryClose connection to D2000.- Specified by:
closein 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:D2SessionFactoryCreate new session object, connect it to D2000 and authorize it with valid D2000 user account.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
ExecutionExceptionwithcause: ConnectSessionException- when kernel refused connection of the sessionLoginFailedException- when kernel refused to logon with provided user account
- Specified by:
createSessionin 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:D2SessionFactoryCreate new session object, connect it to D2000 and authorise it with valid D2000 user account.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
ExecutionExceptionwithcause: ConnectSessionException- when kernel refused connection of the sessionLoginFailedException- when kernel refused to logon with provided user account
- Specified by:
createSessionin 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:D2ConnectorActivate autonomous watchdog. Watchdog ensures that a message is send to d2connector.exe at least every 5 seconds.- Specified by:
setAutonomousWatchdogin interfaceD2Connector- Parameters:
value-trueto activate orfalseto 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:D2ConnectorGet number of bytes read from stream. Note that actual number of bytes received from socket may differ when TLS is used.- Specified by:
getTotalBytesReadin interfaceD2Connector- Returns:
-
getTotalBytesSent
public long getTotalBytesSent()
Description copied from interface:D2ConnectorGet number of bytes sent into stream. Note that actual number of bytes sent by socket may differ when TLS is used.- Specified by:
getTotalBytesSentin interfaceD2Connector- Returns:
-
isClosed
public boolean isClosed()
Description copied from interface:D2SessionFactoryGettrueafterD2SessionFactory.close()has been called. Indicates that no new session can be created and all created sessions has been terminated.- Specified by:
isClosedin interfaceD2SessionFactory- Returns:
truewhen closed;
-
isConnected
public boolean isConnected()
-
registerStructureClasses
public void registerStructureClasses(java.util.List<? extends java.lang.Class<?>> types)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-