Source Code Cross Referenced for ChannelManager.java in  » RSS-RDF » nntp-rss » org » methodize » nntprss » rss » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » nntp rss » org.methodize.nntprss.rss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.methodize.nntprss.rss;
002:
003:        /* -----------------------------------------------------------
004:         * nntp//rss - a bridge between the RSS world and NNTP clients
005:         * Copyright (c) 2002, 2003 Jason Brome.  All Rights Reserved.
006:         *
007:         * email: nntprss@methodize.org
008:         * mail:  Methodize Solutions
009:         *        PO Box 3865
010:         *        Grand Central Station
011:         *        New York NY 10163
012:         * 
013:         * This file is part of nntp//rss
014:         * 
015:         * nntp//rss is free software; you can redistribute it 
016:         * and/or modify it under the terms of the GNU General 
017:         * Public License as published by the Free Software Foundation; 
018:         * either version 2 of the License, or (at your option) any 
019:         * later version.
020:         *
021:         * This program is distributed in the hope that it will be 
022:         * useful, but WITHOUT ANY WARRANTY; without even the implied 
023:         * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
024:         * PURPOSE.  See the GNU General Public License for more 
025:         * details.
026:         *
027:         * You should have received a copy of the GNU General Public 
028:         * License along with this program; if not, write to the 
029:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
030:         * Boston, MA  02111-1307  USA
031:         * ----------------------------------------------------- */
032:
033:        import java.net.Authenticator;
034:        import java.net.PasswordAuthentication;
035:        import java.util.Date;
036:        import java.util.Iterator;
037:        import java.util.Map;
038:        import java.util.Properties;
039:
040:        import org.methodize.nntprss.rss.db.ChannelManagerDAO;
041:        import org.w3c.dom.Document;
042:
043:        /**
044:         * @author Jason Brome <jason@methodize.org>
045:         * @version $Id: ChannelManager.java,v 1.4 2003/03/22 16:30:23 jasonbrome Exp $
046:         */
047:        public class ChannelManager {
048:
049:            private long pollingIntervalSeconds = 60 * 60;
050:
051:            private String proxyServer = null;
052:            private int proxyPort = 0;
053:            private String proxyUserID = null;
054:            private transient String proxyPassword = null;
055:
056:            private Map channels;
057:            private static ChannelManager channelManager = new ChannelManager();
058:            private ChannelManagerDAO channelManagerDAO;
059:            private ChannelPoller channelPoller;
060:
061:            private ChannelManager() {
062:                // Private constructor - singleton class
063:                channelManagerDAO = ChannelManagerDAO.getChannelManagerDAO();
064:            }
065:
066:            public static ChannelManager getChannelManager() {
067:                return channelManager;
068:            }
069:
070:            /**
071:             * RSS Manager configuration
072:             * 
073:             * - Monitored RSS feeds
074:             *   feed url, and matching newsgroup name
075:             * 
076:             * Once feeds are loaded, load existing persistent 
077:             * store information about feeds
078:             * 
079:             */
080:
081:            public void configure(Document config) {
082:
083:                channelManagerDAO.loadConfiguration(this );
084:
085:                // Set proxy configuration, if necessary.
086:                if ((proxyServer != null) && (proxyServer.length() > 0)) {
087:                    System.setProperty("http.proxyHost", proxyServer);
088:                    System.setProperty("http.proxyPort", Integer
089:                            .toString(proxyPort));
090:                    System.setProperty("http.proxySet", "true");
091:
092:                    if ((proxyUserID != null && proxyUserID.length() > 0)
093:                            || (proxyPassword != null && proxyPassword.length() > 0)) {
094:                        Authenticator.setDefault(new Authenticator() {
095:                            protected PasswordAuthentication getPasswordAuthentication() {
096:                                return new PasswordAuthentication(proxyUserID,
097:                                        (proxyPassword == null) ? new char[0]
098:                                                : proxyPassword.toCharArray());
099:                            }
100:                        });
101:                    } else {
102:                        Authenticator.setDefault(null);
103:                    }
104:                } else {
105:                    System.setProperty("http.proxyHost", "");
106:                    System.setProperty("http.proxyPort", "");
107:                    System.setProperty("http.proxySet", "false");
108:                    Authenticator.setDefault(null);
109:                }
110:
111:                // Load feeds...
112:                channels = channelManagerDAO.loadChannels();
113:
114:                //		// Start feed poller...
115:                //		startPoller();
116:
117:            }
118:
119:            public void addChannel(Channel channel) {
120:                channel.setCreated(new Date());
121:                channelManagerDAO.addChannel(channel);
122:                channels.put(channel.getName(), channel);
123:            }
124:
125:            public void deleteChannel(Channel channel) {
126:                channels.remove(channel.getName());
127:                channelManagerDAO.deleteChannel(channel);
128:            }
129:
130:            public void start() {
131:                startPoller();
132:            }
133:
134:            public void shutdown() {
135:                stopPoller();
136:            }
137:
138:            public Iterator channels() {
139:                return channels.values().iterator();
140:            }
141:
142:            public Channel channelByName(String name) {
143:                return (Channel) channels.get(name);
144:            }
145:
146:            private void startPoller() {
147:                channelPoller = new ChannelPoller(channels);
148:                channelPoller.start();
149:            }
150:
151:            private void stopPoller() {
152:                channelPoller.shutdown();
153:            }
154:
155:            public void saveConfiguration() {
156:                channelManagerDAO.saveConfiguration(this );
157:
158:                // Update proxy configuration, if necessary.
159:                if (proxyServer != null && proxyServer.length() > 0) {
160:                    System.setProperty("http.proxyHost", proxyServer);
161:                    System.setProperty("http.proxyPort", Integer
162:                            .toString(proxyPort));
163:                    System.setProperty("http.proxySet", "true");
164:
165:                    if ((proxyUserID != null && proxyUserID.length() > 0)
166:                            || (proxyPassword != null && proxyPassword.length() > 0)) {
167:                        Authenticator.setDefault(new Authenticator() {
168:                            protected PasswordAuthentication getPasswordAuthentication() {
169:                                return new PasswordAuthentication(proxyUserID,
170:                                        (proxyPassword == null) ? new char[0]
171:                                                : proxyPassword.toCharArray());
172:                            }
173:                        });
174:                    } else {
175:                        Authenticator.setDefault(null);
176:                    }
177:
178:                } else {
179:                    Properties props = System.getProperties();
180:                    System.setProperty("http.proxyHost", "");
181:                    System.setProperty("http.proxyPort", "");
182:                    System.setProperty("http.proxySet", "false");
183:                    Authenticator.setDefault(null);
184:                }
185:
186:            }
187:
188:            /**
189:             * Returns the channelManagerDAO.
190:             * @return ChannelManagerDAO
191:             */
192:            public ChannelManagerDAO getChannelManagerDAO() {
193:                return channelManagerDAO;
194:            }
195:
196:            /**
197:             * Returns the pollingIntervalSeconds.
198:             * @return long
199:             */
200:            public long getPollingIntervalSeconds() {
201:                return pollingIntervalSeconds;
202:            }
203:
204:            /**
205:             * Sets the pollingIntervalSeconds.
206:             * @param pollingIntervalSeconds The pollingIntervalSeconds to set
207:             */
208:            public void setPollingIntervalSeconds(long pollingIntervalSeconds) {
209:                this .pollingIntervalSeconds = pollingIntervalSeconds;
210:            }
211:
212:            /**
213:             * Returns the proxyPort.
214:             * @return int
215:             */
216:            public int getProxyPort() {
217:                return proxyPort;
218:            }
219:
220:            /**
221:             * Returns the proxyServer.
222:             * @return String
223:             */
224:            public String getProxyServer() {
225:                return proxyServer;
226:            }
227:
228:            /**
229:             * Sets the proxyPort.
230:             * @param proxyPort The proxyPort to set
231:             */
232:            public void setProxyPort(int proxyPort) {
233:                this .proxyPort = proxyPort;
234:            }
235:
236:            /**
237:             * Sets the proxyServer.
238:             * @param proxyServer The proxyServer to set
239:             */
240:            public void setProxyServer(String proxyServer) {
241:                this .proxyServer = proxyServer;
242:            }
243:
244:            /**
245:             * Returns the proxyPassword.
246:             * @return String
247:             */
248:            public String getProxyPassword() {
249:                return proxyPassword;
250:            }
251:
252:            /**
253:             * Returns the proxyUserID.
254:             * @return String
255:             */
256:            public String getProxyUserID() {
257:                return proxyUserID;
258:            }
259:
260:            /**
261:             * Sets the proxyPassword.
262:             * @param proxyPassword The proxyPassword to set
263:             */
264:            public void setProxyPassword(String proxyPassword) {
265:                this .proxyPassword = proxyPassword;
266:            }
267:
268:            /**
269:             * Sets the proxyUserID.
270:             * @param proxyUserID The proxyUserID to set
271:             */
272:            public void setProxyUserID(String proxyUserID) {
273:                this.proxyUserID = proxyUserID;
274:            }
275:
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.