Author: alexsmirnov
Date: 2009-03-03 20:25:32 -0500 (Tue, 03 Mar 2009)
New Revision: 12816
Added:
trunk/framework/api/src/main/java/org/richfaces/skin/Theme.java
trunk/framework/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java
trunk/framework/test/src/test/resources/META-INF/themes/
trunk/framework/test/src/test/resources/META-INF/themes/test.theme.properties
Modified:
trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcePath.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java
trunk/sandbox/ui/layout/src/main/config/component/page.xml
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractPageRenderer.java
Log:
Page layout component view fixed.
Created 'theme' configuration structure.
Modified: trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java 2009-03-03
23:53:46 UTC (rev 12815)
+++ trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -202,5 +202,12 @@
* @return
*/
public abstract Skin getBaseSkin(FacesContext facesContext);
+
+ /**
+ * @param facesContext
+ * @param name
+ * @return
+ */
+ public abstract Theme getTheme(FacesContext facesContext, String name);
}
Added: trunk/framework/api/src/main/java/org/richfaces/skin/Theme.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/skin/Theme.java
(rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/skin/Theme.java 2009-03-04 01:25:32
UTC (rev 12816)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.richfaces.skin;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface Theme {
+
+ public String getRendererType();
+
+ public String getStyle();
+
+ public String getScript();
+
+ public Object getProperty(String name);
+
+}
Property changes on: trunk/framework/api/src/main/java/org/richfaces/skin/Theme.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2009-03-03
23:53:46 UTC (rev 12815)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -56,6 +56,7 @@
*/
public class SkinFactoryImpl extends SkinFactory {
+
/**
* Name of web application init parameter for current default
* {@link javax.faces.render.RenderKit } interaction. by default -
@@ -66,9 +67,11 @@
/**
* Resource Uri for properties file with default values of skin parameters.
*/
- private static final String DEFAULT_SKIN_PROPERTIES_RESOURCE =
"META-INF/skins/DEFAULT.skin.properties";
+ private static final String DEFAULT_SKIN_PATH =
"META-INF/skins/%s.skin.properties";
- private static final String DEFAULT_CONFIGURATION_RESOURCE =
"META-INF/skins/DEFAULT.configuration.properties";
+ private static final String USER_SKIN_PATH = "%s.skin.properties";
+
+ // private static final String DEFAULT_CONFIGURATION_RESOURCE =
"META-INF/skins/DEFAULT.configuration.properties";
/**
* Name of default skin . "DEFAULT" in this realisation.
*/
@@ -80,19 +83,22 @@
* user-defined.
*/
private static final String[] SKINS_PATHS = {
- "META-INF/skins/%s.skin.properties", "%s.skin.properties" };
- private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PROPERTIES_RESOURCE
};
+ DEFAULT_SKIN_PATH, USER_SKIN_PATH };
+ private static final String[] THEME_PATHS = {
+ "META-INF/themes/%s.theme.properties", "%s.theme.properties" };
+// private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PATH };
- private static final String[] CONFIGURATIONS_PATHS = {
- "META-INF/skins/%s.configuration.properties",
- "%s.configuration.properties" };
- private static final String[] DEFAULT_CONFIGURATION_PATHS = {
"META-INF/skins/DEFAULT.configuration.properties" };
+// private static final String[] CONFIGURATIONS_PATHS = {
+// "META-INF/skins/%s.configuration.properties",
+// "%s.configuration.properties" };
+// private static final String[] DEFAULT_CONFIGURATION_PATHS = {
"META-INF/skins/DEFAULT.configuration.properties" };
- private Map skins = Collections.synchronizedMap(new HashMap());
- private Map baseSkins = Collections.synchronizedMap(new HashMap());
- private Map sourceProperties = Collections.synchronizedMap(new HashMap());
+ private Map<String,Skin> skins = new HashMap<String,Skin>();
+ private Map<String,Skin> baseSkins = new HashMap<String,Skin>();
+ private Map<String,Properties> sourceProperties = new
HashMap<String,Properties>();
+ private Map<String,Theme> themes = new HashMap<String,Theme>();
- private Properties defaultSkinProperties = null;
+// private Properties defaultSkinProperties = null;
private String skinName = null;
private ValueExpression skinBinding = null;
private String baseSkinName = null;
@@ -108,25 +114,29 @@
throw new SkinNotFoundException(Messages
.getMessage(Messages.NULL_SKIN_NAME_ERROR));
}
+ Skin currentSkin = null;
// user binding return skin instance.
if (currentSkinOrName instanceof Skin) {
- return (Skin) currentSkinOrName;
- }
- String currentSkinName = currentSkinOrName.toString();
-
- Map skinsMap = (isBase ? baseSkins : skins);
- Skin currentSkin = (Skin) skinsMap.get(currentSkinName);
- // LAZY creation for skins, since, in case of EL expressions
- // for skin name, we don't can know all names of existing skins.
- if (currentSkin == null) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CREATE_SKIN_INFO,
- currentSkinName));
+ currentSkin = (Skin) currentSkinOrName;
+ } else {
+ String currentSkinName = currentSkinOrName.toString();
+
+ Map<String, Skin> skinsMap = (isBase ? baseSkins : skins);
+ synchronized (skinsMap) {
+ currentSkin = (Skin) skinsMap.get(currentSkinName);
+ // LAZY creation for skins, since, in case of EL expressions
+ // for skin name, we don't can know all names of existing skins.
+ if (currentSkin == null) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.CREATE_SKIN_INFO, currentSkinName));
+ }
+ currentSkin = buildSkin(facesContext, currentSkinName,
+ isBase);
+ skinsMap.put(currentSkinName, currentSkin);
+ }
}
- currentSkin = buildSkin(facesContext, currentSkinName, isBase);
- skinsMap.put(currentSkinName, currentSkin);
}
-
return currentSkin;
}
@@ -146,47 +156,14 @@
return getSkinByName(context, currentSkinOrName, true);
}
- protected Properties getDefaultSkinProperties() {
- if (defaultSkinProperties == null) {
- defaultSkinProperties = loadDefaultProperties(DEFAULT_SKIN_PROPERTIES_RESOURCE);
- }
- return defaultSkinProperties;
- }
+// protected Properties getDefaultSkinProperties() {
+// if (defaultSkinProperties == null) {
+// defaultSkinProperties = loadProperties(DEFAULT_SKIN_NAME,DEFAULT_SKIN_PATHS);
+// }
+// return defaultSkinProperties;
+// }
/**
- *
- */
- private Properties loadDefaultProperties(String path) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Properties defaultProperties = new Properties();
- try {
- Enumeration properties = loader.getResources(path);
- while (properties.hasMoreElements()) {
- URL url = (URL) properties.nextElement();
- InputStream propertyStream = null;
- try {
- propertyStream = URLToStreamHelper.urlToStream(url);
- defaultProperties.load(propertyStream);
- } catch (IOException e) {
- // DO Nothing...
- log.info(Messages.getMessage(
- Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR, path),
- e);
- continue;
- } finally {
- if (null != propertyStream) {
- propertyStream.close();
- }
- }
- }
- } catch (IOException e) {
- log.info(Messages.getMessage(
- Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR, path), e);
- }
- return defaultProperties;
- }
-
- /**
* Calculate name for current skin. For EL init parameter store value
* binding for speed calculations.
*
@@ -238,14 +215,14 @@
} else {
skin = currentSkinName;
}
- }
- if (useBase) {
- baseSkinBinding = binding;
- baseSkinName = skin;
- } else {
- skinBinding = binding;
- skinName = skin;
+ if (useBase) {
+ baseSkinBinding = binding;
+ baseSkinName = skin;
+ } else {
+ skinBinding = binding;
+ skinName = skin;
+ }
}
// }
@@ -294,15 +271,16 @@
*/
protected Skin buildSkin(FacesContext context, String name, boolean isBase)
throws SkinNotFoundException {
-
- Map<Object, Object> skinParams = (Map<Object, Object>)
sourceProperties.get(name);
- if (skinParams == null) {
- skinParams = loadProperties(name, SKINS_PATHS);
- processProperties(context, skinParams);
- skinParams = Collections.unmodifiableMap(skinParams);
- sourceProperties.put(name, skinParams);
- }
-
+ Properties skinParams;
+ synchronized (sourceProperties) {
+ skinParams = sourceProperties.get(name);
+ if (skinParams == null) {
+ skinParams = loadProperties(name, SKINS_PATHS);
+ processProperties(context, skinParams);
+ // skinParams = Collections.unmodifiableMap(skinParams);
+ sourceProperties.put(name, skinParams);
+ }
+ }
BasicSkinImpl skinImpl;
if (DEFAULT_SKIN_NAME.equals(name)) {
skinImpl = new DefaultSkinImpl(skinParams);
@@ -323,45 +301,17 @@
* @throws FacesException
* @throws ReferenceSyntaxException
*/
- protected Map loadProperties(String name, String[] paths) throws SkinNotFoundException,
FacesException,
- ReferenceSyntaxException {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ protected Properties loadProperties(String name, String[] paths) throws
SkinNotFoundException, FacesException {
+ ClassLoader loader = getClassLoader();
// Get properties for concrete skin.
Properties skinProperties = new Properties();
int loadedPropertiesCount = 0;
for (int i = 0; i < paths.length; i++) {
- try {
- String skinPropertiesLocation = paths[i].replaceAll("%s", name);
- Enumeration properties = loader
- .getResources(skinPropertiesLocation);
- while (properties.hasMoreElements()) {
- URL url = (URL) properties.nextElement();
- InputStream propertyStream = null;
- try {
- propertyStream = URLToStreamHelper.urlToStream(url);
- skinProperties.load(propertyStream);
- loadedPropertiesCount++;
- } catch (IOException e) {
- log.warn(Messages
- .getMessage(Messages.SKIN_PROPERTIES_IO_ERROR),
- e);
- continue;
- } finally {
- if (null != propertyStream) {
- propertyStream.close();
- }
- }
- }
- } catch (IOException e) {
- // Do nothing - we can only log error, and continue to load next
- // property.
- if (log.isInfoEnabled()) {
- log.info(Messages
- .getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
- }
+ String skinPropertiesLocation = paths[i].replaceAll("%s", name);
+ if(loadProperties(loader, skinProperties, skinPropertiesLocation)){
+ loadedPropertiesCount++;
}
}
- // TODO - read skin from property file in WEB-INF directory.
if (loadedPropertiesCount == 0) {
throw new SkinNotFoundException(Messages.getMessage(
Messages.SKIN_NOT_FOUND_ERROR, name));
@@ -369,4 +319,62 @@
return skinProperties;
}
+ /**
+ * @return
+ */
+ protected ClassLoader getClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ /**
+ * @param loader
+ * @param properties
+ * @param location
+ */
+ protected boolean loadProperties(ClassLoader loader, Properties properties,
+ String location) {
+ boolean loaded = false;
+ try {
+ Enumeration<URL> resources = loader
+ .getResources(location);
+ while (resources.hasMoreElements()) {
+ URL url = (URL) resources.nextElement();
+ InputStream propertyStream = null;
+ try {
+ propertyStream = URLToStreamHelper.urlToStream(url);
+ properties.load(propertyStream);
+ loaded=true;
+ } catch (IOException e) {
+ log.warn(Messages
+ .getMessage(Messages.SKIN_PROPERTIES_IO_ERROR),
+ e);
+ continue;
+ } finally {
+ if (null != propertyStream) {
+ propertyStream.close();
+ }
+ }
+ }
+ } catch (IOException e) {
+ // Do nothing - we can only log error, and continue to load next
+ // property.
+ if (log.isInfoEnabled()) {
+ log.info(Messages
+ .getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
+ }
+ }
+ return loaded;
+ }
+
+ @Override
+ public Theme getTheme(FacesContext facesContext, String name) {
+ Theme theme = themes.get(name);
+ if(null == theme){
+ Properties properties = loadProperties(name, THEME_PATHS);
+ processProperties(facesContext, properties);
+ theme = new ThemeImpl(properties);
+ themes.put(name, theme);
+ }
+ return theme;
+ }
}
Added: trunk/framework/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/ThemeImpl.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -0,0 +1,59 @@
+/**
+ *
+ */
+package org.richfaces.skin;
+
+import java.util.Properties;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ThemeImpl implements Theme {
+
+ private final Properties themeProperties;
+
+ /**
+ * @param themeProperties
+ */
+ public ThemeImpl(Properties themeProperties) {
+ this.themeProperties = themeProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Theme#getProperty(java.lang.String)
+ */
+ public Object getProperty(String name) {
+ Object property = themeProperties.get(name);
+ if (property instanceof ValueExpression) {
+ ValueExpression ve = (ValueExpression) property;
+ property = ve.getValue(FacesContext.getCurrentInstance().getELContext());
+ }
+ return property;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Theme#getRendererType()
+ */
+ public String getRendererType() {
+ return (String) getProperty("rendererType");
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Theme#getScript()
+ */
+ public String getScript() {
+ return (String) getProperty("script");
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Theme#getStyle()
+ */
+ public String getStyle() {
+ return (String) getProperty("styleSheet");
+ }
+
+}
Property changes on: trunk/framework/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcePath.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcePath.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcePath.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -16,9 +16,9 @@
private static final Pattern SLASH = Pattern.compile("/");
- public static final ServerResourcePath WEB_INF=new
ServerResourcePath("/WEB-INF");
+ public static final ServerResourcePath WEB_INF=new
ServerResourcePath("/WEB-INF/");
- public static final ServerResourcePath META_INF=new
ServerResourcePath("/META-INF");
+ public static final ServerResourcePath META_INF=new
ServerResourcePath("/META-INF/");
public static final ServerResourcePath WEB_XML=new
ServerResourcePath("/WEB-INF/web.xml");
public static final ServerResourcePath FACES_CONFIG=new
ServerResourcePath("/WEB-INF/faces-config.xml");
@@ -45,7 +45,13 @@
if (!path.startsWith("/")) {
throw new IllegalArgumentException();
}
- pathElements = SLASH.split(path);
+ String[] split = SLASH.split(path);
+ if(split.length >1 && path.endsWith("/")){
+ pathElements = new String[split.length+1];
+ System.arraycopy(split, 0, pathElements, 0, split.length);
+ } else {
+ pathElements = split;
+ }
}
/**
@@ -53,17 +59,21 @@
* @return true for a last element in the path.
*/
public boolean isFile() {
- return pathElements.length <= 1;
+ return pathElements.length <= 1 || null == pathElements[1];
}
/**
* Name of the next element ( directory or file ) name.
- * For the "/foo/bar/baz" it should be "foo" , /bar/baz :
"bar" , "/" : null.
+ * For the "/foo/bar/baz" it should be "foo/" , /bar/baz :
"bar/" , "/" : null.
* @return name of the next element or null if it is last element in the chain ( file
).
*/
public String getNextElementName() {
if (pathElements.length > 1) {
- return pathElements[1];
+ String name = pathElements[1];
+ if(pathElements.length>2){
+ name+='/';
+ }
+ return name;
} else {
return null;
}
@@ -75,7 +85,7 @@
* @return next subdirectory path or null.
*/
public ServerResourcePath getNextPath() {
- if (pathElements.length > 1) {
+ if (pathElements.length > 1 && null != pathElements[1]) {
String[] nextElenemts = new String[pathElements.length - 1];
System.arraycopy(pathElements, 1, nextElenemts, 0, nextElenemts.length);
return new ServerResourcePath(nextElenemts);
@@ -90,7 +100,10 @@
if (pathElements.length > 1) {
for (int i = 1; i < pathElements.length; i++) {
String element = pathElements[i];
- str.append("/").append(element);
+ str.append("/");
+ if(null != element){
+ str.append(element);
+ }
}
} else {
str.append("/");
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -9,21 +9,35 @@
import javax.servlet.ServletContext;
import javax.servlet.jsp.JspApplicationContext;
-import com.sun.el.ExpressionFactoryImpl;
+import org.richfaces.test.TestException;
+
/**
* @author asmirnov
*
*/
public class StaggingJspApplicationContext implements JspApplicationContext {
+ private static final String
DEFAULT_EXPRESSION_FACTORY="com.sun.el.ExpressionFactoryImpl";
+
private final ExpressionFactory expressionFactory ;
private final ServletContext servletContext;
public StaggingJspApplicationContext(ServletContext servletContext) {
this.servletContext = servletContext;
- expressionFactory = ExpressionFactory.newInstance();
+ String elFactoryClass =
servletContext.getInitParameter("com.sun.faces.expressionFactory");
+ if(null == elFactoryClass){
+ elFactoryClass =
servletContext.getInitParameter("com.sun.el.ExpressionFactoryImpl");
+ }
+ if(null == elFactoryClass){
+ elFactoryClass = DEFAULT_EXPRESSION_FACTORY;
+ }
+ try {
+ expressionFactory =
Class.forName(elFactoryClass).asSubclass(ExpressionFactory.class).newInstance();
+ } catch (Exception e) {
+ throw new TestException("Couldn't instantiate EL expression
factory",e);
+ }
}
/* (non-Javadoc)
@@ -37,7 +51,6 @@
* @see javax.servlet.jsp.JspApplicationContext#addELResolver(javax.el.ELResolver)
*/
public void addELResolver(ELResolver resolver) {
-
}
/* (non-Javadoc)
Copied:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java
(from rev 12814,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java)
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -0,0 +1,249 @@
+/*
+ * $Id$
+ */
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License").
You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package org.richfaces.test.staging;
+
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.spi.InitialContextFactoryBuilder;
+
+/**
+ * <p class="changed_added_2_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class StagingInitialContextFactoryBuilder implements
+ InitialContextFactoryBuilder {
+
+ private static final class StagingInitialContext implements Context {
+ public Object addToEnvironment(String propName,
+ Object propVal) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void bind(Name name, Object obj)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void bind(String name, Object obj)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close() throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Name composeName(Name name, Name prefix)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String composeName(String name, String prefix)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void destroySubcontext(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void destroySubcontext(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Hashtable<?, ?> getEnvironment()
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookupLink(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookupLink(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rebind(Name name, Object obj)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rebind(String name, Object obj)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object removeFromEnvironment(String propName)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rename(Name oldName, Name newName)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rename(String oldName, String newName)
+ throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(String name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+ }
+
+ public static final class StagingInitialContextFactory implements
+ InitialContextFactory {
+ public Context getInitialContext(Hashtable<?, ?> environment)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return new StagingInitialContext();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.naming.spi.InitialContextFactoryBuilder#createInitialContextFactory(java.util.Hashtable)
+ */
+ public InitialContextFactory createInitialContextFactory(
+ Hashtable<?, ?> environment) throws NamingException {
+ return new StagingInitialContextFactory();
+ }
+
+}
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -20,6 +20,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import javax.naming.NamingException;
+import javax.naming.spi.NamingManager;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
@@ -450,6 +452,9 @@
if (!directory.isDirectory()) {
directory = directory.getParentFile();
}
+ if(!directory.exists()){
+ throw new TestException("directory does not
exist:"+directory.getAbsolutePath());
+ }
try {
addFiles(baseDirectory, directory);
} catch (MalformedURLException e) {
@@ -473,15 +478,11 @@
if (!file.isDirectory()) {
file = file.getParentFile();
}
- if(file.exists()){
try {
addFiles(baseDirectory, file);
} catch (MalformedURLException e) {
throw new TestException(e);
}
- } else {
- throw new TestException("Base webapp directory ["+file.getPath()+"]
does not exist");
- }
}
/**
@@ -535,13 +536,15 @@
throws MalformedURLException {
File[] files = file.listFiles();
for (File subfile : files) {
- ServerResourcePath serverResourcePath = new ServerResourcePath("/"
- + subfile.getName());
if (subfile.isDirectory()) {
+ ServerResourcePath serverResourcePath = new ServerResourcePath("/"
+ + subfile.getName()+"/");
ServerResourcesDirectory subDir = new ServerResourcesDirectory();
baseDirectory.addResource(serverResourcePath, subDir);
addFiles(subDir, subfile);
} else {
+ ServerResourcePath serverResourcePath = new ServerResourcePath("/"
+ + subfile.getName());
UrlServerResource resource = new UrlServerResource(subfile
.toURL());
baseDirectory.addResource(serverResourcePath, resource);
@@ -753,6 +756,13 @@
} catch (ServletException e) {
throw new TestException("Servlet initialisation error ", e);
}
+ try {
+ NamingManager.setInitialContextFactoryBuilder(new
StagingInitialContextFactoryBuilder());
+ } catch (NamingException e) {
+ log.warning("Error set initial context factory builder.");
+ } catch (IllegalStateException e) {
+ log.warning("Initial context factory builder already set.");
+ }
this.initialised = true;
}
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -10,6 +10,7 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -175,11 +176,18 @@
*/
@SuppressWarnings("unchecked")
public Set getResourcePaths(String path) {
+ HashSet result=null;
ServerResource resource = getServerResource(path);
if(null != resource){
- return resource.getPaths();
+ Set<String> paths = resource.getPaths();
+ if(null != paths && paths.size()>0){
+ result = new HashSet(paths.size());
+ for (String resourcePath : paths) {
+ result.add(path+resourcePath);
+ }
+ }
}
- return null;
+ return result;
}
/* (non-Javadoc)
Modified:
trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
===================================================================
---
trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -35,8 +35,8 @@
assertNotNull(path.getNextPath());
assertNotNull(path.getNextElementName());
assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
+ assertEquals("WEB-INF/", path.getNextElementName());
+ assertEquals("/WEB-INF/", path.toString());
path = path.getNextPath();
assertNotNull(path);
assertTrue(path.isFile());
@@ -53,8 +53,8 @@
assertNotNull(path.getNextPath());
assertNotNull(path.getNextElementName());
assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
+ assertEquals("WEB-INF/", path.getNextElementName());
+ assertEquals("/WEB-INF/", path.toString());
path = path.getNextPath();
assertNotNull(path);
assertTrue(path.isFile());
@@ -70,7 +70,7 @@
public void testWebXmlPath() {
ServerResourcePath path = ServerResourcePath.WEB_XML;
assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("WEB-INF/", path.getNextElementName());
assertEquals("/WEB-INF/web.xml", path.toString());
path = path.getNextPath();
assertNotNull(path.getNextElementName());
Modified: trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java 2009-03-03
23:53:46 UTC (rev 12815)
+++ trunk/framework/test/src/test/java/org/richfaces/skin/SkinTestCase.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -219,16 +219,6 @@
assertFalse( hash==skin.hashCode(facesContext) );
}
- /*
- * Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
- */
- public void testGetDefaultProperties() {
- SkinFactoryImpl factory = (SkinFactoryImpl) SkinFactory.getInstance();
- Properties defaultProps = factory.getDefaultSkinProperties();
- // assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
- // Second default config
- assertEquals("default",defaultProps.getProperty("a"));
- }
/*
* Test method for
'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
@@ -236,5 +226,12 @@
public void testGetSkinName() {
}
+
+ public void testGetTheme() throws Exception {
+ SkinFactory factory = SkinFactory.getInstance();
+ Theme theme = factory.getTheme(facesContext, "test");
+ assertNotNull(theme);
+ assertEquals("foo", theme.getRendererType());
+ }
}
Added: trunk/framework/test/src/test/resources/META-INF/themes/test.theme.properties
===================================================================
--- trunk/framework/test/src/test/resources/META-INF/themes/test.theme.properties
(rev 0)
+++
trunk/framework/test/src/test/resources/META-INF/themes/test.theme.properties 2009-03-04
01:25:32 UTC (rev 12816)
@@ -0,0 +1 @@
+rendererType=foo
Property changes on:
trunk/framework/test/src/test/resources/META-INF/themes/test.theme.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sandbox/ui/layout/src/main/config/component/page.xml
===================================================================
--- trunk/sandbox/ui/layout/src/main/config/component/page.xml 2009-03-03 23:53:46 UTC
(rev 12815)
+++ trunk/sandbox/ui/layout/src/main/config/component/page.xml 2009-03-04 01:25:32 UTC
(rev 12816)
@@ -11,6 +11,22 @@
<![CDATA[
]]>
</description>
+ <facet>
+ <name>pageHeader</name>
+ <description><![CDATA[ ]]></description>
+ </facet>
+ <facet>
+ <name>header</name>
+ <description><![CDATA[ ]]></description>
+ </facet>
+ <facet>
+ <name>footer</name>
+ <description><![CDATA[ ]]></description>
+ </facet>
+ <facet>
+ <name>sidebar</name>
+ <description><![CDATA[ ]]></description>
+ </facet>
<renderer generate="true" override="true">
<name>org.richfaces.PageRenderer</name>
<template>org/richfaces/htmlPage.jspx</template>
@@ -58,6 +74,11 @@
</description>
</property>
<property>
+ <name>theme</name>
+ <classname>java.lang.String</classname>
+ <description><![CDATA[ ]]></description>
+ </property>
+ <property>
<name>contentType</name>
<classname>java.lang.String</classname>
<description>
Modified:
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractPageRenderer.java
===================================================================
---
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractPageRenderer.java 2009-03-03
23:53:46 UTC (rev 12815)
+++
trunk/sandbox/ui/layout/src/main/java/org/richfaces/renderkit/AbstractPageRenderer.java 2009-03-04
01:25:32 UTC (rev 12816)
@@ -114,7 +114,7 @@
public String documentClass(FacesContext context, UIComponent component) {
//TODO - calculate class.
- return "ui-t3";
+ return "yui-t3";
}
public boolean hasFacet(UIComponent component, String facet){