Ara,
looks good to me, couple of comments though:
why use method.name().startsWith("ejbCreate")? We can just use equals
yes?
Do we really need to check the return type? If the method name is
"ejbCreate" then we can assume its a create method, I think all we need to
check is the method name and parameters I think... we're not a validator
right? All we do is generate code, we obviously need to validate the
input _we_ require, but I think we can make assumptions about the
spec-compliance. for instance, if someone mis-types a return type, and
sits there wondering why the bean isn't picked up as stateless, it might
seem a bit odd, where as if we generate bad stuff based on bad input, they
will get a more understandable error further on...
its good tho - I like the whole "smart defaults" philosophy (o:
cheers
dim
On Thu, 1 Nov 2001, Ara Abrahamian wrote:
> I'm spending some time on defaults, specifically classname as default
> for ejbName, smart stateless/stateful guesses and so on.
>
> Remember our debate on create-method and your problem with ejbCreateImpl
> method in a base TopLink class?
> I think we really can get rid of create-method! Here is a new algorithm
> for finding out if current class is stateless or not:
>
> public boolean isStatelessSession( ClassDoc clazz )
> {
> if( isSession( clazz ) == false )
> {
> return false;
> }
>
> String value = getParameterValue( DocletUtil.getText(
> getCurrentClass(), "ejb:bean" ), "type", -1 );
>
> if( value != null )
> {
> if( value.equals( "Stateless" ) )
> return true;
> else
> return false;
> }
> else
> {
> //now try to guess
>
> //it's stateful if it implements SessionSynchronization
> if( TypeTagsHandler.isOfType( clazz,
> "javax.ejb.SessionSynchronization", TypeTagsHandler.TYPE_HIERARCHY ) )
> return false;
>
> //it's stateful if it has create methods with parameters,
> //stateless if has a single ejbCreate() method with no args
> //and returning intf type and there's no other ejbCreate
> method
> MethodDoc[] methods = clazz.methods();
> boolean has_empty_create_method = false;
> boolean has_other_create_methods = false;
>
> for( int i = 0; i < methods.length; i++ )
> {
> MethodDoc method = methods[i];
>
> //if an empty create method
> if( method.name().equals( "ejbCreate" ) &&
> method.parameters().length==0 )
> {
> has_empty_create_method = true;
> }
> else if( method.name().startsWith( "ejbCreate" ) &&
> method.parameters().length>0 &&
> (InterfaceTagsHandler.getComponentInterface(
> "remote", getCurrentClass(), getDocletContext()
> ).equals(method.returnType().qualifiedTypeName() ) ||
> InterfaceTagsHandler.getComponentInterface(
> "local", getCurrentClass(), getDocletContext()
> ).equals(method.returnType().qualifiedTypeName() ) )
> )
> {
> has_other_create_methods = true;
> }
> }
>
> if( has_empty_create_method == true && has_other_create_methods
> == false )
> return true;
> else
> return false;
> }
> }
>
> The line that needs your approval is the for loop. Look at the comment
> above it. I don't think it will break your code, will it? I'm planning
> to move it to isCreateMethod().
>
> Ara.
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> _______________________________________________
> Xdoclet-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
>
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel