Author: nbelaevski
Date: 2010-07-28 12:14:09 -0400 (Wed, 28 Jul 2010)
New Revision: 18263
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/main/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/main/java/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
Removed:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
Log:
Dynamic resources prerenderer: converted to Maven plugin
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 15:59:19 UTC
(rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 16:14:09 UTC
(rev 18263)
@@ -2,14 +2,16 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
<groupId>org.richfaces.cdk</groupId>
- <artifactId>dynamic-resources-prerenderer</artifactId>
-
- <!--
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
- -->
- <version>4.0.0-SNAPSHOT</version>
- <name>dynamic-resources-processor</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -25,21 +27,74 @@
<dependencies>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>file-management</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <!-- TODO - review dependencies -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.5-RC2</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>google-collections</artifactId>
+ <groupId>com.google.collections</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.el</groupId>
+ <artifactId>el-ri</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3-b03</version>
</dependency>
<dependency>
- <groupId>org.richfaces.ui</groupId>
- <artifactId>richfaces-components-ui</artifactId>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
@@ -48,28 +103,6 @@
<artifactId>slf4j-simple</artifactId>
<version>1.5.8</version>
</dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.5-RC2</version>
- <exclusions>
- <exclusion>
- <artifactId>google-collections</artifactId>
- <groupId>com.google.collections</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>com.sun.el</groupId>
- <artifactId>el-ri</artifactId>
- <version>1.0</version>
- </dependency>
</dependencies>
<build>
@@ -84,4 +117,42 @@
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>it</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <debug>true</debug>
+ <projectsDirectory>src/it</projectsDirectory>
+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <preBuildHookScript>setup</preBuildHookScript>
+
<postBuildHookScript>verify</postBuildHookScript>
+ <!--
localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath
-->
+ <!-- settingsFile>src/it/settings.xml</settingsFile
-->
+ <goals>
+ <goal>compile</goal>
+ <goal>test</goal>
+ </goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
(rev 0)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml 2010-07-28
16:14:09 UTC (rev 18263)
@@ -0,0 +1,60 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>richfaces-application</artifactId>
+ <name>Test component annotations</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <configuration>
+ </configuration>
+ <executions>
+ <execution>
+ <id>process</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <outputDir>images</outputDir>
+ <skins>
+ <skin>blueSky</skin>
+ <skin>classic</skin>
+ <skin>ruby</skin>
+ <skin>emeraldTown</skin>
+ <skin>wine</skin>
+ </skins>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!--
http://maven.apache.org/plugins/maven-compiler-plugin/
-->
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-components-ui</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh
(rev 0)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh 2010-07-28
16:14:09 UTC (rev 18263)
@@ -0,0 +1,11 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try {
+} catch(Throwable t) {
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Deleted:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -1,92 +0,0 @@
-/*
- * 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.cdk;
-
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.richfaces.cdk.concurrent.CountingExecutorCompletionService;
-import org.richfaces.cdk.faces.FacesImpl;
-import org.richfaces.cdk.naming.FileNameMapperImpl;
-import org.richfaces.cdk.resource.ResourceWriterImpl;
-import org.richfaces.cdk.resource.ResourcesScannerImpl;
-import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class Main {
-
- private static ExecutorService createExecutorService() {
- return Executors.newSingleThreadExecutor();
- }
-
- public static void main(String[] args) throws Exception {
- String dstDir = args[0];
- ResourceWriterImpl resourceWriter = new ResourceWriterImpl(dstDir);
- ResourceTaskFactory taskFactory = new ResourceTaskFactoryImpl();
- taskFactory.setResourceWriter(resourceWriter);
-
- // TODO set webroot
- Faces faces = new FacesImpl(null, new FileNameMapperImpl(), taskFactory);
- faces.start();
-
- ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
- resourcesScanner.scan();
-
- ExecutorService executorService = createExecutorService();
- CompletionService<Object> completionService = new
CountingExecutorCompletionService<Object>(executorService);
- taskFactory.setCompletionService(completionService);
- taskFactory.setSkins(Lists.newArrayList("blueSky", "ruby",
"classic"));
- for (ResourceInfo resourceInfo : resourcesScanner.getResources()) {
- taskFactory.submit(resourceInfo);
- }
-
- try {
- Future<Object> future = null;
- while (true) {
- future = completionService.take();
- if (future != null) {
- try {
- future.get();
- } catch (ExecutionException e) {
- // TODO: handle exception
- e.getCause().printStackTrace();
- }
- } else {
- break;
- }
- }
- } finally {
- executorService.shutdown();
- }
-
- faces.stop();
- }
-
-}
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
(rev 0)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -0,0 +1,171 @@
+/*
+ * 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.cdk;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.richfaces.cdk.concurrent.CountingExecutorCompletionService;
+import org.richfaces.cdk.faces.FacesImpl;
+import org.richfaces.cdk.naming.FileNameMapperImpl;
+import org.richfaces.cdk.resource.ResourceWriterImpl;
+import org.richfaces.cdk.resource.ResourcesScannerImpl;
+import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
+
+/**
+ * @goal process
+ * @requiresDependencyResolution compile
+ * @phase generate-resources
+ */
+public class ProcessMojo extends AbstractMojo {
+
+ /**
+ * @parameter
+ * @required
+ */
+ private String outputDir;
+
+ /**
+ * @parameter
+ * @required
+ */
+ private String[] skins;
+
+ /**
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ private MavenProject project;
+
+ private static ExecutorService createExecutorService() {
+ return Executors.newSingleThreadExecutor();
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL)
{
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ List<?> compileClasspathElements =
project.getCompileClasspathElements();
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[compileClasspathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<?> iter = compileClasspathElements.iterator();
iter.hasNext(); ) {
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ } catch (DependencyResolutionRequiredException e) {
+ getLog().error("Dependencies not resolved ", e);
+ }
+
+ return classLoader;
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ ClassLoader cCL = Thread.currentThread().getContextClassLoader();
+ Faces faces = null;
+ ExecutorService executorService = null;
+
+ try {
+ ClassLoader projectCL = createProjectClassLoader(project, true);
+ Thread.currentThread().setContextClassLoader(projectCL);
+
+ File outputDirFile = new File(outputDir);
+ if (!outputDirFile.exists()) {
+ outputDirFile = new File(project.getBuild().getOutputDirectory(),
outputDir);
+ }
+
+ ResourceWriterImpl resourceWriter = new ResourceWriterImpl(outputDirFile);
+ ResourceTaskFactoryImpl taskFactory = new ResourceTaskFactoryImpl();
+ taskFactory.setResourceWriter(resourceWriter);
+
+ // TODO set webroot
+ faces = new FacesImpl(null, new FileNameMapperImpl(), taskFactory);
+ faces.start();
+
+ ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
+ resourcesScanner.scan();
+
+ executorService = createExecutorService();
+ CompletionService<Object> completionService = new
CountingExecutorCompletionService<Object>(executorService);
+ taskFactory.setCompletionService(completionService);
+ taskFactory.setSkins(skins);
+ taskFactory.setLog(getLog());
+ for (ResourceInfo resourceInfo : resourcesScanner.getResources()) {
+ taskFactory.submit(resourceInfo);
+ }
+
+ Future<Object> future = null;
+ while (true) {
+ future = completionService.take();
+ if (future != null) {
+ try {
+ future.get();
+ } catch (ExecutionException e) {
+ // TODO: handle exception
+ e.getCause().printStackTrace();
+ }
+ } else {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ } finally {
+ //TODO review finally block
+ if (executorService != null) {
+ executorService.shutdown();
+ }
+ if (faces != null) {
+ faces.stop();
+ }
+ Thread.currentThread().setContextClassLoader(cCL);
+ }
+ }
+
+}
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -21,7 +21,6 @@
*/
package org.richfaces.cdk;
-import java.util.Collection;
import java.util.concurrent.CompletionService;
/**
@@ -30,7 +29,7 @@
*/
public interface ResourceTaskFactory {
- public void setSkins(Collection<String> skins);
+ public void setSkins(String[] skins);
public void setCompletionService(CompletionService<Object> completionService);
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -295,12 +295,13 @@
if (root.exists()) {
String[] list = root.list();
for (String childName : list) {
- File child = new File(root, childName);
+ String name = childName;
+ File child = new File(root, name);
if (child.isDirectory()) {
- childName += '/';
+ name += '/';
}
- result.add(path + '/' + childName);
+ result.add(path + '/' + name);
}
}
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -31,6 +31,8 @@
*/
public abstract class ReadOnlyValueExpression extends ValueExpression {
+ private static final long serialVersionUID = 7424302517400727467L;
+
@Override
public abstract Object getValue(ELContext context);
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -40,7 +40,6 @@
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
-import com.sun.faces.util.Util;
/**
* @author Nick Belaevski
@@ -102,7 +101,7 @@
if (!prop.contains(":")) {
resource = handler.createResource(prop);
} else {
- String[] parts = Util.split(prop, ":");
+ String[] parts = prop.split(":");
if (parts.length != 2) {
throw new ELException(MessageFormat.format("Invalid resource
format. Property {0} contains more than one colon (:)", prop));
}
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -113,6 +113,7 @@
result.setResourceName(resourceName);
result.setLibraryName(libraryName);
+ //TODO simply discover & process all available resources
ResourceTaskFactory resourceTaskFactory =
ServiceTracker.getService(ResourceTaskFactory.class);
resourceTaskFactory.submit(new ResourceInfo(resourceName, libraryName));
}
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -32,11 +32,11 @@
*/
public class MarkerResourcesScanner extends AbstractScanner {
+ static final String STORE_KEY = "org.richfaces.cdk.dynamicResourceNames";
+
private static final String RESOURCE_PROPERTIES_EXT =
".resource.properties";
private static final String META_INF = "META-INF/";
-
- static final String STORE_KEY = "org.richfaces.cdk.dynamicResourceNames";
@Override
public void scan(Object cls) {
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -48,12 +48,12 @@
private static final Predicate<String> ECSS_RESOURCE_PREDICATE = new
Predicate<String>() {
- private final Pattern PATH_PATTERN =
Pattern.compile(MessageFormat.format("^{0}.+\\.ecss$",
+ private final Pattern pathPattern =
Pattern.compile(MessageFormat.format("^{0}.+\\.ecss$",
ResourceInfo.CLASSPATH_RESOURCES_LOCATION));
@Override
public boolean apply(String input) {
- return PATH_PATTERN.matcher(input).matches();
+ return pathPattern.matcher(input).matches();
}
};
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -42,8 +42,8 @@
private File baseDir;
- public ResourceWriterImpl(String baseDirectoryName) {
- baseDir = new File(baseDirectoryName);
+ public ResourceWriterImpl(File baseDir) {
+ this.baseDir = baseDir;
baseDir.mkdirs();
}
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -100,12 +100,8 @@
};
- private static boolean containsFacesConfig(Dir dir) {
- return Iterators.any(dir.getFiles().iterator(), IS_FACES_CONFIG);
- }
-
private static final Predicate<URL> FACES_URL = new Predicate<URL>() {
-
+
public boolean apply(URL input) {
Dir dir = Vfs.fromURL(input);
if (dir instanceof ZipDir) {
@@ -115,8 +111,12 @@
}
}
};
-
+
private Collection<ResourceInfo> resources = Sets.newHashSet();
+
+ private static boolean containsFacesConfig(Dir dir) {
+ return Iterators.any(dir.getFiles().iterator(), IS_FACES_CONFIG);
+ }
public void scan() {
resources.clear();
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
===================================================================
---
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28
15:59:19 UTC (rev 18262)
+++
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28
16:14:09 UTC (rev 18263)
@@ -22,8 +22,6 @@
package org.richfaces.cdk.task;
import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ConcurrentMap;
@@ -32,16 +30,14 @@
import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
+import org.apache.maven.plugin.logging.Log;
import org.richfaces.cdk.Faces;
import org.richfaces.cdk.ResourceInfo;
import org.richfaces.cdk.ResourceTaskFactory;
import org.richfaces.cdk.ResourceWriter;
import org.richfaces.cdk.faces.CurrentResourceContext;
import org.richfaces.resource.StateHolderResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -52,8 +48,6 @@
*/
public class ResourceTaskFactoryImpl implements ResourceTaskFactory {
- private static final Logger LOGGER =
LoggerFactory.getLogger(ResourceTaskFactoryImpl.class);
-
private class ResourcesRendererCallable implements Callable<Object> {
private String skinName;
@@ -101,7 +95,7 @@
//TODO check content type
resourceWriter.writeResource(skinName, resource);
} catch (Exception e) {
- LOGGER.error(MessageFormat.format("Exception rendering resorce {0}
using skin {1}: {2}", resourceInfo, skinName, e.getMessage()), e);
+ log.error(MessageFormat.format("Exception rendering resorce {0}
using skin {1}: {2}", resourceInfo, skinName, e.getMessage()), e);
} finally {
faces.setSkin(null);
faces.stopRequest();
@@ -115,6 +109,8 @@
}
+ private Log log;
+
private Faces faces;
private ResourceWriter resourceWriter;
@@ -123,8 +119,12 @@
private CompletionService<Object> completionService;
- private Collection<String> skins = Collections.emptySet();
+ private String[] skins = new String[0];
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
public void setFaces(Faces faces) {
this.faces = faces;
}
@@ -133,8 +133,8 @@
this.resourceWriter = resourceWriter;
}
- public void setSkins(Collection<String> skins) {
- this.skins = Lists.newArrayList(skins);
+ public void setSkins(String[] skins) {
+ this.skins = skins;
}
public void setCompletionService(CompletionService<Object> completionService)
{