private static synchronized boolean isAttachmentSupportEnabled(MessageContext mc) { if (checkForAttachmentSupport) { // aviod testing and possibly failing everytime. checkForAttachmentSupport = false; try { // Get the default setting from AxisProperties String attachImpName = AxisProperties.getProperty( AxisEngine.PROP_ATTACHMENT_IMPLEMENTATION, AxisEngine.DEFAULT_ATTACHMENT_IMPL); // override the default with any changes specified in the engine configuration if (null != mc) { AxisEngine ae = mc.getAxisEngine(); if (null != ae) { attachImpName = (String) ae.getOption(AxisEngine.PROP_ATTACHMENT_IMPLEMENTATION); } } /** Attempt to resolve class name, verify that these are present... */ ClassUtils.forName("javax.activation.DataHandler"); ClassUtils.forName("javax.mail.internet.MimeMultipart"); attachImpl = ClassUtils.forName(attachImpName); attachmentSupportEnabled = true; } catch (ClassNotFoundException ex) { // no support for it, leave mAttachments null. } catch (java.lang.NoClassDefFoundError ex) { // no support for it, leave mAttachments null. } catch (java.lang.SecurityException ex) { // no support for it, leave mAttachments null. } log.debug(Messages.getMessage("attachEnabled") + " " + attachmentSupportEnabled); } return attachmentSupportEnabled; }
protected static String loadResource(String resourceName) throws IOException { String resource = null; synchronized (resourceMap) { if (resourceMap.containsKey(resourceName)) { resource = resourceMap.get(resourceName); } else { InputStream stream = ClassUtils.getResourceAsStream(SDK44EncodingUtils.class, resourceName); if (stream != null) { StringBuffer buffer = Utils.inputStreamToStringBuffer(stream); resource = buffer.toString(); resourceMap.put(resourceName, resource); stream.close(); } } } return resource; }