Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFLY-30 SFSB containing injected DataSource fails to passivate/serialize
- Loading branch information
Stefano Maestri
committed
Nov 7, 2014
1 parent
99e518e
commit 1be82b8
Showing
10 changed files
with
242 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
connector/src/main/java/org/jboss/as/connector/subsystems/datasources/WildFlyDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2014, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.jboss.as.connector.subsystems.datasources; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.Serializable; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.SQLFeatureNotSupportedException; | ||
import java.util.logging.Logger; | ||
|
||
import javax.naming.InitialContext; | ||
import javax.sql.DataSource; | ||
|
||
/** | ||
* WildFly DataSource implementation | ||
* | ||
* @author <a href="jesper.pedersen@redhat.com">Jesper Pedersen</a> | ||
*/ | ||
public class WildFlyDataSource implements DataSource, Serializable { | ||
|
||
/** The serialVersionUID */ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** DataSource */ | ||
private transient DataSource delegate; | ||
|
||
/** Service name */ | ||
private transient String jndiName; | ||
|
||
|
||
/** | ||
* Constructor | ||
* @param delegate The datasource | ||
* @param jndiName The service name | ||
*/ | ||
public WildFlyDataSource(DataSource delegate, String jndiName) { | ||
this.delegate = delegate; | ||
this.jndiName = jndiName; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Connection getConnection() throws SQLException { | ||
return delegate.getConnection(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Connection getConnection(String username, String password) throws SQLException { | ||
return delegate.getConnection(username, password); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public <T> T unwrap(Class<T> iface) throws SQLException { | ||
throw new SQLException("Unwrap not supported"); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public boolean isWrapperFor(Class<?> iface) throws SQLException { | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public PrintWriter getLogWriter() throws SQLException { | ||
return delegate.getLogWriter(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void setLogWriter(PrintWriter out) throws SQLException { | ||
delegate.setLogWriter(out); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void setLoginTimeout(int seconds) throws SQLException { | ||
delegate.setLoginTimeout(seconds); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public int getLoginTimeout() throws SQLException { | ||
return delegate.getLoginTimeout(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | ||
return delegate.getParentLogger(); | ||
} | ||
|
||
private void writeObject(java.io.ObjectOutputStream out) throws IOException { | ||
out.defaultWriteObject(); | ||
out.writeObject(jndiName); | ||
} | ||
|
||
|
||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { | ||
in.defaultReadObject(); | ||
jndiName = (String) in.readObject(); | ||
|
||
|
||
try { | ||
InitialContext context = new InitialContext(); | ||
|
||
DataSource originalDs = (DataSource) context.lookup(jndiName); | ||
this.delegate = originalDs; | ||
} catch (Exception e) { | ||
throw new IOException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.