Alias feature pruning

44 views
Skip to first unread message

Julien Viet

unread,
Oct 7, 2013, 11:09:55 AM10/7/13
to ju...@googlegroups.com
Hello

in my current effort (simple taglib feature) I am adding the ability to use external application templates in an application.

This would use the absolute path of the template when injecting a template:

@Inject
@Path("/some/external/templates/index.gtmpl);

In this case the template would be imported in the application and not compiled (as it was already compiled before).

I will remove the 0.7.0 beta @Alias feature, as this feature was developed for this use case.

hoping it won't hurt anyone.

Julien



benjamin garcia

unread,
Nov 14, 2013, 8:26:17 AM11/14/13
to ju...@googlegroups.com
Hi, 

How use it when tempate is in jar on WEB-INF/lib app?

Regards,

Benjamin

Julien Viet

unread,
Nov 14, 2013, 9:08:26 AM11/14/13
to ju...@googlegroups.com
it should work OOTB (if not it’s a bug).

When using absolute path, it is possible to determine the class name to load and use. So in the case of "/some/external/templates/index.gtmpl” the template class looked up is some.external.templates.index and loaded from the web app classloader.

--
You received this message because you are subscribed to the Google Groups "Juzu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to juzu+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

benjamin garcia

unread,
Nov 14, 2013, 9:59:40 AM11/14/13
to ju...@googlegroups.com
I read ProcessingContext.resolveResourceFromSourcePath method  and I don't understand when juzu search in classloader? 

Julien Viet

unread,
Nov 14, 2013, 10:54:04 AM11/14/13
to ju...@googlegroups.com
so this is done in two steps

1/ at compilation time when a template is injected and this template has a path that is not located inside the application templates then this template is considered as managed, whether it actually exists or not (see TemplateContainerMetaModel#add method). This template is declared in the templates to load at runtime as “needed” by the application in the JSON config of the application, for instance:

{
  "controller":{
    "controllers":["plugin.template.external.A_"],
    "default":null,
    "escapeXML":null
  },
  "template":{
    "package":"plugin.template.external.templates",
    "templates":["plugin.template.simple.templates.index"]
  }
}

In this case the template is plugin.template.simple.templates.index however the template package is plugin.template.external.templates.

2/ at runtime the template bean is loaded from the classloader in the PluginTemplate class when it describes the bean involved in the IOC in the TemplatesDescriptor class.

So for external templates, they can be injected however the actual code does not check their existence at compilation time. Perhaps it could be checked in the TemplateContainerMetaModel#add and if the template is absent then a warning or a failure is issued. I would rather do a warning than a failure at a warning provides more flexibility and a failure would not prevent anyway the template to be here at runtime since the external template would not be packaged along with the application.

Julien Viet

unread,
Nov 14, 2013, 10:54:52 AM11/14/13
to ju...@googlegroups.com
considered as managed => considered as unmanaged

benjamin garcia

unread,
Nov 14, 2013, 11:53:03 AM11/14/13
to ju...@googlegroups.com
Ok, in fact all my modules template package has the same name. thank for explanation.
decorate and include tag work with same functionnality?

Julien Viet

unread,
Nov 14, 2013, 12:12:29 PM11/14/13
to ju...@googlegroups.com
no they do not work this way they require the template to be local, the getTemplate method of MetaModelProcessContext does not use it:

  @Override
  protected <M extends Serializable> Template<M> getTemplate(Path.Absolute path) {
    TemplateMetaModel tmm = owner.get(path);
    if (tmm != null) {
      return (Template<M>)tmm.template;
    } else {
      return null;
    }
  }

now I don’t remember if it works this way for some specific reason or if I just not thought about doing it.

benjamin garcia

unread,
Nov 14, 2013, 1:32:35 PM11/14/13
to ju...@googlegroups.com
Well, know I'm in trouble. 
I need this (it worked with alias)... 
Without this, I can't upgrade juzu version...  

Julien Viet

unread,
Nov 14, 2013, 1:42:57 PM11/14/13
to ju...@googlegroups.com
I will try to implement it soon and see how it goes :-)

benjamin garcia

unread,
Nov 15, 2013, 3:44:59 AM11/15/13
to ju...@googlegroups.com
Ok, thank you :-)

Julien Viet

unread,
Nov 15, 2013, 9:55:54 AM11/15/13
to ju...@googlegroups.com
can you try Juzu master ?

it should work now.

note that you must quote the path value since it begins with a “/“ and this char is also used by the tag closing syntax /}, for example

