| SerializedAdapter.java |
1 // Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
2 // Distributable under LGPL license. See terms of license at gnu.org.
3
4 package nl.justobjects.pushlet.core;
5
6 import javax.servlet.http.HttpServletResponse;
7 import java.io.IOException;
8 import java.io.ObjectOutputStream;
9
10/**
11 * Implementation of ClientAdapter that sends Events as serialized objects.
12 * <p/>
13 * NOTE: You are discouraged to use this adapter, since it is Java-only
14 * and may have JVM-specific problems. Far better choice is to use XML
15 * and the XMLAdapter.
16 *
17 * @author Just van den Broecke - Just Objects ©
18 * @version $Id: SerializedAdapter.java,v 1.4 2007/11/23 14:33:07 justb Exp $
19 */
20class SerializedAdapter implements ClientAdapter {
21 private ObjectOutputStream out = null;
22 public static final String CONTENT_TYPE = "application/x-java-serialized-object";
23 private HttpServletResponse servletRsp;
24
25 /**
26 * Initialize.
27 */
28 public SerializedAdapter(HttpServletResponse aServletResponse) {
29 servletRsp = aServletResponse;
30 }
31
32 public void start() throws IOException {
33
34 servletRsp.setContentType(CONTENT_TYPE);
35
36 // Use a serialized object output stream
37 out = new ObjectOutputStream(servletRsp.getOutputStream());
38
39 // Don't need this further
40 servletRsp = null;
41 }
42
43 /**
44 * Push Event to client.
45 */
46 public void push(Event anEvent) throws IOException {
47 out.writeObject(anEvent);
48
49 out.flush();
50 }
51
52
53 public void stop() throws IOException {
54 }
55}
56
57/*
58 * $Log: SerializedAdapter.java,v $
59 * Revision 1.4 2007/11/23 14:33:07 justb
60 * core classes now configurable through factory
61 *
62 * Revision 1.3 2005/02/28 12:45:59 justb
63 * introduced Command class
64 *
65 * Revision 1.2 2005/02/21 11:50:46 justb
66 * ohase1 of refactoring Subscriber into Session/Controller/Subscriber
67 *
68 * Revision 1.1 2005/02/18 10:07:23 justb
69 * many renamings of classes (make names compact)
70 *
71 * Revision 1.4 2004/09/03 22:35:37 justb
72 * Almost complete rewrite, just checking in now
73 *
74 * Revision 1.3 2003/08/15 08:37:40 justb
75 * fix/add Copyright+LGPL file headers and footers
76 *
77 * Revision 1.2 2003/05/18 16:13:48 justb
78 * fixed blocking for java.net.URL with HTTP/1.1 (JVMs > 1.1)
79 *
80 * Revision 1.1.1.1 2002/09/24 21:02:31 justb
81 * import to sourceforge
82 *
83 * Revision 1.1.1.1 2002/09/20 22:48:18 justb
84 * import to SF
85 *
86 * Revision 1.1.1.1 2002/09/20 14:19:03 justb
87 * first import into SF
88 *
89 * Revision 1.5 2002/04/15 20:42:41 just
90 * reformatting and renaming GuardedQueue to EventQueue
91 *
92 * Revision 1.4 2000/12/27 22:39:35 just
93 * no message
94 *
95 * Revision 1.3 2000/08/21 20:48:29 just
96 * added CVS log and id tags plus copyrights
97 *
98 *
99 */
00| SerializedAdapter.java |