1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 package org.modeshape.jdbc.delegate; 25 26 import java.sql.Connection; 27 import java.sql.SQLException; 28 import java.sql.Statement; 29 import java.util.List; 30 import java.util.Set; 31 32 import javax.jcr.RepositoryException; 33 import javax.jcr.nodetype.NodeType; 34 import javax.jcr.query.QueryResult; 35 36 37 /** 38 * Represents the communication interface thru which the JDBC logic will obtain a connection and issue commands to the Jcr layer. 39 */ 40 41 public interface RepositoryDelegate { 42 43 /** 44 * Call to get the connection information. 45 * @return ConnectionInfo 46 */ 47 ConnectionInfo getConnectionInfo(); 48 49 /** 50 * Called when the {@link Statement} the is closed. This enables the underlying connection to the 51 * JcrRepository remain open until the statement is finished using it. 52 */ 53 void closeStatement(); 54 55 /** 56 * Call to close the delegate connection and any outstanding 57 * transactions will be closed. 58 * 59 * @see java.sql.Connection#close() 60 */ 61 void close(); 62 63 64 /** 65 * Call to get {@link NodeType} based on specified name 66 * @param name 67 * @return NodeType 68 * @throws RepositoryException 69 */ 70 NodeType nodeType( String name ) throws RepositoryException; 71 72 /** 73 * Call to get all the {@link NodeType}s defined. 74 * @return List of all the node types. 75 * @throws RepositoryException 76 */ 77 List<NodeType> nodeTypes( ) throws RepositoryException; 78 79 80 /** 81 * Call to execute the sql <code>query</code> based on the specified Jcr language. 82 * 83 * @param query is the sql query to execute 84 * @param language is the JCR language the <code>query</code> should be executed based on. 85 * @return QueryResult is the JCR query result 86 * @throws RepositoryException 87 */ 88 QueryResult execute(String query, String language) throws RepositoryException; 89 90 91 /** 92 * Call to create the connection based on the implementation of this interface. 93 * @return Connection 94 * @throws SQLException 95 * 96 * @see java.sql.Driver#connect(String, java.util.Properties) 97 */ 98 Connection createConnection() throws SQLException; 99 100 /** 101 * 102 * @see java.sql.Connection#commit() 103 * 104 * @throws RepositoryException 105 */ 106 107 void commit() throws RepositoryException; 108 109 /** 110 * 111 * @see java.sql.Connection#rollback() 112 * 113 * @throws RepositoryException 114 */ 115 void rollback() throws RepositoryException; 116 117 /** 118 * 119 * @see java.sql.Connection#isValid(int) 120 * 121 * @param timeout 122 * @return boolean indicating if timeout is valid 123 * @throws RepositoryException 124 125 */ 126 boolean isValid( int timeout ) throws RepositoryException ; 127 128 129 /** 130 * 131 * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) 132 * 133 * @param iface 134 * @return boolean 135 */ 136 boolean isWrapperFor( Class<?> iface ) ; 137 138 /** 139 * 140 * @see java.sql.Wrapper#unwrap(java.lang.Class) 141 * 142 * @param iface 143 * @param <T> 144 * @return <T> T 145 * @throws SQLException 146 147 */ 148 <T> T unwrap( Class<T> iface ) throws SQLException; 149 150 /** 151 * Called to get all the repository names currently available in the JcrEngine. 152 * @return Set<String> of repository names 153 * @throws RepositoryException 154 */ 155 Set<String> getRepositoryNames() throws RepositoryException; 156 157 /** 158 * Returns the value for the requested <code>descriptorKey</code> 159 * @param descriptorKey 160 * @return String descriptor value 161 */ 162 String getDescriptor(String descriptorKey); 163 164 }