1
14
15 package com.liferay.portal.deploy.hot;
16
17 import com.liferay.portal.apache.bridges.struts.LiferayServletContextProvider;
18 import com.liferay.portal.kernel.configuration.Configuration;
19 import com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil;
20 import com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener;
21 import com.liferay.portal.kernel.deploy.hot.HotDeployEvent;
22 import com.liferay.portal.kernel.deploy.hot.HotDeployException;
23 import com.liferay.portal.kernel.job.Scheduler;
24 import com.liferay.portal.kernel.language.LanguageUtil;
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.poller.PollerProcessor;
28 import com.liferay.portal.kernel.portlet.ConfigurationAction;
29 import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
30 import com.liferay.portal.kernel.portlet.PortletBag;
31 import com.liferay.portal.kernel.portlet.PortletBagPool;
32 import com.liferay.portal.kernel.portlet.PortletLayoutListener;
33 import com.liferay.portal.kernel.search.Indexer;
34 import com.liferay.portal.kernel.search.OpenSearch;
35 import com.liferay.portal.kernel.servlet.PortletServlet;
36 import com.liferay.portal.kernel.servlet.ServletContextProvider;
37 import com.liferay.portal.kernel.servlet.URLEncoder;
38 import com.liferay.portal.kernel.util.ClassUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.HttpUtil;
41 import com.liferay.portal.kernel.util.LocaleUtil;
42 import com.liferay.portal.kernel.util.ObjectValuePair;
43 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
44 import com.liferay.portal.kernel.util.StringUtil;
45 import com.liferay.portal.kernel.util.Validator;
46 import com.liferay.portal.lar.PortletDataHandler;
47 import com.liferay.portal.model.Portlet;
48 import com.liferay.portal.model.PortletApp;
49 import com.liferay.portal.model.PortletCategory;
50 import com.liferay.portal.model.PortletFilter;
51 import com.liferay.portal.model.PortletURLListener;
52 import com.liferay.portal.poller.PollerProcessorUtil;
53 import com.liferay.portal.pop.POPServerUtil;
54 import com.liferay.portal.security.permission.ResourceActionsUtil;
55 import com.liferay.portal.service.PortletLocalServiceUtil;
56 import com.liferay.portal.service.ResourceActionLocalServiceUtil;
57 import com.liferay.portal.service.ResourceCodeLocalServiceUtil;
58 import com.liferay.portal.util.Portal;
59 import com.liferay.portal.util.PortalInstances;
60 import com.liferay.portal.util.PortalUtil;
61 import com.liferay.portal.util.PropsValues;
62 import com.liferay.portal.util.WebAppPool;
63 import com.liferay.portal.util.WebKeys;
64 import com.liferay.portal.velocity.VelocityContextPool;
65 import com.liferay.portlet.CustomUserAttributes;
66 import com.liferay.portlet.PortletBagImpl;
67 import com.liferay.portlet.PortletConfigFactory;
68 import com.liferay.portlet.PortletContextBag;
69 import com.liferay.portlet.PortletContextBagPool;
70 import com.liferay.portlet.PortletFilterFactory;
71 import com.liferay.portlet.PortletInstanceFactory;
72 import com.liferay.portlet.PortletPreferencesSerializer;
73 import com.liferay.portlet.PortletResourceBundles;
74 import com.liferay.portlet.PortletURLListenerFactory;
75 import com.liferay.portlet.social.model.SocialActivityInterpreter;
76 import com.liferay.portlet.social.model.SocialRequestInterpreter;
77 import com.liferay.portlet.social.model.impl.SocialActivityInterpreterImpl;
78 import com.liferay.portlet.social.model.impl.SocialRequestInterpreterImpl;
79 import com.liferay.portlet.social.service.SocialActivityInterpreterLocalServiceUtil;
80 import com.liferay.portlet.social.service.SocialRequestInterpreterLocalServiceUtil;
81
82 import java.util.HashMap;
83 import java.util.HashSet;
84 import java.util.Iterator;
85 import java.util.List;
86 import java.util.Locale;
87 import java.util.Map;
88 import java.util.MissingResourceException;
89 import java.util.Properties;
90 import java.util.ResourceBundle;
91 import java.util.Set;
92
93 import javax.portlet.PortletConfig;
94 import javax.portlet.PortletContext;
95 import javax.portlet.PortletURLGenerationListener;
96 import javax.portlet.PreferencesValidator;
97
98 import javax.servlet.ServletContext;
99
100 import org.apache.portals.bridges.struts.StrutsPortlet;
101
102
109 public class PortletHotDeployListener extends BaseHotDeployListener {
110
111 public void invokeDeploy(HotDeployEvent event) throws HotDeployException {
112 try {
113 doInvokeDeploy(event);
114 }
115 catch (Throwable t) {
116 throwHotDeployException(
117 event, "Error registering portlets for ", t);
118 }
119 }
120
121 public void invokeUndeploy(HotDeployEvent event) throws HotDeployException {
122 try {
123 doInvokeUndeploy(event);
124 }
125 catch (Throwable t) {
126 throwHotDeployException(
127 event, "Error unregistering portlets for ", t);
128 }
129 }
130
131 protected void destroyPortlet(Portlet portlet, Set<String> portletIds)
132 throws Exception {
133
134 PortletApp portletApp = portlet.getPortletApp();
135
136 Set<PortletFilter> portletFilters = portletApp.getPortletFilters();
137
138 for (PortletFilter portletFilter : portletFilters) {
139 PortletFilterFactory.destroy(portletFilter);
140 }
141
142 Set<PortletURLListener> portletURLListeners =
143 portletApp.getPortletURLListeners();
144
145 for (PortletURLListener portletURLListener : portletURLListeners) {
146 PortletURLListenerFactory.destroy(portletURLListener);
147 }
148
149 Scheduler scheduler = portlet.getSchedulerInstance();
150
151 if (scheduler != null) {
152 scheduler.unschedule();
153 }
154
155 PollerProcessorUtil.deletePollerProcessor(portlet.getPortletId());
156
157 POPServerUtil.deleteListener(portlet.getPopMessageListenerInstance());
158
159 SocialActivityInterpreterLocalServiceUtil.deleteActivityInterpreter(
160 portlet.getSocialActivityInterpreterInstance());
161
162 SocialRequestInterpreterLocalServiceUtil.deleteRequestInterpreter(
163 portlet.getSocialRequestInterpreterInstance());
164
165 PortletInstanceFactory.destroy(portlet);
166
167 portletIds.add(portlet.getPortletId());
168 }
169
170 protected void doInvokeDeploy(HotDeployEvent event) throws Exception {
171
172
174 ServletContext servletContext = event.getServletContext();
175
176 String servletContextName = servletContext.getServletContextName();
177
178 if (_log.isDebugEnabled()) {
179 _log.debug("Invoking deploy for " + servletContextName);
180 }
181
182
184 long[] companyIds = PortalInstances.getCompanyIds();
185
186
188 String[] xmls = new String[] {
189 HttpUtil.URLtoString(servletContext.getResource(
190 "/WEB-INF/" + Portal.PORTLET_XML_FILE_NAME_STANDARD)),
191 HttpUtil.URLtoString(servletContext.getResource(
192 "/WEB-INF/" + Portal.PORTLET_XML_FILE_NAME_CUSTOM)),
193 HttpUtil.URLtoString(servletContext.getResource(
194 "/WEB-INF/liferay-portlet.xml")),
195 HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/web.xml"))
196 };
197
198 if (xmls[0] == null) {
199 return;
200 }
201
202 if (_log.isInfoEnabled()) {
203 _log.info("Registering portlets for " + servletContextName);
204 }
205
206 List<Portlet> portlets = PortletLocalServiceUtil.initWAR(
207 servletContextName, servletContext, xmls, event.getPluginPackage());
208
209
211 ClassLoader portletClassLoader = event.getContextClassLoader();
212
213 servletContext.setAttribute(
214 PortletServlet.PORTLET_CLASS_LOADER, portletClassLoader);
215
216
218 _portletAppInitialized = false;
219 _strutsBridges = false;
220
221 Iterator<Portlet> itr = portlets.iterator();
222
223 while (itr.hasNext()) {
224 Portlet portlet = itr.next();
225
226 initPortlet(portlet, servletContext, portletClassLoader, itr);
227 }
228
229
231 if (!_strutsBridges) {
232 _strutsBridges = GetterUtil.getBoolean(
233 servletContext.getInitParameter(
234 "struts-bridges-context-provider"));
235 }
236
237 if (_strutsBridges) {
238 servletContext.setAttribute(
239 ServletContextProvider.STRUTS_BRIDGES_CONTEXT_PROVIDER,
240 new LiferayServletContextProvider());
241 }
242
243
245 String xml = HttpUtil.URLtoString(servletContext.getResource(
246 "/WEB-INF/liferay-display.xml"));
247
248 PortletCategory newPortletCategory =
249 PortletLocalServiceUtil.getWARDisplay(servletContextName, xml);
250
251 for (int i = 0; i < companyIds.length; i++) {
252 long companyId = companyIds[i];
253
254 PortletCategory portletCategory =
255 (PortletCategory)WebAppPool.get(
256 String.valueOf(companyId), WebKeys.PORTLET_CATEGORY);
257
258 if (portletCategory != null) {
259 portletCategory.merge(newPortletCategory);
260 }
261 else {
262 _log.error(
263 "Unable to register portlet for company " + companyId +
264 " because it does not exist");
265 }
266 }
267
268
270 processPortletProperties(servletContextName, portletClassLoader);
271
272
274 itr = portlets.iterator();
275
276 while (itr.hasNext()) {
277 Portlet portlet = itr.next();
278
279 List<String> modelNames =
280 ResourceActionsUtil.getPortletModelResources(
281 portlet.getPortletId());
282
283 for (long companyId : companyIds) {
284 ResourceCodeLocalServiceUtil.checkResourceCodes(
285 companyId, portlet.getPortletId());
286
287 for (String modelName : modelNames) {
288 ResourceCodeLocalServiceUtil.checkResourceCodes(
289 companyId, modelName);
290 }
291 }
292
293 List<String> portletActions =
294 ResourceActionsUtil.getPortletResourceActions(
295 portlet.getPortletId());
296
297 ResourceActionLocalServiceUtil.checkResourceActions(
298 portlet.getPortletId(), portletActions);
299
300 for (String modelName : modelNames) {
301 List<String> modelActions =
302 ResourceActionsUtil.getModelResourceActions(modelName);
303
304 ResourceActionLocalServiceUtil.checkResourceActions(
305 modelName, modelActions);
306 }
307 }
308
309
311 registerClpMessageListeners(servletContext, portletClassLoader);
312
313
315 _vars.put(
316 servletContextName,
317 new ObjectValuePair<long[], List<Portlet>>(
318 companyIds, portlets));
319
320 if (_log.isInfoEnabled()) {
321 if (portlets.size() == 1) {
322 _log.info(
323 "1 portlet for " + servletContextName +
324 " is available for use");
325 }
326 else {
327 _log.info(
328 portlets.size() + " portlets for " + servletContextName +
329 " are available for use");
330 }
331 }
332 }
333
334 protected void doInvokeUndeploy(HotDeployEvent event) throws Exception {
335 ServletContext servletContext = event.getServletContext();
336
337 String servletContextName = servletContext.getServletContextName();
338
339 if (_log.isDebugEnabled()) {
340 _log.debug("Invoking undeploy for " + servletContextName);
341 }
342
343 ObjectValuePair<long[], List<Portlet>> ovp =
344 _vars.remove(servletContextName);
345
346 if (ovp == null) {
347 return;
348 }
349
350 long[] companyIds = ovp.getKey();
351 List<Portlet> portlets = ovp.getValue();
352
353 Set<String> portletIds = new HashSet<String>();
354
355 if (portlets != null) {
356 if (_log.isInfoEnabled()) {
357 _log.info(
358 "Unregistering portlets for " + servletContextName);
359 }
360
361 Iterator<Portlet> itr = portlets.iterator();
362
363 while (itr.hasNext()) {
364 Portlet portlet = itr.next();
365
366 destroyPortlet(portlet, portletIds);
367 }
368 }
369
370 if (portletIds.size() > 0) {
371 for (int i = 0; i < companyIds.length; i++) {
372 long companyId = companyIds[i];
373
374 PortletCategory portletCategory =
375 (PortletCategory)WebAppPool.get(
376 String.valueOf(companyId), WebKeys.PORTLET_CATEGORY);
377
378 portletCategory.separate(portletIds);
379 }
380 }
381
382 PortletResourceBundles.remove(servletContextName);
383
384 unregisterClpMessageListeners(servletContext);
385
386 if (_log.isInfoEnabled()) {
387 if (portlets.size() == 1) {
388 _log.info(
389 "1 portlet for " + servletContextName +
390 " was unregistered");
391 }
392 else {
393 _log.info(
394 portlets.size() + " portlets for " + servletContextName +
395 " was unregistered");
396 }
397 }
398 }
399
400 protected void initPortlet(
401 Portlet portlet, ServletContext servletContext,
402 ClassLoader portletClassLoader, Iterator<Portlet> portletsItr)
403 throws Exception {
404
405 String servletContextName = servletContext.getServletContextName();
406
407 PortletApp portletApp = portlet.getPortletApp();
408
409 if (!portletApp.isWARFile()) {
410 String contextPath = PortalUtil.getPathContext();
411
412 servletContext = VelocityContextPool.get(contextPath);
413
414 portletClassLoader = PortalClassLoaderUtil.getClassLoader();
415 }
416
417 Class<?> portletClass = null;
418
419 try {
420 portletClass = portletClassLoader.loadClass(
421 portlet.getPortletClass());
422 }
423 catch (Throwable e) {
424 _log.error(e, e);
425
426 portletsItr.remove();
427
428 PortletLocalServiceUtil.destroyPortlet(portlet);
429
430 return;
431 }
432
433 javax.portlet.Portlet portletInstance =
434 (javax.portlet.Portlet)portletClass.newInstance();
435
436 if (ClassUtil.isSubclass(portletClass, StrutsPortlet.class.getName())) {
437 _strutsBridges = true;
438 }
439
440 ConfigurationAction configurationActionInstance = null;
441
442 if (Validator.isNotNull(portlet.getConfigurationActionClass())) {
443 configurationActionInstance = (ConfigurationAction)newInstance(
444 portletClassLoader, ConfigurationAction.class,
445 portlet.getConfigurationActionClass());
446 }
447
448 Indexer indexerInstance = null;
449
450 if (Validator.isNotNull(portlet.getIndexerClass())) {
451 indexerInstance = (Indexer)newInstance(
452 portletClassLoader, Indexer.class, portlet.getIndexerClass());
453 }
454
455 OpenSearch openSearchInstance = null;
456
457 if (Validator.isNotNull(portlet.getOpenSearchClass())) {
458 openSearchInstance = (OpenSearch)newInstance(
459 portletClassLoader, OpenSearch.class,
460 portlet.getOpenSearchClass());
461 }
462
463 Scheduler schedulerInstance = null;
464
465 if (PropsValues.SCHEDULER_ENABLED &&
466 Validator.isNotNull(portlet.getSchedulerClass())) {
467
468 schedulerInstance = (Scheduler)newInstance(
469 portletClassLoader, Scheduler.class,
470 portlet.getSchedulerClass());
471
472 schedulerInstance.schedule();
473 }
474
475 FriendlyURLMapper friendlyURLMapperInstance = null;
476
477 if (Validator.isNotNull(portlet.getFriendlyURLMapperClass())) {
478 friendlyURLMapperInstance = (FriendlyURLMapper)newInstance(
479 portletClassLoader, FriendlyURLMapper.class,
480 portlet.getFriendlyURLMapperClass());
481 }
482
483 URLEncoder urlEncoderInstance = null;
484
485 if (Validator.isNotNull(portlet.getURLEncoderClass())) {
486 urlEncoderInstance = (URLEncoder)newInstance(
487 portletClassLoader, URLEncoder.class,
488 portlet.getURLEncoderClass());
489 }
490
491 PortletDataHandler portletDataHandlerInstance = null;
492
493 if (Validator.isNotNull(portlet.getPortletDataHandlerClass())) {
494 portletDataHandlerInstance = (PortletDataHandler)newInstance(
495 portletClassLoader, PortletDataHandler.class,
496 portlet.getPortletDataHandlerClass());
497 }
498
499 PortletLayoutListener portletLayoutListenerInstance = null;
500
501 if (Validator.isNotNull(portlet.getPortletLayoutListenerClass())) {
502 portletLayoutListenerInstance = (PortletLayoutListener)newInstance(
503 portletClassLoader, PortletLayoutListener.class,
504 portlet.getPortletLayoutListenerClass());
505 }
506
507 PollerProcessor pollerProcessorInstance = null;
508
509 if (Validator.isNotNull(portlet.getPollerProcessorClass())) {
510 pollerProcessorInstance = (PollerProcessor)newInstance(
511 portletClassLoader, PollerProcessor.class,
512 portlet.getPollerProcessorClass());
513
514 PollerProcessorUtil.addPollerProcessor(
515 portlet.getPortletId(), pollerProcessorInstance);
516 }
517
518 com.liferay.portal.kernel.pop.MessageListener
519 popMessageListenerInstance = null;
520
521 if (Validator.isNotNull(portlet.getPopMessageListenerClass())) {
522 popMessageListenerInstance =
523 (com.liferay.portal.kernel.pop.MessageListener)newInstance(
524 portletClassLoader,
525 com.liferay.portal.kernel.pop.MessageListener.class,
526 portlet.getPopMessageListenerClass());
527
528 POPServerUtil.addListener(popMessageListenerInstance);
529 }
530
531 SocialActivityInterpreter socialActivityInterpreterInstance = null;
532
533 if (Validator.isNotNull(portlet.getSocialActivityInterpreterClass())) {
534 socialActivityInterpreterInstance =
535 (SocialActivityInterpreter)newInstance(
536 portletClassLoader, SocialActivityInterpreter.class,
537 portlet.getSocialActivityInterpreterClass());
538
539 socialActivityInterpreterInstance =
540 new SocialActivityInterpreterImpl(
541 portlet.getPortletId(), socialActivityInterpreterInstance);
542
543 SocialActivityInterpreterLocalServiceUtil.addActivityInterpreter(
544 socialActivityInterpreterInstance);
545 }
546
547 SocialRequestInterpreter socialRequestInterpreterInstance = null;
548
549 if (Validator.isNotNull(portlet.getSocialRequestInterpreterClass())) {
550 socialRequestInterpreterInstance =
551 (SocialRequestInterpreter)newInstance(
552 portletClassLoader, SocialRequestInterpreter.class,
553 portlet.getSocialRequestInterpreterClass());
554
555 socialRequestInterpreterInstance = new SocialRequestInterpreterImpl(
556 portlet.getPortletId(), socialRequestInterpreterInstance);
557
558 SocialRequestInterpreterLocalServiceUtil.addRequestInterpreter(
559 socialRequestInterpreterInstance);
560 }
561
562 PreferencesValidator preferencesValidatorInstance = null;
563
564 if (Validator.isNotNull(portlet.getPreferencesValidator())) {
565 preferencesValidatorInstance = (PreferencesValidator)newInstance(
566 portletClassLoader, PreferencesValidator.class,
567 portlet.getPreferencesValidator());
568
569 try {
570 if (PropsValues.PREFERENCE_VALIDATE_ON_STARTUP) {
571 preferencesValidatorInstance.validate(
572 PortletPreferencesSerializer.fromDefaultXML(
573 portlet.getDefaultPreferences()));
574 }
575 }
576 catch (Exception e) {
577 _log.warn(
578 "Portlet with the name " + portlet.getPortletId() +
579 " does not have valid default preferences");
580 }
581 }
582
583 Map<String, ResourceBundle> resourceBundles = null;
584
585 if (Validator.isNotNull(portlet.getResourceBundle())) {
586 resourceBundles = new HashMap<String, ResourceBundle>();
587
588 initResourceBundle(
589 resourceBundles, portlet, portletClassLoader,
590 LocaleUtil.getDefault());
591
592 Iterator<String> supportLocalesItr =
593 portlet.getSupportedLocales().iterator();
594
595 while (supportLocalesItr.hasNext()) {
596 String supportedLocale = supportLocalesItr.next();
597
598 Locale locale = LocaleUtil.fromLanguageId(supportedLocale);
599
600 initResourceBundle(
601 resourceBundles, portlet, portletClassLoader, locale);
602 }
603 }
604
605 PortletBag portletBag = new PortletBagImpl(
606 portlet.getPortletId(), servletContext, portletInstance,
607 configurationActionInstance, indexerInstance, openSearchInstance,
608 schedulerInstance, friendlyURLMapperInstance, urlEncoderInstance,
609 portletDataHandlerInstance, portletLayoutListenerInstance,
610 pollerProcessorInstance, popMessageListenerInstance,
611 socialActivityInterpreterInstance, socialRequestInterpreterInstance,
612 preferencesValidatorInstance, resourceBundles);
613
614 PortletBagPool.put(portlet.getPortletId(), portletBag);
615
616 if (!_portletAppInitialized) {
617 initPortletApp(
618 portlet, servletContextName, servletContext,
619 portletClassLoader);
620
621 _portletAppInitialized = true;
622 }
623
624 try {
625 PortletInstanceFactory.create(portlet, servletContext);
626 }
627 catch (Exception e) {
628 _log.error(e, e);
629 }
630 }
631
632 protected void initPortletApp(
633 Portlet portlet, String servletContextName,
634 ServletContext servletContext, ClassLoader portletClassLoader)
635 throws Exception {
636
637 PortletConfig portletConfig = PortletConfigFactory.create(
638 portlet, servletContext);
639
640 PortletContext portletContext = portletConfig.getPortletContext();
641
642 PortletContextBag portletContextBag = new PortletContextBag(
643 servletContextName);
644
645 PortletContextBagPool.put(servletContextName, portletContextBag);
646
647 PortletApp portletApp = portlet.getPortletApp();
648
649 Map<String, String> customUserAttributes =
650 portletApp.getCustomUserAttributes();
651
652 for (Map.Entry<String, String> entry :
653 customUserAttributes.entrySet()) {
654
655 String attrCustomClass = entry.getValue();
656
657 CustomUserAttributes customUserAttributesInstance =
658 (CustomUserAttributes)portletClassLoader.loadClass(
659 attrCustomClass).newInstance();
660
661 portletContextBag.getCustomUserAttributes().put(
662 attrCustomClass, customUserAttributesInstance);
663 }
664
665 Set<PortletFilter> portletFilters = portletApp.getPortletFilters();
666
667 for (PortletFilter portletFilter : portletFilters) {
668 javax.portlet.filter.PortletFilter portletFilterInstance =
669 (javax.portlet.filter.PortletFilter)newInstance(
670 portletClassLoader,
671 new Class<?>[] {
672 javax.portlet.filter.ActionFilter.class,
673 javax.portlet.filter.EventFilter.class,
674 javax.portlet.filter.PortletFilter.class,
675 javax.portlet.filter.RenderFilter.class,
676 javax.portlet.filter.ResourceFilter.class
677 },
678 portletFilter.getFilterClass());
679
680 portletContextBag.getPortletFilters().put(
681 portletFilter.getFilterName(), portletFilterInstance);
682
683 PortletFilterFactory.create(portletFilter, portletContext);
684 }
685
686 Set<PortletURLListener> portletURLListeners =
687 portletApp.getPortletURLListeners();
688
689 for (PortletURLListener portletURLListener : portletURLListeners) {
690 PortletURLGenerationListener portletURLListenerInstance =
691 (PortletURLGenerationListener)newInstance(
692 portletClassLoader, PortletURLGenerationListener.class,
693 portletURLListener.getListenerClass());
694
695 portletContextBag.getPortletURLListeners().put(
696 portletURLListener.getListenerClass(),
697 portletURLListenerInstance);
698
699 PortletURLListenerFactory.create(portletURLListener);
700 }
701 }
702
703 protected void initResourceBundle(
704 Map<String, ResourceBundle> resourceBundles, Portlet portlet,
705 ClassLoader portletClassLoader, Locale locale) {
706
707 try {
708 ResourceBundle resourceBundle = ResourceBundle.getBundle(
709 portlet.getResourceBundle(), locale, portletClassLoader);
710
711 resourceBundles.put(
712 LocaleUtil.toLanguageId(locale), resourceBundle);
713 }
714 catch (MissingResourceException mre) {
715 _log.warn(mre.getMessage());
716 }
717 }
718
719 protected void processPortletProperties(
720 String servletContextName, ClassLoader portletClassLoader)
721 throws Exception {
722
723 Configuration portletPropertiesConfiguration = null;
724
725 try {
726 portletPropertiesConfiguration =
727 ConfigurationFactoryUtil.getConfiguration(
728 portletClassLoader, "portlet");
729 }
730 catch (Exception e) {
731 if (_log.isDebugEnabled()) {
732 _log.debug("Unable to read portlet.properties");
733 }
734
735 return;
736 }
737
738 Properties portletProperties =
739 portletPropertiesConfiguration.getProperties();
740
741 if (portletProperties.size() == 0) {
742 return;
743 }
744
745 String languageBundleName = portletProperties.getProperty(
746 "language.bundle");
747
748 if (Validator.isNotNull(languageBundleName)) {
749 Locale[] locales = LanguageUtil.getAvailableLocales();
750
751 for (int i = 0; i < locales.length; i++) {
752 ResourceBundle bundle = ResourceBundle.getBundle(
753 languageBundleName, locales[i], portletClassLoader);
754
755 PortletResourceBundles.put(
756 servletContextName, LocaleUtil.toLanguageId(locales[i]),
757 bundle);
758 }
759 }
760
761 String[] resourceActionConfigs = StringUtil.split(
762 portletProperties.getProperty("resource.actions.configs"));
763
764 for (int i = 0; i < resourceActionConfigs.length; i++) {
765 ResourceActionsUtil.read(
766 servletContextName, portletClassLoader,
767 resourceActionConfigs[i]);
768 }
769 }
770
771 private static Log _log = LogFactoryUtil.getLog(
772 PortletHotDeployListener.class);
773
774 private static Map<String, ObjectValuePair<long[], List<Portlet>>> _vars =
775 new HashMap<String, ObjectValuePair<long[], List<Portlet>>>();
776
777 private boolean _portletAppInitialized;
778 private boolean _strutsBridges;
779
780 }