Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0003342: Implement SymmetricDS JDBC driver wrapper for optional logging,
stats, and other diagnostics.
- Loading branch information
Showing
10 changed files
with
3,280 additions
and
0 deletions.
There are no files selected for viewing
801 changes: 801 additions & 0 deletions
801
symmetric-jdbc/src/main/java/org/jumpmind/driver/ConnectionWrapper.java
Large diffs are not rendered by default.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
symmetric-jdbc/src/main/java/org/jumpmind/driver/Driver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jumpmind.driver; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.DriverPropertyInfo; | ||
import java.sql.SQLException; | ||
import java.sql.SQLFeatureNotSupportedException; | ||
import java.util.Properties; | ||
import java.util.logging.Logger; | ||
|
||
public class Driver implements java.sql.Driver { | ||
|
||
private static final String DRIVER_PREFIX = "jdbc:symds:"; | ||
|
||
static { | ||
try { | ||
DriverManager.registerDriver(new Driver()); | ||
} catch (Exception ex) { | ||
throw new RuntimeException("Failed to register SymmetricDS driver", ex); | ||
} | ||
} | ||
|
||
@Override | ||
public Connection connect(String url, Properties info) throws SQLException { | ||
if (url == null || !url.toLowerCase().startsWith(DRIVER_PREFIX)) { | ||
return null; | ||
} | ||
|
||
// Properties props = setupConnectProperties(url, info); | ||
|
||
String realUrl = getRealUrl(url); | ||
|
||
Connection connection = DriverManager.getConnection(realUrl); | ||
|
||
return new ConnectionWrapper(connection); | ||
} | ||
|
||
private String getRealUrl(String url) { | ||
// transform "jdbc:symds:jtds:" to just jdbc:jtds: | ||
return url.replace("symds:", ""); | ||
} | ||
|
||
@Override | ||
public boolean acceptsURL(String url) throws SQLException { | ||
if (url == null) { | ||
return false; | ||
} | ||
|
||
return url.toLowerCase().startsWith(DRIVER_PREFIX); | ||
} | ||
|
||
@Override | ||
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getMajorVersion() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getMinorVersion() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean jdbcCompliant() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | ||
return null; | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
symmetric-jdbc/src/main/java/org/jumpmind/driver/DummyInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jumpmind.driver; | ||
|
||
|
||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
public class DummyInterceptor extends WrapperInterceptor { | ||
|
||
public DummyInterceptor(Object wrapped) { | ||
super(wrapped); | ||
} | ||
|
||
@Override | ||
public InterceptResult preExecute(String methodName, Object... parameters) { | ||
InterceptResult interceptResult = new InterceptResult(); | ||
return interceptResult; | ||
} | ||
|
||
@Override | ||
public InterceptResult postExecute(String methodName, Object result, long startTime, long endTime, Object... parameters) { | ||
InterceptResult interceptResult = new InterceptResult(); | ||
return interceptResult; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
symmetric-jdbc/src/main/java/org/jumpmind/driver/InterceptResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jumpmind.driver; | ||
|
||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
public class InterceptResult { | ||
|
||
private boolean intercepted; | ||
private Object interceptResult; | ||
|
||
public boolean isIntercepted() { | ||
return intercepted; | ||
} | ||
public void setIntercepted(boolean intercepted) { | ||
this.intercepted = intercepted; | ||
} | ||
public Object getInterceptResult() { | ||
return interceptResult; | ||
} | ||
public void setInterceptResult(Object interceptResult) { | ||
this.interceptResult = interceptResult; | ||
} | ||
|
||
} |
Oops, something went wrong.