Re: How to access DataChannelMetaData from templates

Juan Manuel Diaz Lara <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
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 <[email protected]> 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
<[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.