Source Code Cross Referenced for LongIdNamingManager.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » naming » lib » 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 » Database ORM » Speedo_1.4.5 » org.objectweb.speedo.naming.lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2004 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.speedo.naming.lib;
018:
019:        import org.objectweb.jorm.api.PException;
020:        import org.objectweb.jorm.api.PMapper;
021:        import org.objectweb.jorm.facility.naming.longid.LongIdBinder;
022:        import org.objectweb.jorm.facility.naming.longid.LongIdManager;
023:        import org.objectweb.jorm.facility.naming.longid.LongIdPNC;
024:        import org.objectweb.jorm.facility.naming.longid.LongIdPName;
025:        import org.objectweb.jorm.metainfo.api.NameDef;
026:        import org.objectweb.jorm.naming.api.PBinder;
027:        import org.objectweb.jorm.naming.api.PName;
028:        import org.objectweb.jorm.naming.api.PNameCoder;
029:        import org.objectweb.jorm.naming.api.PNamingContext;
030:        import org.objectweb.jorm.type.api.PType;
031:        import org.objectweb.jorm.type.api.PTypeSpace;
032:        import org.objectweb.medor.expression.lib.BasicOperand;
033:        import org.objectweb.speedo.metadata.SpeedoClass;
034:        import org.objectweb.speedo.metadata.SpeedoIdentity;
035:
036:        /**
037:         * This is naming manager manages identifier based on a long value 
038:         * generated by Speedo, using a persistent generator (Speedo structure in 
039:         * database). The long value is composed of two parts. Some bits are used for 
040:         * the class identifier, and the rest is used to identify the object instance 
041:         * in the class.  This identifier format supports very well the polymorphism. 
042:         * The null reference  is represented by the -1 value. The long field can be a 
043:         * visible persistent field, otherwise it is hidden by Speedo/JORM 
044:         * implementation.
045:         * 
046:         * @see org.objectweb.speedo.naming.api.NamingManager
047:         * @see org.objectweb.jorm.facility.naming.longid.LongIdManager
048:         * @author S.Chassande-Barrioz
049:         */
050:        public class LongIdNamingManager extends CommonLongIdNamingManager {
051:
052:            private final static String LONG_ID_NAME = "org.objectweb.jorm.facility.naming.longid.LongId";
053:            private final static String LONG_ID_LID = "lid";
054:            private final static String BINDER_FOR_CLASS = "c";
055:            private final static String BINDER_FOR_GENCLASS = "gc";
056:            private final static String HIDDEN_LID_FIELD_NAME = "jdolid";
057:
058:            LongIdManager lidm = new LongIdManager();
059:
060:            protected String getLongIdName() {
061:                return LONG_ID_NAME;
062:            }
063:
064:            protected String getLongIdLid() {
065:                return LONG_ID_LID;
066:            }
067:
068:            protected PType getFieldType() {
069:                return PTypeSpace.LONG;
070:            }
071:
072:            protected java.lang.Class getJavaFieldType() {
073:                return Long.TYPE;
074:            }
075:
076:            protected BasicOperand getBasicOperand() {
077:                return new BasicOperand(1l << 44);
078:            }
079:
080:            protected boolean checkFieldType(String type) {
081:                return "long".equals(type);
082:            }
083:
084:            public PMapper getMapper() {
085:                return lidm.getMapper();
086:            }
087:
088:            protected String getName() {
089:                return "lid";
090:            }
091:
092:            public PBinder newClassPBinder(String className, Object conn)
093:                    throws PException {
094:                return lidm.newClassPBinder(className, conn);
095:            }
096:
097:            public PNamingContext newClassPNamingContext() throws PException {
098:                return lidm.newClassPNamingContext();
099:            }
100:
101:            public PBinder newGenClassPBinder() throws PException {
102:                return lidm.newGenClassPBinder();
103:            }
104:
105:            public void setPMapper(PMapper mapper) {
106:                super .setPMapper(mapper);
107:                try {
108:                    lidm.setPMapper(mapper);
109:                } catch (PException e) {
110:                    e.printStackTrace();
111:                }
112:            }
113:
114:            public java.lang.Class getLongIdManagerClass() {
115:                return LongIdManager.class;
116:            }
117:
118:            public java.lang.Class getPBinderClass() {
119:                return LongIdBinder.class;
120:            }
121:
122:            public java.lang.Class getPNameClass() {
123:                return LongIdPName.class;
124:            }
125:
126:            public java.lang.Class getPNamingContextClass() {
127:                return LongIdPNC.class;
128:            }
129:
130:            protected String getBinderForGenClass() {
131:                return BINDER_FOR_GENCLASS;
132:            }
133:
134:            protected String getBinderForClass() {
135:                return BINDER_FOR_CLASS;
136:            }
137:
138:            protected String getHiddenLidFieldName() {
139:                return HIDDEN_LID_FIELD_NAME;
140:            }
141:
142:            public boolean canManage(SpeedoClass sc) {
143:                return sc.identity.strategy == SpeedoIdentity.DATASTORE_LONG;
144:            }
145:
146:            public Object encode(PName pn) throws PException {
147:                if (pn instanceof  LongIdPName) {
148:                    return pn.getPNameManager().getPType().getJormName() + SEP
149:                            + pn.encodeLong();
150:                }
151:                return null;
152:            }
153:
154:            protected PName decodeLong(PNameCoder pnc, String idStr)
155:                    throws PException {
156:                return pnc.decodeLong(Long.parseLong(idStr));
157:            }
158:
159:            public String getGCPNameHints(SpeedoClass sc, NameDef nd) {
160:                return "new Long(speedoPO.getPName().encodeLong())";
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.