01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *
19: */
20: package org.safehaus.asyncweb.service.pipeline;
21:
22: import org.safehaus.asyncweb.service.HttpServiceContext;
23:
24: public interface RequestPipeline {
25:
26: /**
27: * Adds a request to this pipeline.
28: *
29: * @return <code>true</code> iff the pipeline accepts the request
30: */
31: public boolean addRequest(HttpServiceContext context);
32:
33: /**
34: * Frees any responses which may now be provided to the client as a result
35: * of the specified response becoming available.
36: * If the associated request has not been previously added to this pipeline,
37: * it joins the pipeline at the back of the queue: All previously added
38: * requests must be responded to before the new request can take its turn<br/>
39: */
40: public void releaseResponse(HttpServiceContext context);
41:
42: /**
43: * Sets the <code>PipelineListener</code> to be notified when
44: * a request is released from this pipeline
45: *
46: * @param listener The listener
47: */
48: public void setPipelineListener(RequestPipelineListener listener);
49:
50: /**
51: * Disposes of any requests still living in the pipeline
52: */
53: public void disposeAll();
54:
55: /**
56: * Runs the scheduled command the next time the pipeline is empty.
57: * Run immediately if the pipeline is currently empty;
58: *
59: * @param r The command to run
60: */
61: public void runWhenEmpty(Runnable r);
62:
63: }
|