• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sending a request to a url but not returning the page to the user
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a request to a url but not returning the page to the user


  • Subject: Re: Sending a request to a url but not returning the page to the user
  • From: Kieran Kelleher <email@hidden>
  • Date: Mon, 9 Oct 2006 20:52:11 -0400

THIS IS A RESEND SINCE MODERATOR STOPPED LAST REPLY FOR 9KB OVER!
---------------------------------------------
Or if you don't want to use concurrent request handling, you can dispatch this request in a thread of its own. That way the request generating this DA request gets completed and thus frees up the ap to answer the spun-off second request. 

Here is a snippet example from a ScheduledTaskDetail WOComponent where I fire a direct action at my current development instance for testing scheduled task direct actions. devFireEvent is a simple component action invoked by a WOHyperlink and DevFireEvent is an inner class in the WOComponent class. the request associated with invoking devFireEvent completes and returns before the direct action request it spawned gets handled in the run() method of the inner class. Never mind the superfluous details ... but this gives you a way to do it without turning on Concurrent Request Handling if that is something you want not to do. ... note the httpConn.sendRequest and readResponse are in running in the separate thread......

HTH, Kieran

    /** Usable in development mode only for developer testing. 
        Must fire the request in a separate thread since this request will
        block because AllowsConcurrentRequestHandling is off. */
    public WOComponent devFireEvent()
    {
        Thread devFireEventThread = new DevFireEvent( selectedTaskEvent() );
        devFireEventThread.start();

        

        return null;
    }

    

    protected class DevFireEvent extends Thread {
        protected CTScheduledTaskEvent event;
        protected EOEditingContext ec;

        

        public DevFireEvent() {
            super();
        }

        

        

        /** Create a local instance in a manual lock EC */
        public DevFireEvent( CTScheduledTaskEvent newEvent ) {
            super();

            ec = WKEditingContext.createInstance();
            ec.lock();
            try {
                event = (CTScheduledTaskEvent)EOUtilities.localInstanceOfObject( ec, newEvent );
            } catch ( Exception e ) {
                log.error( "Error creating DevFireEvent with " + WKStringUtilities.toString( newEvent ), e );
            } finally {
                ec.unlock();
            }

        }

        

        /** Fire the event */
        public void run() {
            ec.lock();
            try {
                int portNumber = ERXProperties.intForKeyWithDefault( "singletonOperations.fireEvent.portNumber", 80 );
                String targetHostName = System.getProperty( "singletonOperations.fireEvent.targetHostName" );

                

                WOHTTPConnection httpConn = new WOHTTPConnection( targetHostName,
                                                                  portNumber );

                

                String url = "" "singletonOperations.fireEvent.baseUrl" );
                url = "" + "?keycode=" + event.keycode();

                

                if ( log.isDebugEnabled() ) log.debug("fireEvent url = ""Apple-style-span" face="Monaco" size="2"> + url );

                

                WORequest request = new WORequest( "GET", url, "HTTP/1.1",
                                                   null,
                                                   null,
                                                   null );

                

                httpConn.sendRequest( request );

                

                WOResponse response = httpConn.readResponse();
            }
            catch ( Exception e ) {
                log.error( "Error firing event " + WKStringUtilities.toString( event ), e );
            }
            finally {
                ec.unlock();
            }
        }
    } 

On Oct 9, 2006, at 6:01 PM, Mike Schrag wrote:

Random tidbit ... Be careful of using this to call back into yourself (i.e. App A connecting back to App A).  You want to make sure you have concurrent request handling turned on or you will deadlock yourself.

ms

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sending a request to a url but not returning the page to the user
      • From: Dev WO <email@hidden>
References: 
 >Sending a request to a url but not returning the page to the user (From: Dev WO <email@hidden>)
 >Re: Sending a request to a url but not returning the page to the user (From: Dave Elsner <email@hidden>)
 >Re: Sending a request to a url but not returning the page to the user (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: To lock() or not to lock()
  • Next by Date: Re: To lock() or not to lock()
  • Previous by thread: Re: Sending a request to a url but not returning the page to the user
  • Next by thread: Re: Sending a request to a url but not returning the page to the user
  • Index(es):
    • Date
    • Thread