package org.jboss.axis.attachments;
import org.jboss.axis.AxisEngine;
import org.jboss.axis.MessageContext;
import org.jboss.axis.utils.ClassUtils;
import org.jboss.axis.utils.Messages;
import org.jboss.logging.Logger;
public final class AttachmentSupport
{
private static Logger log = Logger.getLogger(AttachmentSupport.class.getName());
public static final String DEFAULT_ATTACHMNET_IMPL = AxisEngine.DEFAULT_ATTACHMENT_IMPL;
private static String attachImplClassName = DEFAULT_ATTACHMNET_IMPL;
private static boolean checkForAttachmentSupport = true;
private static boolean attachmentSupportEnabled = false;
private static Class attachImplClass;
public static synchronized boolean isAttachmentSupportEnabled()
{
return isAttachmentSupportEnabled(null);
}
public static synchronized boolean isAttachmentSupportEnabled(MessageContext msgCtx)
{
if (checkForAttachmentSupport)
{
checkForAttachmentSupport = false;
try
{
if (msgCtx != null)
{
AxisEngine engine = msgCtx.getAxisEngine();
if (engine != null)
{
attachImplClassName = (String)engine.getOption(AxisEngine.PROP_ATTACHMENT_IMPLEMENTATION);
}
}
if (attachImplClassName == null)
{
attachImplClassName = AxisEngine.DEFAULT_ATTACHMENT_IMPL;
}
ClassUtils.forName("javax.activation.DataHandler");
ClassUtils.forName("javax.mail.internet.MimeMultipart");
attachImplClass = ClassUtils.forName(attachImplClassName);
attachmentSupportEnabled = true;
}
catch (ClassNotFoundException ex)
{
}
catch (NoClassDefFoundError ex)
{
}
log.debug(Messages.getMessage("attachEnabled") + " " + attachmentSupportEnabled);
}
return attachmentSupportEnabled;
}
public static Class getImplementationClass()
{
return attachImplClass;
}
}