-
1. Re: [forge-dev] Hello World Template
gastaldi Mar 29, 2014 2:03 PM (in response to Antonio Goncalves )Hi Antonio,
Roaster currently only maintains a class structure (add/remove fields, methods, interfaces,etc), not code (method bodies) at the moment.
There is a JIRA to allow that though.
See the templates addon README to learn how to generate content from a template.
Best Regards,
George Gastaldi
Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
Hi all,
I'm starting to get a bit more confident with Roaster... and now I would like to add templating. If I'm right, Roaster is nice to add bits and pieces of Java here and there, but it's better to use Templates when there is a lot of code, and mix templating and Roaster for better code customization.
Is there a sample I could use to write a Hello Word ? A template with an "engine" that uses Roaster to add Java code to the template.
Thanks
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 1.1 KB
-
-
2. Re: [forge-dev] Hello World Template
Hum...
In the README there is :
@Inject private TemplateProcessorFactory factory
But is there a way to use the templating from a Main class ? If I use
Forge, I have Furnace as a container, and I was trying something like this,
but it doesn't work :
Furnace furnace = startFurnace();
Imported imported =
furnace.getAddonRegistry(TemplateProcessorFactory.class);
TemplateProcessorFactory factory = imported.get();
Any simple Hello World from a Main class and a pom.xml ?
Thanks
Antonio
2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
Hi Antonio,
Roaster currently only maintains a class structure (add/remove fields,
methods, interfaces,etc), not code (method bodies) at the moment.
There is a JIRA to allow that though.
See the templates addon README to learn how to generate content from a
template.
Best Regards,
George Gastaldi
Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
escreveu:
Hi all,
I'm starting to get a bit more confident with Roaster... and now I would
like to add templating. If I'm right, Roaster is nice to add bits and
pieces of Java here and there, but it's better to use Templates when there
is a lot of code, and mix templating and Roaster for better code
customization.
Is there a sample I could use to write a Hello Word ? A template with an
"engine" that uses Roaster to add Java code to the template.
Thanks
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
3. Re: [forge-dev] Hello World Template
gastaldi Mar 30, 2014 4:17 PM (in response to Antonio Goncalves )Why it doesn't work? Is any exception being thrown?
Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
Hum...
In the README there is :
@Inject private TemplateProcessorFactory factory
But is there a way to use the templating from a Main class ? If I use Forge, I have Furnace as a container, and I was trying something like this, but it doesn't work :
Furnace furnace = startFurnace();
Imported<TemplateProcessorFactory> imported = furnace.getAddonRegistry(TemplateProcessorFactory.class);
TemplateProcessorFactory factory = imported.get();
Any simple Hello World from a Main class and a pom.xml ?
Thanks
Antonio
2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>> Hi Antonio,
>>
>> Roaster currently only maintains a class structure (add/remove fields, methods, interfaces,etc), not code (method bodies) at the moment.
>>
>> There is a JIRA to allow that though.
>>
>> See the templates addon README to learn how to generate content from a template.
>>
>> Best Regards,
>>
>> George Gastaldi
>>
>>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
>>>
>>
>>> Hi all,
>>>
>>> I'm starting to get a bit more confident with Roaster... and now I would like to add templating. If I'm right, Roaster is nice to add bits and pieces of Java here and there, but it's better to use Templates when there is a lot of code, and mix templating and Roaster for better code customization.
>>>
>>> Is there a sample I could use to write a Hello Word ? A template with an "engine" that uses Roaster to add Java code to the template.
>>>
>>> Thanks
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 1.7 KB
-
-
4. Re: [forge-dev] Hello World Template
Good old NPE ;o)
I'm not running the code into a container, so @Inject does not work. In the
readme there is the addonRegistry method. In all the samples, the registery
is injected... but how do I use all that with a good old Main ?
2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
Why it doesn't work? Is any exception being thrown?
Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
escreveu:
Hum...
In the README there is :
@Inject private TemplateProcessorFactory factory
But is there a way to use the templating from a Main class ? If I use
Forge, I have Furnace as a container, and I was trying something like this,
but it doesn't work :
Furnace furnace = startFurnace();
Imported<TemplateProcessorFactory> imported =
furnace.getAddonRegistry(TemplateProcessorFactory.class);
TemplateProcessorFactory factory = imported.get();
Any simple Hello World from a Main class and a pom.xml ?
Thanks
Antonio
>
2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>> Hi Antonio,
>>
>> Roaster currently only maintains a class structure (add/remove fields,
>> methods, interfaces,etc), not code (method bodies) at the moment.
>>
>> There is a JIRA to allow that though.
>>
>> See the templates addon README to learn how to generate content from a
>> template.
>>
>> Best Regards,
>>
>> George Gastaldi
>>
>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
>> escreveu:
>>
>> Hi all,
>>
>> I'm starting to get a bit more confident with Roaster... and now I would
>> like to add templating. If I'm right, Roaster is nice to add bits and
>> pieces of Java here and there, but it's better to use Templates when there
>> is a lot of code, and mix templating and Roaster for better code
>> customization.
>>
>> Is there a sample I could use to write a Hello Word ? A template with an
>> "engine" that uses Roaster to add Java code to the template.
>>
>> Thanks
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
5. Re: [forge-dev] Hello World Template
gastaldi Mar 30, 2014 4:31 PM (in response to Antonio Goncalves )Your code should work, you can't use @Inject outside Furnace environment. Not sure what's going on, need to investigate a little further
Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
Good old NPE ;o)
I'm not running the code into a container, so @Inject does not work. In the readme there is the addonRegistry method. In all the samples, the registery is injected... but how do I use all that with a good old Main ?
2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>> Why it doesn't work? Is any exception being thrown?
>>
>>> Em 30/03/2014, às 17:14, Antonio Goncalves https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 1.9 KB
-
-
6. Re: [forge-dev] Hello World Template
So it might be my pom.xml
Where do you get @Inject from ? Just from javax.inject:javax.inject ? Wich
Furnace dependencies do you need ?
2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
Your code should work, you can't use @Inject outside Furnace environment.
Not sure what's going on, need to investigate a little further
Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
escreveu:
Good old NPE ;o)
I'm not running the code into a container, so @Inject does not work. In
the readme there is the addonRegistry method. In all the samples, the
registery is injected... but how do I use all that with a good old Main ?
>
2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>> Why it doesn't work? Is any exception being thrown?
>>
>> Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
>> escreveu:
>>
>> Hum...
>>
>> In the README there is :
>>
>> @Inject private TemplateProcessorFactory factory
>>
>> But is there a way to use the templating from a Main class ? If I use
>> Forge, I have Furnace as a container, and I was trying something like this,
>> but it doesn't work :
>>
>> Furnace furnace = startFurnace();
>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>> TemplateProcessorFactory factory = imported.get();
>>
>> Any simple Hello World from a Main class and a pom.xml ?
>>
>> Thanks
>> Antonio
>>
>>
>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>
>>> Hi Antonio,
>>>
>>> Roaster currently only maintains a class structure (add/remove fields,
>>> methods, interfaces,etc), not code (method bodies) at the moment.
>>>
>>> There is a JIRA to allow that though.
>>>
>>> See the templates addon README to learn how to generate content from a
>>> template.
>>>
>>> Best Regards,
>>>
>>> George Gastaldi
>>>
>>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
>>> escreveu:
>>>
>>> Hi all,
>>>
>>> I'm starting to get a bit more confident with Roaster... and now I would
>>> like to add templating. If I'm right, Roaster is nice to add bits and
>>> pieces of Java here and there, but it's better to use Templates when there
>>> is a lot of code, and mix templating and Roaster for better code
>>> customization.
>>>
>>> Is there a sample I could use to write a Hello Word ? A template with an
>>> "engine" that uses Roaster to add Java code to the template.
>>>
>>> Thanks
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>> | Devoxx France <http://www.devoxx.fr/>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
7. Re: [forge-dev] Hello World Template
Here is my code. I think it's my dependencies that are not right, because
resourceFactory is not injected so I get a NPE
*public class *RestEndpoint {
@Inject
*private *TemplateProcessorFactory factory;
@Inject
ResourceFactory resourceFactory;
*public static void *main(String[] args) *throws *IOException {
*new *RestEndpoint().doIt();
}
*private void *doIt() *throws *IOException {
Resource templateResource = resourceFactory
.create(getClass().getResource("EndpointWithDTO.jv"));
Template template = *new *FreemarkerTemplate(templateResource);
*// Mark this resource as a Freemarker template *TemplateProcessor
processor = factory.fromTemplate(template);
Map<String,Object> params = *new *HashMap<String,Object>();
*//Could be a POJO also. params.put("name"*, "JBoss Forge");
String output = processor.process(params);
*// should return "Hello JBoss Forge". System.out*
.println(output);
}
}
2014-03-30 22:36 GMT+02:00 Antonio Goncalves <antonio.mailing@gmail.com>:
So it might be my pom.xml
Where do you get @Inject from ? Just from javax.inject:javax.inject ? Wich
Furnace dependencies do you need ?
>
2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
Your code should work, you can't use @Inject outside Furnace environment.
>> Not sure what's going on, need to investigate a little further
>>
>> Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
>> escreveu:
>>
>> Good old NPE ;o)
>>
>> I'm not running the code into a container, so @Inject does not work. In
>> the readme there is the addonRegistry method. In all the samples, the
>> registery is injected... but how do I use all that with a good old Main ?
>>
>>
>> 2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>
>>> Why it doesn't work? Is any exception being thrown?
>>>
>>> Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
>>> escreveu:
>>>
>>> Hum...
>>>
>>> In the README there is :
>>>
>>> @Inject private TemplateProcessorFactory factory
>>>
>>> But is there a way to use the templating from a Main class ? If I use
>>> Forge, I have Furnace as a container, and I was trying something like this,
>>> but it doesn't work :
>>>
>>> Furnace furnace = startFurnace();
>>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>>> TemplateProcessorFactory factory = imported.get();
>>>
>>> Any simple Hello World from a Main class and a pom.xml ?
>>>
>>> Thanks
>>> Antonio
>>>
>>>
>>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>>
>>>> Hi Antonio,
>>>>
>>>> Roaster currently only maintains a class structure (add/remove fields,
>>>> methods, interfaces,etc), not code (method bodies) at the moment.
>>>>
>>>> There is a JIRA to allow that though.
>>>>
>>>> See the templates addon README to learn how to generate content from a
>>>> template.
>>>>
>>>> Best Regards,
>>>>
>>>> George Gastaldi
>>>>
>>>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
>>>> escreveu:
>>>>
>>>> Hi all,
>>>>
>>>> I'm starting to get a bit more confident with Roaster... and now I
>>>> would like to add templating. If I'm right, Roaster is nice to add bits and
>>>> pieces of Java here and there, but it's better to use Templates when there
>>>> is a lot of code, and mix templating and Roaster for better code
>>>> customization.
>>>>
>>>> Is there a sample I could use to write a Hello Word ? A template with
>>>> an "engine" that uses Roaster to add Java code to the template.
>>>>
>>>> Thanks
>>>>
>>>> --
>>>> Antonio Goncalves
>>>> Software architect and Java Champion
>>>>
>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>
>>>
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>> | Devoxx France <http://www.devoxx.fr/>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
8. Re: [forge-dev] Hello World Template
ivan_stefanov Mar 30, 2014 5:58 PM (in response to Antonio Goncalves )Hi Antonio,
As far as I can see, in your main class you are not inside the Furnace
container, you are rather on you own. That is why nobody has injected you
your dependencies.
Cheers,
Ivan
On Sun, Mar 30, 2014 at 11:45 PM, Antonio Goncalves <
antonio.mailing@gmail.com> wrote:
Here is my code. I think it's my dependencies that are not right, because
resourceFactory is not injected so I get a NPE
>
*public class *RestEndpoint {
@Inject
*private *TemplateProcessorFactory factory;
@Inject
ResourceFactory resourceFactory;
>
*public static void *main(String[] args) *throws *IOException {
*new *RestEndpoint().doIt();
}
*private void *doIt() *throws *IOException {
Resource<URL> templateResource = resourceFactory
.create(getClass().getResource("EndpointWithDTO.jv"));
Template template = *new *FreemarkerTemplate(templateResource);
*// Mark this resource as a Freemarker template *TemplateProcessor
processor = factory.fromTemplate(template);
Map<String,Object> params = *new *HashMap<String,Object>();
*//Could be a POJO also. params.put("name"*, "JBoss Forge");
String output = processor.process(params);
*// should return "Hello JBoss Forge". System.out*
.println(output);
}
}
>
2014-03-30 22:36 GMT+02:00 Antonio Goncalves <antonio.mailing@gmail.com>:
So it might be my pom.xml
>>
>> Where do you get @Inject from ? Just from javax.inject:javax.inject ?
>> Wich Furnace dependencies do you need ?
>>
>>
>> 2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>
>> Your code should work, you can't use @Inject outside Furnace environment.
>>> Not sure what's going on, need to investigate a little further
>>>
>>> Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
>>> escreveu:
>>>
>>> Good old NPE ;o)
>>>
>>> I'm not running the code into a container, so @Inject does not work. In
>>> the readme there is the addonRegistry method. In all the samples, the
>>> registery is injected... but how do I use all that with a good old Main ?
>>>
>>>
>>> 2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>
>>>> Why it doesn't work? Is any exception being thrown?
>>>>
>>>> Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
>>>> escreveu:
>>>>
>>>> Hum...
>>>>
>>>> In the README there is :
>>>>
>>>> @Inject private TemplateProcessorFactory factory
>>>>
>>>> But is there a way to use the templating from a Main class ? If I use
>>>> Forge, I have Furnace as a container, and I was trying something like this,
>>>> but it doesn't work :
>>>>
>>>> Furnace furnace = startFurnace();
>>>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>>>> TemplateProcessorFactory factory = imported.get();
>>>>
>>>> Any simple Hello World from a Main class and a pom.xml ?
>>>>
>>>> Thanks
>>>> Antonio
>>>>
>>>>
>>>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>>>
>>>>> Hi Antonio,
>>>>>
>>>>> Roaster currently only maintains a class structure (add/remove fields,
>>>>> methods, interfaces,etc), not code (method bodies) at the moment.
>>>>>
>>>>> There is a JIRA to allow that though.
>>>>>
>>>>> See the templates addon README to learn how to generate content from a
>>>>> template.
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> George Gastaldi
>>>>>
>>>>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>> escreveu:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I'm starting to get a bit more confident with Roaster... and now I
>>>>> would like to add templating. If I'm right, Roaster is nice to add bits and
>>>>> pieces of Java here and there, but it's better to use Templates when there
>>>>> is a lot of code, and mix templating and Roaster for better code
>>>>> customization.
>>>>>
>>>>> Is there a sample I could use to write a Hello Word ? A template with
>>>>> an "engine" that uses Roaster to add Java code to the template.
>>>>>
>>>>> Thanks
>>>>>
>>>>> --
>>>>> Antonio Goncalves
>>>>> Software architect and Java Champion
>>>>>
>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Antonio Goncalves
>>>> Software architect and Java Champion
>>>>
>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>
>>>
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>> | Devoxx France <http://www.devoxx.fr/>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
-
att1.html.zip 2.6 KB
-
-
9. Re: [forge-dev] Hello World Template
Hum.... I just did this (starting Furnace in my main) :
But it doesn't work either.
Any idea ?
2014-03-30 23:58 GMT+02:00 Ivan St. Ivanov <ivan.st.ivanov@gmail.com>:
Hi Antonio,
As far as I can see, in your main class you are not inside the Furnace
container, you are rather on you own. That is why nobody has injected you
your dependencies.
Cheers,
Ivan
>
On Sun, Mar 30, 2014 at 11:45 PM, Antonio Goncalves <
antonio.mailing@gmail.com> wrote:
>> Here is my code. I think it's my dependencies that are not right, because
>> resourceFactory is not injected so I get a NPE
>>
>>
>> *public class *RestEndpoint {
>>
>> @Inject
>> *private *TemplateProcessorFactory factory;
>>
>> @Inject
>> ResourceFactory resourceFactory;
>>
>>
>> *public static void *main(String[] args) *throws *IOException {
>> *new *RestEndpoint().doIt();
>> }
>>
>> *private void *doIt() *throws *IOException {
>> Resource templateResource = resourceFactory
>> .create(getClass().getResource("EndpointWithDTO.jv"));
>> Template template = *new *FreemarkerTemplate(templateResource);
>> *// Mark this resource as a Freemarker template *TemplateProcessor
>> processor = factory.fromTemplate(template);
>> Map<String,Object> params = *new *HashMap<String,Object>();
>> *//Could be a POJO also. params.put("name"*, "JBoss Forge");
>> String output = processor.process(params);
>> *// should return "Hello JBoss Forge". System.out*
>> .println(output);
>> }
>> }
>>
>>
>> 2014-03-30 22:36 GMT+02:00 Antonio Goncalves <antonio.mailing@gmail.com>:
>>
>> So it might be my pom.xml
>>>
>>> Where do you get @Inject from ? Just from javax.inject:javax.inject ?
>>> Wich Furnace dependencies do you need ?
>>>
>>>
>>> 2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>
>>> Your code should work, you can't use @Inject outside Furnace
>>>> environment. Not sure what's going on, need to investigate a little further
>>>>
>>>> Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
>>>> escreveu:
>>>>
>>>> Good old NPE ;o)
>>>>
>>>> I'm not running the code into a container, so @Inject does not work. In
>>>> the readme there is the addonRegistry method. In all the samples, the
>>>> registery is injected... but how do I use all that with a good old Main ?
>>>>
>>>>
>>>> 2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>>
>>>>> Why it doesn't work? Is any exception being thrown?
>>>>>
>>>>> Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>> escreveu:
>>>>>
>>>>> Hum...
>>>>>
>>>>> In the README there is :
>>>>>
>>>>> @Inject private TemplateProcessorFactory factory
>>>>>
>>>>> But is there a way to use the templating from a Main class ? If I use
>>>>> Forge, I have Furnace as a container, and I was trying something like this,
>>>>> but it doesn't work :
>>>>>
>>>>> Furnace furnace = startFurnace();
>>>>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>>>>> TemplateProcessorFactory factory = imported.get();
>>>>>
>>>>> Any simple Hello World from a Main class and a pom.xml ?
>>>>>
>>>>> Thanks
>>>>> Antonio
>>>>>
>>>>>
>>>>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>>>>
>>>>>> Hi Antonio,
>>>>>>
>>>>>> Roaster currently only maintains a class structure (add/remove
>>>>>> fields, methods, interfaces,etc), not code (method bodies) at the moment.
>>>>>>
>>>>>> There is a JIRA to allow that though.
>>>>>>
>>>>>> See the templates addon README to learn how to generate content from
>>>>>> a template.
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>> George Gastaldi
>>>>>>
>>>>>> Em 29/03/2014, às 14:43, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>>> escreveu:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I'm starting to get a bit more confident with Roaster... and now I
>>>>>> would like to add templating. If I'm right, Roaster is nice to add bits and
>>>>>> pieces of Java here and there, but it's better to use Templates when there
>>>>>> is a lot of code, and mix templating and Roaster for better code
>>>>>> customization.
>>>>>>
>>>>>> Is there a sample I could use to write a Hello Word ? A template with
>>>>>> an "engine" that uses Roaster to add Java code to the template.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> --
>>>>>> Antonio Goncalves
>>>>>> Software architect and Java Champion
>>>>>>
>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Antonio Goncalves
>>>>> Software architect and Java Champion
>>>>>
>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Antonio Goncalves
>>>> Software architect and Java Champion
>>>>
>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>
>>>
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>> | Devoxx France <http://www.devoxx.fr/>
>>>
>>
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
10. Re: [forge-dev] Hello World Template
gastaldi Mar 31, 2014 10:00 AM (in response to Antonio Goncalves )Antonio,
main() methods are not managed by Furnace, hence why @Inject does not work. You need to fech these services from the AddonRegistry:
Eg:
furnace.getAddonRegistry(ResourceFactory.class).get()
Em 31/03/2014, às 04:26, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
Hum.... I just did this (starting Furnace in my main) :
But it doesn't work either.
Any idea ?
2014-03-30 23:58 GMT+02:00 Ivan St. Ivanov <ivan.st.ivanov@gmail.com>:
>> Hi Antonio,
>>
>> As far as I can see, in your main class you are not inside the Furnace container, you are rather on you own. That is why nobody has injected you your dependencies.
>>
>> Cheers,
>> Ivan
>>
>>
>>> On Sun, Mar 30, 2014 at 11:45 PM, Antonio Goncalves https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 3.0 KB
-
-
11. Re: [forge-dev] Hello World Template
If I do the following, it doesn't work :
ResourceFactory resourceFactory = furnace.getAddonRegistry(ResourceFactory.
class).get();
TemplateProcessorFactory factory =
furnace.getAddonRegistry(TemplateProcessorFactory.class).get();
That because the method getAddonRegistry takes a AddonRepository.
Any idea ?
2014-03-31 16:00 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
Antonio,
main() methods are not managed by Furnace, hence why @Inject does not
work. You need to fech these services from the AddonRegistry:
Eg:
furnace.getAddonRegistry(ResourceFactory.class).get()
Em 31/03/2014, às 04:26, Antonio Goncalves <antonio.mailing@gmail.com>
escreveu:
Hum.... I just did this (starting Furnace in my main) :
>
But it doesn't work either.
Any idea ?
>
2014-03-30 23:58 GMT+02:00 Ivan St. Ivanov <ivan.st.ivanov@gmail.com>:
>> Hi Antonio,
>>
>> As far as I can see, in your main class you are not inside the Furnace
>> container, you are rather on you own. That is why nobody has injected you
>> your dependencies.
>>
>> Cheers,
>> Ivan
>>
>>
>> On Sun, Mar 30, 2014 at 11:45 PM, Antonio Goncalves <
>> antonio.mailing@gmail.com> wrote:
>>
>>> Here is my code. I think it's my dependencies that are not right,
>>> because resourceFactory is not injected so I get a NPE
>>>
>>>
>>> *public class *RestEndpoint {
>>>
>>> @Inject
>>> *private *TemplateProcessorFactory factory;
>>>
>>> @Inject
>>> ResourceFactory resourceFactory;
>>>
>>>
>>> *public static void *main(String[] args) *throws *IOException {
>>> *new *RestEndpoint().doIt();
>>> }
>>>
>>> *private void *doIt() *throws *IOException {
>>> Resource templateResource = resourceFactory
>>> .create(getClass().getResource("EndpointWithDTO.jv"));
>>> Template template = *new *FreemarkerTemplate(templateResource);
>>> *// Mark this resource as a Freemarker template *TemplateProcessor
>>> processor = factory.fromTemplate(template);
>>> Map<String,Object> params = *new *HashMap<String,Object>();
>>> *//Could be a POJO also. params.put("name"*, "JBoss Forge");
>>> String output = processor.process(params);
>>> *// should return "Hello JBoss Forge". System.out*
>>> .println(output);
>>> }
>>> }
>>>
>>>
>>> 2014-03-30 22:36 GMT+02:00 Antonio Goncalves <antonio.mailing@gmail.com>
>>> :
>>>
>>> So it might be my pom.xml
>>>>
>>>> Where do you get @Inject from ? Just from javax.inject:javax.inject ?
>>>> Wich Furnace dependencies do you need ?
>>>>
>>>>
>>>> 2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>>
>>>> Your code should work, you can't use @Inject outside Furnace
>>>>> environment. Not sure what's going on, need to investigate a little further
>>>>>
>>>>> Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>> escreveu:
>>>>>
>>>>> Good old NPE ;o)
>>>>>
>>>>> I'm not running the code into a container, so @Inject does not work.
>>>>> In the readme there is the addonRegistry method. In all the samples, the
>>>>> registery is injected... but how do I use all that with a good old Main ?
>>>>>
>>>>>
>>>>> 2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>>>
>>>>>> Why it doesn't work? Is any exception being thrown?
>>>>>>
>>>>>> Em 30/03/2014, às 17:14, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>>> escreveu:
>>>>>>
>>>>>> Hum...
>>>>>>
>>>>>> In the README there is :
>>>>>>
>>>>>> @Inject private TemplateProcessorFactory factory
>>>>>>
>>>>>> But is there a way to use the templating from a Main class ? If I use
>>>>>> Forge, I have Furnace as a container, and I was trying something like this,
>>>>>> but it doesn't work :
>>>>>>
>>>>>> Furnace furnace = startFurnace();
>>>>>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>>>>>> TemplateProcessorFactory factory = imported.get();
>>>>>>
>>>>>> Any simple Hello World from a Main class and a pom.xml ?
>>>>>>
>>>>>> Thanks
>>>>>> Antonio
>>>>>>
>>>>>>
>>>>>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>>>>>
>>>>>>> Hi Antonio,
>>>>>>>
>>>>>>> Roaster currently only maintains a class structure (add/remove
>>>>>>> fields, methods, interfaces,etc), not code (method bodies) at the moment.
>>>>>>>
>>>>>>> There is a JIRA to allow that though.
>>>>>>>
>>>>>>> See the templates addon README to learn how to generate content from
>>>>>>> a template.
>>>>>>>
>>>>>>> Best Regards,
>>>>>>>
>>>>>>> George Gastaldi
>>>>>>>
>>>>>>> Em 29/03/2014, às 14:43, Antonio Goncalves <
>>>>>>> antonio.mailing@gmail.com> escreveu:
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I'm starting to get a bit more confident with Roaster... and now I
>>>>>>> would like to add templating. If I'm right, Roaster is nice to add bits and
>>>>>>> pieces of Java here and there, but it's better to use Templates when there
>>>>>>> is a lot of code, and mix templating and Roaster for better code
>>>>>>> customization.
>>>>>>>
>>>>>>> Is there a sample I could use to write a Hello Word ? A template
>>>>>>> with an "engine" that uses Roaster to add Java code to the template.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> --
>>>>>>> Antonio Goncalves
>>>>>>> Software architect and Java Champion
>>>>>>>
>>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> forge-dev mailing list
>>>>>>> forge-dev@lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> forge-dev mailing list
>>>>>>> forge-dev@lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Antonio Goncalves
>>>>>> Software architect and Java Champion
>>>>>>
>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Antonio Goncalves
>>>>> Software architect and Java Champion
>>>>>
>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> forge-dev mailing list
>>>>> forge-dev@lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Antonio Goncalves
>>>> Software architect and Java Champion
>>>>
>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>
>>>
>>>
>>>
>>> --
>>> Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>> | Devoxx France <http://www.devoxx.fr/>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
12. Re: [forge-dev] Hello World Template
gastaldi Mar 31, 2014 1:19 PM (in response to Antonio Goncalves )Oh, sorry, my fault. It should be:
furnace.getAddonRegistry().getServices(ResourceFactory.class).get();
Em 31/03/2014, às 14:11, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
If I do the following, it doesn't work :
ResourceFactory resourceFactory = furnace.getAddonRegistry(ResourceFactory.class).get();
TemplateProcessorFactory factory = furnace.getAddonRegistry(TemplateProcessorFactory.class).get();
That because the method getAddonRegistry takes a AddonRepository.
Any idea ?
2014-03-31 16:00 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>> Antonio,
>>
>> main() methods are not managed by Furnace, hence why @Inject does not work. You need to fech these services from the AddonRegistry:
>>
>> Eg:
>> furnace.getAddonRegistry(ResourceFactory.class).get()
>>
>>> Em 31/03/2014, às 04:26, Antonio Goncalves https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 3.1 KB
-
-
13. Re: [forge-dev] Hello World Template
Grrr....
ContainerException: No services of type
started addons.
Here is the code, I might be doing something wrong.... but I don't know
what else to do now
2014-03-31 19:19 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
Oh, sorry, my fault. It should be:
furnace.getAddonRegistry().getServices(ResourceFactory.class).get();
>
Em 31/03/2014, às 14:11, Antonio Goncalves <antonio.mailing@gmail.com>
escreveu:
If I do the following, it doesn't work :
ResourceFactory resourceFactory = furnace.getAddonRegistry(ResourceFactory.
class).get();
TemplateProcessorFactory factory =
furnace.getAddonRegistry(TemplateProcessorFactory.class).get();
That because the method getAddonRegistry takes a AddonRepository.
>
Any idea ?
>
>
2014-03-31 16:00 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>> Antonio,
>>
>> main() methods are not managed by Furnace, hence why @Inject does not
>> work. You need to fech these services from the AddonRegistry:
>>
>> Eg:
>> furnace.getAddonRegistry(ResourceFactory.class).get()
>>
>> Em 31/03/2014, às 04:26, Antonio Goncalves <antonio.mailing@gmail.com>
>> escreveu:
>>
>> Hum.... I just did this (starting Furnace in my main) :
>>
>>
>>
>> But it doesn't work either.
>>
>> Any idea ?
>>
>>
>> 2014-03-30 23:58 GMT+02:00 Ivan St. Ivanov <ivan.st.ivanov@gmail.com>:
>>
>>> Hi Antonio,
>>>
>>> As far as I can see, in your main class you are not inside the Furnace
>>> container, you are rather on you own. That is why nobody has injected you
>>> your dependencies.
>>>
>>> Cheers,
>>> Ivan
>>>
>>>
>>> On Sun, Mar 30, 2014 at 11:45 PM, Antonio Goncalves <
>>> antonio.mailing@gmail.com> wrote:
>>>
>>>> Here is my code. I think it's my dependencies that are not right,
>>>> because resourceFactory is not injected so I get a NPE
>>>>
>>>>
>>>> *public class *RestEndpoint {
>>>>
>>>> @Inject
>>>> *private *TemplateProcessorFactory factory;
>>>>
>>>> @Inject
>>>> ResourceFactory resourceFactory;
>>>>
>>>>
>>>> *public static void *main(String[] args) *throws *IOException {
>>>> *new *RestEndpoint().doIt();
>>>> }
>>>>
>>>> *private void *doIt() *throws *IOException {
>>>> Resource templateResource = resourceFactory
>>>> .create(getClass().getResource("EndpointWithDTO.jv"));
>>>> Template template = *new *FreemarkerTemplate(templateResource);
>>>>
>>>> *// Mark this resource as a Freemarker template *TemplateProcessor
>>>> processor = factory.fromTemplate(template);
>>>> Map<String,Object> params = *new *HashMap<String,Object>();
>>>> *//Could be a POJO also. params.put("name"*, "JBoss Forge"
>>>> );
>>>> String output = processor.process(params);
>>>> *// should return "Hello JBoss Forge". System.out*
>>>> .println(output);
>>>> }
>>>> }
>>>>
>>>>
>>>> 2014-03-30 22:36 GMT+02:00 Antonio Goncalves <antonio.mailing@gmail.com
>>>> >:
>>>>
>>>> So it might be my pom.xml
>>>>>
>>>>> Where do you get @Inject from ? Just from javax.inject:javax.inject ?
>>>>> Wich Furnace dependencies do you need ?
>>>>>
>>>>>
>>>>> 2014-03-30 22:31 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>>>
>>>>> Your code should work, you can't use @Inject outside Furnace
>>>>>> environment. Not sure what's going on, need to investigate a little further
>>>>>>
>>>>>> Em 30/03/2014, às 17:26, Antonio Goncalves <antonio.mailing@gmail.com>
>>>>>> escreveu:
>>>>>>
>>>>>> Good old NPE ;o)
>>>>>>
>>>>>> I'm not running the code into a container, so @Inject does not work.
>>>>>> In the readme there is the addonRegistry method. In all the samples, the
>>>>>> registery is injected... but how do I use all that with a good old Main ?
>>>>>>
>>>>>>
>>>>>> 2014-03-30 22:17 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>>>>>>
>>>>>>> Why it doesn't work? Is any exception being thrown?
>>>>>>>
>>>>>>> Em 30/03/2014, às 17:14, Antonio Goncalves <
>>>>>>> antonio.mailing@gmail.com> escreveu:
>>>>>>>
>>>>>>> Hum...
>>>>>>>
>>>>>>> In the README there is :
>>>>>>>
>>>>>>> @Inject private TemplateProcessorFactory factory
>>>>>>>
>>>>>>> But is there a way to use the templating from a Main class ? If I
>>>>>>> use Forge, I have Furnace as a container, and I was trying something like
>>>>>>> this, but it doesn't work :
>>>>>>>
>>>>>>> Furnace furnace = startFurnace();
>>>>>>> Imported furnace.getAddonRegistry(TemplateProcessorFactory.class);
>>>>>>> TemplateProcessorFactory factory = imported.get();
>>>>>>>
>>>>>>> Any simple Hello World from a Main class and a pom.xml ?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Antonio
>>>>>>>
>>>>>>>
>>>>>>> 2014-03-29 19:03 GMT+01:00 George Gastaldi <ggastald@redhat.com>:
>>>>>>>
>>>>>>>> Hi Antonio,
>>>>>>>>
>>>>>>>> Roaster currently only maintains a class structure (add/remove
>>>>>>>> fields, methods, interfaces,etc), not code (method bodies) at the moment.
>>>>>>>>
>>>>>>>> There is a JIRA to allow that though.
>>>>>>>>
>>>>>>>> See the templates addon README to learn how to generate content
>>>>>>>> from a template.
>>>>>>>>
>>>>>>>> Best Regards,
>>>>>>>>
>>>>>>>> George Gastaldi
>>>>>>>>
>>>>>>>> Em 29/03/2014, às 14:43, Antonio Goncalves <
>>>>>>>> antonio.mailing@gmail.com> escreveu:
>>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I'm starting to get a bit more confident with Roaster... and now I
>>>>>>>> would like to add templating. If I'm right, Roaster is nice to add bits and
>>>>>>>> pieces of Java here and there, but it's better to use Templates when there
>>>>>>>> is a lot of code, and mix templating and Roaster for better code
>>>>>>>> customization.
>>>>>>>>
>>>>>>>> Is there a sample I could use to write a Hello Word ? A template
>>>>>>>> with an "engine" that uses Roaster to add Java code to the template.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> --
>>>>>>>> Antonio Goncalves
>>>>>>>> Software architect and Java Champion
>>>>>>>>
>>>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> forge-dev mailing list
>>>>>>>> forge-dev@lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> forge-dev mailing list
>>>>>>>> forge-dev@lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Antonio Goncalves
>>>>>>> Software architect and Java Champion
>>>>>>>
>>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> forge-dev mailing list
>>>>>>> forge-dev@lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> forge-dev mailing list
>>>>>>> forge-dev@lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Antonio Goncalves
>>>>>> Software architect and Java Champion
>>>>>>
>>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-dev mailing list
>>>>>> forge-dev@lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Antonio Goncalves
>>>>> Software architect and Java Champion
>>>>>
>>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Antonio Goncalves
>>>> Software architect and Java Champion
>>>>
>>>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>>> | Devoxx France <http://www.devoxx.fr/>
>>>>
>>>> _______________________________________________
>>>> forge-dev mailing list
>>>> forge-dev@lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>>
>>>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>>
>>
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>> | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>> | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
| Devoxx France <http://www.devoxx.fr/>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
>
_______________________________________________
forge-dev mailing list
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
| LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
| Devoxx France <http://www.devoxx.fr/>
-
14. Re: [forge-dev] Hello World Template
gastaldi Mar 31, 2014 1:42 PM (in response to Antonio Goncalves )Check if your target/addons folder contains the deployed addons structure. It should have been created by the furnace-maven-plugin
Em 31/03/2014, às 14:39, Antonio Goncalves <antonio.mailing@gmail.com> escreveu:
Grrr....
ContainerException: No services of type could be found in any started addons.
Here is the code, I might be doing something wrong.... but I don't know what else to do now
2014-03-31 19:19 GMT+02:00 George Gastaldi <ggastald@redhat.com>:
>> Oh, sorry, my fault. It should be:
>> furnace.getAddonRegistry().getServices(ResourceFactory.class).get();
>>
>>
>>> Em 31/03/2014, às 14:11, Antonio Goncalves https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
-
att1.html.zip 3.4 KB
-