Class BrowserFactory

java.lang.Object
org.web3d.x3d.sai.BrowserFactory

public class BrowserFactory extends Object
Factory class for obtaining references to browser instances.

Warning: this is an abstract interface that cannot be instantiated as a concrete object. Java programmers typically only need to use concrete objects provided by the org.web3d.x3d.jsail classes.
Package hint: This specification class is defined by the X3D Java Language Binding Specification for the Scene Authoring Interface (SAI). An implementation-independent representation of the class used to access and create browsers. The model follows that used by java.net.Socket. A setImpl method is provided for browser writers to provide the internal implementations of the browser. An alternative way of doing this is through properties. The class, when it loads first looks for a System property with the key: x3d.sai.factory.class If a non-null value is found for this key, it is used as the name of the class to load as the default browser implementation. If no matching System property is found, the initializer looks for the file x3d.properties in the class path. (For more information on how this works read java.lang.ClassLoader.getSystemResourceAsStream()). If found, and the file contains a non-null value for the x3d.sai.factory.class key, this value is used as the name of the class to load as the default browser implementation. In either case (System properties or x3d.properties file), this name must represent the full package qualified name of the class. If a System property with the required key does not exist, or an x3d.properties file does not exist or the x3d.properties file does not contain a property with the required key for the name of the factory class, then the default class name org.web3d.x3d.sai.DefaultBrowserImpl is assigned. The class is loaded when a call is made to getBrowser() or createX3DComponent() using the following method: Class factory_class = Class.forName(factory_class_name); factory = (BrowserFactoryImpl)factory_class.newInstance(); If a class cast exception is raised at the end, then an error is printed but nothing is done about it. The result would be NullPointerExceptions later in the code. Also, this may cause some security errors in some web browsers. To provide a custom implementation of the factory (which all implementations must do) the user has the choice of the above options of either setting a System property, making sure that an x3d.properties file appears in the classpath before the sample implementation that comes with the classes from the X3DC, or by calling setImpl. If setBrowserFactoryImpl has not been called at the time that any of the other methods have been, then the class will attempt to load the implementation defined in the properties file. Attempting to call the set implementation method after this point shall result in a X3DException being generated. Otherwise, it shall use the set implementation.
See Also: