diff --git a/src/main/java/info/bukova/isspst/services/StringXmlMarshaller.java b/src/main/java/info/bukova/isspst/services/StringXmlMarshaller.java index 38480d3c..fc447195 100644 --- a/src/main/java/info/bukova/isspst/services/StringXmlMarshaller.java +++ b/src/main/java/info/bukova/isspst/services/StringXmlMarshaller.java @@ -1,7 +1,5 @@ package info.bukova.isspst.services; -import info.bukova.isspst.services.settings.GlobalSettingsService; - import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; @@ -12,20 +10,21 @@ import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.GenericTypeResolver; public class StringXmlMarshaller { - private final static Logger log = LoggerFactory.getLogger(GlobalSettingsService.class); + private final static Logger log = LoggerFactory.getLogger(StringXmlMarshaller.class); private final static String MARSHAL_ERROR = "Cannot marshal settings data: "; private final static String UNMARSHAL_ERROR = "Cannot unmarshal settings data: "; private Marshaller marshaller; private Unmarshaller unmarshaller; + private Class dataClass; - public StringXmlMarshaller(Marshaller marshaller, Unmarshaller unmarshaller) { + public StringXmlMarshaller(Marshaller marshaller, Unmarshaller unmarshaller, Class dataClass) { this.marshaller = marshaller; this.unmarshaller = unmarshaller; + this.dataClass = dataClass; } public String marshalData(T data) { @@ -57,7 +56,7 @@ public class StringXmlMarshaller { StringReader sr = new StringReader(data); try { - unmarshaller.setClass(GenericTypeResolver.resolveTypeArgument(getClass(), StringXmlMarshaller.class)); + unmarshaller.setClass(dataClass); return (T) unmarshaller.unmarshal(sr); } catch (MarshalException e) { log.error(UNMARSHAL_ERROR + e.getMessage()); diff --git a/src/main/java/info/bukova/isspst/services/settings/GlobalSettingServiceImpl.java b/src/main/java/info/bukova/isspst/services/settings/GlobalSettingServiceImpl.java index 6827ccbe..70fea14f 100644 --- a/src/main/java/info/bukova/isspst/services/settings/GlobalSettingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/settings/GlobalSettingServiceImpl.java @@ -19,7 +19,7 @@ public class GlobalSettingServiceImpl extends AbstractOwnedService(marshaller, unmarshaller); + this.marshaller = new StringXmlMarshaller(marshaller, unmarshaller, SettingsData.class); } @Override diff --git a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java index 9dc2c205..e35dc814 100644 --- a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java @@ -35,7 +35,7 @@ public class UserServiceImpl extends AbstractService implements UserServic private StringXmlMarshaller marshaller; public UserServiceImpl(Marshaller marshaller, Unmarshaller unmarshaller) { - this.marshaller = new StringXmlMarshaller(marshaller, unmarshaller); + this.marshaller = new StringXmlMarshaller(marshaller, unmarshaller, UserSettingsData.class); } public void setEncoder(PasswordEncoder encoder) {