in boot-plugin/src/main/groovy/org/grails/datastore/gorm/boot/autoconfigure/HibernateGormAutoConfiguration.groovy [77:121]
HibernateDatastore hibernateDatastore() {
List<String> packageNames = AutoConfigurationPackages.get(this.beanFactory)
List<Package> packages = []
for(name in packageNames) {
Package pkg = Package.getPackage(name)
if(pkg != null) {
packages.add(pkg)
}
}
ConfigurableListableBeanFactory beanFactory = applicationContext.beanFactory
HibernateDatastore datastore
if(dataSource == null) {
datastore = new HibernateDatastore(
applicationContext.getEnvironment(),
new ConfigurableApplicationContextEventPublisher(applicationContext),
packages as Package[]
)
beanFactory.registerSingleton("dataSource", datastore.getDataSource())
}
else {
datastore = new HibernateDatastore(
dataSource,
applicationContext.getEnvironment(),
new ConfigurableApplicationContextEventPublisher(applicationContext),
packages as Package[]
)
}
for(Service service in datastore.getServices()) {
Class serviceClass = service.getClass()
grails.gorm.services.Service ann = serviceClass.getAnnotation(grails.gorm.services.Service)
String serviceName = ann?.name()
if(serviceName == null) {
serviceName = Introspector.decapitalize(serviceClass.simpleName)
}
if(!applicationContext.containsBean(serviceName)) {
applicationContext.beanFactory.registerSingleton(
serviceName,
service
)
}
}
return datastore
}