use of com.liferay.faces.util.config.ConfiguredSystemEventListener in project liferay-faces-bridge-impl by liferay.
the class ApplicationCompatImpl method subscribeToJSF2SystemEvent.
protected void subscribeToJSF2SystemEvent(ConfiguredSystemEventListener configuredSystemEventListener) {
try {
ClassLoader classLoader = TCCLUtil.getThreadContextClassLoaderOrDefault(getClass());
@SuppressWarnings("unchecked") Class<? extends SystemEvent> systemEventClass = (Class<? extends SystemEvent>) classLoader.loadClass(configuredSystemEventListener.getSystemEventClass());
@SuppressWarnings("unchecked") Class<? extends SystemEventListener> systemEventListenerClass = (Class<? extends SystemEventListener>) classLoader.loadClass(configuredSystemEventListener.getSystemEventListenerClass());
SystemEventListener systemEventListener = systemEventListenerClass.newInstance();
logger.debug("Subscribing UIViewRootBridgeImpl for systemEventClass=[{0}] systemEventListener=[{1}]", systemEventClass, systemEventListener);
subscribeToEvent(systemEventClass, UIViewRootBridgeImpl.class, systemEventListener);
} catch (Exception e) {
logger.error(e);
}
}
use of com.liferay.faces.util.config.ConfiguredSystemEventListener in project liferay-faces-bridge-impl by liferay.
the class ApplicationImpl method createComponent.
/**
* This method provides the ability to supply an instance of the bridge API's {@link
* PortletNamingContainerUIViewRoot} class which properly handles namespacing of "id" attributes for portlets.
*
* @see Application#createComponent(String)
*/
@Override
@SuppressWarnings("unchecked")
public UIComponent createComponent(String componentType) throws FacesException {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (componentType.equals(UIViewRoot.COMPONENT_TYPE) && BridgeUtil.isPortletRequest(facesContext)) {
// to cleanup @ViewScoped managed-beans.
if (subscribeToEventsAtRuntime) {
// order to ensure that it only happens once.
synchronized (subscribeToEventsAtRuntime) {
// Need to check again within the synchronization block, just in case.
if (subscribeToEventsAtRuntime) {
BridgeConfig bridgeConfig = RequestMapUtil.getBridgeConfig(facesContext);
List<ConfiguredSystemEventListener> configuredSystemEventListeners = (List<ConfiguredSystemEventListener>) bridgeConfig.getAttributes().get(BridgeConfigAttributeMap.CONFIGURED_SYSTEM_EVENT_LISTENERS);
if (configuredSystemEventListeners != null) {
for (ConfiguredSystemEventListener configuredSystemEventListener : configuredSystemEventListeners) {
if (UIVIEWROOT_FQCN.equals(configuredSystemEventListener.getSourceClass())) {
subscribeToJSF2SystemEvent(configuredSystemEventListener);
}
}
}
}
subscribeToEventsAtRuntime = false;
}
}
return new UIViewRootBridgeImpl();
} else {
return getWrapped().createComponent(componentType);
}
}
Aggregations