KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > apollo > HouseholdBrowser


1 /*
2 ** Apollo - Test Skeleton Toolkit for Web Start/JNLP
3 ** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
4 **
5 ** This program is free software.
6 **
7 ** You may redistribute it and/or modify it under the terms of the GNU
8 ** General Public License as published by the Free Software Foundation.
9 ** Version 2 of the license should be included with this distribution in
10 ** the file LICENSE, as well as License.html. If the license is not
11 ** included with this distribution, you may find a copy at the FSF web
12 ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
13 ** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
14 **
15 ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
16 ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
17 ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
18 ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
19 ** REDISTRIBUTION OF THIS SOFTWARE.
20 **
21 */

22
23 package apollo;
24
25 import java.io.*;
26 import java.net.*;
27 import apollo.dev.browser.*;
28 import apollo.jnlp.*;
29 import apollo.spi.*;
30 import houston.*;
31
32 public class HouseholdBrowser
33 {
34
35    private static HouseholdBrowser _instance;
36    private BrowserService _service;
37
38    private HouseholdBrowser()
39    {
40       // check if we are running under webstart
41
try
42       {
43          Class JavaDoc clazz = Class.forName( "javax.jnlp.ServiceManager" );
44
45          /*
46           * / just to make sure
47           * / check for some properties
48           * String jnlpxHeapsize = System.getProperty( "jnlpx.heapsize" );
49           * String jnlpxHome = System.getProperty( "jnlpx.home" );
50           * String jnlpxJvm = System.getProperty( "jnlpx.jvm" );
51           * if( jnlpxHeapsize != null
52           * && jnlpxHome != null
53           * && jnlpxJvm != null )
54           * {
55           * _service = new JnlpBrowserService();
56           * }
57           */

58          _service = new JnlpBrowserService( new SpencerBrowserService() );
59       }
60       catch( ClassNotFoundException JavaDoc ex )
61       {
62          _service = new SpencerBrowserService();
63       }
64    }
65
66    private BrowserService getService()
67    {
68       return _service;
69    }
70
71    public static void showDocument( URL url )
72    {
73       if( url == null )
74          return;
75
76       instance().getService().showDocument( url );
77    }
78
79    public static void showDocument( String JavaDoc url )
80    {
81       try
82       {
83          showDocument( new URL( url ) );
84       }
85       catch( MalformedURLException mex )
86       {
87          Status.error( "*** invalid URL " + url + ": " + mex.toString() );
88       }
89    }
90
91    private static HouseholdBrowser instance()
92    {
93       if( _instance == null )
94          _instance = new HouseholdBrowser();
95
96       return _instance;
97    }
98
99 }
100
Popular Tags