use of org.teiid.resource.spi.BasicConnectionFactory in project teiid by teiid.
the class TestFileConnection method testFileMapping.
@Test
public void testFileMapping() throws Exception {
FileManagedConnectionFactory fmcf = new FileManagedConnectionFactory();
fmcf.setParentDirectory("foo");
fmcf.setFileMapping("x=y,z=a");
BasicConnectionFactory bcf = fmcf.createConnectionFactory();
FileConnection fc = (FileConnection) bcf.getConnection();
File f = fc.getFile("x");
assertEquals("foo" + File.separator + "y", f.getPath());
f = fc.getFile("n");
assertEquals("foo" + File.separator + "n", f.getPath());
}
use of org.teiid.resource.spi.BasicConnectionFactory in project teiid by teiid.
the class TestFileConnection method testParentPaths1.
@Test
public void testParentPaths1() throws Exception {
FileManagedConnectionFactory fmcf = new FileManagedConnectionFactory();
fmcf.setParentDirectory("foo");
fmcf.setAllowParentPaths(true);
BasicConnectionFactory bcf = fmcf.createConnectionFactory();
FileConnection fc = (FileConnection) bcf.getConnection();
fc.getFile(".." + File.separator + "x");
}
use of org.teiid.resource.spi.BasicConnectionFactory in project teiid by teiid.
the class TestFileConnection method testParentPaths.
@Test(expected = ResourceException.class)
public void testParentPaths() throws Exception {
FileManagedConnectionFactory fmcf = new FileManagedConnectionFactory();
fmcf.setParentDirectory("foo");
fmcf.setAllowParentPaths(false);
BasicConnectionFactory bcf = fmcf.createConnectionFactory();
FileConnection fc = (FileConnection) bcf.getConnection();
fc.getFile(".." + File.separator + "x");
}
use of org.teiid.resource.spi.BasicConnectionFactory in project teiid by teiid.
the class WSManagedConnectionFactory method createConnectionFactory.
@SuppressWarnings("serial")
@Override
public BasicConnectionFactory<WSConnectionImpl> createConnectionFactory() throws ResourceException {
if (this.endPointName == null) {
this.endPointName = WSManagedConnectionFactory.DEFAULT_LOCAL_NAME;
}
if (this.serviceName == null) {
this.serviceName = WSManagedConnectionFactory.DEFAULT_LOCAL_NAME;
}
if (this.namespaceUri == null) {
this.namespaceUri = WSManagedConnectionFactory.DEFAULT_NAMESPACE_URI;
}
this.portQName = new QName(this.namespaceUri, this.endPointName);
this.serviceQName = new QName(this.namespaceUri, this.serviceName);
if (this.wsdl != null) {
try {
this.wsdlUrl = new URL(this.wsdl);
} catch (MalformedURLException e) {
File f = new File(this.wsdl);
try {
this.wsdlUrl = f.toURI().toURL();
} catch (MalformedURLException e1) {
throw new InvalidPropertyException(e1);
}
}
}
if (this.configFile != null) {
this.bus = new SpringBusFactory().createBus(this.configFile);
JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
if (this.wsdl == null) {
Configurer configurer = this.bus.getExtension(Configurer.class);
if (null != configurer) {
// $NON-NLS-1$
configurer.configureBean(this.portQName.toString() + ".jaxws-client.proxyFactory", instance);
}
this.outInterceptors = instance.getOutInterceptors();
}
}
return new BasicConnectionFactory<WSConnectionImpl>() {
@Override
public WSConnectionImpl getConnection() throws ResourceException {
return new WSConnectionImpl(WSManagedConnectionFactory.this);
}
};
}
use of org.teiid.resource.spi.BasicConnectionFactory in project teiid by teiid.
the class CouchbaseManagedConnectionFactory method createConnectionFactory.
@SuppressWarnings("serial")
@Override
public BasicConnectionFactory<CouchbaseConnectionImpl> createConnectionFactory() throws ResourceException {
final CouchbaseEnvironment environment = DefaultCouchbaseEnvironment.builder().managementTimeout(managementTimeout).queryTimeout(queryTimeout).viewTimeout(viewTimeout).kvTimeout(kvTimeout).searchTimeout(searchTimeout).connectTimeout(connectTimeout).dnsSrvEnabled(dnsSrvEnabled).build();
if (this.connectionString == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_server"));
}
if (this.keyspace == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_keyspace"));
}
if (this.namespace == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_namespace"));
}
final ScanConsistency consistency = ScanConsistency.valueOf(scanConsistency);
TimeUnit unit = TimeUnit.MILLISECONDS;
if (this.timeUnit != null) {
try {
unit = TimeUnit.valueOf(timeUnit);
} catch (IllegalArgumentException e) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("invalid_timeUnit", timeUnit));
}
}
final TimeUnit timeoutUnit = unit;
return new BasicConnectionFactory<CouchbaseConnectionImpl>() {
@Override
public CouchbaseConnectionImpl getConnection() throws ResourceException {
return new CouchbaseConnectionImpl(environment, connectionString, keyspace, password, timeoutUnit, namespace, consistency);
}
};
}
Aggregations