#{decorate path="/plugin/template/tag/decorate/templates/foo.gtmpl"/}

benjamin garcia

unread,
Nov 15, 2013, 10:27:01 AM11/15/13
to ju...@googlegroups.com
Hi, 

ok, I try.

benjamin garcia

unread,
Nov 15, 2013, 12:09:24 PM11/15/13
to ju...@googlegroups.com
Well, 
Compilation done :-)
Now, I have a ClassNotFoundException on template which are includes when I start my app. It search class in wrong package: https://gist.github.com/benjamingarcia/3ca5b1222b4b9a86f565

Julien Viet

unread,
Nov 15, 2013, 12:40:05 PM11/15/13
to ju...@googlegroups.com
can you describe your 2 projects and package / includes / templates ?

Benjamin Garcia

unread,
Nov 18, 2013, 2:52:21 AM11/18/13
to ju...@googlegroups.com
Hi, 

jar include : a standard maven jar project with template in org.geomatys.gui.style on src/main/resources.
war is a standard war maven project generated with archetype. template package in war is org.geomatys.gui.template.
Jar is on WEB-INF/lib war folder.

Julien Viet

unread,
Nov 18, 2013, 3:07:25 AM11/18/13
to ju...@googlegroups.com
what are the names of the templates that includes and the template that is included ?

Benjamin Garcia

unread,
Nov 18, 2013, 3:16:20 AM11/18/13
to ju...@googlegroups.com
template which include is /org/geomatys/style/style_dashboard.gtmpl
and template included is /org/geomatys/style/style_selected.gtmpl. Both are on included jar.

Julien Viet

unread,
Nov 18, 2013, 3:22:40 AM11/18/13
to ju...@googlegroups.com
so what is my.class.database ?

can you give us the content of the config.json of your application ?

Benjamin Garcia

unread,
Nov 18, 2013, 3:26:20 AM11/18/13
to ju...@googlegroups.com
it was /org/geomatys/style/style_selected.gtmpl. sorry I replace it before send gist

Benjamin Garcia

unread,
Nov 18, 2013, 3:40:09 AM11/18/13
to ju...@googlegroups.com
I think I found. Template which contain #{include ...} can't be in included jar. right?

Julien Viet

unread,
Nov 18, 2013, 5:07:50 AM11/18/13
to ju...@googlegroups.com
can you explain fully the user case and what you are doing ?

benjamin garcia

unread,
Nov 18, 2013, 8:26:16 AM11/18/13
to ju...@googlegroups.com
I'll prepare a source example on github, and I'll send url.

benjamin garcia

unread,
Nov 19, 2013, 8:48:22 AM11/19/13
to ju...@googlegroups.com
Hi, 

I hope README is understandable

regards, 

Benjamin

Julien Viet

unread,
Nov 19, 2013, 6:58:14 PM11/19/13
to ju...@googlegroups.com
thanks I will look after soon.

Julien Viet

unread,
Nov 21, 2013, 9:09:46 AM11/21/13
to ju...@googlegroups.com
I’m looking at the project but it does not seem correct:

index.gtmpl and index2.gtmpl includes /com/geomatys/example1/template01.gtmpl and /com/geomatys/example2/template02.gtmpl

the project2 has a template03.gtmpl

how is that supposed to work ?

benjamin garcia

unread,
Nov 21, 2013, 9:44:31 AM11/21/13
to ju...@googlegroups.com
My mistake. I forgot these files. github is up to date

Julien Viet

unread,
Nov 22, 2013, 3:28:37 AM11/22/13
to ju...@googlegroups.com
does your real project have an application declared for template01/template02/template03 ?

benjamin garcia

unread,
Nov 22, 2013, 4:02:29 AM11/22/13
to ju...@googlegroups.com
Hi, 

No, these projects are an example. I do this to extract my problematic around juzu.

Julien Viet

unread,
Nov 22, 2013, 4:10:06 AM11/22/13
to ju...@googlegroups.com
you need to create such “empty” application to get your templates compiled and then usable.

benjamin garcia

unread,
Nov 22, 2013, 11:43:02 AM11/22/13
to ju...@googlegroups.com
ok, I try this.

benjamin garcia

unread,
Nov 25, 2013, 7:59:25 AM11/25/13
to ju...@googlegroups.com
Hi, 

thank you for your help, project works.

Benjamin

Julien Viet

unread,
Nov 25, 2013, 8:09:51 AM11/25/13
to ju...@googlegroups.com
cool!
Reply all
Reply to author
Forward
0 new messages