i-net Clear Reports

com.inet.report
Class Listener

java.lang.Object
  extended by com.inet.report.Listener
All Implemented Interfaces:
PropertiesChecker

public class Listener
extends java.lang.Object
implements PropertiesChecker

This class implements the listener that is listening for a connection to be made to this socket by a client. If the connection is accepted, then a new client socket will be created. The port number for the server socket, on which the listener is to be waiting for new connections, is specified in the i-net Clear Reports configuration. The default port number is 9000.

With the help of the Listener, the ReportSocket creates a report through the following steps:

1. A client send a report requests with the following report URL: http://<servername>:9000?report=file:c:/report1.rpt&prompt0=1&sf=true&hasexportbutton=false

2. A properties object is created which contains the pairs (report . http://<servername>:9000?report=file:c:/report1.rpt&prompt0=1&SF=1=1), (prompt0 . 1), (SF . true) (hasexportbutton . false).

3. A HTML page is created according to the properties object. You can use the checkHtmlPageProperties() callback (implemented by the default com.inet.report.Listener or your own listener class if you do not want to use the default listener) and the properties object to modify the HTML code. For example if you do not want to load the viewer from <servername>:80, you can change the parameters archive and codebase to:
props.put(archive,"http://<servername>:81/core_V/ReportViewer.jar");
props.put(codebase,"http://<servername>:81/client_V");
This corresponds to the request URL
http://<servername>:9000?report=...&archive=http://<servername>:81/core_V/ReportViewer.jar&codebase=http://<servername>:81/client_V
and will load the Java viewer file ReportViewer.jar from http://<servername>:81/core_V instead.
4. The Java viewer starts in the client's HTML page and pass the report URL above back to the report server (Listener).

5. The report server reads the report URL passed to it from the Java viewer and converts it into key/value pairs and stores them into a newly allocated properties object. The object contains the entries: (report . http://<servername>:9000?report=file:c:/report1.rpt&prompt0=1&SF=true), (prompt0 . 1), (SF . true). Please note that the entry (hasexportbutton . false) is not in the properties object. This entry is an applet parameter for the java viewer bean and has been consumed by the code that has created the HTML page above.

6. The checkProperties() callback is called which you can use to modify the report parameters.

7. The report template is examined, an engine object is created.

8. The checkProperties() callback with an engine parameter is run. You can use this callback to examine or change the report using RDC. For example you can examine and change the parameter fields, the formulas etc.

9. The report is executed, the report socket requests the data from the engine using engine.getData() and sends back the binary data to the Java viewer running in the client's HTML page.


Constructor Summary
Listener()
          Creates a new server socket and binds it to the local port number specified in the i-net Clear Reports configuration or to the default port number 9000.
Listener(boolean standalone)
          Creates a new server socket and binds it to the local port number that is specified in the i-net Clear Reports configuration or to the default port number 9000.
Listener(int port)
          Creates a new server socket and binds it to the local port number, that was specified in parameter port.
Listener(int port, boolean throwException)
          Creates a new server socket and binds it to the local port number, that was specified in parameter port.
Listener(boolean standalone, int port)
          Creates a new server socket and binds it to the local port number, that is specified in parameter port.
Listener(boolean standalone, int port, boolean throwException)
          Creates a new server socket and binds it to the local port number, that was specified in parameter port.
 
Method Summary
 void checkHtmlPageProperties(java.util.Properties props)
          This callback is called before the report server creates and sends back a HTML page with the viewer embedded.
 void checkProperties(java.util.Properties props)
          This method is called by checkProperties(Properties, Object) and is equivalent to checkProperties(props, null) if i-net Clear Reports does not run as servlet.
 void checkProperties(java.util.Properties props, java.lang.Object req)
          This callback is called right before the engine examines the report file.
 void checkProperties(Engine engine, java.util.Properties prop)
          This method is called by checkProperties(Engine, Properties, Object) and is equivalent to checkProperties(engine, prop, null).
 void checkProperties(Engine engine, java.util.Properties prop, java.lang.Object req)
          This callback is called right after the engine has examined the report file.
 int getPort()
          Returns tcp/ip port number where the i-net Clear Reports application is listening for report requests.
 java.lang.String getUrlString()
          Returns the hostname and the tcp/ip port number where the i-net Clear Reports application is listening for report requests.
static void main(java.lang.String[] argv)
          Starts the i-net Clear Reports server standalone.
 void stop()
          Stops the Listener thread and closes the server socket.
 

Constructor Detail

Listener

public Listener()
Creates a new server socket and binds it to the local port number specified in the i-net Clear Reports configuration or to the default port number 9000. Then it starts the thread that is waiting for report requests from the clients.


Listener

public Listener(boolean standalone)
Creates a new server socket and binds it to the local port number that is specified in the i-net Clear Reports configuration or to the default port number 9000. Then it starts the thread that is waiting for report requests from the clients.

If this listener is the listener of a standalone application (parameter standalone = true) and the port number that is specified in the i-net Clear Reports configuration is currently in use then the listener is automatically listening on the next free port number. If the listener is not the listener of a standalone application (parameter standalone = false) then you need to set a free port number in the i-net Clear Reports configuration.

Parameters:
standalone - If true, this is the listener of a standalone application (can search for a free port); otherwise it is not (this means that it cannot look for a free port).

Listener

public Listener(int port)
Creates a new server socket and binds it to the local port number, that was specified in parameter port. Then it starts the thread that is waiting for report requests from the clients.

Parameters:
port - the default port of the server socket, if 0 then the port specified in i-net Clear Reports configuration or the default value 9000 will be used.

Listener

public Listener(int port,
                boolean throwException)
         throws java.io.IOException
Creates a new server socket and binds it to the local port number, that was specified in parameter port. Then it starts the thread that is waiting for report requests from the clients.

Parameters:
port - the default port of the server socket, if it is 0 then the port specified in the i-net Clear Reports configuration or the default value 9000 will be used.
throwException - If true, then an exception will be thrown if the socket could not be created, e.g. because of a BindException.
Throws:
java.io.IOException - If the port is in use.

Listener

public Listener(boolean standalone,
                int port)
Creates a new server socket and binds it to the local port number, that is specified in parameter port. Then it starts the thread that is waiting for report requests from the clients.

If this listener is the listener of a standalone application (parameter standalone = true) and the portnumber that is specified in the parameter port is currently in use then the listener is automatically listening on the next free port number. If the listener is not the listener of a standalone application (parameter standalone = false) then you need to set a free port number in the parameter port.

Parameters:
standalone - If true, this is the listener of a standalone application (can search for a free port); otherwise it is not (this means that it cannot look for a free port).
port - the default port of the server socket, if it is 0 then the port specified in the i-net Clear Reports configuration or the default value 9000 will be used.

Listener

public Listener(boolean standalone,
                int port,
                boolean throwException)
         throws java.io.IOException
Creates a new server socket and binds it to the local port number, that was specified in parameter port. Then it starts the thread that is waiting for report requests from the clients.

If this listener is the listener of a standalone application (parameter standalone = true) and the port number that was specified in the parameter port is currently in use then the listener is automatically listening on the next free port number. If the listener is not the listener of a standalone application (parameter standalone = false) then you need to set a free port number in the parameter port.

Parameters:
standalone - If true, this is the listener of a standalone application (can search for a free port); otherwise it is not (this means that it cannot look for a free port).
port - the default port of the server socket, if it is 0 then the port specified in the i-net Clear Reports configuration or the default value 9000 will be used.
throwException - If true, then an exception will be thrown if standalone is false and the socket could not be created, e.g. because of a BindException.
Throws:
java.io.IOException - If the port is in use.
Method Detail

main

public static void main(java.lang.String[] argv)
Starts the i-net Clear Reports server standalone.

Parameters:
argv - Command line arguments are currently not supported.

getUrlString

public java.lang.String getUrlString()
Returns the hostname and the tcp/ip port number where the i-net Clear Reports application is listening for report requests.

Returns:
http://hostname:portnumber as string

getPort

public int getPort()
Returns tcp/ip port number where the i-net Clear Reports application is listening for report requests.

Returns:
port number, if 0 there was an error during ServerSocket creation

checkProperties

public void checkProperties(java.util.Properties props)
                     throws ReportException
This method is called by checkProperties(Properties, Object) and is equivalent to checkProperties(props, null) if i-net Clear Reports does not run as servlet.

Parameters:
props - The user properties.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
checkProperties(Properties, Object)

checkProperties

public void checkProperties(java.util.Properties props,
                            java.lang.Object req)
                     throws ReportException
This callback is called right before the engine examines the report file. The properties object contains the values that the viewer has passed to the report servlet.
If you override this method, you can change or examine the user properties.
Example
if(...) props.put("report", "file:///c:/my-report.rpt");
Please note: The property "report" is initialized with the full qualified report name if the report has been found on the disc (via file:// or file:///context/) or via http://. If not, then the property will contain the original value.

Specified by:
checkProperties in interface PropertiesChecker
Parameters:
props - The user properties. All keys are lowercase.
req - The HTTP servlet request, either null or HttpServlet
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
PropertiesChecker.checkProperties(Engine engine, Properties prop, Object req)

checkProperties

public void checkProperties(Engine engine,
                            java.util.Properties prop)
                     throws ReportException
This method is called by checkProperties(Engine, Properties, Object) and is equivalent to checkProperties(engine, prop, null).
You should do the following to register your own PropertiesChecker with that you can check the created engine:

Parameters:
engine - The initialized engine that have parsed the rpt file already.
prop - The user properties.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
EngineFactory, EngineFactoryImpl, Cache.setEngineFactory(EngineFactory), checkProperties(Engine, Properties, Object)

checkProperties

public void checkProperties(Engine engine,
                            java.util.Properties prop,
                            java.lang.Object req)
                     throws ReportException
This callback is called right after the engine has examined the report file. The properties object still contains only the user properties, but you can use the engine API to examine and change the properties red from the report file.
If you override this method, you can change or examine the properties from the report file.

Example:
engine.setSchema(...);
engine.setProperty(...);

Specified by:
checkProperties in interface PropertiesChecker
Parameters:
engine - The initialized engine that have parsed the rpt file already.
prop - The user properties. All keys are lowercase.
req - The HTTP servlet request, either null or HttpServlet
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:


checkHtmlPageProperties

public void checkHtmlPageProperties(java.util.Properties props)
                             throws ReportException
This callback is called before the report server creates and sends back a HTML page with the viewer embedded. The properties object contains the default properties for the HTML page.
If you override this method, you can change or examine the default HTML page properties.

Specified by:
checkHtmlPageProperties in interface PropertiesChecker
Parameters:
props - The properties of the html page. Any change to this properties object itself has absolutely no effect. All keys are lowercase. See Example MyReportServlet_withMyHTMLProperties.java.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker.
See Also:
PropertiesChecker.checkProperties(Engine engine, Properties prop, Object req), PropertiesChecker.checkProperties(Properties prop, Object req)

stop

public void stop()
          throws java.io.IOException
Stops the Listener thread and closes the server socket.

Throws:
java.io.IOException - if an I/O error occurs when closing the socket.
See Also:
Engine.stop(), Engine.stop(String), Engine.stopAll()

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH