use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigTest method testViewConfigCustomViewConfigPreProcessor.
@Test
public void testViewConfigCustomViewConfigPreProcessor() {
this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);
// changed by TestConfigPreProcessor
Assert.assertEquals("/test/view.custom", viewConfigDescriptor.getViewId());
Assert.assertEquals(View.ViewParameterMode.DEFAULT, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class DeltaSpikeFacesContextWrapper method init.
private synchronized void init() {
// switch into paranoia mode
if (this.initialized == null) {
this.beanManager = BeanManagerProvider.getInstance().getBeanManager();
this.jsfModuleConfig = BeanProvider.getContextualReference(this.beanManager, JsfModuleConfig.class, false);
if (ClassDeactivationUtils.isActivated(JsfRequestBroadcaster.class)) {
this.jsfRequestBroadcaster = BeanProvider.getContextualReference(JsfRequestBroadcaster.class, true);
}
ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
// deactivate it, if there is no default-error-view available
this.defaultErrorViewExceptionHandlerActivated = viewConfigResolver.getDefaultErrorViewConfigDescriptor() != null && ClassDeactivationUtils.isActivated(DefaultErrorViewAwareExceptionHandlerWrapper.class);
this.bridgeExceptionHandlerActivated = ClassDeactivationUtils.isActivated(BridgeExceptionHandlerWrapper.class);
this.bridgeExceptionQualifier = AnnotationInstanceProvider.of(jsfModuleConfig.getExceptionQualifier());
this.preDestroyViewMapEventFilterMode = ClassDeactivationUtils.isActivated(SecurityAwareViewHandler.class);
this.isNavigationAwareApplicationWrapperActivated = ClassDeactivationUtils.isActivated(NavigationHandlerAwareApplication.class);
org.apache.deltaspike.core.api.projectstage.ProjectStage dsProjectStage = ProjectStageProducer.getInstance().getProjectStage();
for (ProjectStage ps : ProjectStage.values()) {
if (ps.name().equals(dsProjectStage.getClass().getSimpleName())) {
this.projectStage = ps;
break;
}
}
if (this.projectStage == null && dsProjectStage instanceof TestStage) {
this.projectStage = ProjectStage.Development;
}
if (this.projectStage == ProjectStage.Production) {
// reset it to force the delegation to the default handling
this.projectStage = null;
}
this.initialized = true;
}
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class DeltaSpikeNavigationHandler method getNavigationCase.
@Override
public NavigationCase getNavigationCase(FacesContext context, String action, String outcome) {
if (this.wrapped instanceof ConfigurableNavigationHandler) {
if (!this.activated) {
return ((ConfigurableNavigationHandler) this.wrapped).getNavigationCase(context, action, outcome);
}
if (action == null && outcome != null && outcome.contains(".") && outcome.startsWith("class ") && !otherOutcomes.contains(outcome)) {
String originalOutcome = outcome;
NavigationCase navigationCase = this.viewConfigBasedNavigationCaseCache.get(originalOutcome);
if (navigationCase != null) {
return navigationCase;
}
outcome = outcome.substring(6);
ViewConfigDescriptor entry = null;
if (DefaultErrorView.class.getName().equals(originalOutcome)) {
ViewConfigResolver viewConfigResolver = JsfUtils.getViewConfigResolver();
entry = viewConfigResolver.getDefaultErrorViewConfigDescriptor();
}
if (entry == null) {
Object loadedClass = ClassUtils.tryToLoadClassForName(outcome);
if (loadedClass == null) {
this.otherOutcomes.add(originalOutcome);
} else if (ViewConfig.class.isAssignableFrom((Class) loadedClass)) {
entry = JsfUtils.getViewConfigResolver().getViewConfigDescriptor((Class<? extends ViewConfig>) loadedClass);
}
}
if (entry != null) {
View.NavigationMode navigationMode = entry.getMetaData(View.class).iterator().next().navigation();
navigationCase = new NavigationCase("*", null, null, null, entry.getViewId(), null, View.NavigationMode.REDIRECT.equals(navigationMode), false);
this.viewConfigBasedNavigationCaseCache.put(originalOutcome, navigationCase);
return navigationCase;
}
}
return ((ConfigurableNavigationHandler) this.wrapped).getNavigationCase(context, action, outcome);
}
return null;
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigTest method testMetaDataInheritanceInViewConfig.
@Test
public void testMetaDataInheritanceInViewConfig() {
this.viewConfigExtension.addPageDefinition(Pages.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ConfigDescriptor<?> configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.class);
Assert.assertNotNull(configDescriptor);
Assert.assertNotNull(configDescriptor.getConfigClass());
Assert.assertEquals(Pages.class, configDescriptor.getConfigClass());
Assert.assertNotNull(configDescriptor.getMetaData());
Assert.assertEquals(1, configDescriptor.getMetaData().size());
Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
Assert.assertEquals("/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertEquals("/index.xhtml", viewConfigDescriptor.getViewId());
Assert.assertEquals(Pages.Index.class, viewConfigDescriptor.getConfigClass());
Assert.assertNotNull(viewConfigDescriptor.getMetaData());
Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name());
Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
Assert.assertEquals("/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.class);
Assert.assertNotNull(configDescriptor);
Assert.assertNotNull(configDescriptor.getConfigClass());
Assert.assertEquals(Pages.Admin.class, configDescriptor.getConfigClass());
Assert.assertNotNull(configDescriptor.getMetaData());
Assert.assertEquals(1, configDescriptor.getMetaData().size());
Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
Assert.assertEquals("/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Index.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertEquals("/admin/index.xhtml", viewConfigDescriptor.getViewId());
Assert.assertEquals(Pages.Admin.Index.class, viewConfigDescriptor.getConfigClass());
Assert.assertNotNull(viewConfigDescriptor.getMetaData());
Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name());
Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
Assert.assertEquals("/admin/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Public.class);
Assert.assertNotNull(configDescriptor);
Assert.assertNotNull(configDescriptor.getConfigClass());
Assert.assertEquals(Pages.Public.class, configDescriptor.getConfigClass());
Assert.assertNotNull(configDescriptor.getMetaData());
Assert.assertEquals(1, configDescriptor.getMetaData().size());
Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
Assert.assertEquals("/public/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertEquals("/public/index.xhtml", viewConfigDescriptor.getViewId());
Assert.assertEquals(Pages.Public.Index.class, viewConfigDescriptor.getConfigClass());
Assert.assertNotNull(viewConfigDescriptor.getMetaData());
Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name());
Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
Assert.assertEquals("/public/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
}
use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.
the class ViewConfigPathValidatorTest method testMissingPathButUnsupportedExtension.
@Test
public void testMissingPathButUnsupportedExtension() {
this.viewConfigExtension.addPageDefinition(Pages.Index.class);
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
List<String> supportedExtensions = new ArrayList<String>();
supportedExtensions.add(View.Extension.JSF);
try {
new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
} catch (Exception e) {
Assert.fail("unsupported extension wasn't ignored");
}
}
Aggregations