001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
018
019
031 public class SimplePojoClp<T> {
032
033 public SimplePojoClp(
034 Class<? extends T> localImplementationClass,
035 ClassLoader remoteClassLoader)
036 throws ClassNotFoundException {
037
038 this(
039 localImplementationClass, remoteClassLoader,
040 localImplementationClass.getName());
041 }
042
043 public SimplePojoClp(
044 Class<? extends T> localImplementationClass,
045 ClassLoader remoteClassLoader, String remoteImplementationClassName)
046 throws ClassNotFoundException {
047
048 _localImplementationClass = localImplementationClass;
049 _remoteClassLoader = remoteClassLoader;
050 _remoteImplementationClass = _remoteClassLoader.loadClass(
051 remoteImplementationClassName);
052 }
053
054 public T createLocalObject(Object remoteInstance)
055 throws IllegalAccessException, InstantiationException {
056
057 T localInstance = _localImplementationClass.newInstance();
058
059 BeanPropertiesUtil.copyProperties(
060 remoteInstance, localInstance, _localImplementationClass);
061
062 return localInstance;
063 }
064
065 public Object createRemoteObject(T localInstance)
066 throws IllegalAccessException, InstantiationException {
067
068 Object remoteInstance = _remoteImplementationClass.newInstance();
069
070 BeanPropertiesUtil.copyProperties(
071 localInstance, remoteInstance, _remoteImplementationClass);
072
073 return remoteInstance;
074 }
075
076 private Class<? extends T> _localImplementationClass;
077 private ClassLoader _remoteClassLoader;
078 private Class<?> _remoteImplementationClass;
079
080 }