01: package com.opensymphony.webwork.plexus;
02:
03: import org.codehaus.plexus.PlexusContainer;
04: import org.codehaus.plexus.configuration.PlexusConfigurationResourceException;
05: import org.apache.commons.logging.Log;
06: import org.apache.commons.logging.LogFactory;
07:
08: import java.io.InputStream;
09: import java.io.InputStreamReader;
10: import java.io.ByteArrayInputStream;
11:
12: /**
13: * @author Patrick Lightbody (plightbo at gmail dot com)
14: */
15: public class PlexusUtils {
16: private static final Log log = LogFactory
17: .getLog(PlexusObjectFactory.class);
18:
19: public static void configure(PlexusContainer pc, String file)
20: throws PlexusConfigurationResourceException {
21: InputStream is = Thread.currentThread().getContextClassLoader()
22: .getResourceAsStream(file);
23: if (is == null) {
24: log.info("Could not find " + file + ", skipping");
25: is = new ByteArrayInputStream(
26: "<plexus><components></components></plexus>"
27: .getBytes());
28: }
29: pc.setConfigurationResource(new InputStreamReader(is));
30: }
31: }
|