Package org.uberfire.annotations.processors.exceptions

Examples of org.uberfire.annotations.processors.exceptions.GenerationException


        if ( element.getAnnotation( annotation ) != null ) {
            try {
                Method identifier = annotation.getDeclaredMethod( methodName );
                annotations = (Annotation[]) identifier.invoke( element.getAnnotation( annotation ) );
            } catch ( Exception e ) {
                throw new GenerationException( e.getMessage(), e.getCause() );
            }
        }
        return annotations;
    }
View Full Code Here


                    }
                }
            }
            return identifierValue;
        } catch ( Exception e ) {
            throw new GenerationException( e.getMessage(), e.getCause() );
        }
    }
View Full Code Here

        logger.debug( "rolesList: " + rolesList );

        //Validate onStartup0ParameterMethodName and onStartup1ParameterMethodName
        if ( onStartup0ParameterMethodName != null && onStartup1ParameterMethodName != null ) {
            final String msg = "Found multiple @OnStartup methods. Each class can declare at most one.";
            throw new GenerationException( msg );
        }

        //Validate getPerspectiveMethodName
        if ( getPerspectiveMethodName == null && !isTemplate ) {
            throw new GenerationException( "The WorkbenchPerspective must provide a @Perspective annotated method to return a org.uberfire.client.workbench.model.PerspectiveDefinition.", packageName + "." + className );
        }

        if ( isDefault ) {
            warningIfMoreThanOneDefaultPerspective( processingEnvironment, identifier );
        }

        //Setup data for template sub-system
        Map<String, Object> root = new HashMap<String, Object>();
        root.put( "packageName",
                  packageName );
        root.put( "className",
                  className );
        root.put( "identifier",
                  identifier );
        root.put( "isTemplate", isTemplate );
        root.put( "isDefault",
                  isDefault );
        root.put( "realClassName",
                  classElement.getSimpleName().toString() );
        root.put( "onStartup0ParameterMethodName",
                  onStartup0ParameterMethodName );
        root.put( "onStartup1ParameterMethodName",
                  onStartup1ParameterMethodName );
        root.put( "onCloseMethodName",
                  onCloseMethodName );
        root.put( "onShutdownMethodName",
                  onShutdownMethodName );
        root.put( "onOpenMethodName",
                  onOpenMethodName );
        root.put( "getPerspectiveMethodName",
                  getPerspectiveMethodName );
        root.put( "getMenuBarMethodName",
                  getMenuBarMethodName );
        root.put( "getToolBarMethodName",
                  getToolBarMethodName );
        root.put( "securityTraitList",
                  securityTraitList );
        root.put( "rolesList",
                  rolesList );

        if ( isTemplate ) {
            setupTemplateElements( root, classElement );
        }

        //Generate code
        final StringWriter sw = new StringWriter();
        final BufferedWriter bw = new BufferedWriter( sw );
        try {
            final Template template = config.getTemplate( "perspective.ftl" );
            template.process( root,
                              bw );
        } catch ( IOException ioe ) {
            throw new GenerationException( ioe );
        } catch ( TemplateException te ) {
            throw new GenerationException( te );
        } finally {
            try {
                bw.close();
                sw.close();
            } catch ( IOException ioe ) {
                throw new GenerationException( ioe );
            }
        }
        logger.debug( "Successfully generated code for [" + className + "]" );

        return sw.getBuffer();
View Full Code Here

TOP

Related Classes of org.uberfire.annotations.processors.exceptions.GenerationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.