Search in sources :

Example 1 with BasicConnectionFactory

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());
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) File(java.io.File) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 2 with BasicConnectionFactory

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");
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 3 with BasicConnectionFactory

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");
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 4 with BasicConnectionFactory

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);
        }
    };
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) MalformedURLException(java.net.MalformedURLException) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) QName(javax.xml.namespace.QName) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) Configurer(org.apache.cxf.configuration.Configurer) File(java.io.File) URL(java.net.URL)

Example 5 with BasicConnectionFactory

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);
        }
    };
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) ScanConsistency(com.couchbase.client.java.query.consistency.ScanConsistency) TimeUnit(java.util.concurrent.TimeUnit) DefaultCouchbaseEnvironment(com.couchbase.client.java.env.DefaultCouchbaseEnvironment) CouchbaseEnvironment(com.couchbase.client.java.env.CouchbaseEnvironment)

Aggregations

BasicConnectionFactory (org.teiid.resource.spi.BasicConnectionFactory)5 Test (org.junit.Test)3 FileConnection (org.teiid.translator.FileConnection)3 File (java.io.File)2 InvalidPropertyException (javax.resource.spi.InvalidPropertyException)2 CouchbaseEnvironment (com.couchbase.client.java.env.CouchbaseEnvironment)1 DefaultCouchbaseEnvironment (com.couchbase.client.java.env.DefaultCouchbaseEnvironment)1 ScanConsistency (com.couchbase.client.java.query.consistency.ScanConsistency)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 TimeUnit (java.util.concurrent.TimeUnit)1 QName (javax.xml.namespace.QName)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 Configurer (org.apache.cxf.configuration.Configurer)1 JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)1