org.apache.deltaspike.core.api.config.view.ViewConfig Java Examples

The following examples show how to use org.apache.deltaspike.core.api.config.view.ViewConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewConfigReloader.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
private static void doAddPageDefinition(ClassLoader classLoader, ViewConfigExtension viewConfigExtension, Class<?> viewConfigClass) {
    if (ViewConfigUtils.isFolderConfig(viewConfigClass)) {
        viewConfigExtension.addFolderDefinition(viewConfigClass);
    } else if (ViewConfig.class.isAssignableFrom(viewConfigClass)){
        viewConfigExtension.addPageDefinition((Class<? extends ViewConfig>) viewConfigClass);
    }
    for (Class<?> subClass: viewConfigClass.getDeclaredClasses()) {
        Class<?> reloadedSubclass;
        try {
            reloadedSubclass = Class.forName(subClass.getName(), true, classLoader);
            if (reloadedSubclass != null) {
                doAddPageDefinition(classLoader, viewConfigExtension, reloadedSubclass);
            }
        } catch (ClassNotFoundException e) {
            LOGGER.debug("ViewConfig subclass '{}' removed", subClass.getName());
        }
    }
}
 
Example #2
Source File: SecurityUtils.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private static void processApplicationSecurityException(AccessDeniedException exception,
                                                        Class<? extends ViewConfig> errorView,
                                                        boolean allowNavigation)
{
    SecurityViolationHandler securityViolationHandler =
            BeanProvider.getContextualReference(SecurityViolationHandler.class, true);

    if (securityViolationHandler != null)
    {
        //optional (custom handler) - allows to handle custom implementations of SecurityViolation
        securityViolationHandler.processSecurityViolations(exception.getViolations());
    }
    else
    {
        addViolationsAsMessage(exception.getViolations());
    }

    if (allowNavigation)
    {
        BeanProvider.getContextualReference(ViewNavigationHandler.class).navigateTo(errorView);
    }
}
 
Example #3
Source File: DefaultViewConfigResolver.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Override
public ConfigDescriptor<?> getConfigDescriptor(Class configClass)
{
    ConfigDescriptor result = null;
    if (ViewConfig.class.isAssignableFrom(configClass))
    {
        result = getViewConfigDescriptor(configClass);
    }

    if (result == null)
    {
        result = this.folderDefinitionToViewDefinitionEntryMapping.get(configClass);
    }

    return result;
}
 
Example #4
Source File: ViewConfigExtension.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
protected void buildViewConfigMetaDataTreeFor(Class beanClass,
                                              Set<Annotation> annotations,
                                              VetoCallback vetoCallback)
{
    if (ViewConfig.class.isAssignableFrom(beanClass))
    {
        addConfigClass(beanClass, annotations);
        vetoCallback.veto();
    }
    else
    {
        if (ViewConfigUtils.isFolderConfig(beanClass) && beanClass.isAnnotationPresent(Folder.class))
        {
            addConfigClass(beanClass, annotations);
            vetoCallback.veto();
        }
        else
        {
            addIndirectlyInheritedMetaData(beanClass, annotations);
        }
    }
}
 
Example #5
Source File: ViewConfigExtension.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private ViewConfigNode addNode(ViewConfigNode parentNode, Class idOfNewNode, Set<Annotation> viewConfigAnnotations)
{
    if (parentNode == null)
    {
        parentNode = this.rootViewConfigNode;
    }

    ViewConfigNode viewConfigNode;

    if (ViewConfigUtils.isFolderConfig(idOfNewNode))
    {
        viewConfigNode = new FolderConfigNode(idOfNewNode, parentNode, viewConfigAnnotations);
    }
    else
    {
        viewConfigNode = new PageViewConfigNode(
                (Class<? extends ViewConfig>) idOfNewNode, parentNode, viewConfigAnnotations);
    }

    parentNode.getChildren().add(viewConfigNode);
    return viewConfigNode;
}
 
Example #6
Source File: PageBean004.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    currentValue++;

    if (currentValue >= 0)
    {
        this.navigationParameterContext.addPageParameter("cv", this.currentValue);
    }
    return SimplePageConfig.class;
}
 
Example #7
Source File: PageBean002.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@NavigationParameter.List({
        @NavigationParameter(key = "param1", value = "staticMarker1"),
        @NavigationParameter(key = "param2", value = "staticMarker2")
})
public Class<? extends ViewConfig> actionMethod2()
{
    return SimplePageConfig.class;
}
 
Example #8
Source File: SecurityUtils.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private static void tryToHandleSecurityViolation(RuntimeException runtimeException,
                                                 boolean allowNavigation)
{
    ErrorViewAwareAccessDeniedException exception = extractException(runtimeException);

    if (exception == null)
    {
        throw runtimeException;
    }

    Class<? extends ViewConfig> errorView = null;

    Class<? extends ViewConfig> inlineErrorView = exception.getErrorView();

    if (inlineErrorView != null && !DefaultErrorView.class.getName().equals(inlineErrorView.getName()))
    {
        errorView = inlineErrorView;
    }

    if (errorView == null)
    {
        ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
        ViewConfigDescriptor errorPageDescriptor = viewConfigResolver.getDefaultErrorViewConfigDescriptor();

        if (errorPageDescriptor != null)
        {
            errorView = errorPageDescriptor.getConfigClass();
        }
    }

    if (errorView == null && allowNavigation)
    {
        throw exception;
    }

    processApplicationSecurityException(exception, errorView, allowNavigation);
}
 
