private void loadCustomAMF3Serializer(XMap element, boolean custom) { XMap amf3Serializer = element.getOne("amf3-serializer"); if (amf3Serializer != null) { String type = amf3Serializer.get("@type"); try { Class<AMF3Serializer> amf3SerializerClass = TypeUtil.forName(type, AMF3Serializer.class); amf3SerializerConstructor = TypeUtil.getConstructor(amf3SerializerClass, new Class<?>[] {OutputStream.class}); } catch (Exception e) { throw new GraniteConfigException( "Could not get constructor for AMF3 serializer: " + type, e); } } XMap amf3Deserializer = element.getOne("amf3-deserializer"); if (amf3Deserializer != null) { String type = amf3Deserializer.get("@type"); try { Class<AMF3Deserializer> amf3DeserializerClass = TypeUtil.forName(type, AMF3Deserializer.class); amf3DeserializerConstructor = TypeUtil.getConstructor(amf3DeserializerClass, new Class<?>[] {InputStream.class}); } catch (Exception e) { throw new GraniteConfigException( "Could not get constructor for AMF3 deserializer: " + type, e); } } }
private void loadCustomMessageSelector(XMap element, boolean custom) { XMap selector = element.getOne("message-selector"); if (selector != null) { String type = selector.get("@type"); try { messageSelectorConstructor = TypeUtil.getConstructor(type, new Class<?>[] {String.class}); } catch (Exception e) { throw new GraniteConfigException("Could not construct message selector: " + type, e); } } }
public GraniteConfig( String stdConfig, InputStream customConfigIs, Configuration configuration, String MBeanContextName) throws IOException, SAXException { try { amf3SerializerConstructor = TypeUtil.getConstructor(AMF3Serializer.class, new Class<?>[] {OutputStream.class}); amf3DeserializerConstructor = TypeUtil.getConstructor(AMF3Deserializer.class, new Class<?>[] {InputStream.class}); } catch (Exception e) { throw new GraniteConfigException("Could not get constructor for AMF3 (de)serializers", e); } this.MBeanContextName = MBeanContextName; ClassLoader loader = GraniteConfig.class.getClassLoader(); final ByteArrayInputStream dtd = StreamUtil.getResourceAsStream("org/granite/config/granite-config.dtd", loader); final EntityResolver resolver = new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (GRANITE_CONFIG_PUBLIC_ID.equals(publicId)) { dtd.reset(); InputSource source = new InputSource(dtd); source.setPublicId(publicId); return source; } return null; } }; // Load standard config. InputStream is = null; try { is = StreamUtil.getResourceAsStream("org/granite/config/granite-config.xml", loader); XMap doc = new XMap(is, resolver); forElement(doc, false, null); } finally { if (is != null) is.close(); } if (stdConfig != null) { try { is = StreamUtil.getResourceAsStream(stdConfig, loader); XMap doc = new XMap(is, resolver); forElement(doc, false, null); } finally { if (is != null) is.close(); } } // Load custom config (override). if (customConfigIs != null) { XMap doc = new XMap(customConfigIs, resolver); forElement( doc, true, configuration != null ? configuration.getGraniteConfigProperties() : null); } if (amf3DeserializerSecurizer == null) log.warn( "You should configure a deserializer securizer in your granite-config.xml file in order to prevent potential security exploits!"); }