Package org.apache.myfaces.config.impl.digester.elements

Examples of org.apache.myfaces.config.impl.digester.elements.FacesConfig


        configureClasses(application, dispenser, map);
    }*/
   
    protected FacesConfig createFacesConfig(Map< Class<? extends Annotation>, Set<Class<?>> > map)
    {
        FacesConfig facesConfig = new FacesConfig();
       
        Set<Class<?>> classes = map.get(FacesComponent.class);
       
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesComponent comp = (FacesComponent) clazz
                        .getAnnotation(FacesComponent.class);
                if (comp != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addComponent(" + comp.value() + ","
                                + clazz.getName() + ")");
                    }
                   
                    facesConfig.addComponent(comp.value(), clazz.getName());
                }
            }
        }
       
        classes = map.get(FacesConverter.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesConverter conv = (FacesConverter) clazz
                        .getAnnotation(FacesConverter.class);
                if (conv != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addConverter(" + conv.value() + ","
                                + clazz.getName() + ")");
                    }
                    //If there is a previous entry on Application Configuration Resources,
                    //the entry there takes precedence
                    if (!Object.class.equals(conv.forClass()))
                    {
                        Converter converter = new Converter();
                        converter.setForClass(conv.forClass().getName());
                        converter.setConverterClass(clazz.getName());
                        facesConfig.addConverter(converter);
                    }
                    else
                    {
                        Converter converter = new Converter();
                        converter.setConverterId(conv.value());
                        converter.setConverterClass(clazz.getName());
                        facesConfig.addConverter(converter);
                    }
                }               
            }
        }
       
        classes = map.get(FacesValidator.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesValidator val = (FacesValidator) clazz
                .getAnnotation(FacesValidator.class);
                if (val != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addValidator(" + val.value() + "," + clazz.getName()
                                + ")");
                    }
                    facesConfig.addValidator(val.value(), clazz.getName());
                }
            }
        }

        classes = map.get(FacesRenderer.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesRenderer rend = (FacesRenderer) clazz
                .getAnnotation(FacesRenderer.class);
                if (rend != null)
                {
                    String renderKitId = rend.renderKitId();
                    if (renderKitId == null)
                    {
                        renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
                    }
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addRenderer(" + renderKitId + ", "
                                + rend.componentFamily() + ", " + rend.rendererType()
                                + ", " + clazz.getName() + ")");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
                       (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                    if (renderKit == null)
                    {
                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
                        facesConfig.addRenderKit(renderKit);
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.Renderer renderer =
                        new org.apache.myfaces.config.impl.digester.elements.Renderer();
                    renderer.setComponentFamily(rend.componentFamily());
                    renderer.setRendererClass(clazz.getName());
                    renderer.setRendererType(rend.rendererType());
                    renderKit.addRenderer(renderer);
                }       
            }
        }

        classes = map.get(ManagedBean.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                javax.faces.bean.ManagedBean bean =
                    (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
       
                if (bean != null)
                {
                    if (log.isLoggable(Level.FINE))
                    {
                        log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
                        new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
                    String beanName = bean.name();
                   
                    if ((beanName == null) || beanName.equals ("")) {
                        int index;
                       
                        // Missing name attribute algorithm: take the unqualified name and make the
                        // first character lowercase.
                       
                        beanName = clazz.getName();
                        index = beanName.lastIndexOf (".");
                       
                        if (index != -1) {
                            beanName = beanName.substring (index + 1);
                        }
                       
                        beanName = Character.toLowerCase (beanName.charAt (0)) +
                            beanName.substring (1);
                    }
                   
                    mbc.setName(beanName);
                    mbc.setEager(Boolean.toString(bean.eager()));
                    mbc.setBeanClass(clazz.getName());
                   
                    ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
                    if (appScoped != null)
                    {
                        mbc.setScope("application");
                    }
                   
                    else
                    {
                        NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
                        if (noneScoped != null)
                        {
                            mbc.setScope("none");
                        }
                       
                        else
                        {
                            RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
                            if (requestScoped != null)
                            {
                                mbc.setScope("request");
                            }
                           
                            else
                            {
                                SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
                                if (sessionScoped != null)
                                {
                                    mbc.setScope("session");
                                }
                               
                                else
                                {
                                    ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
                                    if (viewScoped != null)
                                    {
                                        mbc.setScope("view");
                                    }
                                   
                                    else {
                                        CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
                                        if (customScoped != null)
                                        {
                                            mbc.setScope(customScoped.value());
                                        }
                                       
                                        else
                                        {
                                            // No scope annotation means default of "request".
                                           
                                            mbc.setScope ("request");
                                        }
                                    }
                                }
                            }
                        }
                    }
                   
                    Field[] fields = fields(clazz);
                    for (Field field : fields)
                    {
                        if (log.isLoggable(Level.FINEST))
                        {
                            log.finest("  Scanning field '" + field.getName() + "'");
                        }
                        javax.faces.bean.ManagedProperty property = (javax.faces.bean.ManagedProperty) field
                                .getAnnotation(javax.faces.bean.ManagedProperty.class);
                        if (property != null)
                        {
                            if (log.isLoggable(Level.FINE))
                            {
                                log.fine("  Field '" + field.getName()
                                        + "' has a @ManagedProperty annotation");
                            }
                            org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
                                new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
                            String name = property.name();
                            if ((name == null) || "".equals(name))
                            {
                                name = field.getName();
                            }
                            mpc.setPropertyName(name);
                            mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
                            mpc.setValue(property.value());
                            mbc.addProperty(mpc);
                            continue;
                        }
                    }
                    facesConfig.addManagedBean(mbc);
                }       
            }
        }

        classes = map.get(NamedEvent.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation (NamedEvent.class);
       
                if (namedEvent != null) {
                    // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
                   
                    if (!ComponentSystemEvent.class.isAssignableFrom (clazz)) {
                        // Just log this.  We'll catch it later in the runtime.
                       
                        if (log.isLoggable(Level.WARNING)) {
                            log.warning (clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does " +
                                "not extend javax.faces.event.ComponentSystemEvent");
                        }
                    }
                    // Have to register @NamedEvent annotations with the NamedEventManager class since
                    // we need to get access to this info later and can't from the dispenser (it's not a
                    // singleton).
                    org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
                        new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
                    facesConfig.addNamedEvent(namedEventConfig);
                }
            }
        }
   
        classes = map.get(FacesBehavior.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation (FacesBehavior.class);
       
                if (facesBehavior != null) {
                    // Can only apply @FacesBehavior to Behavior implementors.
                   
                    if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom (clazz)) {
                        // Just log this.  We'll catch it later in the runtime.
                       
                        if (log.isLoggable(Level.WARNING)) {
                            log.warning (clazz.getName() + " is annotated with @javax.faces.component.behavior.FacesBehavior, " +
                                    "but does not implement javax.faces.component.behavior.Behavior");
                        }
                    }
                   
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest ("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
                    }
                   
                    Behavior behavior = new Behavior();
                    behavior.setBehaviorId(facesBehavior.value());
                    behavior.setBehaviorClass(clazz.getName());
                    facesConfig.addBehavior(behavior);
                }
               
            }
        }
   
        classes = map.get(FacesBehaviorRenderer.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesBehaviorRenderer facesBehaviorRenderer = (FacesBehaviorRenderer) clazz.getAnnotation (FacesBehaviorRenderer.class);
       
                if (facesBehaviorRenderer != null) {
                    String renderKitId = facesBehaviorRenderer.renderKitId();
                    //RenderKit renderKit;
                   
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest ("addClientBehaviorRenderer(" + renderKitId + ", " + facesBehaviorRenderer.rendererType() + ", " +
                             clazz.getName() + ")");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
                        (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                    if (renderKit == null)
                    {
                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
                        facesConfig.addRenderKit(renderKit);
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
                        new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
                    cbr.setRendererType(facesBehaviorRenderer.rendererType());
View Full Code Here


        configureClasses(application, dispenser, map);
    }*/
   
    protected FacesConfig createFacesConfig(Map< Class<? extends Annotation>, Set<Class<?>> > map)
    {
        FacesConfig facesConfig = new FacesConfig();
       
        Set<Class<?>> classes = map.get(FacesComponent.class);
       
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesComponent comp = (FacesComponent) clazz
                        .getAnnotation(FacesComponent.class);
                if (comp != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addComponent(" + comp.value() + ","
                                + clazz.getName() + ")");
                    }
                   
                    facesConfig.addComponent(comp.value(), clazz.getName());
                }
            }
        }
       
        classes = map.get(FacesConverter.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesConverter conv = (FacesConverter) clazz
                        .getAnnotation(FacesConverter.class);
                if (conv != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addConverter(" + conv.value() + ","
                                + clazz.getName() + ")");
                    }
                    //If there is a previous entry on Application Configuration Resources,
                    //the entry there takes precedence
                    boolean hasForClass = !Object.class.equals(conv.forClass());
                    boolean hasValue = conv.value().length() > 0;
                    if (hasForClass || hasValue)
                    {
                        Converter converter = new Converter();
                        if (hasForClass)
                        {
                            converter.setForClass(conv.forClass().getName());
                        }
                        if (hasValue) {
                            converter.setConverterId(conv.value());
                        }
                        converter.setConverterClass(clazz.getName());
                        facesConfig.addConverter(converter);
                    }
                    else
                    {  
                        // TODO MartinKoci MYFACES-3053
                        throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation @FacesConverter on class: "  + clazz.getName());
                    }
                }               
            }
        }
       
        classes = map.get(FacesValidator.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesValidator val = (FacesValidator) clazz
                .getAnnotation(FacesValidator.class);
                if (val != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addValidator(" + val.value() + "," + clazz.getName()
                                + ")");
                    }
                    facesConfig.addValidator(val.value(), clazz.getName());
                    if (val.isDefault())
                    {
                        Application app = null;
                        if(facesConfig.getApplications().isEmpty())
                        {
                            app = new Application();
                        }
                        else
                        {
                            app = (Application) facesConfig.getApplications().get(0);
                        }
                        app.addDefaultValidatorId(val.value());
                    }
                }
            }
        }

        classes = map.get(FacesRenderer.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesRenderer rend = (FacesRenderer) clazz
                .getAnnotation(FacesRenderer.class);
                if (rend != null)
                {
                    String renderKitId = rend.renderKitId();
                    if (renderKitId == null)
                    {
                        renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
                    }
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addRenderer(" + renderKitId + ", "
                                + rend.componentFamily() + ", " + rend.rendererType()
                                + ", " + clazz.getName() + ")");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
                       (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                    if (renderKit == null)
                    {
                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
                        facesConfig.addRenderKit(renderKit);
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.Renderer renderer =
                        new org.apache.myfaces.config.impl.digester.elements.Renderer();
                    renderer.setComponentFamily(rend.componentFamily());
                    renderer.setRendererClass(clazz.getName());
                    renderer.setRendererType(rend.rendererType());
                    renderKit.addRenderer(renderer);
                }       
            }
        }

        classes = map.get(ManagedBean.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                javax.faces.bean.ManagedBean bean =
                    (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
       
                if (bean != null)
                {
                    if (log.isLoggable(Level.FINE))
                    {
                        log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
                        new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
                    String beanName = bean.name();
                   
                    if ((beanName == null) || beanName.equals ("")) {
                        int index;
                       
                        // Missing name attribute algorithm: take the unqualified name and make the
                        // first character lowercase.
                       
                        beanName = clazz.getName();
                        index = beanName.lastIndexOf (".");
                       
                        if (index != -1) {
                            beanName = beanName.substring (index + 1);
                        }
                       
                        beanName = Character.toLowerCase (beanName.charAt (0)) +
                            beanName.substring (1);
                    }
                   
                    mbc.setName(beanName);
                    mbc.setEager(Boolean.toString(bean.eager()));
                    mbc.setBeanClass(clazz.getName());
                   
                    ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
                    if (appScoped != null)
                    {
                        mbc.setScope("application");
                    }
                   
                    else
                    {
                        NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
                        if (noneScoped != null)
                        {
                            mbc.setScope("none");
                        }
                       
                        else
                        {
                            RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
                            if (requestScoped != null)
                            {
                                mbc.setScope("request");
                            }
                           
                            else
                            {
                                SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
                                if (sessionScoped != null)
                                {
                                    mbc.setScope("session");
                                }
                               
                                else
                                {
                                    ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
                                    if (viewScoped != null)
                                    {
                                        mbc.setScope("view");
                                    }
                                   
                                    else {
                                        CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
                                        if (customScoped != null)
                                        {
                                            mbc.setScope(customScoped.value());
                                        }
                                       
                                        else
                                        {
                                            // No scope annotation means default of "request".
                                           
                                            mbc.setScope ("request");
                                        }
                                    }
                                }
                            }
                        }
                    }
                   
                    Field[] fields = fields(clazz);
                    for (Field field : fields)
                    {
                        if (log.isLoggable(Level.FINEST))
                        {
                            log.finest("  Scanning field '" + field.getName() + "'");
                        }
                        javax.faces.bean.ManagedProperty property = (javax.faces.bean.ManagedProperty) field
                                .getAnnotation(javax.faces.bean.ManagedProperty.class);
                        if (property != null)
                        {
                            if (log.isLoggable(Level.FINE))
                            {
                                log.fine("  Field '" + field.getName()
                                        + "' has a @ManagedProperty annotation");
                            }
                            org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
                                new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
                            String name = property.name();
                            if ((name == null) || "".equals(name))
                            {
                                name = field.getName();
                            }
                            mpc.setPropertyName(name);
                            mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
                            mpc.setValue(property.value());
                            mbc.addProperty(mpc);
                            continue;
                        }
                    }
                    facesConfig.addManagedBean(mbc);
                }       
            }
        }

        classes = map.get(NamedEvent.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation (NamedEvent.class);
       
                if (namedEvent != null) {
                    // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
                   
                    if (!ComponentSystemEvent.class.isAssignableFrom (clazz)) {
                        // Just log this.  We'll catch it later in the runtime.
                       
                        if (log.isLoggable(Level.WARNING)) {
                            log.warning (clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does " +
                                "not extend javax.faces.event.ComponentSystemEvent");
                        }
                    }
                    // Have to register @NamedEvent annotations with the NamedEventManager class since
                    // we need to get access to this info later and can't from the dispenser (it's not a
                    // singleton).
                    org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
                        new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
                    namedEventConfig.setEventClass(clazz.getName());
                    namedEventConfig.setShortName(namedEvent.shortName());
                    facesConfig.addNamedEvent(namedEventConfig);
                }
            }
        }
   
        classes = map.get(FacesBehavior.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation (FacesBehavior.class);
       
                if (facesBehavior != null) {
                    // Can only apply @FacesBehavior to Behavior implementors.
                   
                    if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom (clazz)) {
                        // Just log this.  We'll catch it later in the runtime.
                       
                        if (log.isLoggable(Level.WARNING)) {
                            log.warning (clazz.getName() + " is annotated with @javax.faces.component.behavior.FacesBehavior, " +
                                    "but does not implement javax.faces.component.behavior.Behavior");
                        }
                    }
                   
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest ("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
                    }
                   
                    Behavior behavior = new Behavior();
                    behavior.setBehaviorId(facesBehavior.value());
                    behavior.setBehaviorClass(clazz.getName());
                    facesConfig.addBehavior(behavior);
                }
               
            }
        }
   
        classes = map.get(FacesBehaviorRenderer.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesBehaviorRenderer facesBehaviorRenderer = (FacesBehaviorRenderer) clazz.getAnnotation (FacesBehaviorRenderer.class);
       
                if (facesBehaviorRenderer != null) {
                    String renderKitId = facesBehaviorRenderer.renderKitId();
                    //RenderKit renderKit;
                   
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest ("addClientBehaviorRenderer(" + renderKitId + ", " + facesBehaviorRenderer.rendererType() + ", " +
                             clazz.getName() + ")");
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
                        (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
                    if (renderKit == null)
                    {
                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
                        facesConfig.addRenderKit(renderKit);
                    }
                   
                    org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
                        new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
                    cbr.setRendererType(facesBehaviorRenderer.rendererType());
View Full Code Here

     * @param map
     * @return
     */
    protected FacesConfig createFacesConfig(Map<Class<? extends Annotation>, Set<Class<?>>> map)
    {
        FacesConfig facesConfig = new FacesConfig();

        Set<Class<?>> classes = map.get(FacesComponent.class);

        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesComponent comp = (FacesComponent) clazz
                        .getAnnotation(FacesComponent.class);
                if (comp != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addComponent(" + comp.value() + ","
                                + clazz.getName() + ")");
                    }

                    facesConfig.addComponent(comp.value(), clazz.getName());
                }
            }
        }

        classes = map.get(FacesConverter.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesConverter conv = (FacesConverter) clazz
                        .getAnnotation(FacesConverter.class);
                if (conv != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addConverter(" + conv.value() + ","
                                + clazz.getName() + ")");
                    }
                    //If there is a previous entry on Application Configuration Resources,
                    //the entry there takes precedence
                    boolean hasForClass = !Object.class.equals(conv.forClass());
                    boolean hasValue = conv.value().length() > 0;
                    if (hasForClass || hasValue)
                    {
                        Converter converter = new Converter();
                        if (hasForClass)
                        {
                            converter.setForClass(conv.forClass().getName());
                        }
                        if (hasValue)
                        {
                            converter.setConverterId(conv.value());
                        }
                        converter.setConverterClass(clazz.getName());
                        facesConfig.addConverter(converter);
                    }
                    else
                    {
                        // TODO MartinKoci MYFACES-3053
                        throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation "
                                                 + "@FacesConverter on class: " + clazz.getName());
                    }
                }
            }
        }

        classes = map.get(FacesValidator.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesValidator val = (FacesValidator) clazz
                        .getAnnotation(FacesValidator.class);
                if (val != null)
                {
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addValidator(" + val.value() + "," + clazz.getName()
                                + ")");
                    }
                    facesConfig.addValidator(val.value(), clazz.getName());
                    if (val.isDefault())
                    {
                        Application app = null;
                        if (facesConfig.getApplications().isEmpty())
                        {
                            app = new Application();
                        }
                        else
                        {
                            app = (Application) facesConfig.getApplications().get(0);
                        }
                        app.addDefaultValidatorId(val.value());
                    }
                }
            }
        }

        classes = map.get(FacesRenderer.class);
        if (classes != null && !classes.isEmpty())
        {
            for (Class<?> clazz : classes)
            {
                FacesRenderer rend = (FacesRenderer) clazz
                        .getAnnotation(FacesRenderer.class);
                if (rend != null)
                {
                    String renderKitId = rend.renderKitId();
                    if (renderKitId == null)
                    {
                        renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
                    }
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("addRenderer(" + renderKitId + ", "
                                + rend.componentFamily() + ", " + rend.rendererType()
                                + ", " + clazz.getName() + ")");
                    }

                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
                            (org.apache.myfaces.config.impl.digester.elements.RenderKit)
                                    facesConfig.getRenderKit(renderKitId);
                    if (renderKit == null)
                    {
                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
                        renderKit.setId(renderKitId);
                        facesConfig.addRenderKit(renderKit);
                    }

                    org.apache.myfaces.config.impl.digester.elements.Renderer renderer =
                            new org.apache.myfaces.config.impl.digester.elements.Renderer();
                    renderer.setComponentFamily(rend.componentFamily());
View Full Code Here

    {
        InputSource is = new InputSource(in);
        is.setSystemId(systemId);

        //Fix for http://issues.apache.org/jira/browse/MYFACES-236
        FacesConfig config = (FacesConfig) digester.parse(is);

        List li =config.getApplications();

        for (int i = 0; i < li.size(); i++)
        {
            Application application = (Application) li.get(i);
            List localeList = application.getLocaleConfig();
View Full Code Here

     *
     * @throws Exception
     */
    public void testSimpleOrdering() throws Exception
    {
        FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream(
        "empty-config.xml"), "empty-config.xml");
        FacesConfig cfgA = _impl.getFacesConfig(getClass().getResourceAsStream(
            "a-config.xml"), "a-config.xml");
        FacesConfig cfgB = _impl.getFacesConfig(getClass().getResourceAsStream(
            "b-config.xml"), "b-config.xml");
        FacesConfig cfgC = _impl.getFacesConfig(getClass().getResourceAsStream(
            "c-config.xml"), "c-config.xml");
       
       
        List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
        appConfigResources.add(cfgA);
View Full Code Here

     *
     * @throws Exception
     */
    public void testMiddleOrdering() throws Exception
    {
        FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream(
        "empty-config.xml"), "empty-config.xml");       
        FacesConfig cfgA = new FacesConfig();
        FacesConfig cfgB = new FacesConfig();
        FacesConfig cfgC = new FacesConfig();
        FacesConfig cfgD = new FacesConfig();
        FacesConfig cfgE = new FacesConfig();
       
        cfgA.setName("A");
        cfgB.setName("B");
        cfgC.setName("C");
        cfgD.setName("D");
        cfgE.setName("E");
       
        cfgC.setOrdering(new Ordering());
        FacesConfigNameSlot temp = new FacesConfigNameSlot();
        temp.setName("D");
        cfgC.getOrdering().getBeforeList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("E");
        cfgC.getOrdering().getBeforeList().add(temp);       
        temp = new FacesConfigNameSlot();
        temp.setName("A");
        cfgC.getOrdering().getAfterList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgC.getOrdering().getAfterList().add(temp);
       
        cfgA.setOrdering(new Ordering());
        temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgA.getOrdering().getBeforeList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("E");
        cfgA.getOrdering().getBeforeList().add(temp);
       
        cfgE.setOrdering(new Ordering());
        temp = new FacesConfigNameSlot();
        temp.setName("D");
        cfgE.getOrdering().getAfterList().add(temp);
       
        cfgD.setOrdering(new Ordering());
        cfgD.getOrdering().getBeforeList().add(new ConfigOthersSlot());
       
        List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
View Full Code Here

     *
     * @throws Exception
     */
    public void testMaxConditionsOrdering() throws Exception
    {
        FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream(
        "empty-config.xml"), "empty-config.xml");       
        FacesConfig cfgA = new FacesConfig();
        FacesConfig cfgB = new FacesConfig();
        FacesConfig cfgC = new FacesConfig();

        cfgA.setName("A");
        cfgB.setName("B");
        cfgC.setName("C");
       
        cfgA.setOrdering(new Ordering());
        FacesConfigNameSlot temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgA.getOrdering().getBeforeList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("C");
        cfgA.getOrdering().getBeforeList().add(temp);
       
        cfgB.setOrdering(new Ordering());
        temp = new FacesConfigNameSlot();
        temp.setName("A");
        cfgB.getOrdering().getAfterList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("C");
        cfgB.getOrdering().getBeforeList().add(temp);
       
        cfgC.setOrdering(new Ordering());
        temp = new FacesConfigNameSlot();
        temp.setName("A");
        cfgC.getOrdering().getAfterList().add(temp);
        temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgC.getOrdering().getAfterList().add(temp);
        //cfgC.getOrdering().getBeforeList().add(new ConfigOthersSlot());
       
        List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
        appConfigResources.add(cfgC);
        appConfigResources.add(cfgA);
View Full Code Here

        }
    }
   
    public void testEx1()
    {     
        FacesConfig cfgA = new FacesConfig();
        FacesConfig cfgB = new FacesConfig();
        FacesConfig cfgC = new FacesConfig();
        FacesConfig cfgD = new FacesConfig();
        FacesConfig cfgE = new FacesConfig();
        FacesConfig cfgF = new FacesConfig();

        cfgA.setName("A");
        cfgB.setName("B");
        cfgC.setName("C");
        cfgD.setName("D");
        cfgE.setName("E");
        cfgF.setName("F");
       
        cfgA.setOrdering(new Ordering());
        cfgA.getOrdering().getAfterList().add(new ConfigOthersSlot());
        FacesConfigNameSlot temp = new FacesConfigNameSlot();
        temp.setName("C");
        cfgA.getOrdering().getAfterList().add(temp);
       
        cfgB.setOrdering(new Ordering());
        cfgB.getOrdering().getBeforeList().add(new ConfigOthersSlot());

        cfgC.setOrdering(new Ordering());
        cfgC.getOrdering().getAfterList().add(new ConfigOthersSlot());

        cfgF.setOrdering(new Ordering());
        cfgF.getOrdering().getBeforeList().add(new ConfigOthersSlot());
        temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgF.getOrdering().getBeforeList().add(temp);
       
       
        List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
        appConfigResources.add(cfgA);
        appConfigResources.add(cfgB);
View Full Code Here

        }
    }
   
    public void testEx2()
    {
        FacesConfig cfg = new FacesConfig();
        FacesConfig cfgB = new FacesConfig();
        FacesConfig cfgC = new FacesConfig();
        FacesConfig cfgD = new FacesConfig();
        FacesConfig cfgE = new FacesConfig();
        FacesConfig cfgF = new FacesConfig();

        cfgB.setName("B");
        cfgC.setName("C");
        cfgD.setName("D");
        cfgE.setName("E");
        cfgF.setName("F");
       
        cfg.setOrdering(new Ordering());
        cfg.getOrdering().getAfterList().add(new ConfigOthersSlot());
        FacesConfigNameSlot temp = new FacesConfigNameSlot();
        temp.setName("C");
View Full Code Here

        }
    }
   
    public void testEx3()
    {
        FacesConfig cfgA = new FacesConfig();
        FacesConfig cfgB = new FacesConfig();
        FacesConfig cfgC = new FacesConfig();
        FacesConfig cfgD = new FacesConfig();

        cfgA.setName("A");
        cfgB.setName("B");
        cfgC.setName("C");
        cfgD.setName("D");

        cfgA.setOrdering(new Ordering());
        FacesConfigNameSlot temp = new FacesConfigNameSlot();
        temp.setName("B");
        cfgA.getOrdering().getAfterList().add(temp);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.config.impl.digester.elements.FacesConfig

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.