Source Code Cross Referenced for OLongIdNamingManager.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.olongid.LongIdPBinder;
022:        import org.objectweb.jorm.facility.naming.olongid.LongIdPNC;
023:        import org.objectweb.jorm.facility.naming.olongid.LongIdManager;
024:        import org.objectweb.jorm.facility.naming.olongid.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 java.lang.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 NULL value.The java.lang.Long field
043:         * can be a 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.olongid.LongIdManager
048:         * @author S.Chassande-Barrioz
049:         */
050:        public class OLongIdNamingManager extends CommonLongIdNamingManager {
051:
052:            private final static String LONG_ID_NAME = "org.objectweb.jorm.facility.naming.olongid.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:            private 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.OBJLONG;
070:            }
071:
072:            protected BasicOperand getBasicOperand() {
073:                return new BasicOperand(new Long(1l << 44), PTypeSpace.OBJLONG);
074:            }
075:
076:            protected boolean checkFieldType(String type) {
077:                return "Long".equals(type) || "java.lang.Long".equals(type);
078:            }
079:
080:            protected String getBinderForClass() {
081:                return BINDER_FOR_CLASS;
082:            }
083:
084:            protected String getBinderForGenClass() {
085:                return BINDER_FOR_GENCLASS;
086:            }
087:
088:            protected PName decodeLong(PNameCoder pnc, String idStr)
089:                    throws PException {
090:                return pnc.decodeOlong(Long.valueOf(idStr));
091:            }
092:
093:            protected String getHiddenLidFieldName() {
094:                return HIDDEN_LID_FIELD_NAME;
095:            }
096:
097:            protected Class getJavaFieldType() {
098:                return Long.class;
099:            }
100:
101:            public PMapper getMapper() {
102:                return lidm.getMapper();
103:            }
104:
105:            protected String getName() {
106:                return "olid";
107:            }
108:
109:            public PBinder newClassPBinder(String className, Object conn)
110:                    throws PException {
111:                return lidm.newClassPBinder(className, conn);
112:            }
113:
114:            public PNamingContext newClassPNamingContext() throws PException {
115:                return lidm.newClassPNamingContext();
116:            }
117:
118:            public PBinder newGenClassPBinder() throws PException {
119:                return lidm.newGenClassPBinder();
120:            }
121:
122:            public void setPMapper(PMapper mapper) {
123:                super .setPMapper(mapper);
124:                try {
125:                    lidm.setPMapper(mapper);
126:                } catch (PException e) {
127:                    e.printStackTrace();
128:                }
129:            }
130:
131:            public java.lang.Class getLongIdManagerClass() {
132:                return LongIdManager.class;
133:            }
134:
135:            public java.lang.Class getPBinderClass() {
136:                return LongIdPBinder.class;
137:            }
138:
139:            public java.lang.Class getPNameClass() {
140:                return LongIdPName.class;
141:            }
142:
143:            public java.lang.Class getPNamingContextClass() {
144:                return LongIdPNC.class;
145:            }
146:
147:            // IMPLEMENTATION OF THE METHOD FROM THE NamingManager INTERFACE //
148:            //---------------------------------------------------------------//
149:            public boolean canManage(SpeedoClass sc) {
150:                return sc.identity.strategy == SpeedoIdentity.DATASTORE_OLONG;
151:            }
152:
153:            public Object encode(PName pn) throws PException {
154:                if (pn instanceof  LongIdPName) {
155:                    return pn.getPNameManager().getPType().getJormName() + SEP
156:                            + pn.encodeOlong();
157:                }
158:                return null;
159:            }
160:
161:            public String getGCPNameHints(SpeedoClass sc, NameDef nd) {
162:                return "speedoPO.getPName().encodeOlong()";
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.