Skip to content

Commit

Permalink
invoke the plugin after the 'process-classes' phase; javadocs; suppor…
Browse files Browse the repository at this point in the history
…t relative paths in the configuration and translate them to absolute paths for the classloader and the spring properties; add a configuration for the demo module that uses a relative path

git-svn-id: https://svn.apache.org/repos/asf/cocoon/trunk/tools@483413 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
reinhard committed Dec 7, 2006
1 parent c37bb34 commit 82000b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
17 changes: 17 additions & 0 deletions cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties
@@ -0,0 +1,17 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.cocoon.cocoon-rcl-plugin-demo.block%classes-dir=./target/classes
Expand Up @@ -58,7 +58,8 @@
* @goal webapp
* @requiresProject true
* @requiresDependencyResolution runtime
* @phase package
* @execute phase="process-classes"
* @version $Id$
*/
public class ReloadingWebappMojo extends AbstractMojo {

Expand Down Expand Up @@ -183,7 +184,7 @@ public void execute() throws MojoExecutionException {
createUrlClassLoaderConf(webAppBaseDir, props);

// create a file that contains the URLs of all classes directories (config for the ReloadingClassLoader)
createReloadingClassLoaderconf(webAppBaseDir, props);
createReloadingClassLoaderConf(webAppBaseDir, props);

// based on the RCL configuration file, create a Spring properties file
createSpringProperties(webAppBaseDir, props);
Expand All @@ -200,13 +201,13 @@ protected RwmProperties readProperties() throws MojoExecutionException {
return props;
}

protected void createReloadingClassLoaderconf(File webAppBaseDir, RwmProperties props) throws MojoExecutionException {
protected void createReloadingClassLoaderConf(File webAppBaseDir, RwmProperties props) throws MojoExecutionException {
File urlClConfFile = createPath(new File(webAppBaseDir, WEB_INF_RCLWRAPPER_RCL_CONF));
try {
FileWriter fw = new FileWriter(urlClConfFile);
for(Iterator aIt = props.getClassesDirs().iterator(); aIt.hasNext();) {
String dir = (String) aIt.next();
fw.write(dir + "\n");
fw.write(new File(dir).getCanonicalPath() + "\n");
this.getLog().debug("Adding classes-dir to RCLClassLoader configuration: " + dir);
}
fw.close();
Expand Down Expand Up @@ -373,4 +374,4 @@ protected void writeInputStreamToFile(final InputStream is, final File f) throws
}
}

}
}
Expand Up @@ -20,11 +20,14 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

import org.apache.maven.plugin.MojoExecutionException;

public class RwmProperties {

private static final String COB_INF_DIR = "/COB-INF";
Expand All @@ -50,7 +53,7 @@ public Set getClassesDirs() {
return getFilteredPropertiesValuesAsSet(CLASSES_DIR);
}

public Properties getSpringProperties() {
public Properties getSpringProperties() throws MojoExecutionException {
Properties springProps = new Properties();
for(Enumeration rclEnum = rclProps.keys(); rclEnum.hasMoreElements();) {
String key = (String) rclEnum.nextElement();
Expand All @@ -59,7 +62,12 @@ public Properties getSpringProperties() {
}
if(key.endsWith(CLASSES_DIR)) {
String newKey = key.substring(0, key.length() - CLASSES_DIR.length()) + BLOCK_CONTEXT_URL_PARAM;
springProps.put(newKey, this.rclProps.getProperty(key) + COB_INF_DIR);
File blockContext = new File(this.rclProps.getProperty(key) + COB_INF_DIR);
try {
springProps.put(newKey, blockContext.toURL().toExternalForm());
} catch (MalformedURLException e) {
throw new MojoExecutionException("Can't create URL to " + blockContext, e);
}
}
}
return springProps;
Expand Down
Expand Up @@ -29,8 +29,8 @@ public void testLoadingSpringProps() throws Exception {
Properties springProps = p.getSpringProperties();
assertEquals(5, springProps.size());
assertTrue(springProps.containsKey("org.apache.cocoon.cocoon-rcl-plugin-demo.block/blockContextURL"));
assertEquals("file:/F:/blocks/myBlock1/target/classes/COB-INF",
springProps.getProperty("org.apache.cocoon.cocoon-rcl-plugin-demo.block1/blockContextURL"));
assertTrue(springProps.getProperty("org.apache.cocoon.cocoon-rcl-plugin-demo.block1/blockContextURL")
.indexOf("target/classes/COB-INF") > 0);
}

public void testLoadingArtifactValues() throws Exception {
Expand Down

0 comments on commit 82000b9

Please sign in to comment.