diff options
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java')
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java index b47ba0e27..90543e588 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/ConfigurationToJSONConverter.java @@ -5,6 +5,8 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -12,13 +14,15 @@ import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.ConfigurationProvider; import com.datentechnik.moa.id.conf.persistence.Configuration; -import com.datentechnik.moa.id.conf.persistence.ConfigurationImpl; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; public class ConfigurationToJSONConverter { - AuthConfigurationProvider configProvider; + @Autowired + NewAuthConfigurationProvider configProvider; + + @Autowired Configuration configDataBase; public static void main(String[] args) { @@ -39,11 +43,11 @@ public class ConfigurationToJSONConverter { } public ConfigurationToJSONConverter(String pathToDBConfigPropertiesFile) throws ConfigurationException { - configProvider = AuthConfigurationProvider.getInstance(); System.getProperties().setProperty("location", "file:" + pathToDBConfigPropertiesFile); ApplicationContext context = new ClassPathXmlApplicationContext("configuration.beans.xml"); - configDataBase = (ConfigurationImpl) context.getBean(ConfigurationImpl.class); + AutowireCapableBeanFactory acbFactory = context.getAutowireCapableBeanFactory(); + acbFactory.autowireBean(this); } @@ -51,9 +55,11 @@ public class ConfigurationToJSONConverter { try { // find all getter methods - for (PropertyDescriptor pd : Introspector.getBeanInfo(AuthConfigurationProvider.class).getPropertyDescriptors()) { + for (PropertyDescriptor pd : Introspector.getBeanInfo(NewAuthConfigurationProvider.class).getPropertyDescriptors()) { // check if correct methods, and not annotated with @JsonIgnore - if ((pd.getReadMethod() != null) && (!"class".equals(pd.getName())) && (pd.getReadMethod().getAnnotation(JsonIgnore.class) == null)) { + if ((pd.getReadMethod() != null) + && (!"class".equals(pd.getName())) + && (pd.getReadMethod().getAnnotation(JsonIgnore.class) == null)) { JsonProperty name = pd.getReadMethod().getAnnotation(JsonProperty.class); // get result of get method @@ -86,13 +92,12 @@ public class ConfigurationToJSONConverter { public void readConfigFromDB() { try { // find all getter methods - for (PropertyDescriptor pd : Introspector.getBeanInfo(AuthConfigurationProvider.class) + for (PropertyDescriptor pd : Introspector.getBeanInfo(NewAuthConfigurationProvider.class) .getPropertyDescriptors()) { // check if correct methods, and not annotated with @JsonIgnore if ((pd.getReadMethod() != null) && (!"class".equals(pd.getName())) && (pd.getReadMethod().getAnnotation(JsonIgnore.class) == null)) { - JsonProperty name = pd.getReadMethod().getAnnotation(JsonProperty.class); // get result of get method if (name != null) { @@ -106,7 +111,7 @@ public class ConfigurationToJSONConverter { System.out.println("Problems while using reflection to get all getter methods."); } catch (IntrospectionException e) { System.out.println("Problems while using reflection to get all getter methods."); + } } - } } |