Hi,
Below is what I got so far when trying to migrate RDB DAS to use new SDO
APIs.
Please see if there are some gaps in the findings and give any suggestions.

Looks like, so far GeneratedCommandsTest.testReadCustomersStaticTypes() was
succeeding at the mercy of SimplestStaticCrud.testRead() preceding it in
sequential
execution. If we run GeneratedCommandsTest.testReadCustomersStaticTypes()
alone,
it fails with -

java.lang.RuntimeException: SDO Types have not been registered for URI
http:///org.apache.tuscany.das.rdb.test/customer.xsd
   at
org.apache.tuscany.das.rdb.graphbuilder.impl.GraphBuilderMetadata.createDynamicRoot
(GraphBuilderMetadata.java:225)
   at
org.apache.tuscany.das.rdb.graphbuilder.impl.GraphBuilderMetadata.getRootType
(GraphBuilderMetadata.java:93)
   at org.apache.tuscany.das.rdb.impl.ReadCommandImpl.buildGraph(
ReadCommandImpl.java:88)
   at org.apache.tuscany.das.rdb.impl.ReadCommandImpl.executeQuery(
ReadCommandImpl.java:63)
   at
org.apache.tuscany.das.rdb.test.GeneratedCommandTests.testReadCustomersStaticTypes
(GeneratedCommandTests.java:69)
   ...

This is because, when GeneratedCommandsTest.testReadCustomersStaticTypes()
is run alone, there is
no code which registers Customer Type in SDO. When ran in sequence, as
SimplestStaticCrud.testRead()
already does SDOUtil.registerStaticTypes(CustomerFactory.class) and as it
happens in the global
context, GeneratedCommandsTest.testReadCustomersStaticTypes() was able to
find Type Customer
and was completing with success.

Further, SDOUtil.registerStaticTypes(CustomerFactory.class) is deprecated
and in RDB DAS
{...ConfigUtil similar code is already replaced with
       HelperContext context = HelperProvider.getDefaultContext();
       ConfigFactory.INSTANCE.register(context);...}

So, on similar lines, we can add
       HelperContext context = HelperProvider.getDefaultContext();
       CustomerFactory.INSTANCE.register(context);
to static {} block of ReadCustomersStaticTypesCommand to ensure that this
test case succeeds
on its own. Also, as this change is using the newly introduced way of using
SDO APIs, this
needs to go "hand in hand" with the other RDB DAS changes for removing
deprecated use of SDO
APIs.

This is because, the below (deprecated)line from GraphBuilderMetaData,
 List types = SDOUtil.getTypes(typeHelper, typeURI);
is able to detect the Types registered using
(deprecated)SDOUtil.registerStaticTypes() (which goes in
EPackage.Registry.INSTANCE).
But it can not detect Types registered using
       HelperContext context = HelperProvider.getDefaultContext();
       CustomerFactory.INSTANCE.register(context);

I am lost here a bit...why can't it detect?

Regards,
Amita

Reply via email to