Source Code Cross Referenced for PushController.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » jump » push » executive » 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 » 6.0 JDK Modules » j2me » com.sun.midp.jump.push.executive 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004:         * 
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License version
007:         * 2 only, as published by the Free Software Foundation.
008:         * 
009:         * This program is distributed in the hope that it will be useful, but
010:         * WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * General Public License version 2 for more details (a copy is
013:         * included at /legal/license.txt).
014:         * 
015:         * You should have received a copy of the GNU General Public License
016:         * version 2 along with this work; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018:         * 02110-1301 USA
019:         * 
020:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021:         * Clara, CA 95054 or visit www.sun.com if you need additional
022:         * information or have any questions.
023:         */
024:
025:        package com.sun.midp.jump.push.executive;
026:
027:        import com.sun.midp.jump.push.executive.persistence.Store;
028:        import com.sun.midp.push.gcf.ReservationDescriptor;
029:        import com.sun.midp.push.gcf.ReservationDescriptorFactory;
030:        import java.io.IOException;
031:        import javax.microedition.io.ConnectionNotFoundException;
032:
033:        /**
034:         * Push controller.
035:         *
036:         * <p>
037:         * Manages both connections and alarms.
038:         * </p>
039:         */
040:        final class PushController {
041:            /** Alarm controller. */
042:            private final AlarmController alarmController;
043:
044:            /** Connection controller. */
045:            private final ConnectionController connectionController;
046:
047:            /**
048:             * Creates an implementation.
049:             *
050:             * @param store Store to use
051:             * (cannot be <code>null</code>)
052:             *
053:             * @param lifecycleAdapter lifecycle adapter to use
054:             * (cannot be <code>null</code>)
055:             *
056:             * @param reservationDescriptorFactory reservation descriptor factory
057:             * (cannot be <code>null</code>)
058:             */
059:            public PushController(
060:                    final Store store,
061:                    final LifecycleAdapter lifecycleAdapter,
062:                    final ReservationDescriptorFactory reservationDescriptorFactory) {
063:                this .alarmController = new AlarmController(store,
064:                        lifecycleAdapter);
065:                this .connectionController = new ConnectionController(store,
066:                        reservationDescriptorFactory, lifecycleAdapter);
067:            }
068:
069:            /**
070:             * Registers the connection.
071:             *
072:             * <p>
073:             * Saves the connection into persistent store and reserves it
074:             * for <code>MIDlet</code>.
075:             * </p>
076:             *
077:             * <p>
078:             * The connection should be already preverified (see
079:             * <code>reservationDescriptor</code> parameter) and all the security
080:             * checks should be performed.
081:             * </p>
082:             *
083:             * @param midletSuiteID <code>MIDlet</code> suite ID
084:             *
085:             * @param midlet <code>MIDlet</code> class name
086:             * (cannot be <code>null</code>)
087:             *
088:             * @param reservationDescriptor reservation descriptor
089:             * (cannot be <code>null</code>)
090:             *
091:             * @throws IOException if the connection is already registered or
092:             * if there are insufficient resources to handle the registration request
093:             */
094:            public void registerConnection(final int midletSuiteID,
095:                    final String midlet,
096:                    final ReservationDescriptor reservationDescriptor)
097:                    throws IOException {
098:                connectionController.registerConnection(midletSuiteID, midlet,
099:                        reservationDescriptor);
100:            }
101:
102:            /**
103:             * Unregisters the connection.
104:             *
105:             * <p>
106:             * Removes the connection from persistent store and cancels connection
107:             * reservation.
108:             * </p>
109:             *
110:             * @param midletSuiteID <code>MIDlet</code> suite ID
111:             *
112:             * @param connectionName connection to unregister
113:             * (cannot be <code>null</code>)
114:             *
115:             * @return <code>true</code> if the unregistration was successful,
116:             * <code>false</code> if the connection was not registered
117:             *
118:             * @throws SecurityException if the connection was registered by
119:             * another <code>MIDlet</code>  suite
120:             */
121:            public boolean unregisterConnection(final int midletSuiteID,
122:                    final String connectionName) throws SecurityException {
123:                return connectionController.unregisterConnection(midletSuiteID,
124:                        connectionName);
125:            }
126:
127:            /**
128:             * Returns a list of registered connections for <code>MIDlet</code> suite.
129:             *
130:             * @param midletSuiteID <code>MIDlet</code> suite ID
131:             *
132:             * @param available if <code>true</code>, only return
133:             * the list of connections with input available, otherwise
134:             * return the complete list of registered connections for
135:             * <code>MIDlet</code> suite
136:             *
137:             * @return array of registered connection strings, where each connection
138:             * is represented by the generic connection <em>protocol</em>,
139:             * <em>host</em> and <em>port</em> number identification
140:             */
141:            public String[] listConnections(final int midletSuiteID,
142:                    final boolean available) {
143:                return connectionController.listConnections(midletSuiteID,
144:                        available);
145:            }
146:
147:            /**
148:             * Fetches the <code>MIDlet</code> by the connection.
149:             *
150:             * @param midletSuiteID <code>MIDlet</code> suite ID to query for
151:             *
152:             * @param connectionName connectionName as passed into
153:             * {@link #registerConnection}
154:             * (cannot be <code>null</code>)
155:             *
156:             * @return <code>MIDlet</code> associated with <code>connectionName</code>
157:             * or <code>null</code> if there is no appropriate association
158:             */
159:            public synchronized String getMIDlet(final int midletSuiteID,
160:                    final String connectionName) {
161:                return connectionController.getMIDlet(midletSuiteID,
162:                        connectionName);
163:            }
164:
165:            /**
166:             * Fetches the filter by the connection.
167:             *
168:             * @param midletSuiteID <code>MIDlet</code> suite ID to query for
169:             *
170:             * @param connectionName connectionName as passed into
171:             * {@link #registerConnection}
172:             * (cannot be <code>null</code>)
173:             *
174:             * @return filter associated with <code>connectionName</code> or
175:             * <code>null</code> if there is no appropriate association
176:             */
177:            public synchronized String getFilter(final int midletSuiteID,
178:                    final String connectionName) {
179:                return connectionController.getFilter(midletSuiteID,
180:                        connectionName);
181:            }
182:
183:            /**
184:             * Registers an alarm.
185:             *
186:             * <p>
187:             * NOTE: <code>midletSuiteID</code> parameter should refer to a valid
188:             *  <code>MIDlet</code> suite and <code>midlet</code> should refer to
189:             *  valid <code>MIDlet</code> from the given suite. <code>timer</code>
190:             *  parameters is the same as for corresponding <code>Date</code>
191:             *  constructor.  No checks are performed and no guarantees are
192:             *  given if parameters are invalid.
193:             * </p>
194:             *
195:             * @param midletSuiteID <code>MIDlet suite</code> ID
196:             *
197:             * @param midlet <code>MIDlet</code> class name
198:             * (cannot be <code>null</code>)
199:             *
200:             * @param time alarm time
201:             *
202:             * @throws ConnectionNotFoundException if for any reason alarm cannot be
203:             *  registered
204:             *
205:             * @return previous alarm time or 0 if none
206:             */
207:            public long registerAlarm(final int midletSuiteID,
208:                    final String midlet, final long time)
209:                    throws ConnectionNotFoundException {
210:                return alarmController.registerAlarm(midletSuiteID, midlet,
211:                        time);
212:            }
213:
214:            /**
215:             * Removes Push-related information for the suite being uninstalled;
216:             *
217:             * <p>
218:             * NOTE: <code>midletSuiteID</code> must refer to valid installed
219:             *  <code>MIDlet</code> suite.  However, it might refer to the
220:             *  suite without alarms.
221:             * </p>
222:             *
223:             * @param midletSuiteID ID of the suite to remove Push info for
224:             */
225:            public void removeSuiteInfo(final int midletSuiteID) {
226:                alarmController.removeSuiteAlarms(midletSuiteID);
227:                connectionController.removeSuiteConnections(midletSuiteID);
228:            }
229:
230:            /**
231:             * Logs error message.
232:             *
233:             * @param message message to log
234:             */
235:            private static void logError(final String message) {
236:                // TBD: proper logging
237:                System.err.println("[error, " + PushController.class.getName()
238:                        + "]: " + message);
239:            }
240:
241:            /**
242:             * Disposes the controller.
243:             *
244:             * <p>
245:             * This method needs to be called when closing the system.
246:             * </p>
247:             */
248:            public void dispose() {
249:                alarmController.dispose();
250:                connectionController.dispose();
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.