01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms of the Common Development
05: * and Distribution License (the "License"). You may not use this file except in
06: * compliance with the License.
07: *
08: * You can obtain a copy of the license at
09: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
10: * language governing permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL HEADER in each file and
13: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
14: * applicable, add the following below this CDDL HEADER, with the fields
15: * enclosed by brackets "[]" replaced with your own identifying information:
16: * Portions Copyright [yyyy] [name of copyright owner]
17: */
18:
19: package org.restlet.service;
20:
21: import java.util.ArrayList;
22: import java.util.List;
23:
24: import org.restlet.data.Protocol;
25: import org.restlet.resource.Representation;
26:
27: /**
28: * Service providing client and server connectors.
29: *
30: * Implementation note: the parent component will ensure that client connectors
31: * won't automatically follow redirections. This will ensure a consistent
32: * behavior and portability of applications.
33: *
34: * @author Jerome Louvel (contact@noelios.com)
35: */
36: public class ConnectorService {
37: /** The list of required client protocols. */
38: private List<Protocol> clientProtocols;
39:
40: /** The list of required server protocols. */
41: private List<Protocol> serverProtocols;
42:
43: /**
44: * Constructor.
45: */
46: public ConnectorService() {
47: }
48:
49: /**
50: * Call-back method invoked by the client or server connectors just after
51: * sending the entity to the target component. The default implementation
52: * does nothing.
53: *
54: * @param entity
55: * The entity about to be committed.
56: */
57: public void afterSend(Representation entity) {
58: // Do nothing by default.
59: }
60:
61: /**
62: * Call-back method invoked by the client or server connectors just before
63: * sending the entity to the target component. The default implementation
64: * does nothing.
65: *
66: * @param entity
67: * The entity about to be committed.
68: */
69: public void beforeSend(Representation entity) {
70: // Do nothing by default.
71: }
72:
73: /**
74: * Returns the list of required client protocols. You need to update
75: * this list if you need the parent component to provide additional client
76: * connectors.
77: *
78: * @return The list of required client protocols.
79: */
80: public List<Protocol> getClientProtocols() {
81: if (this .clientProtocols == null)
82: this .clientProtocols = new ArrayList<Protocol>();
83: return this .clientProtocols;
84: }
85:
86: /**
87: * Returns the list of required server protocols. An empty list means that
88: * all protocols are potentially supported (default case). You should update
89: * this list to restrict the actual protocols supported by your application.
90: *
91: * @return The list of required server protocols.
92: */
93: public List<Protocol> getServerProtocols() {
94: if (this .serverProtocols == null)
95: this .serverProtocols = new ArrayList<Protocol>();
96: return this.serverProtocols;
97: }
98:
99: }
|