/** * Sets the DataContentHandlerFactory. The DataContentHandlerFactory is called first to find * DataContentHandlers. The DataContentHandlerFactory can only be set once. * * <p>If the DataContentHandlerFactory has already been set, this method throws an Error. * * @param newFactory the DataContentHandlerFactory * @exception Error if the factory has already been defined. * @see javax.activation.DataContentHandlerFactory */ public static synchronized void setDataContentHandlerFactory( DataContentHandlerFactory newFactory) { if (factory != null) throw new Error("DataContentHandlerFactory already defined"); SecurityManager security = System.getSecurityManager(); if (security != null) { try { // if it's ok with the SecurityManager, it's ok with me... security.checkSetFactory(); } catch (SecurityException ex) { // otherwise, we also allow it if this code and the // factory come from the same class loader (e.g., // the JAF classes were loaded with the applet classes). if (DataHandler.class.getClassLoader() != newFactory.getClass().getClassLoader()) throw ex; } } factory = newFactory; }