1 5 package xdoclet.modules.jsf; 6 7 import java.util.*; 8 9 import xdoclet.*; 10 import xdoclet.template.*; 11 import xdoclet.util.*; 12 13 34 public class FacesConfigXmlSubTask extends XmlSubTask 35 { 36 37 private final static String V_10 = "1.0"; 38 private final static String V_11 = "1.1"; 39 40 42 private final static String FACES_PUBLICID_10 = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"; 43 private final static String FACES_SYSTEMID_10 = "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"; 44 45 private final static String FACES_PUBLICID_11 = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"; 46 private final static String FACES_SYSTEMID_11 = "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"; 47 48 private static String DEFAULT_TEMPLATE_FILE = "resources/faces_config_xml.xdt"; 49 private static String GENERATED_FILE_NAME = "faces-config.xml"; 50 51 private String version = V_10; 52 private String messageBundle = null; 53 private String defaultLocale = null; 54 private String supportedLocales = null; 55 private String currentSupportedLocale = null; 56 57 public FacesConfigXmlSubTask() 58 { 59 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 60 setDestinationFile(GENERATED_FILE_NAME); 61 } 62 63 public String getVersion() 64 { 65 return this.version; 66 } 67 68 public String getDefaultLocale() 69 { 70 return this.defaultLocale; 71 } 72 73 public String getMessageBundle() 74 { 75 return this.messageBundle; 76 } 77 78 public String getSupportedLocales() 79 { 80 return this.supportedLocales; 81 } 82 83 87 public String getSupportedLocale() 88 { 89 return this.currentSupportedLocale; 90 } 91 92 96 public void setVersion(String v) 97 { 98 this.version = v; 99 } 100 101 105 public void setDefaultLocale(String loc) 106 { 107 this.defaultLocale = loc; 108 } 109 110 114 public void setMessageBundle(String bundle) 115 { 116 this.messageBundle = bundle; 117 } 118 119 123 public void setSupportedLocales(String listOfLocales) 124 { 125 this.supportedLocales = listOfLocales; 126 } 127 128 133 public void forAllSupportedLocales(String template) throws XDocletException 134 { 135 try { 136 if (this.supportedLocales != null) { 137 for (Iterator it = Arrays.asList(DocletUtil.tokenizeDelimitedToArray(this.supportedLocales, ",")).iterator(); it.hasNext(); ) { 138 currentSupportedLocale = (String ) it.next(); 140 getEngine().generate(template); 141 } 142 } 143 } 144 catch (TemplateException e) { 145 if (e instanceof XDocletException) { 146 throw (XDocletException) e; 147 } 148 else { 149 throw new XDocletException(e, Translator.getString(XDocletMessages.class, XDocletMessages.RUNNING_FAILED) + ": " + e.toString()); 150 } 151 } 152 } 153 154 public void execute() throws XDocletException 155 { 156 157 if (getVersion().equals(V_10)) { 158 setPublicId(FACES_PUBLICID_10); 159 setSystemId(FACES_SYSTEMID_10); 160 } 161 else { 162 setPublicId(FACES_PUBLICID_11); 163 setSystemId(FACES_SYSTEMID_11); 164 } 165 super.startProcess(); 166 } 167 168 } 169 | Popular Tags |