package org.jboss.test.jca.adapter;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Set;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionFactory;
import javax.security.auth.Subject;
public class TestManagedConnectionFactory implements ManagedConnectionFactory
{
int id;
String failure;
public TestManagedConnectionFactory ()
{
}
public void setFailure(String failure)
{
this.failure = failure;
}
public int hashCode()
{
return 0;
}
public boolean equals(Object other)
{
return (other != null) && (other.getClass() == getClass());
}
public void setLogWriter(PrintWriter param1) throws ResourceException
{
}
public PrintWriter getLogWriter() throws ResourceException
{
return null;
}
public Object createConnectionFactory(ConnectionManager cm) throws ResourceException
{
return new TestConnectionFactory(cm, this);
}
public Object createConnectionFactory() throws ResourceException
{
throw new ResourceException("not yet implemented");
}
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException
{
if (failure != null && failure.equals("createManagedConnectionResource"))
throw new ResourceException("");
if (failure != null && failure.equals("createManagedConnectionRuntime"))
throw new RuntimeException("");
return new TestManagedConnection(subject, (TestConnectionRequestInfo)cri, id++);
}
public ManagedConnection matchManagedConnections(Set candidates, Subject subject, ConnectionRequestInfo cri) throws ResourceException
{
if (failure != null && failure.equals("matchManagedConnectionResource"))
throw new ResourceException("");
if (failure != null && failure.equals("matchManagedConnectionRuntime"))
throw new RuntimeException("");
if (candidates.isEmpty())
{
return null;
} return (ManagedConnection)candidates.iterator().next();
}
Integer integerProperty;
public Integer getIntegerProperty()
{
return integerProperty;
}
public void setIntegerProperty(Integer integerProperty)
{
this.integerProperty = integerProperty;
}
Integer defaultIntegerProperty;
public Integer getDefaultIntegerProperty()
{
return defaultIntegerProperty;
}
public void setDefaultIntegerProperty(Integer defaultIntegerProperty)
{
this.defaultIntegerProperty = defaultIntegerProperty;
}
Boolean booleanProperty;
public Boolean getBooleanProperty()
{
return booleanProperty;
}
public void setBooleanProperty(Boolean booleanProperty)
{
this.booleanProperty = booleanProperty;
}
Long longProperty;
public Long getLongProperty()
{
return longProperty;
}
public void setLongProperty(Long longProperty)
{
this.longProperty = longProperty;
}
Double doubleProperty;
public Double getDoubleProperty()
{
return doubleProperty;
}
public void setDoubleProperty(Double doubleProperty)
{
this.doubleProperty = doubleProperty;
}
URL urlProperty;
public URL getUrlProperty()
{
return urlProperty;
}
public void setUrlProperty(URL urlProperty)
{
this.urlProperty = urlProperty;
}
}