-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Accessing config properties in MetadataSourcesContributor
PostPosted: Wed Mar 09, 2016 4:42 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
Hi,

is it possible to access the configuration properties (hibernate.*) inside a SPI MetadataSourcesContributor?

I tried to resolve the CfgXmlAccessService but it is null.

Another question: does @InjectService work inside MetadataSourcesContributor?

Thanks,

Xavier


Top
 Profile  
 
 Post subject: Re: Accessing config properties in MetadataSourcesContributor
PostPosted: Wed Mar 09, 2016 4:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
1. You can access the configuration properties like this:

Code:
ConfigurationService configurationService= metadataSource.getServiceRegistry().getService( ConfigurationService.class );
configurationService.getSetting(
    AvailableSettings.DEFAULT_SCHEMA,
    StandardConverters.STRING,
    null
);


2. I think that `@InjectService` works with classes that implement the Service interface only.


Top
 Profile  
 
 Post subject: Re: Accessing config properties in MetadataSourcesContributor
PostPosted: Wed Mar 09, 2016 5:29 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
mihalcea_vlad wrote:
1. You can access the configuration properties like this:

Code:
ConfigurationService configurationService= metadataSource.getServiceRegistry().getService( ConfigurationService.class );
configurationService.getSetting(
    AvailableSettings.DEFAULT_SCHEMA,
    StandardConverters.STRING,
    null
);


Thanks, I tried that too but ConfigurationService is null (I am using JPA by the way).

It seems that metadataSources contains a BootstrapServiceRegistry which only gives access to ClassLoaderService, StrategySelector and IntegratorService.
ConfigurationService seems to come from a StandardServiceRegistry.


Top
 Profile  
 
 Post subject: Re: Accessing config properties in MetadataSourcesContributor
PostPosted: Wed Mar 09, 2016 5:49 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
MetadataSources takes a ServiceRegistry as parameter in its constructor.

In EntityManagerFactoryBuilderImpl constructor, MetadataSources is created with a BootstrapServiceRegistry, it could be given the StandardServiceRegistry that is built just some lines before.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.