Skip to content

Commit

Permalink
WELDSE-26: Renamed ClassHandler to URLHandler (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroyle committed May 17, 2010
1 parent 3fd6601 commit 79e489d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/jboss/weld/environment/se/Weld.java
Expand Up @@ -84,7 +84,7 @@ public WeldContainer initialize()

final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
URLScanner scanner = new URLScanner(resourceLoader, discovery);
configureClassHandlers(scanner, resourceLoader, discovery);
configureURLHandlers(scanner, resourceLoader, discovery);
scanner.scanResources(new String[]
{
"META-INF/beans.xml"
Expand All @@ -106,19 +106,19 @@ public WeldContainer initialize()
}

/**
* Clients can subclass and override this method to add custom class handlers
* before weld boots up. For example, to set a custom class handler for OSGi bundles,
* Clients can subclass and override this method to add custom URL handlers
* before weld boots up. For example, to set a custom URL handler for OSGi bundles,
* you would subclass Weld like so:
* <code>
* public class MyWeld extends Weld {
* @Override
* public void configureClassHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
* scanner.setClassHandler("bundle", new MyOSGiClassHandler(bundleClassLoader));
* public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
* scanner.setURLHandler("bundle", new MyOSGiURLHandler(bundleClassLoader));
* }
* }
* </code>
*/
public void configureClassHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
{
}

Expand Down
Expand Up @@ -49,28 +49,28 @@ public class URLScanner extends AbstractScanner

private static final String FILE = "file";
private static final String JAR = "jar";
private final Map<String, URLHandler> classHandlers = new HashMap<String, URLHandler>();
private final Map<String, URLHandler> urlHandlers = new HashMap<String, URLHandler>();
private static final Logger log = LoggerFactory.getLogger(URLScanner.class);

public URLScanner(ResourceLoader resourceLoader, SEWeldDiscovery weldDiscovery)
{
super(resourceLoader, weldDiscovery);
URLHandler fileSysHandler = new FileSystemURLHandler(resourceLoader, weldDiscovery);
classHandlers.put(FILE, fileSysHandler);
classHandlers.put(JAR, fileSysHandler);
urlHandlers.put(FILE, fileSysHandler);
urlHandlers.put(JAR, fileSysHandler);
}

public void setClassHandler(String type, URLHandler handler)
public void setURLHandler(String type, URLHandler handler)
{
classHandlers.put(type, handler);
urlHandlers.put(type, handler);
}

public void scanDirectories(File[] directories)
{
for (File directory : directories)
{
// can only use a file-based scanner to scan directories
classHandlers.get(FILE).handleDirectory(directory);
urlHandlers.get(FILE).handleDirectory(directory);
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ public void scanResources(String[] resources)
for (String urlType : paths.keySet())
{
Collection<String> urlPaths = paths.get(urlType);
URLHandler handler = classHandlers.get(urlType);
URLHandler handler = urlHandlers.get(urlType);
if (handler == null)
{
throw new ClasspathScanningException("No handler defined for URL type: " + urlType);
Expand Down

0 comments on commit 79e489d

Please sign in to comment.