1
14
15 package com.liferay.portal.kernel.util;
16
17 import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
18
19
33 public class SimplePojoClp<T> {
34
35 public SimplePojoClp(
36 Class<? extends T> localImplementationClass,
37 ClassLoader remoteClassLoader)
38 throws ClassNotFoundException {
39
40 this(
41 localImplementationClass, remoteClassLoader,
42 localImplementationClass.getName());
43 }
44
45 public SimplePojoClp(
46 Class<? extends T> localImplementationClass,
47 ClassLoader remoteClassLoader, String remoteImplementationClassName)
48 throws ClassNotFoundException {
49
50 _localImplementationClass = localImplementationClass;
51 _remoteClassLoader = remoteClassLoader;
52 _remoteImplementationClass = _remoteClassLoader.loadClass(
53 remoteImplementationClassName);
54 }
55
56 public T createLocalObject(Object remoteInstance)
57 throws IllegalAccessException, InstantiationException {
58
59 T localInstance = _localImplementationClass.newInstance();
60
61 BeanPropertiesUtil.copyProperties(
62 remoteInstance, localInstance, _localImplementationClass);
63
64 return localInstance;
65 }
66
67 public Object createRemoteObject(T localInstance)
68 throws IllegalAccessException, InstantiationException {
69
70 Object remoteInstance = _remoteImplementationClass.newInstance();
71
72 BeanPropertiesUtil.copyProperties(
73 localInstance, remoteInstance, _remoteImplementationClass);
74
75 return remoteInstance;
76 }
77
78 private Class<? extends T> _localImplementationClass;
79 private ClassLoader _remoteClassLoader;
80 private Class<?> _remoteImplementationClass;
81
82 }