01: package com.caucho.protocols.flash;
02:
03: import javax.annotation.*;
04: import java.io.*;
05:
06: import com.caucho.config.*;
07: import com.caucho.server.connection.Connection;
08: import com.caucho.server.port.Protocol;
09: import com.caucho.server.port.ServerRequest;
10: import com.caucho.util.*;
11: import com.caucho.vfs.Path;
12:
13: /**
14: * Simple protocol that sends the contents of a specified file as soon
15: * as it is contacted. It is intended for sending flash policy files
16: * for flash.net.Sockets when the target port of the socket is < 1024.
17: *
18: **/
19: public class SocketPolicyProtocol extends Protocol {
20: private final static L10N L = new L10N(SocketPolicyRequest.class);
21:
22: private String _protocolName = "http";
23: private Path _policy;
24:
25: public void setSocketPolicyFile(Path path) {
26: setPolicyFile(path);
27: }
28:
29: /**
30: * Sets the flash socket policy file.
31: */
32: public void setPolicyFile(Path path) {
33: _policy = path;
34: }
35:
36: /**
37: * Returns the protocol name.
38: */
39: public String getProtocolName() {
40: return _protocolName;
41: }
42:
43: /**
44: * Sets the protocol name.
45: */
46: public void setProtocolName(String name) {
47: _protocolName = name;
48: }
49:
50: @PostConstruct
51: public void init() {
52: if (_policy == null)
53: throw new ConfigException(L
54: .l("flash requires a policy-file"));
55: }
56:
57: public ServerRequest createRequest(Connection conn) {
58: return new SocketPolicyRequest(getServer(), conn, _policy);
59: }
60: }
|