whoa, Thanks for all the replies and input:)
I went for the java.net.URLConnection
and also turned on the concurrentrequesthandling (not sure if this can lead to problem...)

Thanks Kieran for the sample code, I'm pretty sure I'll be using it:)

Xavier



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      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to