genericwindow.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 739 行 · 第 1/2 页
JAVA
739 行
throw new IllegalArgumentException( "'" + className + "' must have a public zero arg constructor"); Object obj = null; try { obj = cl.newInstance(); } catch (Exception ex) { throw new IllegalArgumentException( "error instantiating `" + className + "': " + ex.toString(), ex); } return obj; } protected String getNamespace() { return _namespace; } /** * {@inheritDoc} */ public PortletContext getPortletContext() { if (_portletContext == null) throw new IllegalStateException("missing init()?"); return _portletContext; } /** * {@inheritDoc} */ public PortletConfig getPortletConfig() { return this; } /** * {@inheritDoc} */ public String getPortletName() { return _portletName; } public String getInitParameter(String name) { if (_initParamMap == null) return null; else return _initParamMap.get(name); } public Enumeration getInitParameterNames() { if (_initParamMap == null) return Collections.enumeration(Collections.EMPTY_LIST); else return Collections.enumeration(_initParamMap.keySet()); } /** * {@inheritDoc} */ public int getExpirationCache() { return _expirationCache; } /** * {@inheritDoc} */ public boolean isPrivate() { return _isPrivate; } /** * {@inheritDoc} * * This implementation returns true. */ public boolean isWindowStateAllowed(PortletRequest request, WindowState windowState) { // XXX: todo: support a window-states init-param like // normal, minimized return true; } /** * {@inheritDoc} * * This implementation returns true. */ public boolean isPortletModeAllowed(PortletRequest request, PortletMode portletMode) { // todo: see getSupportedContentTypes() return true; } /** * {@inheritDoc} * * This implementation returns null, which means that all content * types are supported. */ public Set<String> getSupportedContentTypes(PortletMode portletMode) { // XXX: todo: support a content-type init-param like // edit(text/html), view(text/html, application/pdf) return null; } /** * {@inheritDoc} * * This implementation returns null, which means that all locales are * supported. */ public Set<Locale> getSupportedLocales() { return _supportedLocales; } /** * {@inheritDoc} * * This implementation returns null. */ public PortletPreferences getDefaultPreferences() { return _defaultPreferences; } /** * {@inheritDoc} */ public ArrayList<PreferencesValidator> getPreferencesValidators() { if (_defaultPreferences != null) return _defaultPreferences.getPreferencesValidators(); else return null; } /** * {@inheritDoc} * * This implementation returns null. */ public Map<String, String> getRoleRefMap() { return null; // todo } /** * {@inheritDoc} * * This implementation returns null. */ public ArrayList<Constraint> getConstraints() { return null; // todo } /** * {@inheritDoc} */ public Renderer getRenderer() { return _renderer; } /** * {@inheritDoc} * * This implementation returns PortletMode.VIEW. */ public PortletMode handlePortletModeFailure( PortletRequest request, PortletMode notAllowed ) { return PortletMode.VIEW; } /** * {@inheritDoc} * * This implementation returns WindowState.NORMAL. */ public WindowState handleWindowStateFailure( PortletRequest request, WindowState notAllowed ) { return WindowState.NORMAL; } /** * {@inheritDoc} * * @see #setErrorPage(String) */ public void handleConstraintFailure( RenderRequest request, RenderResponse response, ConstraintFailureEvent event ) { if (_errorPage == null) return; Object existingConstraint = request.getAttribute("com.caucho.portal.error.constraint"); Object existingConstraintType = request.getAttribute("com.caucho.portal.error.constraint_type"); Object existingStatusCode = request.getAttribute("com.caucho.portal.error.status_code"); Constraint constraint = event.getConstraint(); Class constraintType = constraint.getClass(); Integer statusCode = new Integer(event.getStatusCode()); request.setAttribute( "com.caucho.portal.error.constraint", constraint ); request.setAttribute( "com.caucho.portal.error.constraint_type", constraintType); request.setAttribute( "com.caucho.portal.error.status_code", statusCode ); try { if (handleErrorPage(request, response)) event.setHandled(false); else event.setHandled(true); } finally { if (existingConstraint == null) { request.removeAttribute( "com.caucho.portal.error.constraint" ); request.removeAttribute( "com.caucho.portal.error.constraint_type" ); request.removeAttribute( "com.caucho.portal.error.status_code" ); } else { request.setAttribute( "com.caucho.portal.error.constraint", existingConstraint ); request.setAttribute( "com.caucho.portal.error.constraint_type", existingConstraintType ); request.setAttribute( "com.caucho.portal.error.status_code", existingStatusCode ); } } } /** * {@inheritDoc} * * @see #setErrorPage(String) */ public void handleException( RenderRequest request, RenderResponse response, ExceptionEvent event ) { if (_errorPage == null) return; Object existingException = request.getAttribute("com.caucho.portal.error.exception"); Object existingExceptionType = request.getAttribute("com.caucho.portal.error.exception_type"); Object existingMessage = request.getAttribute("com.caucho.portal.error.message"); Exception exception = event.getException(); Class exceptionType = exception.getClass(); String message = exception.getMessage(); request.setAttribute( "com.caucho.portal.error.exception", exception ); request.setAttribute( "com.caucho.portal.error.exception_type", exceptionType ); request.setAttribute( "com.caucho.portal.error.message", message ); try { if (handleErrorPage(request, response)) event.setHandled(false); else event.setHandled(true); } finally { if (existingException == null) { request.removeAttribute( "com.caucho.portal.error.exception" ); request.removeAttribute( "com.caucho.portal.error.exception_type" ); request.removeAttribute( "com.caucho.portal.error.message" ); } else { request.setAttribute( "com.caucho.portal.error.exception", existingException ); request.setAttribute( "com.caucho.portal.error.exception_type", existingExceptionType ); request.setAttribute( "com.caucho.portal.error.message", existingMessage ); } } } private boolean handleErrorPage( RenderRequest request, RenderResponse response ) { try { PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(_errorPage); dispatcher.include(request, response); } catch (Exception ex) { log.log(Level.WARNING, ex.toString(), ex); return false; } return true; } /** * {@inheritDoc} */ public ResourceBundle getResourceBundle(Locale locale) { if (_resourceBundleFactory == null) _resourceBundleFactory = new ResourceBundleFactory(); return _resourceBundleFactory.getResourceBundle(locale); } /** * {@inheritDoc} */ public int getBufferSize() { return _bufferSize; } abstract public void processAction(PortletConnection connection) throws PortletException, IOException; abstract public void render(PortletConnection connection) throws PortletException, IOException; public void destroy() { }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?