taylor 2004/10/22 15:43:34 Modified: portals-bridges/myfaces project.xml Added: portals-bridges/velocity project.properties .cvsignore project.xml portals-bridges/velocity/src/java/org/apache/portals/bridges/velocity JetspeedVelocityViewServlet.java portals-bridges/velocity/xdocs navigation.xml Log: moved velocity view servlet into portal bridges so that portlet apps can leverage the velocity bridge Revision Changes Path 1.1 jakarta-jetspeed-2/portals-bridges/velocity/project.properties Index: project.properties =================================================================== # Copyright 2004 The Apache Software Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Id: project.properties,v 1.1 2004/10/22 22:43:33 taylor Exp $ maven.multiproject.type=jar maven.license.licenseFile=${basedir}/../../LICENSE.TXT 1.1 jakarta-jetspeed-2/portals-bridges/velocity/.cvsignore Index: .cvsignore =================================================================== target 1.1 jakarta-jetspeed-2/portals-bridges/velocity/project.xml Index: project.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. $Id: project.xml,v 1.1 2004/10/22 22:43:33 taylor Exp $ --> <project> <extend>${basedir}/../../project.xml</extend> <pomVersion>3</pomVersion> <groupId>portals-bridges</groupId> <id>portals-bridges-velocity</id> <name>Apache Portals Velocity Bridge</name> <currentVersion>0.1</currentVersion> <package>org.apache.portals.bridges.velocity</package> <description> Apache Portals Velocity Bridge </description> <shortDescription>Apache Portals Velocity Bridge</shortDescription> <repository> <connection>scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-jetspeed-2/portals-bridges/velocity</connection> <url>http://cvs.apache.org/viewcvs/jakarta-jetspeed-2/portals-bridges/velocity/</url> </repository> <dependencies> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>portlet-api</groupId> <artifactId>portlet-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>servletapi</groupId> <artifactId>servletapi</artifactId> <version>2.3</version> </dependency> <dependency> <id>velocity</id> <version>1.4</version> </dependency> <dependency> <id>velocity-tools:velocity-tools-view</id> <version>1.1-beta1</version> <url>http://jakarta.apache.org/velocity</url> </dependency> <dependency> <id>jetspeed2:jetspeed-api</id> <version>2.0-a1-dev</version> <properties> <war.bundle>false</war.bundle> </properties> </dependency> <dependency> <id>pluto</id> <groupId>pluto</groupId> <version>1.0.1-rc1</version> <properties> <war.bundle>false</war.bundle> </properties> </dependency> <dependency> <groupId>portals-bridges</groupId> <artifactId>portals-bridges-common</artifactId> <version>0.1</version> </dependency> </dependencies> <build> <sourceDirectory>src/java</sourceDirectory> <resources> <resource> <directory>${basedir}/src/java</directory> <includes> <include>META-INF/*</include> </includes> </resource> </resources> </build> <reports> <report>maven-jdepend-plugin</report> <!-- <report>maven-checkstyle-plugin</report> --> <report>maven-pmd-plugin</report> <report>maven-changelog-plugin</report> <report>maven-file-activity-plugin</report> <report>maven-developer-activity-plugin</report> <report>maven-license-plugin</report> <report>maven-javadoc-plugin</report> <report>maven-jxr-plugin</report> <report>maven-junit-report-plugin</report> <report>maven-jcoverage-plugin</report> <report>maven-linkcheck-plugin</report> <report>maven-tasklist-plugin</report> </reports> </project> 1.3 +11 -3 jakarta-jetspeed-2/portals-bridges/myfaces/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/myfaces/project.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- project.xml 12 Oct 2004 21:33:20 -0000 1.2 +++ project.xml 22 Oct 2004 22:43:33 -0000 1.3 @@ -23,11 +23,11 @@ <id>portals-bridges-myfaces</id> <name>Apache Portals My Faces Bridge</name> <currentVersion>0.1</currentVersion> - <package>org.apache.portals.bridges.myfaes</package> + <package>org.apache.portals.bridges.myfaces</package> <description> Apache Portals My Faces Bridge </description> - <shortDescription>Apache Portals MyFces Bridge</shortDescription> + <shortDescription>Apache Portals MyFaces Bridge</shortDescription> <repository> <connection>scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-jetspeed-2/portals-bridges/myfaces</connection> <url>http://cvs.apache.org/viewcvs/jakarta-jetspeed-2/portals-bridges/myfaces/</url> @@ -37,6 +37,14 @@ <name>David Le Strat</name> <id>dlestrat</id> <email>[EMAIL PROTECTED]</email> + <roles> + <role>Java Developer</role> + </roles> + </developer> + <developer> + <name>David Sean Taylor</name> + <id>taylor</id> + <email>[EMAIL PROTECTED]</email> <roles> <role>Java Developer</role> </roles> 1.1 jakarta-jetspeed-2/portals-bridges/velocity/src/java/org/apache/portals/bridges/velocity/JetspeedVelocityViewServlet.java Index: JetspeedVelocityViewServlet.java =================================================================== /** * Created on Jan 9, 2004 * * * @author */ package org.apache.portals.bridges.velocity; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import javax.portlet.PortletConfig; import javax.portlet.PortletMode; import javax.portlet.PortletRequest; import javax.portlet.RenderResponse; import javax.portlet.WindowState; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jetspeed.request.RequestContext; import org.apache.pluto.Constants; import org.apache.velocity.Template; import org.apache.velocity.context.Context; import org.apache.velocity.exception.MethodInvocationException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.io.VelocityWriter; import org.apache.velocity.tools.view.servlet.VelocityViewServlet; import org.apache.velocity.util.SimplePool; /** * <p> * JetspeedVelocityViewServlet * </p> * Extends <code>VelocityViewServlet</code> to allow us to put portle-specific * information into the Velocity context. * * @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a> * @version $Id: JetspeedVelocityViewServlet.java,v 1.1 2004/10/22 22:43:33 taylor Exp $ * */ public class JetspeedVelocityViewServlet extends VelocityViewServlet { public static final String VELOCITY_WRITER_ATTR = "org.apache.velocity.io.VelocityWriter"; /** Cache of writers */ private static SimplePool writerPool = new SimplePool(40); private static final Log log = LogFactory.getLog(JetspeedVelocityViewServlet.class); public static final String VELOCITY_CONTEXT_ATTR = "org.apache.velocity.Context"; /** * Adds the RenderRequest, RenderResponse and PortletConfig to the context * * @see org.apache.velocity.tools.view.servlet.VelocityViewServlet#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context) */ protected Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context ctx) throws Exception { PortletRequest renderRequest = (PortletRequest) request.getAttribute(Constants.PORTLET_REQUEST); RenderResponse renderResponse = (RenderResponse) request.getAttribute(Constants.PORTLET_RESPONSE); PortletConfig portletConfig = (PortletConfig) request.getAttribute(Constants.PORTLET_CONFIG); if (renderRequest != null) { renderRequest.setAttribute(VELOCITY_CONTEXT_ATTR, ctx); } ctx.put("JS2RequestContext", request.getAttribute(RequestContext.REQUEST_PORTALENV)); ctx.put("renderRequest", renderRequest); ctx.put("renderResponse", renderResponse); ctx.put("portletConfig", portletConfig); ctx.put("portletModeView", PortletMode.VIEW); ctx.put("portletModeEdit", PortletMode.EDIT); ctx.put("portletModeHelp", PortletMode.HELP); ctx.put("windowStateNormal", WindowState.NORMAL); ctx.put("windowStateMinimized", WindowState.MINIMIZED); ctx.put("windowStateMaximized", WindowState.MAXIMIZED); StringBuffer appRoot = new StringBuffer(request.getScheme()).append("://") .append(request.getServerName()).append(":") .append(request.getServerPort()).append(renderRequest.getContextPath()); ctx.put("appRoot", appRoot.toString()); return super.handleRequest(request, response, ctx); } /** * @see org.apache.velocity.tools.view.servlet.VelocityViewServlet#mergeTemplate(org.apache.velocity.Template, org.apache.velocity.context.Context, javax.servlet.http.HttpServletResponse) */ protected void mergeTemplate(Template template, Context context, HttpServletResponse response) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException, UnsupportedEncodingException, Exception { PrintWriter pw = response.getWriter(); VelocityWriter vw = null; try { vw = (VelocityWriter) writerPool.get(); if (vw == null) { vw = new VelocityWriter(pw, 4 * 1024, true); } else { vw.recycle(pw); } // Place the VelocityWriter into the Context context.put(VELOCITY_WRITER_ATTR, vw); template.merge(context, vw); } catch (Exception e) { // log and rethrow exception log.error("Exception occured during merge template: " + e.toString(), e); throw e; } finally { try { if (vw != null) { // flush and put back into the pool // don't close to allow us to play // nicely with others. vw.flush(); /* This hack sets the VelocityWriter's internal ref to the * PrintWriter to null to keep memory free while * the writer is pooled. See bug report #18951 */ vw.recycle(null); writerPool.put(vw); } } catch (Exception e) { // do nothing } } } } 1.1 jakarta-jetspeed-2/portals-bridges/velocity/xdocs/navigation.xml Index: navigation.xml =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project> <body> <links> <item name="Jetspeed 2" href="../../index.html"/> </links> </body> </project>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]