1010import com .fasterxml .jackson .databind .deser .ContextualDeserializer ;
1111import com .fasterxml .jackson .databind .deser .std .StdDeserializer ;
1212import com .fasterxml .jackson .databind .jsontype .TypeDeserializer ;
13+ import javassist .util .proxy .ProxyFactory ;
1314import org .omg .sysml .metamodel .impl .MofObjectImpl ;
1415
1516import javax .persistence .EntityManager ;
@@ -22,7 +23,7 @@ public class MofObjectDeserializer extends StdDeserializer<MofObjectImpl> implem
2223 private EntityManager entityManager ;
2324 private JavaType type ;
2425
25- // private static Map<Class<?>, Class<?>> PROXY_MAP = new HashMap<>();
26+ private static Map <Class <?>, Class <?>> PROXY_MAP = new HashMap <>();
2627
2728 public MofObjectDeserializer (EntityManager entityManager ) {
2829 this (entityManager , null );
@@ -45,14 +46,15 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro
4546 }
4647
4748 MofObjectImpl mof ;
48- /* Class<?> proxyClass = PROXY_MAP.computeIfAbsent(type.getRawClass(), clazz -> {
49+ // Proxy class to handle abstract classes
50+ Class <?> proxyClass = PROXY_MAP .computeIfAbsent (type .getRawClass (), clazz -> {
4951 ProxyFactory factory = new ProxyFactory ();
5052 factory .setSuperclass (clazz );
5153 return factory .createClass ();
52- });*/
54+ });
5355 try {
54- // mof = (MofObjectImpl) proxyClass.getConstructor().newInstance();
55- mof = (MofObjectImpl ) type .getRawClass ().getConstructor ().newInstance ();
56+ mof = (MofObjectImpl ) proxyClass .getConstructor ().newInstance ();
57+ // mof = (MofObjectImpl) type.getRawClass().getConstructor().newInstance();
5658 } catch (ReflectiveOperationException e ) {
5759 throw new IOException (e );
5860 }
0 commit comments