I have created a patch for this. But I can't seem to access JIRA to post a feature request and the patch. So I am including it here (and will add it when JIRA is accessible again). It is a patch against the latest from SVN as of Sept 1st, 4:00PM AST:

Index: C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/IEngine.java
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/IEngine.java (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/IEngine.java (working copy)
@@ -22,6 +22,7 @@
import org.apache.tapestry.engine.IScriptSource;
import org.apache.tapestry.engine.ISpecificationSource;
import org.apache.tapestry.services.Infrastructure;
+import org.apache.tapestry.services.RequestGlobals;
import org.apache.tapestry.services.WebRequestServicer;
import org.apache.tapestry.spec.IApplicationSpecification;

@@ -179,4 +180,6 @@
     */

    public Infrastructure getInfrastructure();
+
+ public void setGlobals(RequestGlobals requestGlobals);
}
\ No newline at end of file
Index: C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/engine/AbstractEngine.java
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/engine/AbstractEngine.java (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/engine/AbstractEngine.java (working copy)
@@ -36,6 +36,7 @@
import org.apache.tapestry.listener.ListenerMap;
import org.apache.tapestry.services.DataSqueezer;
import org.apache.tapestry.services.Infrastructure;
+import org.apache.tapestry.services.RequestGlobals;
import org.apache.tapestry.spec.IApplicationSpecification;
import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebResponse;
@@ -105,6 +106,8 @@

    private Locale _locale;

+ private RequestGlobals _requestGlobals;
+
    /**
* The name of the application specification property used to specify the class of the visit
     * object.
@@ -222,6 +225,7 @@
        try
        {
cycle = _infrastructure.getRequestCycleFactory().newRequestCycle(this);
+            _requestGlobals.store(cycle);
        }
        catch (RuntimeException ex)
        {
@@ -546,4 +550,8 @@
    {
        return _infrastructure.getOutputEncoding();
    }
+
+    public void setGlobals(RequestGlobals requestGlobals) {
+     _requestGlobals = requestGlobals;
+    }
}
\ No newline at end of file
Index: C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/RequestGlobalsImpl.java
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/RequestGlobalsImpl.java (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/RequestGlobalsImpl.java (working copy)
@@ -17,6 +17,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

+import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.services.RequestGlobals;
import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebResponse;
@@ -37,6 +38,8 @@
    private HttpServletRequest _request;

    private HttpServletResponse _response;
+
+    private IRequestCycle _cycle;

    public WebRequest getWebRequest()
    {
@@ -69,4 +72,12 @@
        _request = request;
        _response = response;
    }
+
+ public IRequestCycle getCycle() {
+  return _cycle;
+ }
+
+ public void store(IRequestCycle cycle) {
+  _cycle = cycle;
+ }
}
\ No newline at end of file
Index: C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/EngineFactoryImpl.java
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/EngineFactoryImpl.java (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/impl/EngineFactoryImpl.java (working copy)
@@ -20,6 +20,7 @@
import org.apache.hivemind.ClassResolver;
import org.apache.tapestry.IEngine;
import org.apache.tapestry.services.EngineFactory;
+import org.apache.tapestry.services.RequestGlobals;
import org.apache.tapestry.spec.IApplicationSpecification;

/**
@@ -36,6 +37,7 @@
    private String _defaultEngineClassName;
    private EngineConstructor _constructor;
    private ClassResolver _classResolver;
+    private RequestGlobals _requestGlobals;

    interface EngineConstructor
    {
@@ -90,6 +92,7 @@
        IEngine result = _constructor.construct();

        result.setLocale(locale);
+        result.setGlobals(_requestGlobals);

        return result;
    }
@@ -109,4 +112,8 @@
        _defaultEngineClassName = string;
    }

+ public void setRequestGlobals(RequestGlobals requestGlobals) {
+  _requestGlobals = requestGlobals;
+ }
+
}
Index: C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/RequestGlobals.java
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/RequestGlobals.java (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/java/org/apache/tapestry/services/RequestGlobals.java (working copy)
@@ -17,6 +17,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

+import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebResponse;

@@ -31,6 +32,8 @@
public void store(HttpServletRequest request, HttpServletResponse response);

    public void store(WebRequest request, WebResponse response);
+
+    public void store(IRequestCycle cycle);

    public HttpServletRequest getRequest();

@@ -39,4 +42,6 @@
    public HttpServletResponse getResponse();

    public WebResponse getWebResponse();
+
+    public IRequestCycle getCycle();
}
\ No newline at end of file
Index: C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.globals.xml
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.globals.xml (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.globals.xml (working copy)
@@ -74,6 +74,17 @@
    </invoke-factory>
  </service-point>

+ <service-point id="RequestCycle" interface="org.apache.tapestry.IRequestCycle">
+
+ Exposes the current thread's WebResponse as a service. The response is actually
+    stored in the RequestGlobals service.
+
+
+    <invoke-factory service-id="hivemind.lib.ServicePropertyFactory">
+      <construct service-id="RequestGlobals" property="cycle"/>
+    </invoke-factory>
+  </service-point>
+
<service-point id="WebContext" interface="org.apache.tapestry.web.WebContext">

Exposes the global WebContext (a wrapper around the Servlet or Portlet context)
@@ -109,6 +120,7 @@
    <property name="request" object="service:WebRequest"/>
    <property name="response" object="service:WebResponse"/>
<property name="applicationId" object="service-property:ApplicationGlobals:activatorName"/>
-    <property name="context" object="service:WebContext"/>
+    <property name="context" object="service:WebContext"/>
+    <property name="cycle" object="service:RequestCycle"/>
  </contribution>
</module>
\ No newline at end of file
Index: C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.request.xml
===================================================================
--- C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.request.xml (revision 264932) +++ C:/tapestryv4/Tapestry SVN/framework/src/descriptor/META-INF/tapestry.request.xml (working copy)
@@ -83,6 +83,7 @@
      <construct class="impl.EngineFactoryImpl">
<set-object property="applicationSpecification" value="infrastructure:applicationSpecification"/> <set-object property="defaultEngineClassName" value="global-property:org.apache.tapestry.engine-class"/> + <set-object property="requestGlobals" value="service:tapestry.globals.RequestGlobals"/>
      </construct>
    </invoke-factory>


----- Original Message ----- From: "Howard Lewis Ship" <[EMAIL PROTECTED]>
To: "Tapestry development" <[email protected]>
Sent: Thursday, September 01, 2005 5:01 PM
Subject: Re: Injecting the current RequestCycle into a Hivemind Service


Yes, that could be done; it just isn't yet.

On 9/1/05, Adam Greene <[EMAIL PROTECTED]> wrote:
Could it not be placed into Infrastructure like the WebRequest et al? It is via a class held in Infrastructure that the new RequestCycle is created to begin with, just a small layer of indirection should do it. I'll submit a
patch once I have one and leave it to the community to decide.

----- Original Message -----
From: "Howard Lewis Ship" <[EMAIL PROTECTED]>
To: "Tapestry development" <[email protected]>
Sent: Thursday, September 01, 2005 2:21 PM
Subject: Re: Injecting the current RequestCycle into a Hivemind Service


> Not easily; it isn't a service or a property of a service, it's
> literally passed around from one object to another.
>
> On 8/31/05, Adam Greene <[EMAIL PROTECTED]> wrote:
>> Is there any way to access the current RequestCycle from within a
>> Hivemind service?
>>
>
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to