Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
F
frascati
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 114
    • Issues 114
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • frascati
  • frascati
  • Issues
  • #104

Closed
Open
Opened Feb 19, 2013 by Jeremie Guillemotte@jguillemotte

Improvement for implementation velocity in FraSCAti. Add the possibility to use templates in a tree organisation.

Improvement for implementation velocity in FraSCAti (ProxyImplementationVelocity.java).

Here is the original code : http://websvn.ow2.org/filedetails.php?repname=frascati&path=%2Ftrunk%2Ffrascati%2Fmodules%2Ffrascati-implementation-velocity%2Fsrc%2Fmain%2Fjava%2Forg%2Fow2%2Ffrascati%2Fimplementation%2Fvelocity%2FServletImplementationVelocity.java

The proposition is to add this portion of code to offer the possibility to load Velocity templates not only in a base folder but also in a folder tree.

Here is the code addition to solve this problem (can be found also on GitHub : https://github.com/easysoa/EasySOA/blob/master/easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy/src/main/java/org/ow2/frascati/implementation/velocity/ProxyImplementationVelocity.java)

.... protected final String invoke(String method, VelocityContext context, String[] args, Object... parameters) { // VelocityContext context = new VelocityContext(this.velocityContext); context.put(params, parameters); // FIXME: should not be called but @Lifecycle does not work as expected. registerScaProperties(); StringWriter sw = new StringWriter();

// **** EasySOA Hack begin
      
int pathArgIndex = Integer.parseInt((String) context.get("pathArgIndex")); // pathArgIndex has been set as an SCA xsd:int property
int storeIndex = Integer.parseInt((String) context.get("storeIndex")); // storeIndex has been set as an SCA xsd:int property

Template template = null;
if (parameters.length > pathArgIndex) {
    Object templatePathFound = parameters[pathArgIndex];
Object storeNameFound = parameters[storeIndex];
if (templatePathFound instanceof String) {
    template = this.velocityEngine.getTemplate((String)storeNameFound + "/" + (String) templatePathFound);
}
}
// *** EasySOA Hack end
            
if (template == null) {
    String name = this.velocityEngine.templateExists(method + ".vm") ? method + ".vm" : this.defaultResource;
template = this.velocityEngine.getTemplate(name);
}
if (!this.velocityEngine.invokeVelocimacro(method, method, args, context, sw)) {
    template.merge(context, sw);
    .....

Currently, the method parameter contains the name of the velocity template to use. It is not possible to call templates in an other folder or in a folder tree organisation.

The hack uses 2 properties to set the array position of 2 parameters "pathArgIndex" and "storeIndex". The "pathArgIndex" parameter contains the folder where to find the "storeIndex" template.

An other solution is to have a special method name (eg : folder1_folder2_template) to pass the informations.

A third solution is to use a special method name, allowing to pass special params, to be able get templates in a tree folder organisation.

Assignee
Assign to
1.5
Milestone
1.5 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: frascati/frascati#104