You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Juan Manuel Diaz Lara <jm...@yahoo.com.INVALID> on 2020/01/17 18:39:00 UTC

How to access DataChannelMetaData from templates

This is to be get the "comment" of the mapping node of attributes to generate additional features to _baseClasses. I really need then at run time but I will be happy if I can get it at generation time.
Thanks.

Atte. Juan Manuel Díaz Lara

Re: How to access DataChannelMetaData from templates

Posted by Juan Manuel Diaz Lara <jm...@yahoo.com.INVALID>.
Thanks for your help, I really appreciate this, now I can use the "comment" to pass additional metadata and use it at runtime.

Atte. Juan Manuel Díaz Lara 

    On Monday, January 20, 2020, 2:28:38 AM CST, Nikita Timofeev <nt...@objectstyle.com> wrote:  
 
 Hi,

If you really need to get access to model metadata at runtime, you
could get it by
configuring ServerRuntime like this:

ServerRuntime.builder().addModule(binder -> {
  binder.bind(DataChannelMetaData.class).to(DefaultDataChannelMetaData.class);
  binder.bind(HandlerFactory.class).to(ExtensionAwareHandlerFactory.class);
  ProjectModule.contributeExtensions(binder).add(InfoExtension.class);
})
...
You also need to add 'cayenne-project' dependency to your project.

After that, you can use DataChannelMetaData in your service at runtime:

  @Inject DataChannelMetaData metadata;

It could be tricky to get this in cgen's templates, as it's not that
configurable as server runtime.
We have a task for that [1], but no estimate though.

[1] https://issues.apache.org/jira/browse/CAY-2338

On Fri, Jan 17, 2020 at 9:39 PM Juan Manuel Diaz Lara
<jm...@yahoo.com.invalid> wrote:
>
> This is to be get the "comment" of the mapping node of attributes to generate additional features to _baseClasses. I really need then at run time but I will be happy if I can get it at generation time.
> Thanks.
>
> Atte. Juan Manuel Díaz Lara



-- 
Best regards,
Nikita Timofeev  

Re: How to access DataChannelMetaData from templates

Posted by Nikita Timofeev <nt...@objectstyle.com>.
Hi,

If you really need to get access to model metadata at runtime, you
could get it by
configuring ServerRuntime like this:

ServerRuntime.builder().addModule(binder -> {
  binder.bind(DataChannelMetaData.class).to(DefaultDataChannelMetaData.class);
  binder.bind(HandlerFactory.class).to(ExtensionAwareHandlerFactory.class);
  ProjectModule.contributeExtensions(binder).add(InfoExtension.class);
})
...
You also need to add 'cayenne-project' dependency to your project.

After that, you can use DataChannelMetaData in your service at runtime:

   @Inject DataChannelMetaData metadata;

It could be tricky to get this in cgen's templates, as it's not that
configurable as server runtime.
We have a task for that [1], but no estimate though.

[1] https://issues.apache.org/jira/browse/CAY-2338

On Fri, Jan 17, 2020 at 9:39 PM Juan Manuel Diaz Lara
<jm...@yahoo.com.invalid> wrote:
>
> This is to be get the "comment" of the mapping node of attributes to generate additional features to _baseClasses. I really need then at run time but I will be happy if I can get it at generation time.
> Thanks.
>
> Atte. Juan Manuel Díaz Lara



-- 
Best regards,
Nikita Timofeev