package org.javaee7.jca.connector.simple.connector.outbound;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
/**
*
* @author arungup
*/
public class MyManagedConnection implements ManagedConnection {
private static final Logger LOGGER = Logger.getLogger("MyManagedConnection");
private MyConnection connection;
FileOutputStream fos;
public MyManagedConnection(String file) {
try {
fos = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
@Override
public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
LOGGER.log(Level.INFO, "getConnection");
connection = new MyConnection(this);
return connection;
}
@Override
public void destroy() throws ResourceException {
try {
fos.close();
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
@Override
public void cleanup() throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void associateConnection(Object connection) throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void addConnectionEventListener(ConnectionEventListener listener) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void removeConnectionEventListener(ConnectionEventListener listener) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public XAResource getXAResource() throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ManagedConnectionMetaData getMetaData() throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setLogWriter(PrintWriter out) throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public PrintWriter getLogWriter() throws ResourceException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}