public Statement getStatement() throws SQLException { return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); }
private static KeySpec loadKeySpec(byte[] bytes, String cipher) throws NoSuchAlgorithmException { try { Class<?> aClass = ClassLoaderUtils.loadClass("javax.crypto.spec." + cipher + "KeySpec"); return (KeySpec) aClass.getConstructor(byte[].class).newInstance(bytes); } catch (Exception e) { throw new NoSuchAlgorithmException("No such KeySpec: " + cipher, e); } }
public static Set<Class<?>> getAllInterfaces(Class<?> clazz) { Set<Class<?>> interfaces = new HashSet<Class<?>>(); for (Class<?> intf : Arrays.asList(clazz.getInterfaces())) { if (intf.getInterfaces().length > 0) { interfaces.addAll(getAllInterfaces(intf)); } interfaces.add(intf); } if (clazz.getSuperclass() != null) { interfaces.addAll(getAllInterfaces(clazz.getSuperclass())); } if (clazz.isInterface()) { interfaces.add(clazz); } return interfaces; }
public XAConnection getXAConnection(String user, String password) throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); props.setProperty("user", user); props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } }
Set<Class<?>> interfaces = ClassLoaderUtils.getAllInterfaces(primaryInterface); for (Class<?> intf : interfaces) { CtClass intfCt = classPool.getCtClass(intf.getName()); return targetCt.toClass(ClassLoaderUtils.getClassLoader(), null);
} else { if (log.isDebugEnabled()) log.debug("loading default configuration"); in = ClassLoaderUtils.getResourceAsStream("bitronix-default-config.properties");
public XAConnection getXAConnection() throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); if (user != null) props.setProperty("user", user); if (password != null) props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } }
Set<Class<?>> interfaces = ClassLoaderUtils.getAllInterfaces(primaryInterface); for (Class<?> intf : interfaces) { CtClass intfCt = classPool.getCtClass(intf.getName()); return targetCt.toClass(ClassLoaderUtils.getClassLoader(), null);
} else { if (log.isDebugEnabled()) log.debug("loading default configuration"); in = ClassLoaderUtils.getResourceAsStream("bitronix-default-config.properties");
private static KeySpec loadKeySpec(byte[] bytes, String cipher) throws NoSuchAlgorithmException { try { Class<?> aClass = ClassLoaderUtils.loadClass("javax.crypto.spec." + cipher + "KeySpec"); return (KeySpec) aClass.getConstructor(byte[].class).newInstance(bytes); } catch (Exception e) { throw new NoSuchAlgorithmException("No such KeySpec: " + cipher, e); } }
public Statement getStatement() throws SQLException { return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); }
public XAConnection getXAConnection() throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); if (user != null) props.setProperty("user", user); if (password != null) props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } }
private ProxyFactory<XAConnection> createProxyXAConnectionFactory() { Set<Class<?>> interfaces = ClassLoaderUtils.getAllInterfaces(Connection.class); interfaces.add(XAConnection.class); return new ProxyFactory<XAConnection>(interfaces.toArray(new Class<?>[0])); }
} else { if (log.isDebugEnabled()) { log.debug("loading default configuration"); } in = ClassLoaderUtils.getResourceAsStream("bitronix-default-config.properties");
/** * Create an unitialized {@link XAResourceProducer} implementation which depends on the XA resource class name. * @param xaResourceClassName an XA resource class name. * @return a {@link XAResourceProducer} implementation. * @throws ClassNotFoundException if the {@link XAResourceProducer} cannot be instantiated. * @throws IllegalAccessException if the {@link XAResourceProducer} cannot be instantiated. * @throws InstantiationException if the {@link XAResourceProducer} cannot be instantiated. */ private static XAResourceProducer instantiate(String xaResourceClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class<?> clazz = ClassLoaderUtils.loadClass(xaResourceClassName); // resource classes are instantiated via reflection so that there is no hard class binding between this internal // transaction manager service and 3rd party libraries like the JMS ones. // This allows using the TM with a 100% JDBC application without requiring JMS libraries. if (XADataSource.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JDBC_RESOURCE_CLASSNAME).newInstance(); } else if (XAConnectionFactory.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JMS_RESOURCE_CLASSNAME).newInstance(); } else return null; }
public Connection getConnection() throws SQLException { LrcConnectionHandle lrcConnectionHandle = new LrcConnectionHandle(xaResource, connection); return (Connection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { Connection.class }, lrcConnectionHandle); }
public XAConnection getXAConnection(String user, String password) throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); props.setProperty("user", user); props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } }
public static Set<Class<?>> getAllInterfaces(Class<?> clazz) { Set<Class<?>> interfaces = new HashSet<Class<?>>(); for (Class<?> intf : Arrays.asList(clazz.getInterfaces())) { if (intf.getInterfaces().length > 0) { interfaces.addAll(getAllInterfaces(intf)); } interfaces.add(intf); } if (clazz.getSuperclass() != null) { interfaces.addAll(getAllInterfaces(clazz.getSuperclass())); } if (clazz.isInterface()) { interfaces.add(clazz); } return interfaces; }
} else { if (log.isDebugEnabled()) { log.debug("loading default configuration"); } in = ClassLoaderUtils.getResourceAsStream("bitronix-default-config.properties");
/** * Create an unitialized {@link XAResourceProducer} implementation which depends on the XA resource class name. * @param xaResourceClassName an XA resource class name. * @return a {@link XAResourceProducer} implementation. * @throws ClassNotFoundException if the {@link XAResourceProducer} cannot be instantiated. * @throws IllegalAccessException if the {@link XAResourceProducer} cannot be instantiated. * @throws InstantiationException if the {@link XAResourceProducer} cannot be instantiated. */ private static XAResourceProducer instantiate(String xaResourceClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class clazz = ClassLoaderUtils.loadClass(xaResourceClassName); // resource classes are instantiated via reflection so that there is no hard class binding between this internal // transaction manager service and 3rd party libraries like the JMS ones. // This allows using the TM with a 100% JDBC application without requiring JMS libraries. if (XADataSource.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JDBC_RESOURCE_CLASSNAME).newInstance(); } else if (XAConnectionFactory.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JMS_RESOURCE_CLASSNAME).newInstance(); } else return null; }