Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native OO API implementations #19

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0be6537
Native OO API implementations
Oct 29, 2018
48a1188
Native OO interface fix
Dec 5, 2018
f117647
Merge branch 'master' into native_oo_batch
vasiliy-yashkov Jan 28, 2020
ceb90bb
Update native OO API implementation
vasiliy-yashkov Jan 30, 2020
15b0855
Merge remote-tracking branch 'origin/master' into native_oo_batch
vasiliy-yashkov Jul 27, 2020
c426c70
Add versioning support of native interfaces and update existing class…
vasiliy-yashkov Jul 28, 2020
e0d14ad
Merge remote-tracking branch 'origin/master' into native_oo_batch
vasiliy-yashkov Apr 14, 2022
7b1f4ac
Update native OO API implementations
vasiliy-yashkov Apr 15, 2022
826f698
Merge branch 'master' into native_oo_batch
vasiliy-yashkov Jul 25, 2022
d79b0a5
Update native OO API implementations
vasiliy-yashkov Jul 25, 2022
bf59522
Merge branch 'master' into native_oo_batch
vasiliy-yashkov Sep 5, 2022
f8f18e5
Add support for batch updates to the native OO API statement implemen…
vasiliy-yashkov Sep 5, 2022
5bb1b93
Merge remote-tracking branch 'origin/master' into native_oo_batch
vasiliy-yashkov Sep 12, 2022
a57ca08
Use `ReentrantLock` instead of synchronized object for native OO API …
vasiliy-yashkov Sep 12, 2022
c122329
Update implementation of native OO API
vasiliy-yashkov May 31, 2023
e874a6f
Merge commit '7c3652071766feba1c3e356a292632d1f4c1c1f9' into native_o…
vasiliy-yashkov Jun 5, 2023
b4e6ade
Use correct invalid descriptor field identifier for exception in case…
vasiliy-yashkov Jun 5, 2023
a6fdaba
Minor cleanup and comments
vasiliy-yashkov Jun 5, 2023
63cd757
Merge commit '7a493a89a79e058b171b8dde8e7e37aa0cd4d3d6' into native_o…
vasiliy-yashkov Jun 7, 2023
11ee8f0
Use `org.firebirdsql.jdbc.FirebirdBlob` as arguments when working wit…
vasiliy-yashkov Jun 7, 2023
0d55f0d
Do not check connection when cancel operation in case of forced abort
vasiliy-yashkov Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<classpathentry excluding="org/firebirdsql/hibernate/" kind="src" path="src/test"/>
<classpathentry kind="src" path="src/jdbc_42"/>
<classpathentry kind="src" path="src/jna-client"/>
<classpathentry kind="src" path="src/nativeoo"/>
<classpathentry kind="src" path="src/nativeoo-test"/>
<classpathentry kind="src" path="src/test_42"/>
<classpathentry kind="src" path="src/jna-test"/>
<classpathentry kind="src" path="src/extern"/>
Expand Down
3 changes: 3 additions & 0 deletions build/archive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<fileset dir="${source.jna-client}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${source.nativeoo}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${toString:source.java.openoffice}">
<include name="**/*.java"/>
</fileset>
Expand Down
2 changes: 2 additions & 0 deletions build/compile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<src path="${source.java}"/>
<src path="${source.extern}"/>
<src path="${source.jna-client}"/>
<src path="${source.nativeoo}"/>
<src refid="source.java.openoffice"/>
<src refid="source.java.additional"/>
</javac>
Expand Down Expand Up @@ -87,6 +88,7 @@
<classpath refid="javac.test.classpath"/>
<src path="${source.test}"/>
<src path="${source.test.jna}"/>
<src path="${source.test.nativeoo}"/>
<src refid="source.test.additional"/>
</javac>

