You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/07/11 05:05:17 UTC

svn commit: r420685 [2/2] - in /tapestry/tapestry4/trunk: .settings/ eclipse/ tapestry-examples/TimeTracker/src/context/ tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/ tapestry-examples/Workbench/src/context/ tapestry-fram...

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java?rev=420685&r1=420684&r2=420685&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java Mon Jul 10 20:05:15 2006
@@ -21,7 +21,6 @@
 
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.tapestry.BaseComponentTestCase;
-import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.services.ServiceConstants;
 import org.apache.tapestry.web.WebRequest;
 import org.testng.annotations.Test;
@@ -53,9 +52,8 @@
     public void testGetURLWithParameters()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/context/servlet", ENCODING, _urlCodec,
+        EngineServiceLink l = new EngineServiceLink("/context/servlet", ENCODING, _urlCodec,
                 request, buildParameters("myservice", null), true);
 
         replay();
@@ -72,9 +70,8 @@
     public void testGetURLWithServiceParameters()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
+        EngineServiceLink l = new EngineServiceLink("/ctx/app", ENCODING, _urlCodec, request,
                 buildParameters("foo", new String[]
                 { "godzilla", "frodo" }), false);
         
@@ -90,9 +87,8 @@
     public void testGetURLSansParameters()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/context/servlet", ENCODING, _urlCodec,
+        EngineServiceLink l = new EngineServiceLink("/context/servlet", ENCODING, _urlCodec,
                 request, buildParameters("myservice", null), true);
 
         replay();
@@ -107,9 +103,8 @@
     public void testGetURLWithAnchor()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newMock(IRequestCycle.class);
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/context/servlet", ENCODING, _urlCodec,
+        EngineServiceLink l = new EngineServiceLink("/context/servlet", ENCODING, _urlCodec,
                 request, buildParameters("myservice", null), false);
         
         replay();
@@ -122,9 +117,8 @@
     public void testGetURLWithAnchorAndParameters() throws Exception
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/context/servlet", ENCODING, _urlCodec,
+        EngineServiceLink l = new EngineServiceLink("/context/servlet", ENCODING, _urlCodec,
                 request, buildParameters("myservice", null), false);
         
         replay();
@@ -137,9 +131,8 @@
     public void testGetAbsoluteURL() throws Exception
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
+        EngineServiceLink l = new EngineServiceLink("/ctx/app", ENCODING, _urlCodec, request,
                 buildParameters("myservice", null), false);
 
         trainGetServerPort(request, 9187);
@@ -158,9 +151,8 @@
     public void testGetAbsoluteURLWithOverrides() throws Exception
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
+        EngineServiceLink l = new EngineServiceLink("/ctx/app", ENCODING, _urlCodec, request,
                 buildParameters("myservice", null), false);
         
         replay();
@@ -178,7 +170,6 @@
     public void testGetURLNotAbsolute()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
         trainGetScheme(request, "http");
         trainGetServerName(request, "myserver.net");
@@ -186,7 +177,7 @@
         
         replay();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
