[richfaces-svn-commits] JBoss Rich Faces SVN: r12382 - in trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd: generator and 3 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Jan 23 07:53:14 EST 2009
Author: abelevich
Date: 2009-01-23 07:53:14 -0500 (Fri, 23 Jan 2009)
New Revision: 12382
Modified:
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java
Log:
review
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -15,24 +15,17 @@
public class JarResourceScanner {
private FileObject baseFile;
-
+
private Set <FileObject> result = new HashSet <FileObject>();
- private String [] patterns;
+ private String [] patterns = new String[] {"**"};
+
public String[] getPatterns() {
return patterns;
}
public void setPatterns(String[] patterns) {
- if(patterns == null) {
- patterns = new String[] {"**"};
- }
-
- if(patterns.length < 1) {
- patterns = new String[] {"**"};
- }
-
this.patterns = patterns;
}
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -1,3 +1,23 @@
+/**
+ * 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.richfaces.cdk.rd.generator;
import java.io.File;
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -1,3 +1,23 @@
+/**
+ * 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.richfaces.cdk.rd.generator;
import java.io.File;
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -45,7 +45,7 @@
xmlBody.loadXML(resourceInputStream,true);
builder.append(xmlBody.getContent());
} catch (ParsingException e) {
- log.error("Error processing xcss: " + e.getMessage(), e);
+ log.error("Error process xcss: " + e.getMessage(), e);
}
} else {
builder.append(IOUtil.toString(resourceInputStream));
@@ -69,7 +69,7 @@
public void writeToFile(File file) {
try {
- if(builder.length() > 0) {
+ if(builder.length() > 0 && velocityComponent != null) {
VelocityContext context = new VelocityContext();
context.put("content", builder);
VelocityEngine engine = velocityComponent.getEngine();
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -1,3 +1,23 @@
+/**
+ * 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.richfaces.cdk.rd.handler;
import java.util.LinkedHashSet;
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -1,6 +1,8 @@
package org.richfaces.cdk.rd.mojo;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -160,7 +162,7 @@
public void execute() throws MojoExecutionException, MojoFailureException {
try {
Set <Artifact> artifacts = resolveDependenciesArtifacts();
- Digester defaultDigester = getDigester();
+ Digester defaultDigester = createDigester();
Map <String, Components> components = new HashMap<String, Components>();
for (Artifact artifact : artifacts) {
@@ -208,22 +210,17 @@
styleGenerator.writeToFile();
}
- protected Set <Artifact> resolveDependenciesArtifacts() {
+ protected Set <Artifact> resolveDependenciesArtifacts() throws Exception {
ArtifactResolutionResult result = null;
- try {
- List <Dependency> dependencies = project.getDependencies();
- Set <Artifact> artifacts = MavenMetadataSource.createArtifacts(factory, dependencies, null, null, project);
- artifacts.add(project.getArtifact());
-
- result = resolver.resolveTransitively(artifacts, project.getArtifact(), Collections.EMPTY_LIST, localRepository, metadataSource);
- } catch (Exception e) {
- getLog().error(e);
- }
+ List <Dependency> dependencies = project.getDependencies();
+ Set <Artifact> artifacts = MavenMetadataSource.createArtifacts(factory, dependencies, null, null, project);
+ artifacts.add(project.getArtifact());
+ result = resolver.resolveTransitively(artifacts, project.getArtifact(), Collections.EMPTY_LIST, localRepository, metadataSource);
return result.getArtifacts();
}
- public ComponentsHandler findComponents (File webSourceDir, Map <String, Components> components, String [] includes, String [] excludes) {
+ public ComponentsHandler findComponents (File webSourceDir, Map <String, Components> components, String [] includes, String [] excludes) throws Exception {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(webSourceDir);
@@ -236,28 +233,21 @@
ComponentsHandler handler = new ComponentsHandler();
handler.setComponents(components);
- try {
-
- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
- saxParserFactory.setNamespaceAware(true);
- SAXParser saxParser = saxParserFactory.newSAXParser();
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ saxParserFactory.setNamespaceAware(true);
+ SAXParser saxParser = saxParserFactory.newSAXParser();
- for(String processFile : collectedFiles) {
- File file = new File(webSourceDir,processFile);
- if(file.exists()) {
- getLog().info("process file: " + file.getName());
- try {
- saxParser.parse(file, handler);
- } catch (Exception e) {
- getLog().error("Error process file: " + file.getAbsolutePath() + "\n" + e.getMessage(), e);
- }
- }
- }
-
- } catch (Exception e) {
- getLog().error(e);
- }
-
+ for(String processFile : collectedFiles) {
+ File file = new File(webSourceDir,processFile);
+ if(file.exists()) {
+ getLog().info("process file: " + file.getName());
+ try {
+ saxParser.parse(file, handler);
+ } catch (Exception e) {
+ getLog().error("Error process file: " + file.getAbsolutePath() + "\n" + e.getMessage(), e);
+ }
+ }
+ }
return handler;
}
@@ -284,46 +274,48 @@
return jarFileObjects;
}
- public Digester getDigester() {
+ public Digester createDigester() {
// default digester for *.component-dependencies.xml
return PluginUtils.createDefaultDigester();
}
- protected ClassLoader createClassLoader() {
+ protected ClassLoader createClassLoader() throws Exception {
ClassLoader classLoader = null;
- try {
- Set <Artifact> artifacts = resolveDependenciesArtifacts();
-
- //create a new classloading space
- ClassWorld world = new ClassWorld();
+ Set <Artifact> artifacts = resolveDependenciesArtifacts();
- //use the existing ContextClassLoader in a realm of the classloading space
- ClassRealm realm = world.newRealm("org.richfaces.cdk", Thread.currentThread().getContextClassLoader());
-
- //create another realm for the app jars
- ClassRealm childRealm = realm.createChildRealm("jar");
- for(Artifact jar : artifacts ) {
+ //create a new classloading space
+ ClassWorld world = new ClassWorld();
+
+ //use the existing ContextClassLoader in a realm of the classloading space
+ ClassRealm realm = world.newRealm("org.richfaces.cdk", Thread.currentThread().getContextClassLoader());
+ //create another realm for the app jars
+ ClassRealm childRealm = realm.createChildRealm("jar");
+
+ for(Artifact jar : artifacts ) {
+ try {
childRealm.addConstituent(jar.getFile().toURL());
+ } catch (MalformedURLException e) {
+ getLog().error("Artifact url " + jar.getFile() + " is invalid");
}
- // add project classes, scripts etc ...
- List compileClasspathElements = project.getCompileClasspathElements();
- for (Object path: compileClasspathElements) {
- try {
- childRealm.addConstituent(new File((String)path).toURI().toURL());
- } catch (Exception e) {
- getLog().error(e);
- }
+ }
+
+ // add project classes, scripts etc ...
+ List compileClasspathElements = project.getCompileClasspathElements();
+ for (Object path: compileClasspathElements) {
+ try {
+ URL url = new File((String)path).toURI().toURL();
+ childRealm.addConstituent(url);
+ }catch (MalformedURLException e) {
+ getLog().error("Artifact url " + path + " is invalid");
}
- //make the child realm the ContextClassLoader
- classLoader = childRealm.getClassLoader();
-
- } catch (Exception e) {
- getLog().error(e);
- }
+ }
+
+ //make the child realm the ContextClassLoader
+ classLoader = childRealm.getClassLoader();
return classLoader;
}
}
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java 2009-01-23 12:46:27 UTC (rev 12381)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java 2009-01-23 12:53:14 UTC (rev 12382)
@@ -1,14 +1,37 @@
+/**
+ * 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.richfaces.cdk.rd.utils;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.digester.Digester;
import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
import org.richfaces.cdk.rd.Component;
import org.richfaces.cdk.rd.Components;
import org.richfaces.cdk.rd.JarResourceScanner;
+import org.xml.sax.SAXException;
public class PluginUtils {
@@ -17,33 +40,27 @@
public static String [] DEFAULT_PROCESS_INCLUDES = new String [] {"**/*.xhtml"};
- public static FileObject [] resolveConfigsFromJar(FileObject jarFileObject, String [] patterns) throws Exception {
+ public static FileObject [] resolveConfigsFromJar(FileObject jarFileObject, String [] patterns) throws IOException{
FileObject [] result = new FileObject[0];
JarResourceScanner jarScanner = new JarResourceScanner();
jarScanner.setBaseFile(jarFileObject);
jarScanner.setPatterns(patterns);
jarScanner.doScan();
result = (FileObject [])jarScanner.getResult().toArray(new FileObject[jarScanner.getResult().size()]);
-
return result;
}
- public static Map <String,Components> processConfigs(FileObject [] configs, Digester digester) throws Exception{
-
+ public static Map <String,Components> processConfigs(FileObject [] configs, Digester digester) throws SAXException, IOException {
Map <String, Components>collector = new HashMap <String, Components>();
for (FileObject config: configs) {
- InputStream configInputStream = null;
+ InputStream configInputStream = config.getContent().getInputStream();
try {
- configInputStream = config.getContent().getInputStream();
- Components components = (Components)digester.parse(configInputStream);
+ Components components = (Components)digester.parse(configInputStream);
collector.put(components.getNamespace(), components);
} finally {
- if(configInputStream != null) {
- configInputStream.close();
- }
- }
+ configInputStream.close();
+ }
}
-
return collector;
}
More information about the richfaces-svn-commits
mailing list