Source Code Cross Referenced for LuceneManagedConnectionFactory.java in  » Net » lucene-connector » net » bagaluten » jca » lucene » connector » impl » 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 » Net » lucene connector » net.bagaluten.jca.lucene.connector.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.bagaluten.jca.lucene.connector.impl;
002:
003:        import java.io.PrintWriter;
004:        import java.util.Set;
005:        import java.util.logging.Logger;
006:
007:        import javax.resource.ResourceException;
008:        import javax.resource.spi.ConnectionManager;
009:        import javax.resource.spi.ConnectionRequestInfo;
010:        import javax.resource.spi.ManagedConnection;
011:        import javax.resource.spi.ManagedConnectionFactory;
012:        import javax.security.auth.Subject;
013:
014:        public class LuceneManagedConnectionFactory implements 
015:                ManagedConnectionFactory {
016:
017:            private static final long serialVersionUID = -5795350364827952255L;
018:
019:            private static final Logger log = Logger
020:                    .getLogger(LuceneManagedConnectionFactory.class.getName());
021:
022:            /** Log writer */
023:            private transient PrintWriter writer;
024:
025:            /** Path to file system repository */
026:            private String repository;
027:
028:            /*
029:             * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
030:             */
031:            public Object createConnectionFactory(ConnectionManager cm)
032:                    throws ResourceException {
033:                return new LuceneConnectionFactoryImpl(this , cm);
034:            }
035:
036:            /*
037:             * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
038:             */
039:            public Object createConnectionFactory() throws ResourceException {
040:                return new LuceneConnectionFactoryImpl(this , null);
041:            }
042:
043:            /*
044:             * @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject,
045:             *      javax.resource.spi.ConnectionRequestInfo)
046:             */
047:            public ManagedConnection createManagedConnection(Subject subj,
048:                    ConnectionRequestInfo conReqInfo) throws ResourceException {
049:                if (conReqInfo instanceof  LuceneConnectionRequestInfo) {
050:                    LuceneConnectionRequestInfo cri = (LuceneConnectionRequestInfo) conReqInfo;
051:                    log.fine("creating new manageged connection for index "
052:                            + cri.getIndexName());
053:                } else {
054:                    log.fine("creating new unconfigured managed connection.");
055:                }
056:                return new LuceneManagedConnection(conReqInfo, writer,
057:                        repository);
058:            }
059:
060:            /*
061:             * @see javax.resource.spi.ManagedConnectionFactory#matchManagedConnections(java.util.Set,
062:             *      javax.security.auth.Subject,
063:             *      javax.resource.spi.ConnectionRequestInfo)
064:             */
065:            public ManagedConnection matchManagedConnections(Set set,
066:                    Subject subj, ConnectionRequestInfo conReqInfo)
067:                    throws ResourceException {
068:                log.info("trying to match a managed connection");
069:                if (conReqInfo == null
070:                        || !(conReqInfo instanceof  LuceneConnectionRequestInfo)) {
071:                    log
072:                            .severe("internal error - invalid request info parameter");
073:                    throw new ResourceException(
074:                            "invalid request info parameter");
075:                }
076:
077:                for (Object obj : set) {
078:                    if (obj instanceof  LuceneManagedConnection) {
079:                        LuceneManagedConnection mc = (LuceneManagedConnection) obj;
080:                        String idx = mc.getIndex();
081:                        if (idx == null) {
082:                            log
083:                                    .fine("found unconfigured connection - configuring it.");
084:                            mc.setIndex(conReqInfo);
085:                            return mc;
086:                        }
087:                        if (mc.matches(conReqInfo)) {
088:                            log.fine("found matching connection for index '"
089:                                    + idx + "'.");
090:                            return (LuceneManagedConnection) obj;
091:                        }
092:                    }
093:                }
094:                return null;
095:            }
096:
097:            /*
098:             * @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter)
099:             */
100:            public void setLogWriter(PrintWriter out) throws ResourceException {
101:                this .writer = out;
102:            }
103:
104:            /*
105:             * @see javax.resource.spi.ManagedConnectionFactory#getLogWriter()
106:             */
107:            public PrintWriter getLogWriter() throws ResourceException {
108:                return writer;
109:            }
110:
111:            /*
112:             * @see javax.resource.spi.ManagedConnectionFactory#hashCode()
113:             */
114:            public int hashCode() {
115:                if (repository == null) {
116:                    return super .hashCode();
117:                } else {
118:                    return repository.hashCode();
119:                }
120:            }
121:
122:            /*
123:             * @see javax.resource.spi.ManagedConnectionFactory#equals(java.lang.Object)
124:             */
125:            public boolean equals(Object obj) {
126:                if (this  == obj) {
127:                    return true;
128:                }
129:                if (!(obj instanceof  LuceneManagedConnectionFactory)) {
130:                    return false;
131:                }
132:                if (repository == null) {
133:                    return false;
134:                }
135:                return repository.equals(((LuceneManagedConnectionFactory) obj)
136:                        .getRepositoryPath());
137:            }
138:
139:            /**
140:             * Returns path to file system repository
141:             * 
142:             * @return path to file system repository
143:             */
144:            public String getRepositoryPath() {
145:                return repository;
146:            }
147:
148:            /**
149:             * Sets path to file system repository
150:             * 
151:             * @param path
152:             *            path to file system repository
153:             */
154:            public void setRepositoryPath(String path) {
155:                this.repository = path;
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.