Author: nbelaevski
Date: 2010-09-03 13:34:35 -0400 (Fri, 03 Sep 2010)
New Revision: 19119
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItem.java
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItemSource.java
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationService.java
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationServiceHelper.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/CoreConfiguration.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConfigurationServiceImpl.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConstantValueExpression.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ValueExpressionHolder.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameter.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameters.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/FacesRequestSetupRule.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Configuration.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/ConfigurationServiceImplTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Enumeration.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/aplication/
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/aplication/CoreComponentsConfiguration.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/application/
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/application/IterationComponentsConfiguration.java
Removed:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java
Modified:
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/faces/FacesImpl.java
branches/RF-7560/core/api/src/main/java/org/richfaces/application/ServiceTracker.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/InitializationListener.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/EhCacheCacheFactory.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/LRUMapCacheFactory.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/model/ArrangeableModel.java
Log:
RF-7560
Modified:
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/faces/FacesImpl.java
===================================================================
---
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/faces/FacesImpl.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/faces/FacesImpl.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -26,13 +26,14 @@
import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.InitParametersStorage;
import org.richfaces.application.DependencyInjectionServiceImpl;
import org.richfaces.application.DependencyInjector;
import org.richfaces.application.Module;
import org.richfaces.application.ServiceTracker;
import org.richfaces.application.ServicesFactory;
import org.richfaces.application.ServicesFactoryImpl;
+import org.richfaces.application.configuration.ConfigurationService;
+import org.richfaces.application.configuration.ConfigurationServiceImpl;
import org.richfaces.cdk.Faces;
import org.richfaces.cdk.FileNameMapper;
import org.richfaces.cdk.skin.SkinFactoryImpl;
@@ -62,15 +63,15 @@
Module module = new Module() {
public void configure(ServicesFactory factory) {
+ serviceFactory.setInstance(ConfigurationService.class, new
ConfigurationServiceImpl());
serviceFactory.setInstance(SkinFactory.class, new SkinFactoryImpl());
- serviceFactory.setInstance(InitParametersStorage.class, new
InitParametersStorage());
serviceFactory.setInstance(FileNameMapper.class, fileNameMapper);
serviceFactory.setInstance(DependencyInjector.class, new
DependencyInjectionServiceImpl());
serviceFactory.setInstance(ResourceHandler.class, resourceHandler);
}
};
+ ServiceTracker.setFactory(serviceFactory);
serviceFactory.init(Collections.singleton(module));
- ServiceTracker.setFactory(serviceFactory);
}
public void stop() {
Modified:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/ServiceTracker.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -70,7 +70,7 @@
private static ServicesFactory getServicesFactory() {
if(!INSTANCES.containsKey(getCurrentLoader())){
- throw new FacesException("Service Traccker has not been
initialized");
+ throw new FacesException("Service Tracker has not been
initialized");
}
ServicesFactory service = INSTANCES.get(getCurrentLoader());
return service;
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItem.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItem.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItem.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.FIELD)
+@Documented
+public @interface ConfigurationItem {
+
+ public ConfigurationItemSource source() default
ConfigurationItemSource.contextInitParameter;
+
+ public String[] names();
+
+ public boolean literal() default false;
+
+ public String defaultValue() default "";
+
+}
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItemSource.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItemSource.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationItemSource.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public enum ConfigurationItemSource {
+
+ contextInitParameter
+
+}
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationService.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationService.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationService.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,22 @@
+package org.richfaces.application.configuration;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface ConfigurationService {
+
+ public Boolean getBooleanValue(FacesContext facesContext, Enum<?> key);
+
+ public Integer getIntValue(FacesContext facesContext, Enum<?> key);
+
+ public Long getLongValue(FacesContext facesContext, Enum<?> key);
+
+ public String getStringValue(FacesContext facesContext, Enum<?> key);
+
+ public Object getValue(FacesContext facesContext, Enum<?> key);
+
+ public <T extends Enum<T>> T getEnumValue(FacesContext facesContext,
Enum<?> key, Class<T> enumClass);
+
+}
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationServiceHelper.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationServiceHelper.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/configuration/ConfigurationServiceHelper.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.application.ServiceTracker;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class ConfigurationServiceHelper {
+
+ public static final Boolean getBooleanConfigurationValue(FacesContext facesContext,
Enum<?> key) {
+ return
ServiceTracker.getService(ConfigurationService.class).getBooleanValue(facesContext, key);
+ }
+
+ public static final Integer getIntConfigurationValue(FacesContext facesContext,
Enum<?> key) {
+ return
ServiceTracker.getService(ConfigurationService.class).getIntValue(facesContext, key);
+ }
+
+ public static final Long getLongConfigurationValue(FacesContext facesContext,
Enum<?> key) {
+ return
ServiceTracker.getService(ConfigurationService.class).getLongValue(facesContext, key);
+ }
+
+ public static final String getStringConfigurationValue(FacesContext facesContext,
Enum<?> key) {
+ return
ServiceTracker.getService(ConfigurationService.class).getStringValue(facesContext, key);
+ }
+
+ public static final Object getConfigurationValue(FacesContext facesContext,
Enum<?> key) {
+ return
ServiceTracker.getService(ConfigurationService.class).getValue(facesContext, key);
+ }
+
+ public static final <T extends Enum<T>> T
getEnumConfigurationValue(FacesContext facesContext, Enum<?> key, Class<T>
enumClass) {
+ return
ServiceTracker.getService(ConfigurationService.class).getEnumValue(facesContext, key,
enumClass);
+ }
+
+}
\ No newline at end of file
Modified:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,16 +21,11 @@
package org.ajax4jsf.context;
-import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.FacesException;
-import javax.faces.application.Application;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.util.ELUtils;
-import org.richfaces.application.ServiceTracker;
-
/**
* This class hold all methods for get application init parameters. Created for
* single access point to all parameters - simplest for a documentation.
@@ -39,41 +34,6 @@
*/
public final class ContextInitParameters {
- public static final String[] DATATABLE_USES_VIEW_LOCALE =
{"org.richfaces.datatableUsesViewLocale"};
-
- /**
- * This parameter define where {@link javax.faces.application.ViewExpiredException}
should be handled.
- * If is it equals "true" , framework should proparate exception to
client-side.
- */
- public static final String HANDLE_VIEW_EXPIRED_ON_CLIENT =
"org.ajax4jsf.handleViewExpiredOnClient";
- public static final String STD_CONTROLS_SKINNING_PARAM =
"org.richfaces.enableControlSkinning";
- public static final String STD_CONTROLS_SKINNING_CLASSES_PARAM =
"org.richfaces.enableControlSkinningClasses";
- public static final String[] QUEUE_ENABLED =
{"org.richfaces.queue.enabled"};
-
- //TODO - better name
- public static final String RESOURCES_TTL =
"org.richfaces.resourceDefaultTTL";
- public static final String RESOURCES_CACHE_SIZE =
"org.richfaces.resourceCacheSize";
-
- /**
- * Name of web application init parameter for current skin . Can be simple
- * String for non-modified name, or EL-expression for calculate current
- * skin. If EL evaluated to <code>String</code> - used as skin name, if
to
- * instance of {@link Skin } - used this instance. by default -
- * "org.exadel.chameleon.SKIN"
- */
- public static final String SKIN = "org.richfaces.skin";
- public static final String BASE_SKIN = "org.richfaces.baseSkin";
-
- public static final String STATIC_RESOURCE_LOCATION =
"org.richfaces.staticResourceLocation";
-
- public static final String STATIC_RESOURCE_LOCATION_VARIABLE =
"resourceLocation";
-
- public static final String EXECUTE_AWT_INITIALIZER =
"org.richfaces.executeAWTInitializer";
-
- private static final int DEFAULT_TTL = 60 * 60 * 24;
- private static final String[] RESOURCES_TTL_ARRAY = { RESOURCES_TTL };
- private static final String[] RESOURCES_CACHE_SIZE_ARRAY = { RESOURCES_CACHE_SIZE };
-
private static final String INIT_PARAM_PREFIX =
ContextInitParameters.class.getSimpleName() + ":";
private static final Object NULL = new Object() {
@@ -92,68 +52,6 @@
// parameters. Do not Instantiate !
}
- /**
- * Defines whether data table should use view root locale for sorting and filtering
or the
- * default platform one
- *
- * @param context
- * @return
- */
- public static boolean isDatatableUsesViewLocale(FacesContext context) {
- return getBoolean(context, DATATABLE_USES_VIEW_LOCALE, false);
- }
-
- public static boolean isQueueEnabled(FacesContext context) {
- return getBoolean(context, QUEUE_ENABLED, true);
- }
-
- /**
- * Method for determining STD_CONTROLS_SKINNING_PARAM parameter
- *
- * @param context
- * @return value of STD_CONTROLS_SKINNING_PARAM parameter if present.
- */
- public static boolean isStandardControlSkinningEnabled(FacesContext context) {
- Object paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_PARAM);
- return getBooleanValue(paramValue, true);
- }
-
- public static int getResourcesTimeToLive(FacesContext context) {
- return getInteger(context, RESOURCES_TTL_ARRAY, DEFAULT_TTL);
- }
-
- public static int getResourcesCacheSize(FacesContext context) {
- return getInteger(context, RESOURCES_CACHE_SIZE_ARRAY, 512);
- }
-
- /**
- * Method for determining STD_CONTROLS_SKINNING_CLASSES_PARAM parameter
- *
- * @param context
- * @return value of STD_CONTROLS_SKINNING_CLASSES_PARAM parameter if present.
- */
- public static boolean isStandardControlSkinningClassesEnabled(FacesContext context)
{
- Object paramValue = evaluateInitParameter(context,
STD_CONTROLS_SKINNING_CLASSES_PARAM);
- return getBooleanValue(paramValue, false);
- }
-
- public static Object getSkin(FacesContext context) {
- return evaluateInitParameter(context, SKIN);
- }
-
- public static Object getBaseSkin(FacesContext context) {
- return evaluateInitParameter(context, BASE_SKIN);
- }
-
- public static String getStaticResourceLocation(FacesContext context) {
- return (String) evaluateInitParameter(context, STATIC_RESOURCE_LOCATION);
- }
-
- public static boolean isExecuteAWTInitializer(FacesContext context) {
- Object paramValue = evaluateInitParameter(context, EXECUTE_AWT_INITIALIZER);
- return getBooleanValue(paramValue, true);
- }
-
static int getInteger(FacesContext context, String[] paramNames, int defaultValue) {
String initParameter = getInitParameter(context, paramNames);
@@ -218,41 +116,6 @@
return ("true".equalsIgnoreCase(stringValue) ||
"yes".equalsIgnoreCase(stringValue));
}
- private static InitParametersStorage getExpressionsMap(FacesContext context) {
- InitParametersStorage concurrentStorage =
ServiceTracker.getService(InitParametersStorage.class);
- return concurrentStorage;
- }
-
- private static Object evaluateInitParameter(FacesContext context, String
parameterName) {
- InitParametersStorage expressionsMap = getExpressionsMap(context);
- String parameterKey = INIT_PARAM_PREFIX + parameterName;
-
- Object parameterValue = expressionsMap.get(parameterKey);
- if (parameterValue == null) {
- String initParameter =
context.getExternalContext().getInitParameter(parameterName);
- if (initParameter != null) {
-
- if (ELUtils.isValueReference(initParameter)) {
- Application application = context.getApplication();
- ExpressionFactory expressionFactory =
application.getExpressionFactory();
-
- parameterValue =
expressionFactory.createValueExpression(context.getELContext(),
- initParameter,
- String.class);
- } else {
- parameterValue = initParameter;
- }
-
- } else {
- parameterValue = NULL;
- }
-
- expressionsMap.put(parameterKey, parameterValue);
- }
-
- return evaluateInitParameterExpression(context, parameterValue);
- }
-
private static Object evaluateInitParameterExpression(FacesContext context, Object
parameterValue) {
if (parameterValue == NULL || parameterValue == null) {
return null;
Deleted:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -1,49 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class InitParametersStorage {
-
- ConcurrentMap<String,Object> storage = new ConcurrentHashMap<String,
Object>(5);
-
- public Object get(String key){
- return storage.get(key);
- }
-
- public Object put(String key,Object value) {
- return storage.put(key, value);
- }
-
- public boolean containsKey(String key) {
- return storage.containsKey(key);
- }
-}
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/CoreConfiguration.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/CoreConfiguration.java
(rev 0)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/CoreConfiguration.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application;
+
+import org.richfaces.application.configuration.ConfigurationItem;
+import org.richfaces.skin.Skin;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class CoreConfiguration {
+
+ public static final String SKIN_PARAM_NAME = "org.richfaces.skin";
+
+ public static final String BASE_SKIN_PARAM_NAME =
"org.richfaces.baseSkin";
+
+ public static final String RESOURCES_CACHE_SIZE_PARAM_NAME =
"org.richfaces.resourceCacheSize";
+
+ private CoreConfiguration() {}
+
+ public enum Items {
+ @ConfigurationItem(defaultValue = "true", names =
"org.richfaces.enableControlSkinning")
+ standardControlsSkinning,
+
+ @ConfigurationItem(defaultValue = "false", names =
"org.richfaces.enableControlSkinningClasses")
+ standardControlsSkinningClasses,
+
+ /**
+ * Name of web application init parameter for current skin . Can be simple
+ * String for non-modified name, or EL-expression for calculate current
+ * skin. If EL evaluated to <code>String</code> - used as skin name,
if to
+ * instance of {@link Skin } - used this instance. by default -
+ * "org.richfaces.skin"
+ */
+ @ConfigurationItem(names = SKIN_PARAM_NAME)
+ skin,
+
+ @ConfigurationItem(names = BASE_SKIN_PARAM_NAME)
+ baseSkin,
+
+ @ConfigurationItem(defaultValue = "86400" /* 24 * 60 * 60 */, names =
"org.richfaces.resourceDefaultTTL", literal = true)
+ resourcesTTL,
+
+ @ConfigurationItem(defaultValue = "512", names =
RESOURCES_CACHE_SIZE_PARAM_NAME, literal = true)
+ resourcesCacheSize,
+
+ @ConfigurationItem(names = "org.ajax4jsf.cache.LRU_MAP_CACHE_SIZE",
literal = true)
+ lruMapCacheSize,
+
+ @ConfigurationItem(names = "org.richfaces.staticResourceLocation")
+ staticResourceLocation,
+
+ @ConfigurationItem(defaultValue = "true", names =
"org.richfaces.executeAWTInitializer", literal = true)
+ executeAWTInitializer
+ }
+}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -1,7 +1,8 @@
package org.richfaces.application;
-import org.ajax4jsf.context.InitParametersStorage;
import org.ajax4jsf.renderkit.AJAXDataSerializer;
+import org.richfaces.application.configuration.ConfigurationService;
+import org.richfaces.application.configuration.ConfigurationServiceImpl;
import org.richfaces.cache.Cache;
import org.richfaces.l10n.BundleLoader;
import org.richfaces.resource.DefaultResourceCodec;
@@ -12,13 +13,13 @@
public class DefaultModule implements Module {
public void configure(ServicesFactory factory) {
+ factory.setInstance(ConfigurationService.class, new ConfigurationServiceImpl());
factory.setInstance(SkinFactory.class, new SkinFactoryImpl());
factory.setInstance(AJAXDataSerializer.class,new AJAXDataSerializer());
factory.setInstance(ResourceCodec.class,ServiceLoader.loadService(ResourceCodec.class,
DefaultResourceCodec.class));
factory.setInstance(Cache.class,new CacheProvider());
factory.setInstance(Uptime.class, new Uptime());
factory.setInstance(DependencyInjector.class, new
DependencyInjectionServiceImpl());
- factory.setInstance(InitParametersStorage.class, new InitParametersStorage());
factory.setInstance(MessageFactory.class, new MessageFactoryImpl(new
BundleLoader()));
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/InitializationListener.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
*/
package org.richfaces.application;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+
import java.awt.Toolkit;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -37,7 +39,6 @@
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
-import org.ajax4jsf.context.ContextInitParameters;
import org.richfaces.VersionBean;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -107,7 +108,6 @@
protected void onStart() {
ServicesFactory injector = createFactory();
- ServiceTracker.setFactory(injector);
if (LOGGER.isInfoEnabled()) {
String versionString = VersionBean.VERSION.toString();
@@ -117,7 +117,7 @@
}
FacesContext context = FacesContext.getCurrentInstance();
- if (ContextInitParameters.isExecuteAWTInitializer(context)) {
+ if (getBooleanConfigurationValue(context,
CoreConfiguration.Items.executeAWTInitializer)) {
try {
AWTInitializer.initialize();
} catch (NoClassDefFoundError e) {
@@ -128,6 +128,7 @@
protected ServicesFactory createFactory() {
ServicesFactoryImpl injector = new ServicesFactoryImpl();
+ ServiceTracker.setFactory(injector);
ArrayList<Module> modules = new ArrayList<Module>();
modules.add(new DefaultModule());
try {
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConfigurationServiceImpl.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConfigurationServiceImpl.java
(rev 0)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConfigurationServiceImpl.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.util.ELUtils;
+
+import com.google.common.base.Strings;
+import com.google.common.primitives.Primitives;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ConfigurationServiceImpl implements ConfigurationService {
+
+ private Map<Enum<?>, ValueExpressionHolder> itemsMap = new
ConcurrentHashMap<Enum<?>, ValueExpressionHolder>();
+
+ private final ConfigurationItem getConfigurationItemAnnotation(Enum<?> enumKey)
{
+ try {
+ return
enumKey.getClass().getField(enumKey.name()).getAnnotation(ConfigurationItem.class);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ private <T> T coerce(FacesContext context, Object value, Class<T>
targetType) {
+ if (value == null) {
+ return null;
+ }
+
+ if (targetType.isInstance(value)) {
+ return targetType.cast(value);
+ }
+
+ if (value instanceof String) {
+ PropertyEditor editor = PropertyEditorManager.findEditor(targetType);
+ if (editor == null && Primitives.isWrapperType(targetType)) {
+ editor =
PropertyEditorManager.findEditor(Primitives.unwrap(targetType));
+ }
+
+ if (editor != null) {
+
+ editor.setAsText((String) value);
+ return targetType.cast(editor.getValue());
+ } else if (targetType.isEnum()) {
+ return targetType.cast(Enum.valueOf((Class<Enum>) targetType,
(String) value));
+ }
+ }
+
+ //TODO message
+ throw new IllegalArgumentException();
+ }
+
+ protected ValueExpressionHolder createValueExpressionHolder(FacesContext context,
Enum<?> key, Class<?> targetType) {
+ ConfigurationItem annotation = getConfigurationItemAnnotation(key);
+ if (annotation == null) {
+ //TODO - handle this
+ }
+
+ ValueExpression expression = createValueExpression(context, annotation,
targetType);
+
+ Object defaultValue = null;
+
+ if (expression == null || !expression.isLiteralText()) {
+ String defaultValueString = annotation.defaultValue();
+ if (!Strings.isNullOrEmpty(defaultValueString)) {
+ defaultValue = coerce(context, defaultValueString, targetType);
+ }
+ }
+
+ return new ValueExpressionHolder(expression, defaultValue);
+ }
+
+ private final ValueExpression createValueExpression(FacesContext context,
ConfigurationItem annotation, Class<?> targetType) {
+ ConfigurationItemSource source = annotation.source();
+
+ if (source == ConfigurationItemSource.contextInitParameter) {
+ Map initMap = context.getExternalContext().getInitParameterMap();
+
+ for (String name : annotation.names()) {
+ String value = (String) initMap.get(name);
+
+ if (Strings.isNullOrEmpty(value)) {
+ continue;
+ }
+
+ if (ELUtils.isValueReference(value)) {
+ ExpressionFactory expressionFactory =
context.getApplication().getExpressionFactory();
+
+ if (expressionFactory == null) {
+ //TODO message
+ throw new IllegalStateException();
+ }
+
+ if (annotation.literal()) {
+ //TODO message
+ throw new IllegalArgumentException();
+ }
+
+ return
expressionFactory.createValueExpression(context.getELContext(), value, targetType);
+ } else {
+ Object coercedValue = coerce(context, value, targetType);
+ if (coercedValue != null) {
+ return new ConstantValueExpression(coercedValue);
+ }
+ }
+ }
+
+ return null;
+ } else {
+ throw new IllegalArgumentException(source.toString());
+ }
+ }
+
+ protected <T> T getValue(FacesContext facesContext, Enum<?> key,
Class<T> returnType) {
+ ValueExpressionHolder holder = itemsMap.get(key);
+
+ if (holder == null) {
+ holder = createValueExpressionHolder(facesContext, key, returnType);
+ itemsMap.put(key, holder);
+ }
+
+ return returnType.cast(holder.getValue(facesContext));
+ }
+
+ public Boolean getBooleanValue(FacesContext facesContext, Enum<?> key) {
+ return getValue(facesContext, key, Boolean.class);
+ }
+
+ public Integer getIntValue(FacesContext facesContext, Enum<?> key) {
+ return getValue(facesContext, key, Integer.class);
+ }
+
+ public Long getLongValue(FacesContext facesContext, Enum<?> key) {
+ return getValue(facesContext, key, Long.class);
+ }
+
+ public String getStringValue(FacesContext facesContext, Enum<?> key) {
+ return getValue(facesContext, key, String.class);
+ }
+
+ public <T extends Enum<T>> T getEnumValue(FacesContext facesContext,
Enum<?> key, Class<T> enumClass) {
+ return getValue(facesContext, key, enumClass);
+ }
+
+ public Object getValue(FacesContext facesContext, Enum<?> key) {
+ return getValue(facesContext, key, Object.class);
+ }
+}
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConstantValueExpression.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConstantValueExpression.java
(rev 0)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ConstantValueExpression.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ConstantValueExpression extends ValueExpression {
+
+ private static final long serialVersionUID = -4455404133234988782L;
+
+ private Object value;
+
+ public ConstantValueExpression(Object value) {
+ super();
+ this.value = value;
+ }
+
+ @Override
+ public Object getValue(ELContext context) {
+ return value;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object value) {
+ throw new ELException("This expression is read-only");
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context) {
+ return true;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context) {
+ return null;
+ }
+
+ @Override
+ public Class<?> getExpectedType() {
+ return Object.class;
+ }
+
+ @Override
+ public String getExpressionString() {
+ return null;
+ }
+
+ @Override
+ public boolean isLiteralText() {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+}
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ValueExpressionHolder.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ValueExpressionHolder.java
(rev 0)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/configuration/ValueExpressionHolder.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application.configuration;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class ValueExpressionHolder {
+
+ private ValueExpression valueExpression;
+
+ private Object defaultValue;
+
+ public ValueExpressionHolder(ValueExpression valueExpression, Object defaultValue) {
+ super();
+ this.valueExpression = valueExpression;
+ this.defaultValue = defaultValue;
+ }
+
+ public Object getValue(FacesContext context) {
+ if (valueExpression != null) {
+ try {
+ Object result = valueExpression.getValue(context.getELContext());
+
+ if (result != null) {
+ return result;
+ }
+ } catch (ELException e) {
+ // TODO: handle exception
+ }
+ }
+
+ return defaultValue;
+ }
+
+}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/EhCacheCacheFactory.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/EhCacheCacheFactory.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/EhCacheCacheFactory.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -3,6 +3,8 @@
*/
package org.richfaces.cache;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getIntConfigurationValue;
+
import java.net.URL;
import java.text.MessageFormat;
import java.util.Map;
@@ -12,7 +14,7 @@
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -49,7 +51,7 @@
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?>
env) {
LOG.info("Creating EhCache cache instance");
- int maxCacheSize = ContextInitParameters.getResourcesCacheSize(facesContext);
+ int maxCacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesCacheSize);
boolean preconfiguredCache = false;
Ehcache ehcache = cacheManager.getEhcache(cacheName);
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -3,6 +3,8 @@
*/
package org.richfaces.cache;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getIntConfigurationValue;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -12,7 +14,6 @@
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
@@ -23,6 +24,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.EvictionAlgorithmConfigBase;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -49,7 +51,7 @@
if (evictionAlgorithmConfig instanceof EvictionAlgorithmConfigBase) {
EvictionAlgorithmConfigBase baseEvicitonConfig =
(EvictionAlgorithmConfigBase) evictionAlgorithmConfig;
if (baseEvicitonConfig.getMaxNodes() <= 0) {
- int maxCacheSize =
ContextInitParameters.getResourcesCacheSize(facesContext);
+ int maxCacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesCacheSize);
LOG.info(MessageFormat.format("Maximum cache size hasn''t
been set, resetting to {0} max items", maxCacheSize));
baseEvicitonConfig.setMaxNodes(maxCacheSize);
}
@@ -90,7 +92,8 @@
Configuration configuration = new Configuration();
EvictionRegionConfig evictionRegionConfig = new
EvictionRegionConfig(Fqn.root());
ExpirationAlgorithmConfig expirationAlgorithm = new
ExpirationAlgorithmConfig();
-
expirationAlgorithm.setMaxNodes(ContextInitParameters.getResourcesCacheSize(facesContext));
+ int maxCacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesCacheSize);
+ expirationAlgorithm.setMaxNodes(maxCacheSize);
evictionRegionConfig.setEvictionAlgorithmConfig(expirationAlgorithm);
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
package org.richfaces.cache;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getIntConfigurationValue;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -32,8 +34,8 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -107,7 +109,7 @@
String property =
cacheProperties.getProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY);
if (property == null) {
- int maxCacheSize =
ContextInitParameters.getResourcesCacheSize(facesContext);
+ int maxCacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesCacheSize);
LOG.info(MessageFormat.format("Maximum cache size hasn''t been
set, resetting to {0} max items", maxCacheSize));
cacheProperties.put(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,
Integer.toString(maxCacheSize));
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/LRUMapCacheFactory.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/LRUMapCacheFactory.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/LRUMapCacheFactory.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,38 +21,38 @@
package org.richfaces.cache.lru;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getIntConfigurationValue;
+
import java.util.Map;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.cache.Cache;
import org.richfaces.cache.CacheFactory;
+import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
-import org.richfaces.log.Logger;
/**
* @author Nick - mailto:nbelaevski@exadel.com
* created 01.05.2007
*/
public class LRUMapCacheFactory implements CacheFactory {
- public static final String CACHE_SIZE_PARAMETER =
"org.ajax4jsf.cache.LRU_MAP_CACHE_SIZE";
private static final Logger LOG = RichfacesLogger.CACHE.getLogger();
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?>
env) {
//TODO - handle cache name
LOG.info("Creating LRUMap cache instance using parameters: " + env);
- String size = (String) env.get(CACHE_SIZE_PARAMETER);
- if ((size == null) || (size.length() == 0)) {
- size =
Integer.toString(ContextInitParameters.getResourcesCacheSize(facesContext));
+ Integer cacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.lruMapCacheSize);
+
+ if (cacheSize == null) {
+ cacheSize = getIntConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesCacheSize);
}
+
+ LOG.info("Creating LRUMap cache instance of " + cacheSize + "
items capacity");
- int parsedSize = Integer.parseInt(size);
-
- LOG.info("Creating LRUMap cache instance of " + parsedSize + "
items capacity");
-
- return new LRUMapCache(parsedSize);
+ return new LRUMapCache(cacheSize);
}
public void destroy() {
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -33,7 +33,9 @@
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.application.configuration.ConfigurationService;
import org.richfaces.el.BaseReadOnlyValueExpression;
/**
@@ -81,9 +83,11 @@
public Object getValue(ELContext context) {
FacesContext facesContext = getFacesContext(context);
- boolean controls =
ContextInitParameters.isStandardControlSkinningEnabled(facesContext);
- boolean classes =
ContextInitParameters.isStandardControlSkinningClassesEnabled(facesContext);
+ ConfigurationService configurationService =
ServiceTracker.getService(ConfigurationService.class);
+ boolean controls = configurationService.getBooleanValue(facesContext,
CoreConfiguration.Items.standardControlsSkinning);
+ boolean classes = configurationService.getBooleanValue(facesContext,
CoreConfiguration.Items.standardControlsSkinningClasses);
+
if (controls && classes) {
return BOTH_SKINNING;
}
@@ -109,8 +113,10 @@
public Object getValue(ELContext context) {
FacesContext facesContext = getFacesContext(context);
- return ContextInitParameters.isStandardControlSkinningEnabled(facesContext)
||
-
ContextInitParameters.isStandardControlSkinningClassesEnabled(facesContext);
+ ConfigurationService configurationService =
ServiceTracker.getService(ConfigurationService.class);
+
+ return configurationService.getBooleanValue(facesContext,
CoreConfiguration.Items.standardControlsSkinning) ||
+ configurationService.getBooleanValue(facesContext,
CoreConfiguration.Items.standardControlsSkinningClasses);
}
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,7 @@
package org.richfaces.resource;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getLongConfigurationValue;
import static org.richfaces.resource.ResourceUtils.millisToSecond;
import static org.richfaces.resource.ResourceUtils.secondToMillis;
@@ -30,7 +31,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.util.Util;
@@ -188,7 +189,7 @@
formattedExpireDate = Util.formatHttpDate(expired);
maxAge = millisToSecond(expired.getTime() - currentTime);
} else {
- maxAge = ContextInitParameters.getResourcesTimeToLive(facesContext);
+ maxAge = getLongConfigurationValue(facesContext,
CoreConfiguration.Items.resourcesTTL);
formattedExpireDate = Util.formatHttpDate(currentTime +
secondToMillis(maxAge));
}
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
*/
package org.richfaces.resource;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getStringConfigurationValue;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -29,7 +31,7 @@
import javax.faces.application.Resource;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
import org.richfaces.skin.SkinFactory;
import com.google.common.base.Joiner;
@@ -40,6 +42,8 @@
*/
public class ExternalStaticResource extends Resource {
+ public static final String STATIC_RESOURCE_LOCATION_VARIABLE =
"resourceLocation";
+
private static final Joiner RESOURCE_PATH_JOINER =
Joiner.on('/').skipNulls();
private String location;
@@ -77,18 +81,18 @@
public String getRequestPath() {
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
- Object resourceVarValue =
requestMap.get(ContextInitParameters.STATIC_RESOURCE_LOCATION_VARIABLE);
+ Object resourceVarValue = requestMap.get(STATIC_RESOURCE_LOCATION_VARIABLE);
try {
String resourceLocation = getResourceLocation(facesContext);
- requestMap.put(ContextInitParameters.STATIC_RESOURCE_LOCATION_VARIABLE,
resourceLocation);
+ requestMap.put(STATIC_RESOURCE_LOCATION_VARIABLE, resourceLocation);
//TODO pass via ViewHandler?
- return ContextInitParameters.getStaticResourceLocation(facesContext);
+ return getStringConfigurationValue(facesContext,
CoreConfiguration.Items.staticResourceLocation);
} finally {
- requestMap.remove(ContextInitParameters.STATIC_RESOURCE_LOCATION_VARIABLE);
+ requestMap.remove(STATIC_RESOURCE_LOCATION_VARIABLE);
if (resourceVarValue != null) {
- requestMap.put(ContextInitParameters.STATIC_RESOURCE_LOCATION_VARIABLE,
resourceVarValue);
+ requestMap.put(STATIC_RESOURCE_LOCATION_VARIABLE, resourceVarValue);
}
}
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
package org.richfaces.skin;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getConfigurationValue;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -28,7 +30,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.application.CoreConfiguration;
/**
* Implementation of {@link SkinFactory} with building skins from properties
@@ -117,7 +119,7 @@
* expression.
*/
protected Skin getSkinOrName(FacesContext context, boolean useBase) {
- Object skinObject = useBase ? ContextInitParameters.getBaseSkin(context) :
ContextInitParameters.getSkin(context);
+ Object skinObject = getConfigurationValue(context, useBase ?
CoreConfiguration.Items.baseSkin : CoreConfiguration.Items.skin);
Skin result = null;
Added: branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameter.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameter.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameter.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface ContextInitParameter {
+
+ public String name();
+
+ public String value();
+
+}
Added: branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameters.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameters.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/ContextInitParameters.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface ContextInitParameters {
+
+ public ContextInitParameter[] value();
+
+}
Added: branches/RF-7560/core/impl/src/test/java/org/richfaces/FacesRequestSetupRule.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/FacesRequestSetupRule.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/FacesRequestSetupRule.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.test.faces.FacesEnvironment;
+import org.jboss.test.faces.FacesEnvironment.FacesRequest;
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
+
+import com.google.common.collect.Maps;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class FacesRequestSetupRule implements MethodRule {
+
+ private FacesEnvironment environment;
+
+ private FacesRequest facesRequest;
+
+ public Statement apply(final Statement base, final FrameworkMethod method,
+ Object target) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ starting(method);
+ try {
+ base.evaluate();
+ } catch (Throwable t) {
+ throw t;
+ } finally {
+ finished(method);
+ }
+ }
+ };
+ }
+
+ private Map<String, String> getInitParameters(FrameworkMethod method) {
+ Map<String, String> result = Maps.newHashMap();
+
+ ContextInitParameter parameter =
method.getAnnotation(ContextInitParameter.class);
+ if (parameter != null) {
+ result.put(parameter.name(), parameter.value());
+ }
+
+ ContextInitParameters parameters =
method.getAnnotation(ContextInitParameters.class);
+ if (parameters != null) {
+ for (ContextInitParameter param : parameters.value()) {
+ if (result.put(param.name(), param.value()) != null) {
+ throw new IllegalArgumentException("Parameter " + param +
" specified twice");
+ }
+ }
+ }
+
+ return result;
+ }
+
+ protected void starting(FrameworkMethod method) throws Exception {
+ createFacesEnvironment();
+ setUpFacesEnvironment(method);
+
+ createFacesRequest();
+ setUpFacesRequest();
+ }
+
+ protected void finished(FrameworkMethod method) throws Exception {
+ tearDownFacesRequest();
+ tearDownFacesEnvironment();
+ }
+
+ protected void setUpFacesRequest() {
+ facesRequest.start();
+ }
+
+ protected void createFacesRequest() throws Exception {
+ facesRequest = environment.createFacesRequest();
+ }
+
+ protected void setUpFacesEnvironment(FrameworkMethod method) {
+ for (Entry<String, String> paramEntry:
getInitParameters(method).entrySet()) {
+ environment.getServer().addInitParameter(paramEntry.getKey(),
paramEntry.getValue());
+ }
+
+ environment.start();
+ }
+
+ protected void createFacesEnvironment() {
+ environment = FacesEnvironment.createEnvironment();
+ }
+
+ protected void tearDownFacesEnvironment() {
+ if (environment != null) {
+ environment.release();
+ environment = null;
+ }
+ }
+
+ protected void tearDownFacesRequest() {
+ if (facesRequest != null) {
+ facesRequest.release();
+ facesRequest = null;
+ }
+ }
+
+ public FacesRequest getFacesRequest() {
+ return facesRequest;
+ }
+
+}
Added:
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Configuration.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Configuration.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Configuration.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application;
+
+import org.richfaces.application.configuration.ConfigurationItem;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public enum Configuration {
+
+ @ConfigurationItem(names = "org.richfaces.LongValue")
+ longValue,
+
+ @ConfigurationItem(names = "org.richfaces.LongValueWithDefault",
defaultValue = "-100")
+ longValueWithDefault,
+
+ @ConfigurationItem(names = "org.richfaces.IntValue")
+ intValue,
+
+ @ConfigurationItem(names = "org.richfaces.IntValueWithDefault",
defaultValue = "-1")
+ intValueWithDefault,
+
+ @ConfigurationItem(names = "org.richfaces.StringValue")
+ stringValue,
+
+ @ConfigurationItem(names = "org.richfaces.StringValueWithDefault",
defaultValue = "default name")
+ stringValueWithDefault,
+
+ @ConfigurationItem(names = "org.richfaces.EnumValue")
+ enumValue,
+
+ @ConfigurationItem(names = "org.richfaces.EnumValue", defaultValue =
"foo")
+ enumValueWithDefault,
+
+ @ConfigurationItem(names = "org.richfaces.BooleanValue")
+ booleanValue,
+
+ @ConfigurationItem(names = "org.richfaces.BooleanValue", defaultValue =
"false")
+ booleanValueWithDefault,
+
+ @ConfigurationItem(names = {"org.richfaces.MultiValue1",
"org.richfaces.MultiValue2"})
+ multiValue,
+
+ @ConfigurationItem(names = "org.richfaces.FacesContextReference")
+ facesContext,
+
+ @ConfigurationItem(names = "org.richfaces.DynamicValueWithDefault",
defaultValue = "<something>")
+ dynamicValueWithDefault,
+
+ @ConfigurationItem(names = "org.richfaces.LiteralOnlyValue", literal =
true)
+ literalOnly,
+
+ @ConfigurationItem(names = "org.richfaces.LiteralOnlyFailingValue", literal
= true)
+ literalOnlyFailing
+}
Added:
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/ConfigurationServiceImplTest.java
===================================================================
---
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/ConfigurationServiceImplTest.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/ConfigurationServiceImplTest.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getConfigurationValue;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getEnumConfigurationValue;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getIntConfigurationValue;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getLongConfigurationValue;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getStringConfigurationValue;
+
+import javax.faces.context.FacesContext;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.richfaces.ContextInitParameter;
+import org.richfaces.ContextInitParameters;
+import org.richfaces.FacesRequestSetupRule;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ConfigurationServiceImplTest {
+
+ @Rule
+ public FacesRequestSetupRule rule = new FacesRequestSetupRule();
+
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = "org.richfaces.LongValue", value =
"223372036854775807"),
+ @ContextInitParameter(name = "org.richfaces.IntValue", value =
"32768"),
+ @ContextInitParameter(name = "org.richfaces.StringValue", value =
"some string"),
+ @ContextInitParameter(name = "org.richfaces.BooleanValue", value =
"true"),
+ @ContextInitParameter(name = "org.richfaces.EnumValue", value =
"bar")
+ })
+
+ public void testLiteralValues() throws Exception {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ assertEquals(223372036854775807l, getLongConfigurationValue(context,
Configuration.longValue).longValue());
+ assertEquals(32768, getIntConfigurationValue(context,
Configuration.intValue).intValue());
+ assertEquals("some string", getStringConfigurationValue(context,
Configuration.stringValue));
+ assertEquals(true, getBooleanConfigurationValue(context,
Configuration.booleanValue).booleanValue());
+ assertEquals(Enumeration.bar, getEnumConfigurationValue(context,
Configuration.enumValue, Enumeration.class));
+ }
+
+ @Test
+ public void testDefaultValues() throws Exception {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ assertEquals(-100l, getLongConfigurationValue(context,
Configuration.longValueWithDefault).longValue());
+ assertEquals(-1, getIntConfigurationValue(context,
Configuration.intValueWithDefault).intValue());
+ assertEquals("default name", getStringConfigurationValue(context,
Configuration.stringValueWithDefault));
+ assertEquals(false, getBooleanConfigurationValue(context,
Configuration.booleanValueWithDefault).booleanValue());
+ assertEquals(Enumeration.foo, getEnumConfigurationValue(context,
Configuration.enumValueWithDefault, Enumeration.class));
+ }
+
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = "org.richfaces.MultiValue2", value =
"test value")
+ })
+ public void testMultiValues() throws Exception {
+ assertEquals("test value",
getStringConfigurationValue(FacesContext.getCurrentInstance(),
Configuration.multiValue));
+ }
+
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = "org.richfaces.FacesContextReference",
value = "#{facesContext}"),
+ @ContextInitParameter(name = "org.richfaces.DynamicValueWithDefault",
value = "#{facesContext.attributes['dummyValue']}")
+ })
+ public void testDynamicValues() throws Exception {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ assertSame(context, getConfigurationValue(context, Configuration.facesContext));
+ assertEquals("<something>", getConfigurationValue(context,
Configuration.dynamicValueWithDefault));
+ }
+
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = "org.richfaces.LiteralOnlyValue", value =
"pure literal"),
+ @ContextInitParameter(name = "org.richfaces.LiteralOnlyFailingValue",
value = "#{someEl}")
+ })
+ public void testLiteral() throws Exception {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ assertEquals("pure literal", getConfigurationValue(context,
Configuration.literalOnly));
+ try {
+ getConfigurationValue(context, Configuration.literalOnlyFailing);
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ // TODO: handle exception
+ }
+ }
+}
Added:
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Enumeration.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Enumeration.java
(rev 0)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/Enumeration.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public enum Enumeration {
+
+ foo, bar
+}
Modified: branches/RF-7560/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java
===================================================================
---
branches/RF-7560/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -29,11 +29,9 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.ajax4jsf.context.ContextInitParameters;
import org.jboss.test.faces.AbstractFacesTest;
import org.junit.Assert;
-import org.richfaces.cache.Cache;
-import org.richfaces.cache.CacheManager;
+import org.richfaces.application.CoreConfiguration;
/**
* @author Nick Belaevski
@@ -56,7 +54,7 @@
protected void setupJsfInitParameters() {
super.setupJsfInitParameters();
this.facesServer.addInitParameter(CacheManager.CACHE_MANAGER_FACTORY_CLASS,
cacheManagerFactoryClassName);
- this.facesServer.addInitParameter(ContextInitParameters.RESOURCES_CACHE_SIZE,
Integer.toString(sizeLimit));
+
this.facesServer.addInitParameter(CoreConfiguration.RESOURCES_CACHE_SIZE_PARAM_NAME,
Integer.toString(sizeLimit));
}
protected Cache getCache() {
Modified: branches/RF-7560/core/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
---
branches/RF-7560/core/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,18 +21,26 @@
package org.richfaces.skin;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.reflect.Method;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+import static org.richfaces.application.CoreConfiguration.BASE_SKIN_PARAM_NAME;
+import static org.richfaces.application.CoreConfiguration.SKIN_PARAM_NAME;
+
import java.util.HashMap;
import java.util.Map;
import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.ContextInitParameters;
-import org.jboss.test.faces.AbstractFacesTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.richfaces.ContextInitParameter;
+import org.richfaces.ContextInitParameters;
+import org.richfaces.FacesRequestSetupRule;
/**
* Test for Skin/skin factory methods.
@@ -40,78 +48,43 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/10 14:28:13 $
*
*/
-public class SkinTestCase extends AbstractFacesTest {
+public class SkinTestCase {
+
+ @Rule
+ public FacesRequestSetupRule rule = new FacesRequestSetupRule();
- @Override
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- @Override
- protected void setupJsfInitParameters() {
- super.setupJsfInitParameters();
- setupSkinParameters();
- }
-
- private void setupSkinParameters() {
- try {
- Method method = getClass().getMethod(getName());
- SkinParameters skinParameters = method.getAnnotation(SkinParameters.class);
-
- if (skinParameters != null) {
- String skinName = skinParameters.skinName();
-
- if (skinName != null && skinName.length() != 0) {
- facesServer.addInitParameter(ContextInitParameters.SKIN, skinName);
- }
-
- String baseSkinName = skinParameters.baseSkinName();
-
- if (baseSkinName != null && baseSkinName.length() != 0) {
- facesServer.addInitParameter(ContextInitParameters.BASE_SKIN,
baseSkinName);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
+ private void addParameters(FacesContext facesContext, Object[][] strings) {
+ Map<Object, Object> baseMap = new HashMap<Object, Object>();
+
+ for (Object[] objects : strings) {
+ baseMap.put(objects[0], objects[1]);
}
+
+ facesContext.getExternalContext().getRequestMap().put("test",
baseMap);
}
-
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getInstance()'
- */
+
+ @Test
public void testGetInstance() {
- SkinFactory factory = SkinFactory.getInstance();
- SkinFactory factory1 = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
+ SkinFactory factory1 = SkinFactory.getInstance(facesContext);
assertSame(factory, factory1);
}
- private void addParameters(Object[][] strings) {
- Map<Object, Object> baseMap = new HashMap<Object, Object>();
-
- for (Object[] objects : strings) {
- baseMap.put(objects[0], objects[1]);
- }
-
- facesContext.getExternalContext().getRequestMap().put("test",
baseMap);
- }
-
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "test")
+ @Test
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "test")
public void testGetSkin() {
- addParameters(new Object[][] {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ addParameters(facesContext, new Object[][] {
new Object[] {"bean", "test.value"}
});
- SkinFactory factory = SkinFactory.getInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
// test call
Skin skin = factory.getSkin(facesContext);
@@ -129,9 +102,13 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "test", baseSkinName = "DEFAULT")
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "test"),
+ @ContextInitParameter(name = BASE_SKIN_PARAM_NAME, value = "DEFAULT")
+ })
public void testSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
// test call
Skin skin = factory.getSkin(facesContext);
@@ -144,9 +121,14 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "style", baseSkinName = "style_base")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "style"),
+ @ContextInitParameter(name = BASE_SKIN_PARAM_NAME, value =
"style_base")
+ })
public void testSkinReferences1() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
// test call
Skin skin = factory.getSkin(facesContext);
@@ -158,11 +140,16 @@
assertEquals("white.textcolor", skin.getParameter(facesContext,
"additionalTextColor"));
}
- @SkinParameters(skinName = "dynatest", baseSkinName =
"dynatest_base")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "dynatest"),
+ @ContextInitParameter(name = BASE_SKIN_PARAM_NAME, value =
"dynatest_base")
+ })
public void testBaseSkin() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
- addParameters(new Object[][] {
+ addParameters(facesContext, new Object[][] {
new Object[] {"bean", "dynabase1"}
});
@@ -183,9 +170,13 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "cyclic")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "cyclic")
+ })
public void testCyclicSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
try {
Skin skin = factory.getSkin(facesContext);
@@ -201,9 +192,13 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "noref")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "noref")
+ })
public void testBadSkinReferences() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
// test call
try {
@@ -220,11 +215,15 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
*/
- @SkinParameters(skinName = "#{test.skin}")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "#{test.skin}")
+ })
public void testGetBindedSkin() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
- addParameters(new Object[][] {
+ addParameters(facesContext, new Object[][] {
new Object[] {"skin", "bindedtest"}, new Object[]
{"bean", "binded.test.value"}
});
@@ -240,11 +239,15 @@
assertEquals("binded.test.value", skin.getParameter(facesContext,
"bind.property"));
}
- @SkinParameters(skinName = "#{test.skin}")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "#{test.skin}")
+ })
public void testSkinHash() {
- SkinFactory factory = SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = SkinFactory.getInstance(facesContext);
- addParameters(new Object[][] {
+ addParameters(facesContext, new Object[][] {
new Object[] {"skin", "bindedtest"}, new Object[]
{"bean", "binded.test.value"}
});
@@ -267,39 +270,36 @@
/*
* Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
*/
+ @Test
public void testGetDefaultProperties() {
- SkinFactory factory = (SkinFactory) SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = (SkinFactory) SkinFactory.getInstance(facesContext);
//
assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
// Second default config
assertEquals("default",
factory.getDefaultSkin(facesContext).getParameter(facesContext, "a"));
}
- /*
- * Test method for
'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
- */
- public void testGetSkinName() {}
-
- @SkinParameters(skinName = "plain")
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = SKIN_PARAM_NAME, value = "plain")
+ })
public void testPlainSkin() throws Exception {
- SkinFactory factory = (SkinFactory) SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = (SkinFactory) SkinFactory.getInstance(facesContext);
assertNull(factory.getSkin(facesContext).getParameter(facesContext,
Skin.GENERAL_BACKGROUND_COLOR));
}
-
- @SkinParameters(baseSkinName = "plain")
+
+ @Test
+ @ContextInitParameters({
+ @ContextInitParameter(name = BASE_SKIN_PARAM_NAME, value = "plain")
+ })
public void testPlainSkinBase() throws Exception {
- SkinFactory factory = (SkinFactory) SkinFactory.getInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ SkinFactory factory = (SkinFactory) SkinFactory.getInstance(facesContext);
assertNull(factory.getBaseSkin(facesContext).getParameter(facesContext,
Skin.GENERAL_BACKGROUND_COLOR));
}
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- private @interface SkinParameters {
- String skinName() default "";
- String baseSkinName() default "";
- }
-
- ;
}
Added:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/aplication/CoreComponentsConfiguration.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/aplication/CoreComponentsConfiguration.java
(rev 0)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/aplication/CoreComponentsConfiguration.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.aplication;
+
+import org.richfaces.application.configuration.ConfigurationItem;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class CoreComponentsConfiguration {
+
+ private CoreComponentsConfiguration() {}
+
+ public enum Items {
+
+ @ConfigurationItem(defaultValue = "true", names =
"org.richfaces.queue.enabled", literal = true)
+ queueEnabled
+
+ }
+
+}
Modified:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
*/
package org.richfaces.component;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
@@ -30,7 +32,7 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.aplication.CoreComponentsConfiguration;
/**
* @author Nick Belaevski
@@ -48,7 +50,7 @@
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot viewRoot = context.getViewRoot();
- boolean queueEnabled = ContextInitParameters.isQueueEnabled(context);
+ boolean queueEnabled = getBooleanConfigurationValue(context,
CoreComponentsConfiguration.Items.queueEnabled);
if (queueEnabled) {
Application application = context.getApplication();
UIComponent queueResourceComponent = application.createComponent(context,
Modified:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -21,6 +21,8 @@
*/
package org.richfaces.renderkit.html;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
@@ -34,7 +36,7 @@
import javax.faces.event.PreRemoveFromViewEvent;
import javax.faces.render.Renderer;
-import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.aplication.CoreComponentsConfiguration;
import org.richfaces.component.QueueRegistry;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -60,7 +62,7 @@
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException
{
FacesContext context = FacesContext.getCurrentInstance();
- if (!ContextInitParameters.isQueueEnabled(context)) {
+ if (!getBooleanConfigurationValue(context,
CoreComponentsConfiguration.Items.queueEnabled)) {
return;
}
Added:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/application/IterationComponentsConfiguration.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/application/IterationComponentsConfiguration.java
(rev 0)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/application/IterationComponentsConfiguration.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.application;
+
+import org.richfaces.application.configuration.ConfigurationItem;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class IterationComponentsConfiguration {
+
+ private IterationComponentsConfiguration() {}
+
+ public enum Items {
+
+ @ConfigurationItem(defaultValue = "false", names =
"org.richfaces.datatableUsesViewLocale")
+ datatableUsesViewLocale
+
+ }
+}
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/model/ArrangeableModel.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/model/ArrangeableModel.java 2010-09-03
15:36:40 UTC (rev 19118)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/model/ArrangeableModel.java 2010-09-03
17:34:35 UTC (rev 19119)
@@ -22,6 +22,8 @@
package org.richfaces.model;
+import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -35,12 +37,12 @@
import javax.faces.context.FacesContext;
import javax.faces.model.DataModelListener;
-import org.ajax4jsf.context.ContextInitParameters;
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
import org.ajax4jsf.model.SequenceRange;
+import org.richfaces.application.IterationComponentsConfiguration;
import org.richfaces.component.SortOrder;
/**
@@ -335,7 +337,7 @@
private Comparator<? super String> createStringComparator(FacesContext context)
{
Comparator<? super String> comparator = null;
Locale locale = state.getLocale();
- if (locale != null &&
ContextInitParameters.isDatatableUsesViewLocale(context)) {
+ if (locale != null && getBooleanConfigurationValue(context,
IterationComponentsConfiguration.Items.datatableUsesViewLocale)) {
comparator = Collator.getInstance(locale);
} else {
comparator = new Comparator<String>() {