1
22
23 package com.liferay.portal.lar;
24
25 import javax.portlet.PortletPreferences;
26
27
34 public class InvokerPortletDataHandler implements PortletDataHandler {
35
36 public InvokerPortletDataHandler(
37 PortletDataHandler portletDataHandler, ClassLoader classLoader) {
38
39 _portletDataHandler = portletDataHandler;
40 _classLoader = classLoader;
41 }
42
43 public PortletPreferences deleteData(
44 PortletDataContext context, String portletId,
45 PortletPreferences preferences)
46 throws PortletDataException {
47
48 Thread currentThread = Thread.currentThread();
49
50 ClassLoader threadClassLoader = currentThread.getContextClassLoader();
51 ClassLoader contextClassLoader = context.getClassLoader();
52
53 try {
54 currentThread.setContextClassLoader(_classLoader);
55 context.setClassLoader(_classLoader);
56
57 return _portletDataHandler.deleteData(
58 context, portletId, preferences);
59 }
60 finally {
61 currentThread.setContextClassLoader(threadClassLoader);
62 context.setClassLoader(contextClassLoader);
63 }
64 }
65
66 public String exportData(
67 PortletDataContext context, String portletId,
68 PortletPreferences preferences)
69 throws PortletDataException {
70
71 Thread currentThread = Thread.currentThread();
72
73 ClassLoader threadClassLoader = currentThread.getContextClassLoader();
74 ClassLoader contextClassLoader = context.getClassLoader();
75
76 try {
77 currentThread.setContextClassLoader(_classLoader);
78 context.setClassLoader(_classLoader);
79
80 return _portletDataHandler.exportData(
81 context, portletId, preferences);
82 }
83 finally {
84 currentThread.setContextClassLoader(threadClassLoader);
85 context.setClassLoader(contextClassLoader);
86 }
87 }
88
89 public PortletDataHandlerControl[] getExportControls()
90 throws PortletDataException {
91
92 Thread currentThread = Thread.currentThread();
93
94 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
95
96 try {
97 currentThread.setContextClassLoader(_classLoader);
98
99 return _portletDataHandler.getExportControls();
100 }
101 finally {
102 currentThread.setContextClassLoader(contextClassLoader);
103 }
104 }
105
106 public PortletDataHandlerControl[] getImportControls()
107 throws PortletDataException {
108
109 Thread currentThread = Thread.currentThread();
110
111 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
112
113 try {
114 currentThread.setContextClassLoader(_classLoader);
115
116 return _portletDataHandler.getImportControls();
117 }
118 finally {
119 currentThread.setContextClassLoader(contextClassLoader);
120 }
121 }
122
123 public PortletPreferences importData(
124 PortletDataContext context, String portletId,
125 PortletPreferences preferences, String data)
126 throws PortletDataException {
127
128 Thread currentThread = Thread.currentThread();
129
130 ClassLoader threadClassLoader = currentThread.getContextClassLoader();
131 ClassLoader contextClassLoader = context.getClassLoader();
132
133 try {
134 currentThread.setContextClassLoader(_classLoader);
135 context.setClassLoader(_classLoader);
136
137 return _portletDataHandler.importData(
138 context, portletId, preferences, data);
139 }
140 finally {
141 currentThread.setContextClassLoader(threadClassLoader);
142 context.setClassLoader(contextClassLoader);
143 }
144 }
145
146 public boolean isAlwaysExportable() {
147 Thread currentThread = Thread.currentThread();
148
149 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
150
151 try {
152 currentThread.setContextClassLoader(_classLoader);
153
154 return _portletDataHandler.isAlwaysExportable();
155 }
156 finally {
157 currentThread.setContextClassLoader(contextClassLoader);
158 }
159 }
160
161 public boolean isPublishToLiveByDefault() {
162 Thread currentThread = Thread.currentThread();
163
164 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
165
166 try {
167 currentThread.setContextClassLoader(_classLoader);
168
169 return _portletDataHandler.isPublishToLiveByDefault();
170 }
171 finally {
172 currentThread.setContextClassLoader(contextClassLoader);
173 }
174 }
175
176 private PortletDataHandler _portletDataHandler;
177 private ClassLoader _classLoader;
178
179 }