Expand Down
1 change: 1 addition & 0 deletions build/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<pathelement path="${source.java}"/>
<pathelement path="${source.extern}"/>
<pathelement path="${source.jna-client}"/>
<pathelement path="${source.nativeoo}"/>
</sourcepath>
<sourcepath refid="source.java.openoffice"/>
<sourcepath refid="source.java.additional"/>
Expand Down
2 changes: 2 additions & 0 deletions build/init.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@
<property name="source.jdbc.41" value="${module.source}/jdbc_41"/>
<property name="source.jdbc.42" value="${module.source}/jdbc_42"/>
<property name="source.jna-client" value="${module.source}/jna-client"/>
<property name="source.nativeoo" value="${module.source}/nativeoo"/>
<property name="source.etc" value="${module.source}/etc"/>
<property name="source.resources" value="${module.source}/resources"/>
<property name="source.stylesheets" value="${module.source}/stylesheets"/>
<property name="source.test" value="${module.source}/test"/>
<property name="source.test.42" value="${module.source}/test_42"/>
<property name="source.test.jna" value="${module.source}/jna-test"/>
<property name="source.test.nativeoo" value="${module.source}/nativeoo-test"/>
<property name="source.documentation" value="${module.source}/documentation"/>

<property name="thirdparty" value="${module.root}/thirdparty"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
*/
package org.firebirdsql.gds.ng.jna;

import org.firebirdsql.gds.ng.FbDatabaseFactory;
import org.firebirdsql.gds.ng.IAttachProperties;
import org.firebirdsql.gds.ng.IConnectionProperties;
import org.firebirdsql.gds.ng.IServiceProperties;
import org.firebirdsql.gds.ng.*;
import org.firebirdsql.jna.fbclient.FbClientLibrary;

import java.sql.SQLException;
Expand All @@ -35,14 +32,14 @@
public abstract class AbstractNativeDatabaseFactory implements FbDatabaseFactory {

@Override
public JnaDatabase connect(IConnectionProperties connectionProperties) throws SQLException {
public FbDatabase connect(IConnectionProperties connectionProperties) throws SQLException {
Copy link
Member

@mrotteveel mrotteveel Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the covariant inheritance here? This also introduces casts in TestJnaDatabase and TestJnaBlob (and other tests) that were previously unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot. It was a rough initial version, need to reverse it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, revert back to covariant inheritance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

final JnaDatabaseConnection jnaDatabaseConnection = new JnaDatabaseConnection(getClientLibrary(),
filterProperties(connectionProperties));
return jnaDatabaseConnection.identify();
}

@Override
public JnaService serviceConnect(IServiceProperties serviceProperties) throws SQLException {
public FbService serviceConnect(IServiceProperties serviceProperties) throws SQLException {
final JnaServiceConnection jnaServiceConnection = new JnaServiceConnection(getClientLibrary(),
filterProperties(serviceProperties));
return jnaServiceConnection.identify();
Expand Down
15 changes: 15 additions & 0 deletions src/jna-client/org/firebirdsql/gds/ng/jna/JnaDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,21 @@ public void cancelEvent(EventHandle eventHandle) throws SQLException {
}
}

@Override
public FbBatch createBatch(FbTransaction transaction, String statement, FbMessageMetadata metadata, BatchParameterBuffer parameters) throws SQLException {
throw new SQLException("Not implemented");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use FBDriverNotCapableException (also for the other two methods)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

}

@Override
public FbBatch createBatch(FbTransaction transaction, String statement, BatchParameterBuffer parameters) throws SQLException {
throw new SQLException("Not implemented");
}

@Override
public FbMetadataBuilder getMetadataBuilder(int fieldCount) throws SQLException {
throw new SQLException("Not implemented");
}

private void processStatusVector() throws SQLException {
processStatusVector(statusVector, getDatabaseWarningCallback());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.firebirdsql.jna.fbclient;

/**
* @author <a href="mailto:[email protected]">Vasiliy Yashkov</a>
* @since 4.0
*/
public class CryptoObjectInfo {
}
41 changes: 41 additions & 0 deletions src/jna-client/org/firebirdsql/jna/fbclient/FB_DEC16.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.firebirdsql.jna.fbclient;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;

/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
* @since 4.0
*/
public class FB_DEC16 extends Structure {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this form compatible/usable with the form used within Jaybird?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested.


public long[] fb_data = new long[1];
public FB_DEC16() {
super();
}

protected List getFieldOrder() {
return Arrays.asList("fb_data");
}
public FB_DEC16(long fb_data[]) {
super();
if ((fb_data.length != this.fb_data.length))
throw new IllegalArgumentException("Wrong array size !");
this.fb_data = fb_data;
}

public FB_DEC16(Pointer peer) {
super(peer);
}

public static class ByReference extends FB_DEC16 implements Structure.ByReference {

};
public static class ByValue extends FB_DEC16 implements Structure.ByValue {

};
}
37 changes: 37 additions & 0 deletions src/jna-client/org/firebirdsql/jna/fbclient/FB_DEC34.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.firebirdsql.jna.fbclient;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;

/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
* @since 4.0
*/
public class FB_DEC34 extends Structure {
public long[] fb_data = new long[2];
public FB_DEC34() {
super();
}
protected List getFieldOrder() {
return Arrays.asList("fb_data");
}
public FB_DEC34(long fb_data[]) {
super();
if ((fb_data.length != this.fb_data.length))
throw new IllegalArgumentException("Wrong array size !");
this.fb_data = fb_data;
}
public FB_DEC34(Pointer peer) {
super(peer);
}
public static class ByReference extends FB_DEC34 implements Structure.ByReference {

};
public static class ByValue extends FB_DEC34 implements Structure.ByValue {

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.ShortByReference;
import org.firebirdsql.nativeoo.gds.ng.FbInterface;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
Expand Down Expand Up @@ -752,4 +753,10 @@ ISC_STATUS fb_shutdown_callback(ISC_STATUS[] statusVector, FbShutdownCallback FB
* <i>native declaration : C:\Program Files\Firebird\Firebird_2_5\include\ibase.h:1306</i>
*/
int isc_get_client_minor_version();

/**
* Original signature : <code>extern "C" IMaster* ISC_EXPORT fb_get_master_interface();</code><br>
* <i>native declaration : firebird/include/firebird/interface.h:364</i>
*/
FbInterface.IMaster fb_get_master_interface();
}
17 changes: 17 additions & 0 deletions src/jna-client/org/firebirdsql/jna/fbclient/ISC_DATE.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.firebirdsql.jna.fbclient;

import com.sun.jna.Structure;

import java.util.Arrays;
import java.util.List;

public class ISC_DATE extends Structure implements Structure.ByValue
{
public int value;

@Override
protected List<String> getFieldOrder()
{
return Arrays.asList("value");
}
}
4 changes: 4 additions & 0 deletions src/jna-client/org/firebirdsql/jna/fbclient/ISC_QUAD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.firebirdsql.jna.fbclient;

public class ISC_QUAD extends GDS_QUAD_t {
}
17 changes: 17 additions & 0 deletions src/jna-client/org/firebirdsql/jna/fbclient/ISC_TIME.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.firebirdsql.jna.fbclient;

import com.sun.jna.Structure;

import java.util.Arrays;
import java.util.List;

public class ISC_TIME extends Structure implements Structure.ByValue
{
public int value;

@Override
protected List<String> getFieldOrder()
{
return Arrays.asList("value");
}
}
2 changes: 1 addition & 1 deletion src/jna-test/org/firebirdsql/gds/ng/jna/TestJnaBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public void testOutputBlobDoubleOpen() throws Exception {

@Override
protected JnaDatabase createFbDatabase(FbConnectionProperties connectionInfo) throws SQLException {
final JnaDatabase db = factory.connect(connectionInfo);
final JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
db.attach();
return db;
}
Expand Down
22 changes: 11 additions & 11 deletions src/jna-test/org/firebirdsql/gds/ng/jna/TestJnaDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class TestJnaDatabase {
public void testBasicAttach() throws Exception {
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try (JnaDatabase db = factory.connect(connectionInfo)) {
try (JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo)) {
db.attach();

assertTrue("Expected isAttached() to return true", db.isAttached());
Expand All @@ -104,7 +104,7 @@ public void doubleAttach() throws Exception {
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);

try (JnaDatabase db = factory.connect(connectionInfo)) {
try (JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo)) {
db.attach();

//Second attach should throw exception
Expand All @@ -120,7 +120,7 @@ public void basicStatusVectorProcessing_wrongLogin() throws Exception {
FBTestProperties.GDS_TYPE, not(isEmbeddedType()));
// set invalid password
connectionInfo.setPassword("abcd");
try (JnaDatabase db = factory.connect(connectionInfo)) {
try (JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo)) {

expectedException.expect(allOf(
isA(SQLException.class),
Expand All @@ -137,7 +137,7 @@ public void testBasicStatusVectorProcessing_wrongDatabase() throws Exception {
// set invalid database
final String invalidDatabaseName = FBTestProperties.getDatabasePath() + "doesnotexist";
connectionInfo.setDatabaseName(invalidDatabaseName);
try (JnaDatabase db = factory.connect(connectionInfo)) {
try (JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo)) {

expectedException.expect(allOf(
isA(SQLException.class),
Expand Down Expand Up @@ -166,7 +166,7 @@ public void testBasicStatusVectorProcessing_wrongDatabase() throws Exception {
public void testBasicCreateAndDrop() throws Exception {
connectionInfo.getExtraDatabaseParameters()
.addArgument(ISCConstants.isc_dpb_sql_dialect, 3);
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
File dbFile = new File(connectionInfo.getDatabaseName());
try {
db.createDatabase();
Expand Down Expand Up @@ -194,7 +194,7 @@ public void testDrop_NotAttached() throws Exception {
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
db.dropDatabase();
} finally {
defaultDatabaseTearDown(fbManager);
Expand All @@ -203,7 +203,7 @@ public void testDrop_NotAttached() throws Exception {

@Test
public void testDetach_NotConnected() throws Exception {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);

// Note: the error is different from the one in the pure java implementation as we cannot discern between
// not connected and not attached
Expand All @@ -219,7 +219,7 @@ public void testBasicDetach() throws Exception {
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
try {
db.attach();

Expand All @@ -240,7 +240,7 @@ public void testDetach_openTransactions() throws Exception {
defaultDatabaseSetUp(fbManager);

try {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
FbTransaction transaction = null;
try {
db.attach();
Expand Down Expand Up @@ -274,7 +274,7 @@ FBTestProperties.GDS_TYPE, not(
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
try {
db.attach();
assumeTrue("expected database attached", db.isAttached());
Expand All @@ -293,7 +293,7 @@ FBTestProperties.GDS_TYPE, not(

@Test
public void testExecuteImmediate_createDatabase() throws Exception {
JnaDatabase db = factory.connect(connectionInfo);
JnaDatabase db = (JnaDatabase) factory.connect(connectionInfo);
try {
String createDb = String.format("CREATE DATABASE '%s' USER '%s' PASSWORD '%s'",
getDatabasePath(), DB_USER, DB_PASSWORD);
Expand Down
6 changes: 3 additions & 3 deletions src/jna-test/org/firebirdsql/gds/ng/jna/TestJnaEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final void tearDown() throws Exception {

@Test
public void testCreateEventHandle() throws Exception {
db = factory.connect(connectionInfo);
db = (JnaDatabase) factory.connect(connectionInfo);
db.attach();

JnaEventHandle eventHandle = db.createEventHandle("TEST_EVENT", new EventHandler() {
Expand All @@ -109,7 +109,7 @@ public void eventOccurred(EventHandle eventHandle) {

@Test
public void testQueueEvent_andNotification() throws Exception {
db = factory.connect(connectionInfo);
db = (JnaDatabase) factory.connect(connectionInfo);
db.attach();

FbTransaction transaction = getTransaction(db);
Expand Down Expand Up @@ -176,7 +176,7 @@ public void testQueueEvent_andNotification() throws Exception {

@Test
public void cancelAfterCallback_directJNA() throws Exception {
db = factory.connect(connectionInfo);
db = (JnaDatabase) factory.connect(connectionInfo);
db.attach();

FbClientLibrary lib = db.getClientLibrary();
Expand Down
Loading