+        EngineServiceLink l = new EngineServiceLink("/ctx/app", ENCODING, _urlCodec, request,
                 buildParameters("myservice", null), false);
 
         assertEquals("/ctx/app?service=myservice#myanchor", l.getURL(
@@ -202,13 +193,12 @@
     public void testGetURLAbsolute()
     {
         WebRequest request = newRequest();
-        IRequestCycle rc = newCycle();
 
         trainGetScheme(request, "http");
         
         replay();
 
-        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
+        EngineServiceLink l = new EngineServiceLink("/ctx/app", ENCODING, _urlCodec, request,
                 buildParameters("myservice", null), false);
 
         assertEquals("https://override.net:8080/ctx/app?service=myservice#myanchor", l.getURL(

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/hivemodule.xml?rev=420685&r1=420684&r2=420685&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/hivemodule.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/hivemodule.xml Mon Jul 10 20:05:15 2006
@@ -204,6 +204,25 @@
     
   </service-point>
   
+  <service-point id="PortletAssetLinkFactory" interface="org.apache.tapestry.services.LinkFactory">
+    Implementation of LinkFactory for portlet assets. Uses servlet paths to generate asset links
+    as is normally done, but also re encodes the URL's using IRequestCycle.encodeUrl(string).
+    
+    <invoke-factory>
+      <construct class="PortletAssetLinkFactoryImpl">
+        <set-object property="dataSqueezer" value="infrastructure:dataSqueezer"/>
+        <set-configuration property="contributions" configuration-id="tapestry.url.ServiceEncoders"/>
+        <set-object property="servletPath" value="app-property:org.apache.tapestry.servlet-path"/>
+        <set-object property="contextPath" value="infrastructure:contextPath"/>
+        <set-object property="request" value="infrastructure:request"/>
+        <set-object property="requestCycle" value="infrastructure:requestCycle"/>
+        <set-service property="persistenceStrategySource" 
+          service-id="tapestry.persist.PropertyPersistenceStrategySource"/>
+      </construct>
+    </invoke-factory>
+    
+  </service-point>
+  
  <service-point id="SetupPortletApplicationGlobals" interface="PortletApplicationInitializer">
   
   Contributed into the tapestry.init.ApplicationInitializers configuration point

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/tapestry.portlet.services.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/tapestry.portlet.services.xml?rev=420685&r1=420684&r2=420685&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/tapestry.portlet.services.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/descriptor/META-INF/tapestry.portlet.services.xml Mon Jul 10 20:05:15 2006
@@ -65,10 +65,12 @@
       <construct class="org.apache.tapestry.asset.AssetService">
         <set-object property="exceptionReporter" value="infrastructure:requestExceptionReporter"/>
         <!-- The big change: use the servlet LinkFactory, not the portlet LinkFactory. -->
-        <set-service property="linkFactory" service-id="tapestry.url.LinkFactory"/>
+        <set-service property="linkFactory" service-id="tapestry.portlet.PortletAssetLinkFactory"/>
         <set-service property="context" service-id="tapestry.globals.WebContext"/>
         <set-object property="response" value="service:tapestry.globals.WebResponse"/>
         <set-service property="digestSource" service-id="tapestry.asset.ResourceDigestSource"/>
+        <set-service property="unprotectedMatcher" service-id="tapestry.asset.UnprotectedResourceMatcher" />
+        <event-listener service-id="tapestry.ResetEventHub"/>
       </construct>
     </invoke-factory>
   </service-point>  

Added: tapestry/tapestry4/trunk/tapestry-portlet/src/java/org/apache/tapestry/portlet/PortletAssetLinkFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/java/org/apache/tapestry/portlet/PortletAssetLinkFactoryImpl.java?rev=420685&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/java/org/apache/tapestry/portlet/PortletAssetLinkFactoryImpl.java (added)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/java/org/apache/tapestry/portlet/PortletAssetLinkFactoryImpl.java Mon Jul 10 20:05:15 2006
@@ -0,0 +1,55 @@
+// Copyright Jul 10, 2006 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.
+package org.apache.tapestry.portlet;
+
+import java.util.Map;
+
+import org.apache.tapestry.IEngine;
+import org.apache.tapestry.engine.EngineServiceLink;
+import org.apache.tapestry.engine.IEngineService;
+import org.apache.tapestry.engine.ILink;
+import org.apache.tapestry.engine.ServiceEncoding;
+import org.apache.tapestry.services.impl.LinkFactoryImpl;
+
+
+/**
+ * Creates {@link EngineServiceLink}s that will re-encode asset URL's
+ * using {@link IRequestCycle#encodeUrl()}.
+ * 
+ * @author jkuhnert
+ */
+public class PortletAssetLinkFactoryImpl extends LinkFactoryImpl
+{
+    
+    public ILink constructLink(IEngineService service, boolean post, Map parameters,
+            boolean stateful)
+    {
+        finalizeParameters(service, parameters);
+        
+        IEngine engine = _requestCycle.getEngine();
+        
+        ServiceEncoding serviceEncoding = createServiceEncoding(parameters);
+        
+        // Give persistent property strategies a chance to store extra data
+        // into the link.
+        
+        if (stateful)
+            _persistenceStrategySource.addParametersForPersistentProperties(serviceEncoding, post);
+        
+        String fullServletPath = _contextPath + serviceEncoding.getServletPath();
+        
+        return new EngineServiceLink(_requestCycle, fullServletPath, engine.getOutputEncoding(),
+                _codec, _request, parameters, stateful);
+    }
+}