10 private static BrowserFactoryImpl freewrlFactory;
11 private static Properties freewrlProperties;
15 freewrlProperties =
new Properties();
17 InputStream is =
BrowserFactory.class.getClassLoader().getResourceAsStream(
"freewrlsai.properties");
20 freewrlProperties.put(
"factory",
"sai.FreeWRLFactory");
23 freewrlProperties.load(is);
24 }
catch (IOException e) {
25 System.out.println(e);
35 public static void setBrowserFactoryImpl(BrowserFactoryImpl fac)
throws IllegalArgumentException, X3DException, SecurityException {
36 if (freewrlFactory !=
null) {
37 throw new X3DException(
"Factory has already been defined");
41 throw new IllegalArgumentException(
"Null factory passed to setBrowserFactoryImpl");
47 public static X3DComponent createX3DComponent(Map params)
throws NotSupportedException {
48 if (freewrlFactory ==
null)
51 return freewrlFactory.createX3DComponent(params);
54 public static ExternalBrowser getBrowser(Applet applet)
throws NotSupportedException, NoSuchBrowserException {
55 if (freewrlFactory ==
null)
58 ExternalBrowser b = freewrlFactory.getBrowser(applet);
61 throw new NoSuchBrowserException(
"getBrowser(Applet): no such browser found");
67 public static ExternalBrowser getBrowser(Applet applet, String frameName,
int index)
throws NotSupportedException, NoSuchBrowserException {
68 if (freewrlFactory ==
null)
71 ExternalBrowser b = freewrlFactory.getBrowser(applet);
74 throw new NoSuchBrowserException(
"getBrowser(Applet, String, int): no such browser found");
81 public static ExternalBrowser getBrowser(InetAddress address,
int port)
throws NotSupportedException, NoSuchBrowserException, UnknownHostException, ConnectionException {
82 if (freewrlFactory ==
null)
85 return freewrlFactory.getBrowser(address, port);
88 private static void loadFactory() {
90 String factoryClassName = (String) freewrlProperties.getProperty(
"factory");
91 Class factoryClass = Class.forName(factoryClassName);
92 freewrlFactory = (BrowserFactoryImpl)factoryClass.newInstance();
93 }
catch (Exception e) {
94 System.out.println(e);