You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/11/20 20:05:40 UTC
svn commit: r1204214 - in /commons/sandbox/meiyo/trunk/src:
main/java/org/apache/commons/meiyo/classpath/ site/
test/java/org/apache/commons/meiyo/classpath/filter/
Author: simonetripodi
Date: Sun Nov 20 19:05:40 2011
New Revision: 1204214
URL: http://svn.apache.org/viewvc?rev=1204214&view=rev
Log:
simplifying the design, there were too much interfaces/classes for a simple task
Added:
commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java (with props)
Removed:
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/Matcher.java
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/MatcherImpl.java
Modified:
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/AbstractHandlerConfiguration.java
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/ClassPathScanner.java
commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfigurationsBuilder.java
commons/sandbox/meiyo/trunk/src/site/site.xml
commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/FiltersTestCase.java
Modified: commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/AbstractHandlerConfiguration.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/AbstractHandlerConfiguration.java?rev=1204214&r1=1204213&r2=1204214&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/AbstractHandlerConfiguration.java (original)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/AbstractHandlerConfiguration.java Sun Nov 20 19:05:40 2011
@@ -19,6 +19,9 @@ package org.apache.commons.meiyo.classpa
* under the License.
*/
+import java.util.Collection;
+import java.util.LinkedList;
+
import org.apache.commons.meiyo.classpath.filter.Filter;
/**
@@ -26,42 +29,51 @@ import org.apache.commons.meiyo.classpat
* in a more readable configuration.
*/
public abstract class AbstractHandlerConfiguration
- implements HandlerConfiguration
{
- private Matcher wrapped;
+ /**
+ * Configured {@link ClassPathHandler}s storage.
+ */
+ private final Collection<ClassPathHandler> handlers = new LinkedList<ClassPathHandler>();
/**
- * {@inheritDoc}
+ * Allows to associate the given filter to one or more {@link ClassPathEntryHandler}.
+ *
+ * @param filter The filter that ClassPath entry should match
+ * @return the {@link ClassPathEntryHandler} builder
+ * @see Matcher#ifMatches(Filter)
*/
- public final void configure( final Matcher matcher )
+ protected LinkedHandlerBuilder ifMatches( final Filter filter )
{
- if ( wrapped != null )
+ if ( filter == null )
{
- throw new IllegalStateException( "Re-entry is not allowed." );
+ throw new IllegalArgumentException( "Filter must not be null" );
}
- wrapped = matcher;
- try
- {
- configure();
- }
- finally
+ return new LinkedHandlerBuilder()
{
- wrapped = null;
- }
+
+ public void handleWith( final ClassPathEntryHandler... entryHandlers )
+ {
+ if ( entryHandlers == null || entryHandlers.length == 0 )
+ {
+ throw new IllegalArgumentException( "At least one ClassPathEntryHandler must be specified" );
+ }
+
+ handlers.add( new ClassPathHandler( filter, entryHandlers ) );
+ }
+
+ };
}
/**
- * Allows to associate the given filter to one or more {@link ClassPathEntryHandler}.
+ * Returns the configured {@link ClassPathHandler}s storage.
*
- * @param filter The filter that ClassPath entry should match
- * @return the {@link ClassPathEntryHandler} builder
- * @see Matcher#ifMatches(Filter)
+ * @return the configured {@link ClassPathHandler}s storage.
*/
- protected LinkedHandlerBuilder ifMatches( Filter filter )
+ Collection<ClassPathHandler> getHandlers()
{
- return wrapped.ifMatches( filter );
+ return handlers;
}
/**
Modified: commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/ClassPathScanner.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/ClassPathScanner.java?rev=1204214&r1=1204213&r2=1204214&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/ClassPathScanner.java (original)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/ClassPathScanner.java Sun Nov 20 19:05:40 2011
@@ -21,10 +21,8 @@ package org.apache.commons.meiyo.classpa
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
@@ -51,7 +49,7 @@ public final class ClassPathScanner
}
/**
- * Initializes the scanner to scan the ClassPath obtained by {@code System.getProperty( "java.class.path" )}
+ * Initializes the scanner to scan the ClassPath obtained by {@code System.getProperty( "java.class.path" )}
*
* @return the builder to configure {@link Matcher} patterns and {@link ClassPathEntryHandler}.
*/
@@ -95,29 +93,16 @@ public final class ClassPathScanner
return new HandlerConfigurationsBuilder()
{
- public ClassLoaderBuilder withConfiguration( final HandlerConfiguration... configurations )
+ public ClassLoaderBuilder withConfiguration( final AbstractHandlerConfiguration configuration )
{
- if ( configurations == null || configurations.length == 0 )
+ if ( configuration == null )
{
throw new IllegalArgumentException( "At least one HandlerConfiguration has to be specified" );
}
- return withConfiguration( Arrays.asList( configurations ) );
- }
-
- public ClassLoaderBuilder withConfiguration( final Iterable<HandlerConfiguration> configurations )
- {
- final Iterator<HandlerConfiguration> iter = configurations == null ? null : configurations.iterator();
- if ( iter == null || !iter.hasNext())
- {
- throw new IllegalArgumentException( "Parameter 'configurations' must not be null or empty" );
- }
- MatcherImpl matcher = new MatcherImpl();
- while (iter.hasNext()) {
- iter.next().configure( matcher );
- }
+ configuration.configure();
- final Collection<ClassPathHandler> handlers = matcher.getHandlers();
+ final Collection<ClassPathHandler> handlers = configuration.getHandlers();
return new ClassLoaderBuilder()
{
Modified: commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfigurationsBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfigurationsBuilder.java?rev=1204214&r1=1204213&r2=1204214&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfigurationsBuilder.java (original)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfigurationsBuilder.java Sun Nov 20 19:05:40 2011
@@ -31,14 +31,6 @@ public interface HandlerConfigurationsBu
* @param configurations configurations needed to set-up the scanner
* @return the builder to set-up the scanner ClassLoader
*/
- ClassLoaderBuilder withConfiguration( HandlerConfiguration... configurations );
-
- /**
- * Initialize the scanner given a collection of configurations.
- *
- * @param configurations configurations needed to set-up the scanner
- * @return the builder to set-up the scanner ClassLoader
- */
- ClassLoaderBuilder withConfiguration( Iterable<HandlerConfiguration> configurations );
+ ClassLoaderBuilder withConfiguration( AbstractHandlerConfiguration configuration );
}
Modified: commons/sandbox/meiyo/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/site/site.xml?rev=1204214&r1=1204213&r2=1204214&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/site/site.xml (original)
+++ commons/sandbox/meiyo/trunk/src/site/site.xml Sun Nov 20 19:05:40 2011
@@ -23,6 +23,12 @@
<href>${project.url}/index.html</href>
</bannerRight>
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </skin>
+
<version position="left" />
<body>
Added: commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java?rev=1204214&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java (added)
+++ commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java Sun Nov 20 19:05:40 2011
@@ -0,0 +1,25 @@
+package org.apache.commons.meiyo.classpath.filter;
+
+/*
+ * 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.
+ */
+
+public interface DummyInterface
+{
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/DummyInterface.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/FiltersTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/FiltersTestCase.java?rev=1204214&r1=1204213&r2=1204214&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/FiltersTestCase.java (original)
+++ commons/sandbox/meiyo/trunk/src/test/java/org/apache/commons/meiyo/classpath/filter/FiltersTestCase.java Sun Nov 20 19:05:40 2011
@@ -30,7 +30,6 @@ import java.util.List;
import org.apache.commons.meiyo.classpath.ClassLoaderBuilder;
import org.apache.commons.meiyo.classpath.ClassPathScanner;
-import org.apache.commons.meiyo.classpath.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -75,7 +74,7 @@ public final class FiltersTestCase
{
Filter isInterface = isInterface();
assert !isInterface.matches( DummyAnnotation.class );
- assert isInterface.matches( Matcher.class );
+ assert isInterface.matches( DummyInterface.class );
}
@Test