View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    *******************************************************************************/
8   /**
9    * 
10   */
11  package it.imolinfo.jbi4cics.connection.jdbc.util;
12  
13  import java.lang.reflect.Proxy;
14  
15  /**
16   * l'obiettivo di questi statemetn disconnessi è di consentire l'operativita anche in assenza di una connessione sql
17   * il funzionamento generale è quello di "memorizzare" le operazioni che vengono su di essi chiamate e poi eseguirle
18   * in sequenza quando viene assegnata la connessione.
19   * In generale le operazioni che è possibile memorizzare sono quelle che ritornano void. Le altre possono essere eseguite solo 
20   * quando lo statement è in fase connessa, in tal caso saranno immediatamente delegate al vero statement sottostante
21   * @author raffaele
22   *
23   */
24  public class DisconnectedStatementFactory {
25  	
26  	/**
27  	 * void constructor.
28  	 */
29  	  public DisconnectedStatementFactory(){
30  		  super();
31  	  }
32  
33    public static DisconnectedStatement createDisconnectedStatement(){
34      return (DisconnectedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedStatement.class},new StatementInvocationHandler());
35    }
36    
37    public static DisconnectedStatement createDisconnectedStatement(int resultSetType, int resultSetConcurrency){
38      return (DisconnectedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedStatement.class},new StatementInvocationHandler(resultSetType,resultSetConcurrency));
39    }  
40    
41    public static DisconnectedStatement createDisconnectedStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability){
42      return (DisconnectedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedStatement.class},new StatementInvocationHandler(resultSetType,resultSetConcurrency,resultSetHoldability));
43    }  
44    
45    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql){
46      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql));
47    }
48  
49    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql, int autoGeneratedKeys){
50      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql, autoGeneratedKeys));
51    }
52    
53    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql, int[] columnIndexes){
54      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql, columnIndexes));
55    }
56    
57    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql, int resultSetType, int resultSetConcurrency){
58      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql, resultSetType, resultSetConcurrency));
59    }
60    
61    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
62      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
63    }
64    
65    public static DisconnectedPreparedStatement prepareDisconnectedStatement(String sql, String[] columnNames){
66      return (DisconnectedPreparedStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedPreparedStatement.class},new PreparedStatementInvocationHandler(sql, columnNames));
67    }  
68    
69    public static DisconnectedCallableStatement prepareDisconnectedCall(String sql){
70      return (DisconnectedCallableStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedCallableStatement.class},new CallableStatementInvocationHandler(sql));
71    }
72    
73    public static DisconnectedCallableStatement prepareDisconnectedCall(String sql, int resultSetType, int resultSetConcurrency){
74      return (DisconnectedCallableStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedCallableStatement.class},new CallableStatementInvocationHandler(sql,resultSetType,resultSetConcurrency));
75    }  
76    
77    public static DisconnectedCallableStatement prepareDisconnectedCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
78      return (DisconnectedCallableStatement)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),new Class[]{DisconnectedCallableStatement.class},new CallableStatementInvocationHandler(sql,resultSetType,resultSetConcurrency,resultSetHoldability));
79    }      
80    
81  
82  }