protected StoreConfiguration buildStoreConfiguration(StoreConfigurationType storeConfigType) { String className = storeConfigType.getClassName(); if (className == null) { throw new SecurityConfigurationException("Classname of all storeConfigurationTypes must be provided!"); } StoreConfiguration storeConfig = (StoreConfiguration)instantiateComponent(className); Class<?> storeConfigClass = storeConfig.getClass(); Map<String, Object> props = storeConfigType.getAllProperties(); for (String propertyName : props.keySet()) { // It's not optimal as we need to query and iterate methods separately for each property. // But performance shouldn't be big deal during reading configuration as it usually needs to be read only once... PropertyQuery<Object> propertyQuery = PropertyQueries.createQuery(storeConfigClass); propertyQuery.addCriteria(new NamedPropertyCriteria(propertyName)); Property<Object> property = propertyQuery.getWritableSingleResult(); // Obtain value from XML configuration Object propertyValueFromConfig = props.get(propertyName); // Create real instance of property from XML configuration Object propertyValue = PropertyResolverMapper.getInstance().resolveProperty(propertyValueFromConfig, property.getJavaClass()); // Set property to current storeConfiguration property.setValue(storeConfig, propertyValue); } return storeConfig; }
@SuppressWarnings("unchecked") @Override protected V resolvePropertyFromObjectType(ObjectType objectType) { // TODO: this code is almost the same like XMLBasedIdentityManagerProvider.buildStoreConfiguration String className = objectType.getClassName(); if (className == null) { throw new SecurityConfigurationException("ClassName must be always configured for all 'Object' types from configuration"); } V object = (V) XMLBasedIdentityManagerProvider.instantiateComponent(className); Class<?> objectClass = object.getClass(); Map<String, Object> props = objectType.getAllProperties(); for (String propertyName : props.keySet()) { // It's not optimal as we need to query and iterate methods separately for each property. // But performance shouldn't be big deal during reading configuration as it usually needs to be read only once... PropertyQuery<Object> propertyQuery = PropertyQueries.createQuery(objectClass); propertyQuery.addCriteria(new NamedPropertyCriteria(propertyName)); Property<Object> property = propertyQuery.getWritableSingleResult(); // Obtain value from XML configuration Object propertyValueFromConfig = props.get(propertyName); // Create real instance of property from XML configuration Object propertyValue = PropertyResolverMapper.getInstance().resolveProperty(propertyValueFromConfig, property.getJavaClass()); // Set property to current storeConfiguration property.setValue(object, propertyValue); } return object; }