static { SerializerFactory factory; String list; StringTokenizer token; String className; // The default factories are always registered first, // any factory specified in the properties file and supporting // the same method will override the default factory. factory = new SerializerFactoryImpl(Method.XML); registerSerializerFactory(factory); factory = new SerializerFactoryImpl(Method.HTML); registerSerializerFactory(factory); factory = new SerializerFactoryImpl(Method.XHTML); registerSerializerFactory(factory); factory = new SerializerFactoryImpl(Method.TEXT); registerSerializerFactory(factory); list = System.getProperty(FactoriesProperty); if (list != null) { token = new StringTokenizer(list, " ;,:"); while (token.hasMoreTokens()) { className = token.nextToken(); try { factory = (SerializerFactory) ObjectFactory.newInstance( className, SerializerFactory.class.getClassLoader(), true); if (_factories.containsKey(factory.getSupportedMethod())) _factories.put(factory.getSupportedMethod(), factory); } catch (Exception except) { } } } }
/** Register a serializer factory, keyed by the given method string. */ public static void registerSerializerFactory(SerializerFactory factory) { String method; synchronized (_factories) { method = factory.getSupportedMethod(); _factories.put(method, factory); } }