01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.services;
16:
17: /**
18: * Used by other services to obtain cookie values for the current request.
19: */
20: public interface Cookies {
21: /**
22: * Returns the value of the first cookie whose name matches. Returns null if no such cookie
23: * exists. This method is only aware of cookies that are part of the incoming request; it does
24: * not know about additional cookies added since then (via
25: * {@link #writeCookieValue(String, String)}).
26: */
27: String readCookieValue(String name);
28:
29: /**
30: * Creates or updates a cookie value. The value is stored using a max age (in seconds) defined
31: * by the symbol <code>org.apache.tapestry.default-cookie-max-age</code>. The factory default
32: * for this value is the equivalent of one week.
33: */
34:
35: void writeCookieValue(String name, String value);
36:
37: /**
38: * As with {@link #writeCookieValue(String, String)} but an explicit maximum age may be set.
39: *
40: * @param name
41: * the name of the cookie
42: * @param value
43: * the value to be stored in the cookie
44: * @param maxAge
45: * the maximum age, in seconds, to store the cookie
46: */
47:
48: void writeCookieValue(String name, String value, int maxAge);
49:
50: /**
51: * As with {@link #writeCookieValue(String, String)} but an explicit path may be set.
52: */
53: void writeCookieValue(String name, String value, String path);
54:
55: /**
56: * As with {@link #writeCookieValue(String, String)} but an explicit path may be set.
57: */
58: void writeDomainCookieValue(String name, String value, String domain);
59:
60: /**
61: * As with {@link #writeCookieValue(String, String)} but an explicit path may be set.
62: */
63: void writeDomainCookieValue(String name, String value,
64: String domain, int maxAge);
65:
66: /**
67: * As with {@link #writeCookieValue(String, String, String)} but an explicit domain may be set.
68: */
69: void writeCookieValue(String name, String value, String path,
70: String domain);
71:
72: /**
73: * Removes a previously written cookie, by writing a new cookie with a maxAge of 0.
74: */
75:
76: void removeCookieValue(String name);
77: }
|