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


001:        /*
002:         * @(#)JumpExecIxcRegistryWrapper.java	1.3 06/09/06
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package com.sun.jumpimpl.ixc.executive;
029:
030:        import java.rmi.*;
031:        import java.util.Arrays;
032:        import java.util.ArrayList;
033:        import java.util.List;
034:
035:        import javax.microedition.xlet.XletContext;
036:        import javax.microedition.xlet.ixc.IxcPermission;
037:        import javax.microedition.xlet.ixc.IxcRegistry;
038:        import javax.microedition.xlet.ixc.StubException;
039:
040:        import com.sun.jumpimpl.ixc.ExportedObject;
041:        import com.sun.jumpimpl.ixc.ImportedObject;
042:        import com.sun.jumpimpl.ixc.RemoteRef;
043:
044:        /*
045:         * Special purpose IxcRegistry for the Executive VM only.
046:         * Talks with JUMPExecIxcRegistry directly without serialization 
047:         * or Socket connection.
048:         */
049:
050:        public class JUMPExecIxcRegistryWrapper extends IxcRegistry {
051:
052:            private static JUMPExecIxcRegistryWrapper serviceRegistry;
053:            private JUMPExecIxcRegistry mainRegistry;
054:            private XletContext context;
055:
056:            // The 'name' Strings binded by this IxcRegistry
057:            private ArrayList exportedNames;
058:
059:            protected JUMPExecIxcRegistryWrapper(XletContext context) {
060:                this .context = context;
061:                exportedNames = new ArrayList();
062:                mainRegistry = JUMPExecIxcRegistry.getJUMPExecIxcRegistry();
063:            }
064:
065:            public static IxcRegistry getRegistry(XletContext context) {
066:                if (serviceRegistry == null)
067:                    serviceRegistry = new JUMPExecIxcRegistryWrapper(context);
068:
069:                return serviceRegistry;
070:            }
071:
072:            public Remote lookup(String name) throws StubException,
073:                    NotBoundException {
074:
075:                SecurityManager sm = System.getSecurityManager();
076:                if (sm != null)
077:                    sm.checkPermission(new IxcPermission(name, "lookup"));
078:
079:                RemoteRef remoteRef = (RemoteRef) mainRegistry.lookup(name);
080:
081:                Remote nextObject;
082:
083:                ExportedObject eo = ExportedObject.findExportedObject(remoteRef
084:                        .getObjectID());
085:
086:                if (eo != null && eo.getRemoteRef().equals(remoteRef)) {
087:                    nextObject = eo.getRemoteObject(); // get the original
088:                } else {
089:                    nextObject = ImportedObject.registerImportedObject(
090:                            remoteRef, context); // Implicit import
091:                }
092:
093:                return nextObject;
094:            }
095:
096:            public void bind(String name, Remote obj) throws StubException,
097:                    AlreadyBoundException {
098:
099:                SecurityManager sm = System.getSecurityManager();
100:                if (sm != null)
101:                    sm.checkPermission(new IxcPermission(name, "bind"));
102:
103:                try {
104:                    ExportedObject eo = ExportedObject.registerExportedObject(
105:                            (Remote) obj, context);
106:
107:                    RemoteRef remoteRef = eo.getRemoteRef();
108:
109:                    mainRegistry.bind(name, remoteRef);
110:
111:                } catch (RemoteException e) {
112:                    if (e instanceof  StubException)
113:                        throw (StubException) e;
114:                    throw new RuntimeException(e.getCause());
115:                }
116:
117:                // The object is successfully registered.
118:                // Record the name to the local list.
119:                synchronized (exportedNames) {
120:                    exportedNames.add(name);
121:                }
122:
123:            }
124:
125:            public void unbind(String name) throws NotBoundException,
126:                    AccessException {
127:
128:                if (!exportedNames.contains(name)) {
129:                    // First, a security check.
130:                    SecurityManager sm = System.getSecurityManager();
131:                    if (sm != null) {
132:                        sm.checkPermission(new IxcPermission(name, "bind"));
133:                    }
134:
135:                    // This is inefficient, but we need to check for
136:                    // NotBoundException first.
137:                    List list = Arrays.asList(mainRegistry.list());
138:                    if (!list.contains(name))
139:                        throw new NotBoundException("Name " + name
140:                                + " not bound");
141:
142:                    // At this point, just throw AccessException
143:                    throw new AccessException(
144:                            "Cannot unbind objects bound by other xlets");
145:                }
146:
147:                mainRegistry.unbind(name);
148:
149:                // Successfully unbinded, remove the name
150:                // from the local list as well.
151:                synchronized (exportedNames) {
152:                    exportedNames.remove(name);
153:                }
154:
155:            }
156:
157:            public void rebind(String name, Remote obj) throws StubException,
158:                    AccessException {
159:
160:                SecurityManager sm = System.getSecurityManager();
161:                if (sm != null)
162:                    sm.checkPermission(new IxcPermission(name, "bind"));
163:
164:                if (name == null || obj == null)
165:                    throw new NullPointerException("name and obj can't be null");
166:
167:                try {
168:                    mainRegistry.unbind(name);
169:                    bind(name, obj);
170:                } catch (NotBoundException nbe) { // just ignore
171:                } catch (AlreadyBoundException abe) { // can't happen
172:                }
173:            }
174:
175:            public String[] list() {
176:                String[] names = mainRegistry.list();
177:
178:                SecurityManager sm = System.getSecurityManager();
179:                if (sm != null) {
180:                    ArrayList list = new ArrayList();
181:                    for (int i = 0; i < names.length; i++) {
182:                        try {
183:                            sm.checkPermission(new IxcPermission(names[i],
184:                                    "lookup"));
185:                            list.add(names[i]);
186:                        } catch (SecurityException e) {
187:                        }
188:                    }
189:                    names = (String[]) list.toArray(new String[] {});
190:                }
191:
192:                return names;
193:
194:            }
195:
196:            public void unbindAll() {
197:
198:                String[] names = (String[]) exportedNames
199:                        .toArray(new String[] {});
200:
201:                for (int i = 0; i < names.length; i++) {
202:                    try {
203:                        mainRegistry.unbind(names[i]);
204:                    } catch (NotBoundException nbe) {
205:                        // Just ignore it.
206:                    } catch (RemoteException re) {
207:                        System.err
208:                                .println("Unexpected exception during unbindAll()");
209:                        throw new RuntimeException(re.getCause());
210:                    }
211:                }
212:
213:                // Successfully cleared, remove all names from the local list.
214:                synchronized (exportedNames) {
215:                    exportedNames.clear();
216:                }
217:
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.