Overblog
Suivre ce blog
Editer l'article Administration Créer mon blog
14 octobre 2006 6 14 /10 /octobre /2006 19:36

Purpose

Here is a Java bean that allows to transform a Forms module into a socket server.

This way, it can receive messages from the outside.
- In this example, the messages are sent through a telnet session.


Forms Socket Server

In this sample dialog, I have opened a telnet session:

   open localhost 4450

Then I can send messages to the Forms application.


- In another way, messages can also be sent by the database:

DECLARE
  c  utl_tcp.connection;  -- TCP/IP connection to the Socket server
  ret_val PLS_INTEGER;
BEGIN
  c := utl_tcp.open_connection(remote_host => '10.40.40.40',
                               remote_port =>  4450);  -- open connection
  ret_val := utl_tcp.write_line(c, 'Incoming Message Send by my Oracle DB');
  utl_tcp.close_connection(c);
END;



The Java code

     SocketServer.java     Server.java  



The implementation class of the Bean Item

     oracle.forms.fd.SocketServer


The methods you can call


Init the socket server

Set_Custom_Property('BLOCK.ITEM', 1, 'INIT_SERVER', 'port_number');

e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'INIT_SERVER', '4450' ) ;
   
 

The event received from the Bean

SENDMSG


this event tells Forms that a message is sent by the Java Bean.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Msg    varchar2(512);
    LC$Value  varchar2(256);
   
BEGIN
   
   IF (eventName='SENDMSG') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MESSAGEVALUE',eventValueType, LC$Msg);
      -- Display the message --
      :BL.MSGS := :BL.MSGS || LC$Msg || Chr(10) ;
      Synchronize ;           
   END IF;
   
END;


The sample dialog

     . Download the socketserver.zip file
     . Unzip the file
     . copy the socketserver.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the SOCKETSERVER.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     the jar file must be signed.
     the jar file provided in this article is already signed.

Partager cet article

Published by Oracle Forms community - dans Bean - general
commenter cet article

commentaires

ziaur 19/07/2008 09:34

hiI tried to use your bean in my main screen. I have some links in main screen, which opens other forms. Our goal was when we recieve a message in port, we wanted to show a form on top of other existing forms. It does the job, if there is only main screen. But, when we open a new form [using call_form or open_form] whenever a message is recieved an error message is shown 'cannot navigate to main_screen'. Then we tried to close the socket before opening other forms. And, opening the socket from the new form. But, this was not successful either. Because, we were unable to stop the socket server from listening. Only way, we could do this by showing two consecutive messages. And, only after that, the socket stops listening! Any idea how to resolve the issue? My question is why the socket server is not stopping as soon as we call set_custom_property passing 'STOP_SERVER' ?Thanks in advance.

Oracle Forms community 21/07/2008 09:59


I'm not able to reproduce the issue. I have added a call_form() in the When-Custom-Item-Event trigger, then the other form is correctly called and displayed without any message (using JPI 1.5_014)


K 27/02/2007 23:29

Why do we have to have a static thread object in the SocketServer and why do we have this condition in its run method:
Thread theThread = Thread.currentThread();        while (runner == theThread)        {?
 
Thanks

Torben 31/10/2006 13:42

Hi Francois
The solution to this is so simple that i should be ashamed to have asked you the question ;-)
DECLARE  c  utl_tcp.connection;  -- TCP/IP connection to the Socket server  ret_val pls_integer; BEGIN  c := utl_tcp.open_connection(remote_host => 'localhost',                               remote_port =>  4450);  -- open connection  ret_val := utl_tcp.write_line(c, 'Incoming Message Send by my Oracle DB');  utl_tcp.close_connection(c);
END;/
Thanks again and best regardsTorben

Oracle Forms community 31/10/2006 17:11

Fine. I will blog on this  ;o)

Torben 30/10/2006 10:06

Hello Francois
 
Thanks a lot for the Jinitiator update, it works with the Jinitiator update.
Having to deliver Proof of Concept regarding Forms being able to recieve the Response from an Oracle Database Advanced queue,and having read the Oracle White paper
Building Internet Applications with Oracle Forms 6i and Oracle8iAn Oracle Technical White PaperMarch 2000
on Which i have seen your recommandation on Technet.
This solution seems rather complicated though and is for Forms 6i and the 8i DB,as i stated we will be using Forms 10g 10.1.2.0.2 and a 10g DBand my immediate idea was to maybe shortcut this using the SocketServer variant and just to have a DB Stored procedure call the Socket Server without involving the AQ in first place.My deduction is that if the stored procedure can call the Socket Server then in a second step i can combine this with the AQs later on.
In the First place i could make a stored procedure that via Java Stored procedure calls telnet on the OS and sends a Message to the Forms socketServer,The forms could then react to this message, so having provided a first Proof of Concept as to Forms being able to react to a generel DB event.
I know its to much to hope for an comment on a Solution path for the proof of concept,but i thought id give a shoot anyway.
Best regardsTorben

Torben 26/10/2006 10:26

Hi Francois
Thanks for your quick response.
I also figured this out reading your comments elsewhere recommending the general use of the SUN Java plug-in instead of  the JInitiator.
Also thanks for providing the JInitiator JAR file
Best Regards
Torben
 
 
 

Oracle Forms community 26/10/2006 20:49

The zip file contains now a JRE 1.3 .jar file and a 9.0.2 sample dialog.