Changeset 6095
- Timestamp:
- 12/09/11 18:30:40 (6 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 modified
-
pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartsInfoFactory.java (modified) (1 diff)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/AuxDependencyManager.java (modified) (6 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/LeafTarget.java (modified) (3 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetDependencyRelation.java (modified) (2 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGenerationReport.java (modified) (2 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGenerator.java (modified) (12 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGeneratorListener.java (modified) (1 diff)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGeneratorRunner.java (modified) (4 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetImpl.java (modified) (5 diffs)
-
pustefix-core/src/main/java/de/schlund/pfixxml/targets/VirtualTarget.java (modified) (4 diffs)
-
pustefix-core/src/main/java/org/pustefixframework/container/spring/http/PustefixHandlerMapping.java (modified) (1 diff)
-
pustefix-core/src/main/java/org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java (modified) (2 diffs)
-
pustefix-plugins/pustefix-generate-plugin/pom.xml (modified) (1 diff)
-
pustefix-plugins/pustefix-generate-plugin/src/main/java/org/pustefixframework/maven/plugins/GenerateMojo.java (modified) (3 diffs)
-
pustefix-plugins/pustefix-generate-plugin/src/main/java/org/pustefixframework/maven/plugins/GenerateReportLogger.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/IncludePartsInfoFactory.java
r5915 r6095 36 36 } 37 37 38 public void reset() { 39 urisToInfo.clear(); 40 } 41 38 42 } -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/AuxDependencyManager.java
r5743 r6095 117 117 118 118 if (parent_path != null && parent_part != null && parent_theme != null) { 119 LOG.debug("*** Found another AuxDependency as Parent..."); 119 if(LOG.isDebugEnabled()) { 120 LOG.debug("*** Found another AuxDependency as Parent..."); 121 } 120 122 parent = auxFactory.getAuxDependencyInclude(parent_path, parent_part, 121 123 parent_theme); … … 143 145 if (part != null && part.equals("")) part = null; 144 146 if (theme != null && theme.equals("")) theme = null; 145 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 146 LOG.info("*** [" + path.toURI().toString() + "][" + part + "][" + theme + "][" + 147 ((parent_path == null)? "null" : parent_path.toURI().toString()) + "][" + parent_part + "][" + parent_theme + "]"); 148 147 if(LOG.isInfoEnabled()) { 148 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 149 LOG.info("*** [" + path.toURI().toString() + "][" + part + "][" + theme + "][" + 150 ((parent_path == null)? "null" : parent_path.toURI().toString()) + "][" + parent_part + "][" + parent_theme + "]"); 151 } 152 149 153 child = auxFactory.getAuxDependencyInclude(path, part, theme); 150 154 parent = getParentDependency(parent_path, parent_part, parent_theme); … … 161 165 AuxDependency parent = null; 162 166 163 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 164 LOG.info("*** [" + path.toURI().toString() + "][" + 165 ((parent_path == null)? "null" : parent_path.toURI().toString()) + "][" + parent_part + "][" + parent_theme + "]"); 166 167 if(LOG.isInfoEnabled()) { 168 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 169 LOG.info("*** [" + path.toURI().toString() + "][" + 170 ((parent_path == null)? "null" : parent_path.toURI().toString()) + "][" + parent_part + "][" + parent_theme + "]"); 171 } 172 167 173 child = auxFactory.getAuxDependencyImage(path); 168 174 parent = getParentDependency(parent_path, parent_part, parent_theme); … … 178 184 AuxDependency child = null; 179 185 180 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 181 LOG.info("*** [" + path.toURI().toString() + "]"); 182 186 if(LOG.isInfoEnabled()) { 187 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 188 LOG.info("*** [" + path.toURI().toString() + "]"); 189 } 190 183 191 child = auxFactory.getAuxDependencyFile(path); 184 192 … … 193 201 AuxDependency child = null; 194 202 195 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 196 LOG.info("*** [" + target.getTargetKey() + "]"); 197 203 if(LOG.isInfoEnabled()) { 204 LOG.info("Adding Dependency of type 'text' to Target '" + target.getTargetKey() + "':"); 205 LOG.info("*** [" + target.getTargetKey() + "]"); 206 } 207 198 208 child = auxFactory.getAuxDependencyTarget(target.getTargetGenerator(), targetkey); 199 209 … … 229 239 230 240 public synchronized void saveAuxdepend() throws IOException { 231 LOG.info("===> Trying to save aux info of Target '" + target.getTargetKey() + "'"); 232 241 if(LOG.isInfoEnabled()) { 242 LOG.info("===> Trying to save aux info of Target '" + target.getTargetKey() + "'"); 243 } 244 233 245 FileResource path = getAuxFile(); 234 246 FileResource dir = path.getParentAsFileResource(); -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/LeafTarget.java
r5788 r6095 147 147 long maxmodtime = ResourceUtil.getResource(getTargetKey()).lastModified(); 148 148 NDC.push(" "); 149 TREE.debug("> " + getTargetKey()); 149 if(TREE.isDebugEnabled()) { 150 TREE.debug("> " + getTargetKey()); 151 } 150 152 151 153 for (Iterator<AuxDependency> i = this.getAuxDependencyManager().getChildren() … … 169 171 // invalidate Memcache: 170 172 storeValue(null); 171 TREE.debug(" [" + getTargetKey() + ": updated leaf node...]"); 173 if(TREE.isDebugEnabled()) { 174 TREE.debug(" [" + getTargetKey() + ": updated leaf node...]"); 175 } 172 176 setModTime(maxmodtime); 173 177 } catch (Exception e) { … … 175 179 } 176 180 } else { 177 TREE.debug(" [" + getTargetKey() + ": leaf node...]"); 181 if(TREE.isDebugEnabled()) { 182 TREE.debug(" [" + getTargetKey() + ": leaf node...]"); 183 } 178 184 } 179 185 NDC.pop(); -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetDependencyRelation.java
r5743 r6095 177 177 + " for target " + target.getTargetKey() + " would result in a LOOP!"); 178 178 } 179 180 LOG.debug("+++ Adding relations " + target.getTargetKey() + " <-> " + aux.toString() + " / " + parent.toString());181 179 if(LOG.isDebugEnabled()) { 180 LOG.debug("+++ Adding relations " + target.getTargetKey() + " <-> " + aux.toString() + " / " + parent.toString()); 181 } 182 182 if (allauxs.get(aux) == null) { 183 183 allauxs.put(aux, new TreeSet<Target>()); … … 218 218 219 219 public synchronized void resetRelation(Target target) { 220 LOG.debug("--- Removing all relations for " + target.getTargetKey()); 221 220 if(LOG.isDebugEnabled()) { 221 LOG.debug("--- Removing all relations for " + target.getTargetKey()); 222 } 222 223 TreeSet<AuxDependency> auxsForTarget = alltargets.get(target); 223 224 -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGenerationReport.java
r5743 r6095 18 18 package de.schlund.pfixxml.targets; 19 19 20 import java.io.File; 20 21 import java.util.ArrayList; 22 import java.util.Iterator; 23 import java.util.List; 21 24 22 public class TargetGenerationReport { 25 import java.util.logging.Level; 26 import java.util.logging.Logger; 27 28 public class TargetGenerationReport implements TargetGeneratorListener { 23 29 24 private ArrayList<Exception> errors = new ArrayList<Exception>(); 30 private String LINE1 = "============================================================================================"; 31 private String LINE2 = "|----------------------------------------------------------------------------------"; 32 33 private Logger logger; 34 35 private List<TargetGenerationException> errors = new ArrayList<TargetGenerationException>(); 36 37 private long start; 38 private long end; 39 40 private int startedTargets; 41 private int finishedTargets; 42 private int failedTargets; 25 43 26 44 public TargetGenerationReport() { 27 45 } 28 46 29 public void addError(Exception e) { 30 errors.add(e); 47 public TargetGenerationReport(Logger logger) { 48 this.logger = logger; 49 } 50 51 public void start(TargetGenerator targetGen) { 52 start = System.currentTimeMillis(); 53 info("Start generating targets..."); 54 } 55 56 public void end(TargetGenerator targetGen) { 57 end = System.currentTimeMillis(); 58 info(LINE1); 59 info("Generated " + finishedTargets + " targets in " + (end - start) + "ms"); 60 if(failedTargets > 0) { 61 info("Failed to create " + failedTargets + " from " + startedTargets + " targets due to errors"); 62 } 63 if (errors.isEmpty()) { 64 info("No exceptions"); 65 } else { 66 info("Exceptions:"); 67 Iterator<TargetGenerationException> it = errors.iterator(); 68 if(it.hasNext()) { 69 info(LINE2); 70 } 71 while(it.hasNext()) { 72 String errorMsg = it.next().toStringRepresentation(); 73 String[] errorLines = errorMsg.split("\n"); 74 for(String errorLine: errorLines) { 75 info(errorLine); 76 } 77 if(it.hasNext()) { 78 info(LINE2); 79 } 80 } 81 } 82 info(LINE1); 31 83 } 32 84 … … 35 87 } 36 88 37 @Override 38 public String toString() { 39 StringBuffer buf = new StringBuffer(255); 40 String prod_break = "'============================================================================================'\n"; 41 String ex_break = "|----------------------------------------------------------------------------------\n"; 42 if (errors.isEmpty()) { 43 StringBuffer sb = new StringBuffer(); 44 sb.append(prod_break); 45 sb.append("| No exceptions\n"); 46 sb.append(prod_break); 47 return sb.toString(); 48 } 49 buf.append(prod_break); 50 buf.append("| Exceptions: ").append("\n"); 51 for (int i = 0; i < errors.size(); i++) { 52 TargetGenerationException tgex = (TargetGenerationException) errors.get(i); 53 String str = tgex.toStringRepresentation(); 54 buf.append(str); 55 if (errors.size() - 1 > i) 56 buf.append(ex_break); 57 } 58 buf.append(prod_break); 59 60 return buf.toString(); 89 public void error(Target target, TargetGenerationException exception) { 90 failedTargets++; 91 errors.add(exception); 92 String path = target.getTargetGenerator().getDisccachedir().toURI().toString(); 93 error(">>>>> Error generating " + path + File.separator + target.getTargetKey() + " from " + 94 target.getXMLSource().getTargetKey() + " and " + target.getXSLSource().getTargetKey(), exception); 61 95 } 96 97 public void start(Target target) { 98 startedTargets++; 99 } 100 101 public void end(Target target) { 102 finishedTargets++; 103 String path = target.getTargetGenerator().getDisccachedir().toURI().toString(); 104 debug(">>>>> Generated " + path + File.separator + target.getTargetKey() + " from " + 105 target.getXMLSource().getTargetKey() + " and " + target.getXSLSource().getTargetKey()); 106 } 107 108 protected void debug(String msg) { 109 logger.log(Level.FINE, msg); 110 } 111 112 protected void error(String msg, TargetGenerationException exception) { 113 logger.log(Level.SEVERE, msg, exception); 114 } 115 116 protected void info(String msg) { 117 logger.log(Level.INFO, msg); 118 } 119 62 120 } -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGenerator.java
r6057 r6095 22 22 import java.io.IOException; 23 23 import java.io.StringReader; 24 import java.lang.management.ManagementFactory; 24 25 import java.net.URI; 25 26 import java.net.URISyntaxException; … … 114 115 private static final Logger LOG = Logger.getLogger(TargetGenerator.class); 115 116 116 private TargetGenerationReport report = new TargetGenerationReport();117 118 117 private PageTargetTree pagetree = new PageTargetTree(); 119 118 … … 157 156 private IncludePartsInfoFactory includePartsInfo; 158 157 private boolean parseIncludes = true; 158 private boolean parallel = false; 159 159 160 160 private Map<String, String> renderParams; … … 167 167 168 168 public TargetGenerator(final Resource confile, final FileResource cacheDir, final boolean parseIncludes) throws IOException, SAXException, XMLException { 169 this(confile, cacheDir, new SPCacheFactory().init(), new SiteMap(confile), parseIncludes); 169 this(confile, cacheDir, new SPCacheFactory().init(), new SiteMap(confile), parseIncludes, false); 170 } 171 172 public TargetGenerator(final Resource confile, final FileResource cacheDir, final boolean parseIncludes, final boolean parallel) throws IOException, SAXException, XMLException { 173 this(confile, cacheDir, new SPCacheFactory().init(), new SiteMap(confile), parseIncludes, parallel); 170 174 } 171 175 172 176 public TargetGenerator(final Resource confile, final FileResource cacheDir, final SPCacheFactory cacheFactory, final SiteMap siteMap) throws IOException, SAXException, XMLException { 173 this(confile, cacheDir, cacheFactory, siteMap, true );174 } 175 176 public TargetGenerator(final Resource confile, final FileResource cacheDir, final SPCacheFactory cacheFactory, final SiteMap siteMap, final boolean parseIncludes ) throws IOException, SAXException, XMLException {177 this(confile, cacheDir, cacheFactory, siteMap, true, false); 178 } 179 180 public TargetGenerator(final Resource confile, final FileResource cacheDir, final SPCacheFactory cacheFactory, final SiteMap siteMap, final boolean parseIncludes, final boolean parallel) throws IOException, SAXException, XMLException { 177 181 this.config_path = confile; 178 182 this.cacheDir = cacheDir; … … 180 184 this.siteMap = siteMap; 181 185 this.parseIncludes = parseIncludes; 186 this.parallel = parallel; 182 187 } 183 188 … … 206 211 pageInfoFactory = new PageInfoFactory(); 207 212 includePartsInfo = new IncludePartsInfoFactory(); 208 //TODO: factory init on reload209 213 Meminfo meminfo = new Meminfo(); 210 214 meminfo.print("TG: Before loading " + config_path.toString()); 211 215 loadConfig(config_path); 212 216 meminfo.print("TG: after loading targets for " + config_path.toString()); 217 } 218 219 private void reload() throws Exception { 220 pagetree = new PageTargetTree(); 221 alltargets.clear(); 222 includeDocumentFactory.reset(); 223 targetDependencyRelation.reset(); 224 auxDependencyFactory.reset(); 225 targetFactory.reset(); 226 sharedLeafFactory.reset(); 227 pageInfoFactory.reset(); 228 includePartsInfo.reset(); 229 loadConfig(config_path); 213 230 } 214 231 … … 379 396 } 380 397 } 381 pagetree = new PageTargetTree(); 382 alltargets = new HashMap<String, Target>(); 383 loadConfig(this.config_path); 398 reload(); 384 399 this.fireConfigurationChangeEvent(); 385 400 return true; … … 1095 1110 gen.generateAll(); 1096 1111 System.out.println("---------- ...done [" + args[i] + "]"); 1097 report.append(gen.getReportAsString());1098 1112 } else { 1099 1113 LOG.error("Couldn't read configfile '" + args[i] + "'"); … … 1114 1128 1115 1129 public void generateAll() throws Exception { 1130 notifyListenerStart(); 1131 if(parallel) { 1132 generateAllParallel(); 1133 } else { 1134 generateAllSerial(); 1135 } 1136 notifyListenerEnd(); 1137 } 1138 1139 private void generateAllSerial() throws Exception { 1116 1140 for (Iterator<String> e = getAllTargets().keySet().iterator(); e.hasNext();) { 1117 1141 Target current = getTarget(e.next()); 1118 1142 generateTarget(current); 1119 /* if all listeners want to stop, 1120 * there is no point in continuing ... */ 1121 if (needsToStop()) { 1122 break; 1123 } 1143 } 1144 } 1145 1146 private void generateAllParallel() throws Exception { 1147 int processors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); 1148 List<Target> genTargets = new ArrayList<Target>(); 1149 for (Iterator<String> e = getAllTargets().keySet().iterator(); e.hasNext();) { 1150 Target current = getTarget(e.next()); 1151 genTargets.add(current); 1152 } 1153 Thread[] genThreads = new Thread[processors]; 1154 for(int i=0; i<processors; i++) { 1155 Thread genThread = new GenThread(genTargets); 1156 genThread.start(); 1157 genThreads[i] = genThread; 1158 } 1159 for(int i=0; i<processors; i++) { 1160 genThreads[i].join(); 1124 1161 } 1125 1162 } … … 1127 1164 public void generateTarget(Target target) throws Exception { 1128 1165 if (target.getType() != TargetType.XML_LEAF && target.getType() != TargetType.XSL_LEAF) { 1129 String path = getDisccachedir().toURI().toString();1130 System.out.println(">>>>> Generating " + path + File.separator + target.getTargetKey() + " from " + target.getXMLSource().getTargetKey() + " and " + target.getXSLSource().getTargetKey());1131 1132 1166 boolean needs_update = false; 1133 1167 needs_update = target.needsUpdate(); 1134 1168 if (needs_update) { 1135 1169 try { 1170 notifyListenerStart(target); 1136 1171 target.getValue(); 1137 notifyListenerTargetDone(target); 1138 } catch (TargetGenerationException tgex) { 1139 notifyListenerTargetException(target, tgex); 1140 report.addError(tgex); 1141 tgex.printStackTrace(); 1142 } 1143 } else { 1144 notifyListenerTargetDone(target); 1145 } 1146 System.out.println("done."); 1147 } else { 1148 notifyListenerTargetDone(target); 1149 } 1150 } 1151 1152 /** 1153 * This method checks, if a TargetGeneratorListener wants to stop, 1154 * if so he will get kicked out of the listener set. 1155 * 1156 * @return true if all listeners want to stop 1157 */ 1158 private boolean needsToStop() { 1159 boolean result = false; 1160 if (generationListeners.size() > 0) { 1161 result = true; 1162 for (Iterator<TargetGeneratorListener> it = generationListeners.iterator(); it.hasNext();) { 1163 TargetGeneratorListener listener = it.next(); 1164 if (listener.needsStop()) { 1165 result = result && true; 1166 it.remove(); 1167 } else { 1168 result = false; 1169 } 1170 } 1171 } 1172 return result; 1173 } 1174 1175 /** 1176 * This calls the finishedTarget method of all registered listeners 1177 * @param target the finished target 1178 */ 1179 private void notifyListenerTargetDone(Target target) { 1180 for (Iterator<TargetGeneratorListener> it = generationListeners.iterator(); it.hasNext();) { 1181 TargetGeneratorListener listener = it.next(); 1182 listener.finishedTarget(target); 1183 } 1184 } 1185 1186 /** 1187 * This calls the generationException method of all registered listeners 1188 * @param target the finished target 1189 * @param tgex the exception! 1190 */ 1191 private void notifyListenerTargetException(Target target, TargetGenerationException tgex) { 1192 for (Iterator<TargetGeneratorListener> it = generationListeners.iterator(); it.hasNext();) { 1193 TargetGeneratorListener listener = it.next(); 1194 listener.generationException(target, tgex); 1172 notifyListenerEnd(target); 1173 } catch (TargetGenerationException e) { 1174 notifyListenerError(target, e); 1175 } 1176 } 1177 } 1178 } 1179 1180 private void notifyListenerStart() { 1181 for(TargetGeneratorListener listener: generationListeners) { 1182 listener.start(this); 1183 } 1184 } 1185 1186 private void notifyListenerEnd() { 1187 for(TargetGeneratorListener listener: generationListeners) { 1188 listener.end(this); 1189 } 1190 } 1191 1192 private void notifyListenerStart(Target target) { 1193 for(TargetGeneratorListener listener: generationListeners) { 1194 listener.start(target); 1195 } 1196 } 1197 1198 private void notifyListenerEnd(Target target) { 1199 for(TargetGeneratorListener listener: generationListeners) { 1200 listener.end(target); 1201 } 1202 } 1203 1204 private void notifyListenerError(Target target, TargetGenerationException e) { 1205 for(TargetGeneratorListener listener: generationListeners) { 1206 listener.error(target, e); 1195 1207 } 1196 1208 } … … 1220 1232 } 1221 1233 1222 /**1223 * @return report containing sensilbe information after {@link #generateAll()}, not null1224 */1225 public String getReportAsString() {1226 return report.toString();1227 }1228 1229 public boolean errorsReported() {1230 return report.hasError();1231 }1232 1233 public void resetGenerationReport() {1234 report = new TargetGenerationReport();1235 }1236 1237 1234 //-- 1238 1235 … … 1287 1284 } 1288 1285 1286 1287 private class GenThread extends Thread { 1288 1289 private List<Target> genTargets; 1290 1291 GenThread(List<Target> genTargets) { 1292 this.genTargets = genTargets; 1293 } 1294 1295 @Override 1296 public void run() { 1297 Target genTarget = null; 1298 do { 1299 synchronized(genTargets) { 1300 if(!genTargets.isEmpty()) { 1301 genTarget = genTargets.remove(0); 1302 } else { 1303 genTarget = null; 1304 } 1305 } 1306 if(genTarget != null) { 1307 try { 1308 generateTarget(genTarget); 1309 } catch(Exception x) { 1310 throw new RuntimeException("Error generating target " + genTarget.getTargetKey(), x); 1311 } 1312 } else { 1313 break; 1314 } 1315 } while(genTarget != null); 1316 } 1317 1318 } 1289 1319 } -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGeneratorListener.java
r4517 r6095 20 20 21 21 22 /**23 * @author Niels Schelbach24 * 23.04.200425 */26 22 public interface TargetGeneratorListener { 27 23 24 public void start(TargetGenerator targetGen); 25 public void end(TargetGenerator targetGen); 28 26 29 public void finishedTarget(Target target); 30 public void abortedTargetGeneration(Target target); 31 public void generationException(Target target, TargetGenerationException exception); 32 33 public boolean needsStop(); 27 public void start(Target target); 28 public void end(Target target); 29 30 public void error(Target target, TargetGenerationException exception); 34 31 35 32 } -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetGeneratorRunner.java
r5875 r6095 3 3 import java.io.File; 4 4 import java.io.FileInputStream; 5 import java.io.Writer;6 5 import java.net.URI; 7 6 import java.util.ArrayList; … … 48 47 private TenantInfo tenantInfo; 49 48 private Resource confFile; 50 51 public boolean run(File docroot, File cache, String mode, Writer output, String logLevel) throws Exception {49 50 public boolean run(File docroot, File cache, String mode, boolean parallel, java.util.logging.Logger reportLogger) throws Exception { 52 51 53 52 if(!docroot.exists()) throw new Exception("TargetGenerator docroot " + docroot.getAbsolutePath() + " doesn't exist"); … … 59 58 if(projectConfigLocation == null) throw new Exception("Can't get project config location from web.xml"); 60 59 61 ConsoleAppender appender = new ConsoleAppender(new PatternLayout("[%p] %c - %m\n"));62 Logger logger=Logger.getRootLogger();63 logger.setLevel(Level.toLevel(logLevel));64 logger.addAppender(appender);60 Logger rootLogger = Logger.getRootLogger(); 61 rootLogger.setLevel(Level.toLevel("error")); 62 ConsoleAppender rootAppender = new ConsoleAppender(new PatternLayout("[%p] %c - %m\n")); 63 rootLogger.addAppender(rootAppender); 65 64 66 65 Properties props = new Properties(); … … 85 84 FileResource cacheDir = ResourceUtil.getFileResource(cache.toURI()); 86 85 87 try { 88 TargetGenerator gen = new TargetGenerator(confFile, cacheDir, true );89 gen.setIsGetModTimeMaybeUpdateSkipped( false);86 try { 87 TargetGenerator gen = new TargetGenerator(confFile, cacheDir, true, parallel); 88 gen.setIsGetModTimeMaybeUpdateSkipped(true); 90 89 gen.setTenantInfo(tenantInfo); 91 90 gen.afterPropertiesSet(); 91 TargetGenerationReport report = new TargetGenerationReport(reportLogger); 92 gen.addListener(report); 92 93 gen.generateAll(); 93 output.write(gen.getReportAsString()); 94 return !gen.errorsReported(); 94 return !report.hasError(); 95 95 } catch(Exception x) { 96 96 throw new Exception("Generating targets failed", x); -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/TargetImpl.java
r5743 r6095 127 127 * @see de.schlund.pfixxml.targets.Target#getValue() 128 128 */ 129 public Object getValue() throws TargetGenerationException {129 public synchronized Object getValue() throws TargetGenerationException { 130 130 // Idea: if skip_getmodtimemaybeupdate is set we do not need to call getModeTimeMaybeUpdate 131 131 // but: if the target is not in disk-cache (has not been generated) we must call … … 134 134 if (generator.isGetModTimeMaybeUpdateSkipped()) { 135 135 // skip getModTimeMaybeUpdate! 136 LOG.debug("skip_getmodtimemaybeupdate is true. Trying to skip getModTimeMaybeUpdate..."); 136 if(LOG.isDebugEnabled()) { 137 LOG.debug("skip_getmodtimemaybeupdate is true. Trying to skip getModTimeMaybeUpdate..."); 138 } 137 139 if (!onceLoaded) { 138 140 // do test for exists here! … … 142 144 } 143 145 if (thefile==null || !thefile.exists()) { // Target has not been loaded once and it doesn't exist in disk cache 144 LOG.debug("Cant't skip getModTimeMaybeUpdated because it has not been loaded " + 145 "and doesn't even exist in disk cache! Generating now !!"); 146 if(LOG.isDebugEnabled()) { 147 LOG.debug("Cant't skip getModTimeMaybeUpdated because it has not been loaded " + 148 "and doesn't even exist in disk cache! Generating now !!"); 149 } 146 150 try { 147 151 getModTimeMaybeUpdate(); … … 153 157 } 154 158 } else { 155 LOG.debug("Target exists in disc cache, using it..."); 159 if(LOG.isDebugEnabled()) { 160 LOG.debug("Target exists in disc cache, using it..."); 161 } 156 162 } 157 } else { // target generated -> nop 158 LOG.debug("Target has already been loaded, reusing it..."); 163 } else { // target generated -> nop 164 if(LOG.isDebugEnabled()) { 165 LOG.debug("Target has already been loaded, reusing it..."); 166 } 159 167 } 160 168 } else { // do not skip getModTimeMaybeUpdate 161 LOG.debug("Skipping getModTimeMaybeUpdate disabled in TargetGenerator!"); 169 if(LOG.isDebugEnabled()) { 170 LOG.debug("Skipping getModTimeMaybeUpdate disabled in TargetGenerator!"); 171 } 162 172 try { 163 173 getModTimeMaybeUpdate(); … … 215 225 obj = getValueFromSPCache(); 216 226 if (obj == null || isDiskCacheNewerThenMemCache()) { 217 if (LOG.isDebugEnabled()) { 218 if (LOG.isDebugEnabled() && isDiskCacheNewerThenMemCache()) { 219 LOG.debug( 227 if (LOG.isDebugEnabled() && isDiskCacheNewerThenMemCache()) { 228 LOG.debug( 220 229 "File in disk cache is newer then in memory cache. Rereading target from disk..."); 221 }222 230 } 223 231 -
trunk/pustefix-core/src/main/java/de/schlund/pfixxml/targets/VirtualTarget.java
r5966 r6095 128 128 */ 129 129 @Override 130 public boolean needsUpdate() throws Exception {130 public synchronized boolean needsUpdate() throws Exception { 131 131 long mymodtime = getModTime(); 132 132 long xmlmod; … … 228 228 long tmpmodtime; 229 229 NDC.push(" "); 230 TREE.debug("> " + getTargetKey()); 230 if(TREE.isDebugEnabled()) { 231 TREE.debug("> " + getTargetKey()); 232 } 231 233 maxmodtime = ((TargetImpl) getXMLSource()).getModTimeMaybeUpdate(); 232 234 // if (maxmodtime > currmodtime) { … … 276 278 try { 277 279 generateValue(); 278 TREE.debug(" [" + getTargetKey() + ": generated...]"); 280 if(TREE.isDebugEnabled()) { 281 TREE.debug(" [" + getTargetKey() + ": generated...]"); 282 } 279 283 } catch (TransformerException e) { 280 284 LOG.error("Error when generating: " + getTargetKey() … … 309 313 } 310 314 } else { 311 TREE.debug(" [" + getTargetKey() + ": skipping...]"); 315 if(TREE.isDebugEnabled()) { 316 TREE.debug(" [" + getTargetKey() + ": skipping...]"); 317 } 312 318 } 313 319 NDC.pop(); -
trunk/pustefix-core/src/main/java/org/pustefixframework/container/spring/http/PustefixHandlerMapping.java
r5393 r6095 70 70 } 71 71 72 public void reload() { 73 initApplicationContext(); 74 } 75 72 76 } -
trunk/pustefix-core/src/main/java/org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java
r6087 r6095 51 51 import org.pustefixframework.config.contextxmlservice.AbstractXMLServletConfig; 52 52 import org.pustefixframework.config.contextxmlservice.ServletManagerConfig; 53 import org.pustefixframework.container.spring.http.PustefixHandlerMapping; 53 54 import org.springframework.context.ApplicationContext; 54 55 import org.springframework.context.ApplicationContextAware; … … 496 497 } 497 498 499 if(!generator.isGetModTimeMaybeUpdateSkipped()) { 500 synchronized(this) { 501 try { 502 boolean reloaded = generator.tryReinit(); 503 if(reloaded) { 504 PustefixHandlerMapping handlerMapping = (PustefixHandlerMapping)applicationContext.getBean(PustefixHandlerMapping.class.getName()); 505 handlerMapping.reload(); 506 } 507 } catch(Exception x) { 508 throw new PustefixCoreException(x); 509 } 510 } 511 } 512 498 513 if (spdoc.getResponseError() == HttpServletResponse.SC_NOT_FOUND && spdoc.getDocument() != null) { 499 514 String stylesheet = extractStylesheetFromSPDoc(spdoc, preq); -
trunk/pustefix-plugins/pustefix-generate-plugin/pom.xml
r6094 r6095 34 34 <version>1.5.1</version> 35 35 </dependency> 36 <dependency>37 <groupId>org.pustefixframework</groupId>38 <artifactId>pustefix-core</artifactId>39 <version>0.18.5-SNAPSHOT</version>40 </dependency>41 36 </dependencies> 42 37 -
trunk/pustefix-plugins/pustefix-generate-plugin/src/main/java/org/pustefixframework/maven/plugins/GenerateMojo.java
r6080 r6095 19 19 20 20 import java.io.File; 21 import java.io.StringWriter;22 import java.io.Writer;23 21 import java.lang.reflect.Method; 24 22 import java.net.URL; 25 23 import java.net.URLClassLoader; 26 24 import java.util.List; 25 import java.util.logging.Level; 26 import java.util.logging.Logger; 27 27 28 28 import org.apache.maven.plugin.AbstractMojo; … … 56 56 57 57 /** 58 * @parameter default-value= "error"58 * @parameter default-value=true 59 59 * @required 60 60 */ 61 private String loglevel;61 private boolean parallel; 62 62 63 63 /** @parameter default-value="${project}" */ … … 74 74 75 75 File cache = new File(webappdir, ".cache"); 76 76 77 Logger reportLogger = new GenerateReportLogger(getLog()); 78 if(getLog().isDebugEnabled()) { 79 reportLogger.setLevel(Level.FINE); 80 } else if(getLog().isInfoEnabled()) { 81 reportLogger.setLevel(Level.INFO); 82 } else if(getLog().isWarnEnabled()) { 83 reportLogger.setLevel(Level.WARNING); 84 } else if(getLog().isErrorEnabled()) { 85 reportLogger.setLevel(Level.SEVERE); 86 } 87 77 88 URLClassLoader loader = getProjectRuntimeClassLoader(); 78 89 ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); 79 90 try { 80 91 Class<?> generator = Class.forName("de.schlund.pfixxml.targets.TargetGeneratorRunner", true, loader); 81 Method meth = 82 generator.getMethod("run", File.class, File.class, String.class, 83 Writer.class, String.class); 92 Method meth = generator.getMethod("run", File.class, File.class, String.class, boolean.class, Logger.class); 84 93 Object instance = generator.newInstance(); 85 StringWriter output = new StringWriter();86 94 Thread.currentThread().setContextClassLoader(loader); 87 boolean ok = 88 (Boolean) meth.invoke(instance, docroot, cache, "prod", output, loglevel); 89 getLog().info(output.toString()); 95 boolean ok = (Boolean) meth.invoke(instance, docroot, cache, "prod", parallel, reportLogger); 90 96 if (!ok) 91 97 throw new MojoExecutionException("Target generation errors occurred.");
