[ https://issues.apache.org/jira/browse/TUSCANY-1505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David T. Adcox updated TUSCANY-1505: ------------------------------------ Attachment: 1505.patch This attachment corrects the primary issues identified by this JIRA and it also addresses the cyclic dependency issue cited in this JIRA's comments. Three changes were made: 1) Frank's assertion was correct, the offending generated code was no longer needed under the new codegen pattern. The reason those calls were made was somewhat historical. Since the dependent packages are initialized in the initializeMetaData(), there is no reason to initialize them in the init() method. The template was changed to remove the dependent package initializations in the init() method. Frank's concern of cyclic dependencies was valid. There were two issues I found in test this scenario. First I found that the calls made to dependent package interfaces to get the INSTANCE values were returning null. This was due to the fact that the call from Package 'A' to get an instance of Package 'B' would cause Package 'B' to try and get an instance of Package 'A'. Since this was occurring during a static member initialization, Java was returning a null. The second issue was a recursive problem where the factory register method was recursively being called A->B->A->B... So, I've addressed these issues as follows: 2) Instead using the package factory INSTANCE member to get an instance of the dependent factory, I'm calling the impl.init() method directly. The INSTANCE member initializes to the same method, but as cited above, this causes problems in a cyclic situation. 3) I've placed a guard in the factory.register() method to protect against recursion. > Naming scheme used for variables in code gen factory init() method breaks > under specific circumstances > ------------------------------------------------------------------------------------------------------ > > Key: TUSCANY-1505 > URL: https://issues.apache.org/jira/browse/TUSCANY-1505 > Project: Tuscany > Issue Type: Bug > Components: Java SDO Tools > Affects Versions: Java-SDO-1.0 > Environment: n/a > Reporter: David T. Adcox > Priority: Minor > Fix For: Java-SDO-Next > > Attachments: 1505.patch, test1505.zip > > > A new code gen pattern was recently added to change how dependent packages > are initialized in the xxxFactoryImpl.init() method. Under this new pattern, > all dependent packages are initialized via the factoryInterface.INSTANCE > method. An initialization call is made for each dependent gen package. The > getImportedFactoryInterfaceName() is used to retrieve the short name. This > value is mashed with the text 'Instnace' to form a variable name. If > circumstances dictate that multiple packages contain the same factory > interface name, the getImportedFactoryInterfaceName() will fully qualify the > response instead of using the short name. This breaks the generated code, > due to the use of a '.' in the variable name. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]