From 73ff2534e25ec52b4625f09f203e3a5fc3a2c3f2 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 21 Feb 2011 19:19:20 -0600 Subject: [PATCH] HHH-5943 - Make ServiceRegistry mutable --- .../internal/C3P0ConnectionProvider.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java index 3ac46ddfdf..1dfbb723ec 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2007-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution - * statements applied by the authors.  All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -94,10 +94,18 @@ public class C3P0ConnectionProvider implements ConnectionProvider { conn.close(); } + @Override + public boolean isUnwrappableAs(Class unwrapType) { + return ConnectionProvider.class.equals( unwrapType ) || + C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) || + DataSource.class.isAssignableFrom( unwrapType ); + } + @Override @SuppressWarnings( {"unchecked"}) public T unwrap(Class unwrapType) { - if ( ConnectionProvider.class.isAssignableFrom( unwrapType ) ) { + if ( ConnectionProvider.class.equals( unwrapType ) || + C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else if ( DataSource.class.isAssignableFrom( unwrapType ) ) {