001: package com.sun.portal.proxylet.client.jnlp;
002:
003: /**
004: *Created on Jan 23, 2005
005: * Sun Microsystems Inc., Copyright 2005
006: *
007: * JnlpMain
008: * Performs JNLP related initializations and invokes the server method
009: */
010:
011: /**
012: * @author Sudha
013: *
014: */
015:
016: import com.sun.portal.proxylet.client.common.Param;
017: import com.sun.portal.proxylet.client.common.Log;
018: import com.sun.portal.proxylet.client.common.ValidateSession;
019: import com.sun.portal.proxylet.client.common.browser.BrowserType;
020: import com.sun.portal.proxylet.client.common.browser.MozillaEventHandler_JNLP;
021: import com.sun.portal.proxylet.client.common.ui.ProxyletUI;
022: import com.sun.portal.proxylet.client.common.ui.AbstractEventHandler;
023: import com.sun.portal.proxylet.client.common.server.Cookie;
024:
025: import java.lang.reflect.InvocationTargetException;
026:
027: public class JnlpMain {
028:
029: public static void main(String[] args) {
030: try {
031: if (args.length == 0) {
032: System.out.println("Missing Arguments");
033: System.out
034: .println("Expects the following arguments GW_URL followed by SERVLET_URL");
035: System.exit(1);
036: }
037:
038: for (int i = 0; i < args.length; i++) {
039: System.out.println("arg[" + i + "] = " + args[i]);
040: }
041:
042: String gwURL = args[0];
043: String servletURL = args[1];
044: String cookie = args[2];
045: String browser = args[3];
046: String bindPort = args[4];
047: String bindIP = args[5];
048: String gatewayHost = args[6];
049: String gatewayPort = args[7];
050: String gatewaymode = args[8];
051: String rules = args[9];
052: String debuglevel = args[10];
053: String width = args[11];
054: String height = args[12];
055: String platformLoginURL = args[13];
056: String sessionIdleTimeout = args[14];
057: String propertyfile = args[15];
058:
059: if (debuglevel != null && debuglevel.equals("1"))
060: Log.setloglevel_JavaConsole(true);
061:
062: // cleanup previous session proxylet files
063: Param.cleanupPreviousSessionsProxyletFiles();
064:
065: // initialize Param with values
066: Param.setGatewayUrl(gwURL);
067: Param.setServletUrl(servletURL);
068: Param.setRawCookie(cookie);
069: Cookie c = new Cookie(cookie,
070: Cookie.APPLETPARAM_COOKIE_FORMAT);
071: Param.setCookie(c);
072: Param.setBrowserType(BrowserType.getType(browser));
073: Param.setBindPort(bindPort);
074: Param.setBindIP(bindIP);
075: Param.setGatewayHost(gatewayHost);
076: Param.setGatewayPort(gatewayPort);
077: Param.setGatewayMode(gatewaymode);
078: Param.setRules(rules);
079: Param.setVMVersion();
080: Param.setVendor();
081: Param.setSSLProvider();
082: Param.setPacfileLoc();
083: Param.setSource("App");
084: Param.setWindowDimension(Integer.parseInt(width), Integer
085: .parseInt(height));
086: Param.setPlatformLoginURL(platformLoginURL);
087: Param.setSessionIdleTimeout(sessionIdleTimeout);
088: Param.setPropertyFile(propertyfile);
089:
090: // Check if Proxylet is already running.. if so quit this session
091: if (Param.isProxyletRunning()) {
092: try {
093: Param.sendMsgtoServlet("?command=setJWSLoaded",
094: false, false, null);
095: } catch (Exception e) {
096: Log
097: .debugu("Unable to update session with JWS status "
098: + e.getMessage());
099: }
100: Log
101: .info(Param
102: .getString("pinfo.7",
103: "Detected another instance of proxylet on this machine \\n Quitting"));
104:
105: try {
106: // Wait for few seconds for user to read the message
107: Thread.sleep(5 * 1000);
108: } catch (Exception e) {
109: }
110: System.exit(1);
111: }
112:
113: // if rules is not defined , load pac content
114: if (Param.getRules() != null
115: && Param.getRules().equals("$RULES")) {
116: Param.loadPacContent();
117: }
118:
119: // update the servlet with JWS status as the first thing
120: try {
121: Param.sendMsgtoServlet("?command=setJWSLoaded", true,
122: false, null);
123: } catch (Exception e) {
124: Log.debugu("Unable to update session with JWS status "
125: + e.getMessage());
126: return;
127: }
128:
129: // Load resource
130: try {
131: Param.loadResourceBundle(true);
132: } catch (Exception ignore) {
133: Log
134: .info(Param
135: .getString("pexcp.1",
136: "Failed to get resource bundle for locale. Defaulting to en_US"));
137: }
138:
139: // Display UI
140: AbstractEventHandler abstractEventHandler = null;
141:
142: if (Param.getBrowserType().equals(BrowserType.IE))
143: abstractEventHandler = new RegistryEventHandler_JNLP();
144: //currently jnlp for netscape is supported only on windows..
145: else if ((Param.getBrowserType()
146: .equals(BrowserType.Netscape))) {
147: System.out
148: .println("Mozilla eventhandler going to be called ");
149: abstractEventHandler = new MozillaEventHandler_JNLP();
150: }
151:
152: (new JnlpMain()).launchUI(abstractEventHandler);
153: } catch (Exception e) {
154: e.printStackTrace();
155: }
156: }
157:
158: void launchUI(final AbstractEventHandler abstractEventHandler) {
159: try {
160: javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
161: public void run() {
162: ProxyletUI.createAndShowGUI(abstractEventHandler);
163: }
164: });
165: } catch (InterruptedException e) {
166: Log.debug(Param.getString("perr.9",
167: "ERR: Problem in displaying UI. Unknown error."));
168: return;
169: } catch (InvocationTargetException e) {
170: Log.debug(Param.getString("perr.9",
171: "ERR: Problem in displaying UI. Unknown error."));
172: return;
173: }
174:
175: Param.setProxyletFilesForCleanup();
176:
177: abstractEventHandler.handleStart(true);
178:
179: //Start timer thread
180: ValidateSession v = new ValidateSession(abstractEventHandler);
181: }
182: }
|