|
6 | 6 |
|
7 | 7 | import java.util.ArrayList; |
8 | 8 | import java.util.Collection; |
9 | | -import java.util.Collections; |
10 | 9 | import java.util.HashMap; |
11 | 10 | import java.util.Map; |
12 | 11 |
|
|
41 | 40 |
|
42 | 41 | import org.jboss.logging.Logger; |
43 | 42 |
|
| 43 | +import static java.util.Collections.emptyList; |
| 44 | +import static java.util.Collections.emptyMap; |
| 45 | + |
44 | 46 | /** |
45 | 47 | * @author Andrea Boriero |
46 | 48 | */ |
@@ -75,42 +77,42 @@ public class BootstrapContextImpl implements BootstrapContext { |
75 | 77 | private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorMap; |
76 | 78 | private ArrayList<CacheRegionDefinition> cacheRegionDefinitions; |
77 | 79 | private final ManagedTypeRepresentationResolver representationStrategySelector; |
78 | | - private ConfigurationService configurationService; |
| 80 | + private final ConfigurationService configurationService; |
79 | 81 |
|
80 | 82 | public BootstrapContextImpl( |
81 | 83 | StandardServiceRegistry serviceRegistry, |
82 | 84 | MetadataBuildingOptions metadataBuildingOptions) { |
83 | 85 | this.serviceRegistry = serviceRegistry; |
84 | | - this.classmateContext = new ClassmateContext(); |
85 | 86 | this.metadataBuildingOptions = metadataBuildingOptions; |
86 | 87 |
|
87 | | - this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); |
88 | | - this.classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService ); |
| 88 | + classmateContext = new ClassmateContext(); |
| 89 | + classLoaderService = serviceRegistry.requireService( ClassLoaderService.class ); |
| 90 | + classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService ); |
89 | 91 |
|
90 | 92 | final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class ); |
91 | 93 | final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class ); |
92 | 94 |
|
93 | | - this.jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings() ); |
94 | | - this.scanOptions = new StandardScanOptions( |
| 95 | + jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings() ); |
| 96 | + scanOptions = new StandardScanOptions( |
95 | 97 | (String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ), |
96 | 98 | false |
97 | 99 | ); |
98 | 100 |
|
99 | 101 | // ScanEnvironment must be set explicitly |
100 | | - this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER ); |
101 | | - this.archiveDescriptorFactory = strategySelector.resolveStrategy( |
| 102 | + scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER ); |
| 103 | + archiveDescriptorFactory = strategySelector.resolveStrategy( |
102 | 104 | ArchiveDescriptorFactory.class, |
103 | 105 | configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER ) |
104 | 106 | ); |
105 | 107 |
|
106 | | - this.representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE; |
| 108 | + representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE; |
107 | 109 |
|
108 | | - this.typeConfiguration = new TypeConfiguration(); |
109 | | - this.beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry ); |
110 | | - this.sqmFunctionRegistry = new SqmFunctionRegistry(); |
| 110 | + typeConfiguration = new TypeConfiguration(); |
| 111 | + beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry ); |
| 112 | + sqmFunctionRegistry = new SqmFunctionRegistry(); |
111 | 113 |
|
112 | | - this.managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class ); |
113 | | - this.configurationService = serviceRegistry.requireService( ConfigurationService.class ); |
| 114 | + managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class ); |
| 115 | + configurationService = serviceRegistry.requireService( ConfigurationService.class ); |
114 | 116 | } |
115 | 117 |
|
116 | 118 | @Override |
@@ -210,24 +212,24 @@ public Object getJandexView() { |
210 | 212 |
|
211 | 213 | @Override |
212 | 214 | public Map<String, SqmFunctionDescriptor> getSqlFunctions() { |
213 | | - return sqlFunctionMap == null ? Collections.emptyMap() : sqlFunctionMap; |
| 215 | + return sqlFunctionMap == null ? emptyMap() : sqlFunctionMap; |
214 | 216 | } |
215 | 217 |
|
216 | 218 | @Override |
217 | 219 | public Collection<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList() { |
218 | | - return auxiliaryDatabaseObjectList == null ? Collections.emptyList() : auxiliaryDatabaseObjectList; |
| 220 | + return auxiliaryDatabaseObjectList == null ? emptyList() : auxiliaryDatabaseObjectList; |
219 | 221 | } |
220 | 222 |
|
221 | 223 | @Override |
222 | 224 | public Collection<ConverterDescriptor> getAttributeConverters() { |
223 | 225 | return attributeConverterDescriptorMap != null |
224 | 226 | ? attributeConverterDescriptorMap.values() |
225 | | - : Collections.emptyList(); |
| 227 | + : emptyList(); |
226 | 228 | } |
227 | 229 |
|
228 | 230 | @Override |
229 | 231 | public Collection<CacheRegionDefinition> getCacheRegionDefinitions() { |
230 | | - return cacheRegionDefinitions == null ? Collections.emptyList() : cacheRegionDefinitions; |
| 232 | + return cacheRegionDefinitions == null ? emptyList() : cacheRegionDefinitions; |
231 | 233 | } |
232 | 234 |
|
233 | 235 | private final Map<String,BasicType<?>> adHocBasicTypeRegistrations = new HashMap<>(); |
@@ -281,12 +283,11 @@ public ManagedTypeRepresentationResolver getRepresentationStrategySelector() { |
281 | 283 | // Mutations |
282 | 284 |
|
283 | 285 | public void addAttributeConverterDescriptor(ConverterDescriptor descriptor) { |
284 | | - if ( this.attributeConverterDescriptorMap == null ) { |
285 | | - this.attributeConverterDescriptorMap = new HashMap<>(); |
| 286 | + if ( attributeConverterDescriptorMap == null ) { |
| 287 | + attributeConverterDescriptorMap = new HashMap<>(); |
286 | 288 | } |
287 | 289 |
|
288 | | - final Object old = this.attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor ); |
289 | | - |
| 290 | + final Object old = attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor ); |
290 | 291 | if ( old != null ) { |
291 | 292 | throw new AssertionFailure( |
292 | 293 | String.format( |
@@ -328,17 +329,17 @@ void injectJandexView(Object jandexView) { |
328 | 329 | } |
329 | 330 |
|
330 | 331 | public void addSqlFunction(String functionName, SqmFunctionDescriptor function) { |
331 | | - if ( this.sqlFunctionMap == null ) { |
332 | | - this.sqlFunctionMap = new HashMap<>(); |
| 332 | + if ( sqlFunctionMap == null ) { |
| 333 | + sqlFunctionMap = new HashMap<>(); |
333 | 334 | } |
334 | | - this.sqlFunctionMap.put( functionName, function ); |
| 335 | + sqlFunctionMap.put( functionName, function ); |
335 | 336 | } |
336 | 337 |
|
337 | 338 | public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) { |
338 | | - if ( this.auxiliaryDatabaseObjectList == null ) { |
339 | | - this.auxiliaryDatabaseObjectList = new ArrayList<>(); |
| 339 | + if ( auxiliaryDatabaseObjectList == null ) { |
| 340 | + auxiliaryDatabaseObjectList = new ArrayList<>(); |
340 | 341 | } |
341 | | - this.auxiliaryDatabaseObjectList.add( auxiliaryDatabaseObject ); |
| 342 | + auxiliaryDatabaseObjectList.add( auxiliaryDatabaseObject ); |
342 | 343 | } |
343 | 344 |
|
344 | 345 |
|
|
0 commit comments