ManagedObject managedObject = ((ManagedObjectAddedEvent) event).getManagedObject();
if (managedObject instanceof ManagedPortletContainer) {
ManagedPortletContainer managedPortletContainer = (ManagedPortletContainer) managedObject;
PortletApplication portletApp = managedPortletContainer.getManagedPortletApplication().getPortletApplication();
createMetaData(managedPortletContainer.getId(), portletApp);
} else if (managedObject instanceof ManagedPortletFilter) {
ManagedPortletFilter managedPortletFilter = (ManagedPortletFilter) managedObject;
PortletApplication portletApp = managedPortletFilter.getManagedPortletApplication().getPortletApplication();
createMetaData(managedPortletFilter.getId(), portletApp);
}
} else if (event instanceof ManagedObjectLifeCycleEvent) {
ManagedObjectLifeCycleEvent lifeCycleEvent = (ManagedObjectLifeCycleEvent) event;
ManagedObject managedObject = lifeCycleEvent.getManagedObject();
LifeCycleStatus status = lifeCycleEvent.getStatus();
if (managedObject instanceof ManagedPortletContainer) {
if (LifeCycleStatus.STARTED == status || LifeCycleStatus.INITIALIZED == status) {
return;
}
ManagedPortletContainer managedPortletContainer = (ManagedPortletContainer) managedObject;
CDIMetaData cdiMetaData = cdiMetaDataMap.get(managedPortletContainer.getId());
if (!cdiMetaData.cdiInjectionEnabled) {
return;
}
Portlet portlet = managedPortletContainer.getPortletInstance();
if (null != portlet) {
if (null != portlet.getClass() && "javax.portlet.faces.GenericFacesPortlet".equals(portlet.getClass().getName())) {
// Only perform injection on non JSF portlets
cdiMetaData.cdiInjectionEnabled = false;
cdiMetaDataMap.put(cdiMetaData.key, cdiMetaData);
return;
}
PortletApplication portletApp = managedPortletContainer.getManagedPortletApplication().getPortletApplication();
if (!cdiMetaData.injectionPerformed) {
performInjection(portlet, cdiMetaData, portletApp.getContext().getServletContext());
} else {
performCleanup(portlet, cdiMetaData, portletApp.getContext().getServletContext());