Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 941EB9EB8 for ; Sun, 20 Nov 2011 19:06:06 +0000 (UTC) Received: (qmail 37781 invoked by uid 500); 20 Nov 2011 19:06:06 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 37711 invoked by uid 500); 20 Nov 2011 19:06:06 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 37704 invoked by uid 99); 20 Nov 2011 19:06:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 19:06:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 19:06:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E7D2223889E2 for ; Sun, 20 Nov 2011 19:05:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Sun, 20 Nov 2011 19:05:40 -0000 To: commits@commons.apache.org From: simonetripodi@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111120190540.E7D2223889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 handlers = new LinkedList(); /** - * {@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 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 configurations ) - { - final Iterator 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 handlers = matcher.getHandlers(); + final Collection 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 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 @@ ${project.url}/index.html + + org.apache.maven.skins + maven-fluido-skin + 1.0-SNAPSHOT + + 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