Details
-
Improvement
-
Resolution: Incomplete
-
Major
-
None
-
1.4 M1
-
None
-
N/A
-
N/A
-
Description
When we do this, move the current VelocityManager/DefaultVelocityManager from xwiki-core to xwiki-velocity and modify getVelocityEngine() accordingly:
public VelocityEngine getVelocityEngine() throws XWikiVelocityException { // Get the current skin in order to find the corresponding VelocityEngine instance. String skin = this.skinManager.getSkin(); // Note: It's possible that several threads call this method at the same time and thus // it's possible that a few instances for the VelocityEngine are created. However // this is not a real problem even though it'll use a little bit more memory. // The alternative which is to make the method synchronized would penalize performances // which is why we're not synchronizing it. VelocityEngine engine; if (this.velocityManagers.containsKey(skin)) { engine = this.velocityManagers.get(skin); } else { String skinMacros = this.skinManager.getSkinResource("macros.vm"); Properties properties = new Properties(); String macroList = this.skinManager.getTemplateResource("macros.vm") + ((skinMacros == null) ? "" : "," + skinMacros); properties.put(RuntimeConstants.VM_LIBRARY, macroList); try { engine = (VelocityEngine) this.componentManager.lookup(VelocityEngine.ROLE); } catch (ComponentLookupException e) { throw new XWikiVelocityException("Failed to create Velocity Engine", e); } engine.initialize(properties); this.velocityManagers.put(skin, engine); } return engine; }