closing solution in headless client

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

closing solution in headless client

Postby Thomas Parry » Wed Sep 10, 2008 4:17 am

Is it possible to do
Code: Select all
//Get the application type
var appType = application.getApplicationType();
//type 1 = SERVER
//type 2 = CLIENT
//type 3 = DEVELOPER
//type 4 = HEADLESS_CLIENT
//type 5 = WEB_CLIENT
//type 6 = RUNTIME
//Close the current open solution and optionally open a new one
if (appType == 4) {
   application.closeSolution();
   }

when running as a batch process?

When I try "start" in the servoy-admin page the headless client does not seem to close.

My objective is to start the solution as a batch process upon startup of the application server, run, then close itself.
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: closing solution in headless client

Postby IT2Be » Wed Sep 10, 2008 8:31 am

If I am not mistaken a headless client will timeout...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: closing solution in headless client

Postby Thomas Parry » Wed Sep 10, 2008 3:16 pm

Marcel,
While a timeout would work eventually. I would want a short timeout but prefer that the application.closeSolution() actually work immediately.
Is this expected behaviour in a headless client or a defect? If "expected" then I will raise a support request to change it if no impact anywhere else of course.
All:
The second part of my question is how does one start a batch process (headless client) when the application server starts up? IS this outside the scope of Servoy programming model and has to be done by a batch file?
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: closing solution in headless client

Postby ngervasi » Wed Sep 10, 2008 3:25 pm

Thomas Parry wrote:Marcel,
While a timeout would work eventually. I would want a short timeout but prefer that the application.closeSolution() actually work immediately.
Is this expected behaviour in a headless client or a defect? If "expected" then I will raise a support request to change it if no impact anywhere else of course.


You can simply configure the headless client to close the session when it's done, have a look at this syntax (especially the last line):

Code: Select all
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
   ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
   if (servoy_hc == null)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"mySolution","myUserName","myPass");
      session.setAttribute("servoy",servoy_hc);
   }
   boolean ok = servoy_hc.setMainForm("myForm");
   
   if (!ok)
   {
      out.print("error cannot work on required form");
      return;
   }

%>
<%
    String result="";
   
    result= (String)servoy_hc.executeMethod(null,"myVeryImportantMethod",null);
   
    out.println(result);
   
    session.setAttribute("servoy", null);
%>


Thomas Parry wrote:The second part of my question is how does one start a batch process (headless client) when the application server starts up? IS this outside the scope of Servoy programming model and has to be done by a batch file?


Take a look at the admin pages, all you need to setup batch processors is there.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: closing solution in headless client

Postby Thomas Parry » Wed Sep 10, 2008 6:36 pm

Nicola,
thanks for the sample code - which I do not understand yet because it seems to be JSP?

I was assuming that I could write a global method to the the "work" and then assign the solution onOpen method to this method. I tested this and it seems to work.
My last line was as you can see in my code to close the solution. I had assumed that the Servoy application.closeSolution would function as advertised in a headless client since the help documents make no distinction.

IN my version 3.5.7 the admin pages only have "Start"/"Close" and "Remove" buttons. There is no attribute or field to indicate that I want it executed at application server start up time. Or does it start automatically?
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: closing solution in headless client

Postby ngervasi » Wed Sep 10, 2008 7:52 pm

Sorry, I was too quick to read your post, forget all I said, that is related to an headless client called through jsp.
What you simply need is to create a solution, setup a startup method to execute all your stuff and at the end call "application.exit()".
To setup the batch processor to automatically start at servoy server startup go to the Admin Pages, click on the batch Processor link on the left, select your solution, enter username/password if login is needed to access that solution and optionally a string to pass as argument to the startup method, click the add button and it will be added to the list of batch processors. Everytime the servoy server is started all the batch processor in the list will be started as well.

Sorry for the completely wrong post :)
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: closing solution in headless client

Postby Thomas Parry » Thu Sep 11, 2008 5:32 pm

Well I should have read the doc a little closer as they say. I had assumed the .close was the correct method but now I see it should be exit. Thanks for pointing out that I should read twice and talk once!
The small little solution with the global method now runs at server startup, then exits nicely.
Tom
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 5 guests