[
https://issues.apache.org/jira/browse/TUSCANY-1505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526536
]
Frank Budinsky commented on TUSCANY-1505:
-----------------------------------------
The way the register method is using a boolean to guard against cycles is no
good:
private boolean registered = false;
public void register(HelperContext scope)
{
if( registered ) return; else registered = true;
if(scope == null) {
throw new IllegalArgumentException("Scope can not be null");
}
//Register dependent packages with provided scope
ModelFactory.INSTANCE.register(scope);
tuscany.jira.test1505.base.base.BaseFactory.INSTANCE.register(scope);
// Initialize this package
TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
}
The problem is that it needs to check if the model is already registered in the
given scope, but this is checking if it's been registered in any scope.
Here is how I suggest the method should be generated:
public void register(HelperContext scope)
{
if (scope == null) throw new IllegalArgumentException("Scope can not be
null");
TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
if (th.getExtendedMetaData().getPackage(NAMESPACE_URI) != null) return;
th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
//Register dependent packages with provided scope
ModelFactory.INSTANCE.register(scope);
tuscany.jira.test1505.base.base.BaseFactory.INSTANCE.register(scope);
}
> 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]