Re: How to access DataChannelMetaData from templates

Nikita Timofeev <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAMi+qzA_JA6Xacjk8N5bOuTLBqBvPD779zFA0SwyPSqxOqg+ow@mail.gmail.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
<[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.