Skip to content

Conversation

@thymepuns
Copy link

### Building

To build the project simply run
Works on JDK1.8. To build the project simply run
Copy link
Author

Choose a reason for hiding this comment

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

Various conflicts on higher versions of java

*/
public class JdbcServiceVirtualizationFactory implements P6Factory {

@Getter @Setter
Copy link
Author

Choose a reason for hiding this comment

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

I saw lombok was being used some places, so tidied up and started using it more.

protected Object interceptPreparedStatementExecution(PreparedStatementInformation preparedStatementInformation, Object underlying, Method method, Object[] args) {
CloseableHttpClient httpclient = HttpClients.createDefault();

HttpPost httpPost = prepareHttpCall(preparedStatementInformation);
Copy link
Author

Choose a reason for hiding this comment

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

A lot of this is just refactoring so others can extend. When I made my changes originally, I had to copy/paste source files to get it to work, so in case others want to extend more easily.

protected Object callUnderlyingMethod(Object underlying, Method method, Object[] args, PreparedStatementInformation preparedStatementInformation) {
Object actualResult = method.invoke(underlying, args);

if (recorder != null && actualResult instanceof ResultSet) {
Copy link
Author

Choose a reason for hiding this comment

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

Not recording anything for updates as didn't have the use case

final List<String> colNames;
final Map<String, String> namedValues;
final String[] positionalValues;
final Map<String, Object> namedValues;
Copy link
Author

Choose a reason for hiding this comment

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

Needed to migrate to Object type, but this doesn't change the behaviour for Strings

}
else {
String type = col.getAttributeValue("type", nsXsi);
if (type != null) {
Copy link
Author

Choose a reason for hiding this comment

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

This behaviour is on by default, which seems safe since it will only happen if xs:type is in the xml.

private int statementInTest = 0;

@SneakyThrows
protected String getSybaseXMLFromDBResult(ResultSet resultSet) {
Copy link
Author

Choose a reason for hiding this comment

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

Fairly hacky, but just wanted something that works. Probably can make it a ton easier to read the files, but will leave that for a later exercise (if ever)

}

@SneakyThrows
public void writeOutMapping(JdbcServiceVirtualizationFactory.PreparedStatementInformation preparedStatementInformation, ResultSet resultSet) {
Copy link
Author

Choose a reason for hiding this comment

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

Some terrible and lazy templating, but I didn't want to bring in a dependency or anything. I expect others using this functionality will want to roll their own from scratch anyway.

public class XmlTypeRegistry {

private static final List<XmlTypeInfo<?>> DEFAULT_TYPES = new ArrayList<>();
static {
Copy link
Author

Choose a reason for hiding this comment

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

I just added the ones we were using for now. It's easy to extend when using, but it would also be easy to add more defaults if someone were so inclined.

.orElse(null);
}

public Object parseValue(String xmlType, String val) {
Copy link
Author

Choose a reason for hiding this comment

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

There are probably XML libraries for this, but I just went super simple.

@thymepuns
Copy link
Author

Hi @eeichinger can I get a review on this?

@eeichinger
Copy link
Owner

Hi @eeichinger can I get a review on this?
my apologies, I will do my best to review on the weekend

@thymepuns
Copy link
Author

Hi @eeichinger , just another ping on this one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants