1 7 package org.jboss.axis.attachments; 8 9 11 import org.jboss.axis.AxisEngine; 12 import org.jboss.axis.MessageContext; 13 import org.jboss.axis.utils.ClassUtils; 14 import org.jboss.axis.utils.Messages; 15 import org.jboss.logging.Logger; 16 17 26 public final class AttachmentSupport 27 { 28 29 32 private static Logger log = Logger.getLogger(AttachmentSupport.class.getName()); 33 34 37 public static final String DEFAULT_ATTACHMNET_IMPL = AxisEngine.DEFAULT_ATTACHMENT_IMPL; 38 39 42 private static String attachImplClassName = DEFAULT_ATTACHMNET_IMPL; 43 44 private static boolean checkForAttachmentSupport = true; 45 private static boolean attachmentSupportEnabled = false; 46 private static Class attachImplClass; 47 48 53 public static synchronized boolean isAttachmentSupportEnabled() 54 { 55 return isAttachmentSupportEnabled(null); 56 } 57 58 63 public static synchronized boolean isAttachmentSupportEnabled(MessageContext msgCtx) 64 { 65 66 if (checkForAttachmentSupport) 67 { 68 checkForAttachmentSupport = false; 69 70 try 71 { 72 if (msgCtx != null) 73 { 74 AxisEngine engine = msgCtx.getAxisEngine(); 75 if (engine != null) 76 { 77 attachImplClassName = (String )engine.getOption(AxisEngine.PROP_ATTACHMENT_IMPLEMENTATION); 78 } 79 } 80 81 if (attachImplClassName == null) 82 { 83 attachImplClassName = AxisEngine.DEFAULT_ATTACHMENT_IMPL; 84 } 85 86 89 ClassUtils.forName("javax.activation.DataHandler"); 90 ClassUtils.forName("javax.mail.internet.MimeMultipart"); 91 92 attachImplClass = ClassUtils.forName(attachImplClassName); 93 attachmentSupportEnabled = true; 94 } 95 catch (ClassNotFoundException ex) 96 { 97 } 99 catch (NoClassDefFoundError ex) 100 { 101 } 103 log.debug(Messages.getMessage("attachEnabled") + " " + attachmentSupportEnabled); 104 } 105 106 return attachmentSupportEnabled; 107 } 108 109 112 public static Class getImplementationClass() 113 { 114 return attachImplClass; 115 } 116 } 117 | Popular Tags |