Example #9
Source File: ViewConfigUtils.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public static boolean isFolderConfig(Class configClass)
{
    return configClass != null && (
            (ViewConfig.class.isAssignableFrom(configClass) &&
                    Modifier.isAbstract(configClass.getModifiers()) ||
                    Modifier.isInterface(configClass.getModifiers())
            ) ||
            configClass.isAnnotationPresent(Folder.class));
}
 
Example #10
Source File: DefaultConfigNodeConverter.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public ConfigDescriptor convert(ViewConfigNode node)
{
    List<Annotation> mergedMetaData = mergeMetaData(node.getMetaData(), node.getInheritedMetaData());
    //e.g. replace default placeholders needed for the merge with real default values
    mergedMetaData = preProcessMetaData(mergedMetaData, node);

    Class sourceClass = node.getSource();

    if (ViewConfigUtils.isFolderConfig(sourceClass))
    {
        Folder folderAnnotation = findMetaDataByType(mergedMetaData, Folder.class);
        return new DefaultFolderConfigDescriptor(folderAnnotation.name(), node.getSource(),
                mergedMetaData, node.getCallbackDescriptors());
    }
    else if (ViewConfig.class.isAssignableFrom(sourceClass))
    {
        View viewAnnotation = findMetaDataByType(mergedMetaData, View.class);
        String viewId = viewAnnotation.basePath() + viewAnnotation.name() + "." + viewAnnotation.extension();
        return new DefaultViewPathConfigDescriptor(viewId, (Class<? extends ViewConfig>) node.getSource(),
                filterInheritedFolderMetaData(mergedMetaData), node.getCallbackDescriptors());
    }
    else
    {
        throw new IllegalStateException(node.getSource() + " isn't a valid view-config");
    }
}
 
Example #11
Source File: DefaultViewPathConfigDescriptor.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
DefaultViewPathConfigDescriptor(String viewId,
                                Class<? extends ViewConfig> configClass,
                                List<Annotation> mergedMetaData,
                                Map<Class<? extends Annotation>, List<CallbackDescriptor>> callbackDescriptors)
{
    super(configClass, mergedMetaData, callbackDescriptors);
    this.viewId = viewId;
}
 
Example #12
Source File: DefaultViewNavigationHandler.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public void navigateTo(Class<? extends ViewConfig> targetView)
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, targetView.getName());
    facesContext.renderResponse();
}
 
Example #13
Source File: DefaultViewConfigResolver.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public ViewConfigDescriptor getViewConfigDescriptor(Class<? extends ViewConfig> viewDefinitionClass)
{
    if (DefaultErrorView.class.equals(viewDefinitionClass))
    {
        return getDefaultErrorViewConfigDescriptor();
    }
    return this.viewDefinitionToViewDefinitionEntryMapping.get(viewDefinitionClass);
}
 
Example #14
Source File: PageBean004.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> item()
{
    return Pages.Public.Index.class;
}
 
Example #15
Source File: ViewConfigResolverProxy.java    From HotswapAgent with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ViewConfigDescriptor getViewConfigDescriptor(Class<? extends ViewConfig> viewDefinitionClass) {
    return viewConfigResolver.getViewConfigDescriptor(viewDefinitionClass);
}
 
Example #16
Source File: LoggedInAccessDecisionVoter.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> getDeniedPage()
{
    return deniedPage;
}
 
Example #17
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionWithoutError()
{
    return Pages.Overview.class;
}
 
Example #18
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionWithError()
{
    return DefaultErrorView.class;
}
 
Example #19
Source File: PageBean003.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    return Pages.Index.class;
}
 
Example #20
Source File: PageBean003.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod2()
{
    return Pages.Overview.class;
}
 
Example #21
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionWithoutError()
{
    return Pages.Overview.class;
}
 
Example #22
Source File: LoggedInAccessDecisionVoter.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> getDeniedPage()
{
    return deniedPage;
}
 
Example #23
Source File: PageBean004.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod2()
{
    return Pages.Overview.class;
}
 
Example #24
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionWithError()
{
    return DefaultErrorView.class;
}
 
Example #25
Source File: PageBean006.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    return Pages.Wizard1.Step1.class;
}
 
Example #26
Source File: PageBean001.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    return Pages.Index.class;
}
 
Example #27
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    return Pages.Index.class;
}
 
Example #28
Source File: PageBean004.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> actionMethod()
{
    return Pages.Index.class;
}
 
Example #29
Source File: PageBean003.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public Class<? extends ViewConfig> item()
{
    return Pages.Public.Item.class;
}
 
Example #30
Source File: PageBean002.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@NavigationParameter(key = "param1", value = "staticMarker")
public Class<? extends ViewConfig> actionMethod1()
{
    return SimplePageConfig.class;
}