1 /*
2 Jameleon Selenium plug-in - A plug-in that uses Selenium (http://www.openqa.org/selenium/) to drive web sites
3 Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 package net.sf.jameleon.plugin.selenium.util;
20
21 import org.openqa.selenium.server.SeleniumServer;
22
23 public class SeleniumProxyServer {
24
25 protected static SeleniumProxyServer spServer;
26 protected SeleniumServer server;
27
28 private SeleniumProxyServer(){
29 }
30
31 public static SeleniumProxyServer getInstance(){
32 if (spServer == null){
33 spServer = new SeleniumProxyServer();
34 }
35 return spServer;
36 }
37
38 public void setSeleniumServer(SeleniumServer server){
39 this.server = server;
40 }
41
42 public SeleniumServer getSeleniumServer(){
43 return server;
44 }
45
46 public void setTimeoutSeconds(int seconds){
47 SeleniumServer.timeoutInSeconds = seconds;
48 }
49
50 public static void clearInstance(){
51 if (spServer != null && spServer.server != null){
52 spServer.server.stop();
53 spServer.server = null;
54 }
55 spServer = null;
56 }
57
58 public void run(){
59 startUp();
60 }
61
62 public void startUp(){
63 if (server != null){
64 try {
65 server.start();
66 }catch (Exception e) {
67 e.printStackTrace();
68 }
69 }
70 }
71
72 public void shutDown(){
73 if (server != null){
74 server.stop();
75 server = null;
76 }
77 }
78 }