KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > server > JAFConfigService


1 /* JBoss, the OpenSource J2EE webOS
2  *
3  * Distributable under LGPL license.
4  * See terms of license at gnu.org.
5  */

6 package org.jboss.net.axis.server;
7
8 import javax.activation.CommandMap JavaDoc;
9 import javax.activation.MailcapCommandMap JavaDoc;
10
11 import org.jboss.logging.Logger;
12
13 /** A pojo service which can be used to populate the JAF MailcapCommandMap
14  * @author Scott.Stark@jboss.org
15  * @version $Revision: 1.2 $
16  */

17 public class JAFConfigService
18 {
19    private static Logger log = Logger.getLogger(JAFConfigService.class);
20    private String JavaDoc[] mailcaps = {
21       "text/xml;;x-java-content-handler=org.jboss.net.axis.jaf.XMLDataContentHandler",
22       "application/xml;;x-java-content-handler=org.jboss.net.axis.jaf.XMLDataContentHandler"
23    };
24
25    public String JavaDoc[] getMailcaps()
26    {
27       return mailcaps;
28    }
29    public void setMailcaps(String JavaDoc[] mailcaps)
30    {
31       this.mailcaps = mailcaps;
32    }
33
34    public void start() throws Exception JavaDoc
35    {
36       CommandMap JavaDoc commandMap = CommandMap.getDefaultCommandMap();
37       if( commandMap instanceof MailcapCommandMap JavaDoc )
38       {
39          MailcapCommandMap JavaDoc mailMap = (MailcapCommandMap JavaDoc) commandMap;
40          for(int n = 0; n < mailcaps.length; n ++)
41          {
42             String JavaDoc mailcap = mailcaps[n];
43             mailMap.addMailcap(mailcap);
44             log.debug("Added mailcap: "+mailcap);
45          }
46       }
47       else
48       {
49          throw new Exception JavaDoc("Cannot handle non-MailcapCommandMap, map="
50             +commandMap);
51       }
52    }
53 }
54
Popular Tags