Rendering operations require a certain environment or context. We refer to this environment as a Comet Project.
In the Java Rendering Library context, we associate Comet Projects with a unique name. In the SDK, this association is represented via aNamedConnection
object.
A Comet Project configuration can be read from (ODBC) database connections, a SOAP / HTTP service or from a file system folder.
A connection to a Comet Project represents the status of the renderer application.
This includes
Connecting to a Comet Project requires appropriate access data and credentials.
We associate these connection data with a unique name and register at the Renderer factory:
((Renderer) renderer).registerConnection (namedConnection, ...);Connections must be registered at the latest before they are referred (e.g. by calling
((Renderer) renderer).openDocument
).((Renderer) renderer).registerConnection( NamedConnection.createSOAPConnection( "my-soap-project", // unique name "http://localhost:40082/CometBridge/Comet3Service", // service endpoint "user", // user login "passwd", // password "aio", // project "" // language ));
((Renderer) renderer).registerConnection( NamedConnection.createXMLConnection( "my-xml-project", // unique name "/path/to/project" // base path of XML folder ));
((Renderer) renderer).registerConnection( NamedConnection.createODBCConnection( "my-odbc-project", // unique name "service", // user or system dsn "login", // user login "passwd", // password "project" // project / domain ));
NamedConnections
can be added and deleted any time during application lifetime.
Renderer renderer = new Renderer(); renderer.connectAll("myChangedConnection");This procedure has some drawbacks:
We can improve this behaviour by adding temporarily adding an observer and skip event provessing, if a renderer instance isn't connected to the changed datasource:
String changedConnectionName = "myChangedConnection"; Renderer renderer = new Renderer(); RendererObserver connectionObserver = (event, control, data) -> { String connectionName = control.getConnectionName(); if (changedConnectionName.equals(connectionName)) { return EventChain.CONTINUE; } return EventChain.TERMINATE; }; renderer.addObserver(connectionObserver, Event.CONNECT_BEFORE); renderer.connectAll(changedConnectionName); renderer.removeObserver(connectionObserver);See the Observer section for details regarding intercepting operations.