plexus-active-collections-1.0~beta2/0000755000175000017500000000000011240615034017525 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/0000755000175000017500000000000011240615034020314 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/it/0000755000175000017500000000000011240615034020730 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/0000755000175000017500000000000011240615034026614 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/0000755000175000017500000000000011240615034033454 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/src/plexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/sr0000755000175000017500000000000011240615034034021 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/src/main/plexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/sr0000755000175000017500000000000011240615034034021 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/src/main/java/plexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/sr0000755000175000017500000000000011240615034034021 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/src/main/java/its/plexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/sr0000755000175000017500000000000011240615034034021 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/src/main/java/its/MyMojo.javaplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/sr0000644000175000017500000000240010601754430034023 0ustar twernertwernerpackage its; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed 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. */ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.plexus.collections.ActiveCollectionManager; import org.codehaus.plexus.collections.ActiveList; import java.io.File; import java.io.FileWriter; import java.io.IOException; /** * @goal test * * @phase validate */ public class MyMojo extends AbstractMojo { /** * @component */ private ActiveCollectionManager collectionManager; public void execute() throws MojoExecutionException { ActiveList list = collectionManager.getActiveList( ActiveCollectionManager.ROLE ); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/pom.xmlplexus-active-collections-1.0~beta2/src/it/collectionManager-compat-test/maven-compat-test-plugin/po0000644000175000017500000000177410601754430034032 0ustar twernertwerner 4.0.0 its maven-compat-test-plugin maven-plugin 1.0-SNAPSHOT maven-compat-test-plugin Maven Mojo http://maven.apache.org org.codehaus.plexus plexus-active-collections 1.0-beta-2-SNAPSHOT org.apache.maven maven-plugin-api 2.0 junit junit 3.8.1 test plexus-active-collections-1.0~beta2/src/test/0000755000175000017500000000000011240615034021273 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/resources/0000755000175000017500000000000011240615034023305 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/resources/META-INF/0000755000175000017500000000000011240615034024445 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/resources/META-INF/plexus/0000755000175000017500000000000011240615034025765 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/resources/META-INF/plexus/components.xml0000644000175000017500000000423210600616650030701 0ustar twernertwerner org.codehaus.plexus.collections.TestComponent one org.codehaus.plexus.collections.TestComponent first org.codehaus.plexus.collections.TestComponent two org.codehaus.plexus.collections.TestComponent second org.codehaus.plexus.collections.TestComponent three org.codehaus.plexus.collections.TestComponent first org.codehaus.plexus.collections.TestBadComponent bad org.codehaus.plexus.collections.TestBadComponent org.codehaus.plexus.collections.ActiveMap default-active-map-test org.codehaus.plexus.collections.DefaultActiveMap org.codehaus.plexus.collections.TestComponent org.codehaus.plexus.collections.ActiveList default-active-list-test org.codehaus.plexus.collections.DefaultActiveList org.codehaus.plexus.collections.TestComponent org.codehaus.plexus.collections.ActiveSet default-active-set-test org.codehaus.plexus.collections.DefaultActiveSet org.codehaus.plexus.collections.TestComponent plexus-active-collections-1.0~beta2/src/test/java/0000755000175000017500000000000011240615033022213 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/java/org/0000755000175000017500000000000011240615034023003 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/0000755000175000017500000000000011240615034024576 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/0000755000175000017500000000000011240615034026116 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/0000755000175000017500000000000011240615034030434 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveListTest.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveListT0000644000175000017500000000054310600616650034065 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class DefaultActiveListTest extends ActiveListTCK { protected ActiveList constructKnownBadActiveList() { return new DefaultActiveList( getContainer(), TestBadComponent.class ); } protected String getTestListRoleHint() { return "default-active-list-test"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveCollectionManagerTest.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveColle0000644000175000017500000000032010601547075034062 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class DefaultActiveCollectionManagerTest extends ActiveCollectionManagerTCK { protected String getRoleHint() { return "default"; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultProtoCollectionTest.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultProtoCollec0000644000175000017500000000042210601760025034110 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class DefaultProtoCollectionTest extends ProtoCollectionTCK { protected ProtoCollection getProtoCollection() { return new DefaultProtoCollection( getContainer(), TestComponent.class.getName() ); } } plexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveMapTCK.java0000644000175000017500000002576710600616650033537 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public abstract class ActiveMapTCK extends PlexusTestCase { private ActiveMap map; protected abstract String getTestMapRoleHint(); protected abstract ActiveMap constructKnownBadActiveMap(); public void setUp() throws Exception { super.setUp(); map = (ActiveMap) lookup( ActiveMap.ROLE, getTestMapRoleHint() ); } // public void clear() // { // throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); // } public void testClear_ShouldThrowUnsupportedOperationException() { try { map.clear(); fail( "Should fail with UnsupportedOperationException; ActiveMap impls are not directly mutable." ); } catch( UnsupportedOperationException e ) { // expected } } // public Object put( Object arg0, Object arg1 ) // { // throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); // } public void testPut_ShouldThrowUnsupportedOperationException() { try { map.put( "test", "test" ); fail( "Should fail with UnsupportedOperationException; ActiveMap impls are not directly mutable." ); } catch( UnsupportedOperationException e ) { // expected } } // public void putAll( Map arg0 ) // { // throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); // } public void testPutAll_ShouldThrowUnsupportedOperationException() { try { map.putAll( Collections.singletonMap( "test", "test" ) ); fail( "Should fail with UnsupportedOperationException; ActiveMap impls are not directly mutable." ); } catch( UnsupportedOperationException e ) { // expected } } // public Object remove( Object key ) // { // throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); // } public void testRemove_ShouldThrowUnsupportedOperationException() { try { map.remove( "test" ); fail( "Should fail with UnsupportedOperationException; ActiveMap impls are not directly mutable." ); } catch( UnsupportedOperationException e ) { // expected } } public void testGet() { TestComponent comp1 = (TestComponent) map.get( "one" ); assertEquals( "first", comp1.getValue() ); TestComponent comp2 = (TestComponent) map.get( "two" ); assertEquals( "second", comp2.getValue() ); } public void testContainsKey() { assertTrue( map.containsKey( "one" ) ); assertFalse( map.containsKey( "one thousand" ) ); } public void testContainsValue() { TestComponent oneTest = new TestComponent( "first" ); TestComponent oneThousandTest = new TestComponent( "one thousandth" ); assertTrue( map.containsValue( oneTest ) ); assertFalse( map.containsValue( oneThousandTest ) ); } // Set entrySet(); public void testEntrySet() { TestComponent first = new TestComponent( "first" ); TestComponent second = new TestComponent( "second" ); Set entries = map.entrySet(); assertEquals( 3, entries.size() ); for ( Iterator it = entries.iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); assertTrue( entry.getKey().equals( "one" ) || entry.getKey().equals( "two" ) || entry.getKey().equals( "three" ) ); // NOTE: The third entry is a copy of the first, mostly for testing lists assertTrue( entry.getValue().equals( first ) || entry.getValue().equals( second ) ); } } // Set keySet(); public void testKeySet() { Set keysTest = new HashSet( 3 ); keysTest.add( "one" ); keysTest.add( "two" ); keysTest.add( "three" ); assertEquals( keysTest, map.keySet() ); } // Collection values(); public void testValues() { TestComponent first = new TestComponent( "first" ); TestComponent second = new TestComponent( "second" ); // NOTE: The third entry is a copy of the first, mostly for testing lists TestComponent third = new TestComponent( "first" ); List valuesTest = new ArrayList( 3 ); valuesTest.add( first ); valuesTest.add( second ); valuesTest.add( third ); Collection values = map.values(); assertEquals( valuesTest.size(), values.size() ); assertTrue( values.containsAll( valuesTest ) ); } // boolean checkedContainsKey( Object key ) // throws ComponentLookupException; public void testCheckedContainsKey_ShouldFindKey() throws ComponentLookupException { assertTrue( map.checkedContainsKey( "one" ) ); assertFalse( map.checkedContainsKey( "one thousand" ) ); } public void testCheckedContainsKey_ShouldThrowExceptionWhenWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedContainsKey( "bad" ); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } // boolean checkedContainsValue( Object value ) // throws ComponentLookupException; public void testCheckedContainsValue_ShouldFindValue() throws ComponentLookupException { assertTrue( map.checkedContainsValue( new TestComponent( "first" ) ) ); assertFalse( map.checkedContainsValue( new TestComponent( "one thousandth" ) ) ); } public void testCheckedContainsValue_ShouldThrowExceptionWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedContainsKey( TestBadComponent.newTestInstance() ); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } // Set checkedEntrySet() // throws ComponentLookupException; public void testCheckedEntrySet_ShouldContainTwoElementsAndNotAThird() throws ComponentLookupException { TestComponent first = new TestComponent( "first" ); TestComponent second = new TestComponent( "second" ); TestComponent thousandth = new TestComponent( "one thousandth" ); Set entries = map.checkedEntrySet(); assertEquals( 3, entries.size() ); for ( Iterator it = entries.iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); assertTrue( !entry.getKey().equals( "one thousandth" ) && ( entry.getKey().equals( "one" ) || entry.getKey().equals( "two" ) || entry.getKey().equals( "three" ) ) ); // NOTE: The third entry is a copy of the first, mostly for testing lists assertTrue( !entry.getValue().equals( thousandth ) && ( entry.getValue().equals( first ) || entry.getValue().equals( second ) ) ); } } public void testCheckedEntrySet_ShouldThrowExceptionWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedEntrySet(); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } // Object checkedGet( Object key ) // throws ComponentLookupException; public void testCheckedGet() throws ComponentLookupException { TestComponent comp1 = (TestComponent) map.checkedGet( "one" ); assertEquals( "first", comp1.getValue() ); TestComponent comp2 = (TestComponent) map.checkedGet( "two" ); assertEquals( "second", comp2.getValue() ); } public void testCheckedGet_ShouldThrowExceptionWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedGet( TestBadComponent.newTestInstance() ); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } // Set checkedKeySet() // throws ComponentLookupException; public void testCheckedKeySet_ShouldFindTwoComponents() throws ComponentLookupException { Set keysTest = new HashSet( 2 ); keysTest.add( "one" ); keysTest.add( "two" ); keysTest.add( "three" ); Set keySet = map.checkedKeySet(); assertEquals( 3, keySet.size() ); assertEquals( keysTest, keySet ); } public void testCheckedKeySet_ShouldThrowExceptionWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedKeySet(); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } // Collection checkedValues() // throws ComponentLookupException; public void testCheckedValues_ShouldFindTwoComponents() throws ComponentLookupException { TestComponent first = new TestComponent( "first" ); TestComponent second = new TestComponent( "second" ); // NOTE: The third entry is a copy of the first, mostly for testing lists TestComponent third = new TestComponent( "first" ); List valuesTest = new ArrayList( 3 ); valuesTest.add( first ); valuesTest.add( second ); valuesTest.add( third ); Collection values = map.checkedValues(); assertEquals( valuesTest.size(), values.size() ); assertTrue( values.containsAll( valuesTest ) ); } public void testCheckedValues_ShouldThrowExceptionWhenComponentsCannotBeCreated() { ActiveMap map = constructKnownBadActiveMap(); try { map.checkedValues(); fail( "Should throw ComponentLookupException when mapped components cannot be created." ); } catch ( ComponentLookupException e ) { // expected } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ProtoCollectionTCK.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ProtoCollectionTCK0000644000175000017500000000261110601760025034041 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusTestCase; public abstract class ProtoCollectionTCK extends PlexusTestCase { private ProtoCollection protoCollection; public void setUp() throws Exception { super.setUp(); this.protoCollection = getProtoCollection(); } protected abstract ProtoCollection getProtoCollection(); public void testGetValidActiveMap_ByClass() { ActiveMap map = protoCollection.getActiveMap(); assertEquals( 3, map.size() ); } public void testGetValidActiveList_ByClass() { ActiveList list = protoCollection.getActiveList(); assertEquals( 3, list.size() ); } public void testGetValidActiveSet_ByClass() { ActiveSet set = protoCollection.getActiveSet(); assertEquals( 2, set.size() ); } public void testGetValidActiveMap_ByString() { ActiveMap map = protoCollection.getActiveMap(); assertEquals( 3, map.size() ); } public void testGetValidActiveList_ByString() { ActiveList list = protoCollection.getActiveList(); assertEquals( 3, list.size() ); } public void testGetValidActiveSet_ByString() { ActiveSet set = protoCollection.getActiveSet(); assertEquals( 2, set.size() ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/TestBadComponent.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/TestBadComponent.j0000644000175000017500000000057510600616650034033 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class TestBadComponent { public TestBadComponent( TestBadComponent component ) { throw new IllegalStateException( "Make sure this will not construct!" ); } private TestBadComponent() { } public static TestBadComponent newTestInstance() { return new TestBadComponent(); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveCollectionManagerTCK.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveCollectionMa0000644000175000017500000000316410601547075034101 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusTestCase; public abstract class ActiveCollectionManagerTCK extends PlexusTestCase { private ActiveCollectionManager collectionManager; public void setUp() throws Exception { super.setUp(); this.collectionManager = (ActiveCollectionManager) lookup( ActiveCollectionManager.ROLE, getRoleHint() ); } protected abstract String getRoleHint(); public void testGetValidActiveMap_ByClass() { ActiveMap map = collectionManager.getActiveMap( TestComponent.class ); assertEquals( 3, map.size() ); } public void testGetValidActiveList_ByClass() { ActiveList list = collectionManager.getActiveList( TestComponent.class ); assertEquals( 3, list.size() ); } public void testGetValidActiveSet_ByClass() { ActiveSet set = collectionManager.getActiveSet( TestComponent.class ); assertEquals( 2, set.size() ); } public void testGetValidActiveMap_ByString() { ActiveMap map = collectionManager.getActiveMap( TestComponent.class.getName() ); assertEquals( 3, map.size() ); } public void testGetValidActiveList_ByString() { ActiveList list = collectionManager.getActiveList( TestComponent.class.getName() ); assertEquals( 3, list.size() ); } public void testGetValidActiveSet_ByString() { ActiveSet set = collectionManager.getActiveSet( TestComponent.class.getName() ); assertEquals( 2, set.size() ); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveSetTest.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveSetTe0000644000175000017500000000053410600616650034052 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class DefaultActiveSetTest extends ActiveSetTCK { protected ActiveSet constructKnownBadActiveSet() { return new DefaultActiveSet( getContainer(), TestBadComponent.class ); } protected String getTestSetRoleHint() { return "default-active-set-test"; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/TestComponent.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/TestComponent.java0000644000175000017500000000215510600616650034110 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class TestComponent { private String value; public TestComponent( String value ) { this.value = value; } public TestComponent() { } public String getValue() { return value; } public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ( ( value == null ) ? 0 : value.hashCode() ); return result; } public boolean equals( Object obj ) { if ( this == obj ) return true; if ( obj == null ) return false; if ( getClass() != obj.getClass() ) return false; final TestComponent other = (TestComponent) obj; if ( value == null ) { if ( other.value != null ) return false; } else if ( !value.equals( other.value ) ) return false; return true; } public String toString() { return "TestComponent[value: " + value + "; hashCode: " + hashCode() + "]"; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveMapTest.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/DefaultActiveMapTe0000644000175000017500000000053510600616650034035 0ustar twernertwernerpackage org.codehaus.plexus.collections; public class DefaultActiveMapTest extends ActiveMapTCK { protected ActiveMap constructKnownBadActiveMap() { return new DefaultActiveMap( getContainer(), TestBadComponent.class ); } protected String getTestMapRoleHint() { return "default-active-map-test"; } } plexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveSetTCK.java0000644000175000017500000002341410600616650033540 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public abstract class ActiveSetTCK extends PlexusTestCase { private ActiveSet set; protected abstract String getTestSetRoleHint(); protected abstract ActiveSet constructKnownBadActiveSet(); public void setUp() throws Exception { super.setUp(); set = (ActiveSet) lookup( ActiveSet.ROLE, getTestSetRoleHint() ); } // public boolean add( Object arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAdd_ShouldThrowUnsupportedOperationException() { try { set.add( "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean addAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAddAll_ShouldThrowUnsupportedOperationException() { try { set.addAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public void clear() // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testClear_ShouldThrowUnsupportedOperationException() { try { set.clear(); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean remove( Object o ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRemove_ShouldThrowUnsupportedOperationException() { try { set.remove( "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean removeAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRemoveAll_ShouldThrowUnsupportedOperationException() { try { set.removeAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean retainAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRetainAll_ShouldThrowUnsupportedOperationException() { try { set.retainAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } //boolean contains( Object value ); public void testContains() { assertTrue( set.contains( new TestComponent( "first" ) ) ); assertFalse( set.contains( new TestComponent( "one thousandth" ) ) ); } //boolean containsAll( Collection collection ); public void testContainsAll() { Set containsTest = new HashSet( 2 ); containsTest.add( new TestComponent( "first" ) ); containsTest.add( new TestComponent( "second" ) ); Set doesntContainTest = Collections.singleton( new TestComponent( "one thousandth" ) ); assertTrue( set.containsAll( containsTest ) ); assertFalse( set.containsAll( doesntContainTest ) ); } // public Iterator iterator(); public void testIterator() { Iterator it = set.iterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertFalse( it.hasNext() ); } //Object[] toArray(); public void testToArray() { Object[] test = { new TestComponent( "first" ), new TestComponent( "second" ), }; assertTrue( Arrays.equals( test, set.toArray() ) ); } //Object[] toArray( Object[] array ); public void testToArray_WithInputArray() { TestComponent[] test = { new TestComponent( "first" ), new TestComponent( "second" ), }; assertTrue( Arrays.equals( test, (TestComponent[]) set.toArray( new TestComponent[]{} ) ) ); } //boolean checkedContains( Object value ) // throws ComponentLookupException; public void testCheckedContains() throws ComponentLookupException { assertTrue( set.checkedContains( new TestComponent( "first" ) ) ); assertFalse( set.checkedContains( new TestComponent( "one thousandth" ) ) ); } public void testCheckedContains_FailOnBadComponentInit() { ActiveSet list = constructKnownBadActiveSet(); try { list.checkedContains( TestBadComponent.newTestInstance() ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //boolean checkedContainsAll( Collection collection ) // throws ComponentLookupException; public void testCheckedContainsAll() throws ComponentLookupException { Set containsTest = new HashSet( 2 ); containsTest.add( new TestComponent( "first" ) ); containsTest.add( new TestComponent( "second" ) ); Set doesntContainTest = Collections.singleton( new TestComponent( "one thousandth" ) ); assertTrue( set.checkedContainsAll( containsTest ) ); assertFalse( set.checkedContainsAll( doesntContainTest ) ); } public void testCheckedContainsAll_FailOnBadComponentInit() { ActiveSet set = constructKnownBadActiveSet(); try { set.checkedContainsAll( Collections.singletonList( TestBadComponent.newTestInstance() ) ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Iterator checkedIterator() // throws ComponentLookupException; public void testCheckedIterator() throws ComponentLookupException { Iterator it = set.checkedIterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertFalse( it.hasNext() ); } public void testCheckedIterator_FailOnBadComponentInit() { ActiveSet set = constructKnownBadActiveSet(); try { set.checkedIterator(); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Object[] checkedToArray() // throws ComponentLookupException; public void testCheckedToArray() throws ComponentLookupException { Object[] test = { new TestComponent( "first" ), new TestComponent( "second" ), }; assertTrue( Arrays.equals( test, set.checkedToArray() ) ); } public void testCheckedToArray_FailOnBadComponentInit() { ActiveSet list = constructKnownBadActiveSet(); try { list.checkedToArray(); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Object[] checkedToArray( Object[] array ) // throws ComponentLookupException; public void testCheckedToArray_WithInputArray() throws ComponentLookupException { TestComponent[] test = { new TestComponent( "first" ), new TestComponent( "second" ), }; assertTrue( Arrays.equals( test, (TestComponent[]) set.checkedToArray( new TestComponent[]{} ) ) ); } public void testCheckedToArray_WithInputArray_FailOnBadComponentInit() { ActiveSet set = constructKnownBadActiveSet(); try { set.checkedToArray( new TestComponent[]{} ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveListTCK.javaplexus-active-collections-1.0~beta2/src/test/java/org/codehaus/plexus/collections/ActiveListTCK.java0000644000175000017500000005060410600616650033721 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.ListIterator; import java.util.Set; public abstract class ActiveListTCK extends PlexusTestCase { private ActiveList list; protected abstract String getTestListRoleHint(); protected abstract ActiveList constructKnownBadActiveList(); public void setUp() throws Exception { super.setUp(); list = (ActiveList) lookup( ActiveList.ROLE, getTestListRoleHint() ); } // public boolean add( Object arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAdd_ShouldThrowUnsupportedOperationException() { try { list.add( "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public void add( int arg0, Object arg1 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAdd_WithIndex_ShouldThrowUnsupportedOperationException() { try { list.add( 0, "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean addAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAddAll_ShouldThrowUnsupportedOperationException() { try { list.addAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean addAll( int arg0, Collection arg1 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testAddAll_WithIndex_ShouldThrowUnsupportedOperationException() { try { list.addAll( 0, Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public void clear() // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testClear_ShouldThrowUnsupportedOperationException() { try { list.clear(); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean remove( Object o ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRemove_ShouldThrowUnsupportedOperationException() { try { list.remove( "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public Object remove( int index ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRemove_WithIndex_ShouldThrowUnsupportedOperationException() { try { list.remove( 0 ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean removeAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRemoveAll_ShouldThrowUnsupportedOperationException() { try { list.removeAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public boolean retainAll( Collection arg0 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testRetainAll_ShouldThrowUnsupportedOperationException() { try { list.retainAll( Collections.singletonList( "test" ) ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } // public Object set( int arg0, Object arg1 ) // { // throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); // } public void testSet_ShouldThrowUnsupportedOperationException() { try { list.set( 0, "test" ); fail( "Should throw UnsupportedOperationException; ActiveList impls are not directly mutable." ); } catch ( UnsupportedOperationException e ) { // expected. } } //boolean contains( Object value ); public void testContains() { assertTrue( list.contains( new TestComponent( "first" ) ) ); assertFalse( list.contains( new TestComponent( "one thousandth" ) ) ); } //boolean containsAll( Collection collection ); public void testContainsAll() { Set containsTest = new HashSet( 2 ); containsTest.add( new TestComponent( "first" ) ); containsTest.add( new TestComponent( "second" ) ); Set doesntContainTest = Collections.singleton( new TestComponent( "one thousandth" ) ); assertTrue( list.containsAll( containsTest ) ); assertFalse( list.containsAll( doesntContainTest ) ); } //Object get( int index ); public void testGet() { assertEquals( new TestComponent( "first" ), list.get( 0 ) ); } //int indexOf( Object value ); public void testIndexOf() { assertEquals( 0, list.indexOf( new TestComponent( "first" ) ) ); } //Iterator iterator(); public void testIterator() { Iterator it = list.iterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); } //int lastIndexOf( Object value ); public void testLastIndexOf() { assertEquals( list.size() - 1, list.lastIndexOf( new TestComponent( "first" ) ) ); } //ListIterator listIterator(); public void testListIterator() { ListIterator it = list.listIterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "second" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertFalse( it.hasPrevious() ); } //ListIterator listIterator( int index ); public void testListIterator_WithIndex() { ListIterator it = list.listIterator( 1 ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "second" ), it.previous() ); // should allow iterating back PREVIOUS to the initial index in the list order... assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertFalse( it.hasPrevious() ); } //List subList( int fromIndex, int toIndex ); public void testSubList() { assertEquals( new TestComponent( "first" ), list.subList( 0, 1 ).get( 0 ) ); assertEquals( new TestComponent( "second" ), list.subList( 1, 2 ).get( 0 ) ); assertEquals( new TestComponent( "first" ), list.subList( 2, 3 ).get( 0 ) ); } //Object[] toArray(); public void testToArray() { Object[] test = { new TestComponent( "first" ), new TestComponent( "second" ), new TestComponent( "first" ) }; assertTrue( Arrays.equals( test, list.toArray() ) ); } //Object[] toArray( Object[] array ); public void testToArray_WithInputArray() { TestComponent[] test = { new TestComponent( "first" ), new TestComponent( "second" ), new TestComponent( "first" ) }; assertTrue( Arrays.equals( test, (TestComponent[]) list.toArray( new TestComponent[]{} ) ) ); } //boolean checkedContains( Object value ) // throws ComponentLookupException; public void testCheckedContains() throws ComponentLookupException { assertTrue( list.checkedContains( new TestComponent( "first" ) ) ); assertFalse( list.checkedContains( new TestComponent( "one thousandth" ) ) ); } public void testCheckedContains_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedContains( TestBadComponent.newTestInstance() ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //boolean checkedContainsAll( Collection collection ) // throws ComponentLookupException; public void testCheckedContainsAll() throws ComponentLookupException { Set containsTest = new HashSet( 2 ); containsTest.add( new TestComponent( "first" ) ); containsTest.add( new TestComponent( "second" ) ); Set doesntContainTest = Collections.singleton( new TestComponent( "one thousandth" ) ); assertTrue( list.checkedContainsAll( containsTest ) ); assertFalse( list.checkedContainsAll( doesntContainTest ) ); } public void testCheckedContainsAll_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedContainsAll( Collections.singletonList( TestBadComponent.newTestInstance() ) ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Object checkedGet( int index ) // throws ComponentLookupException; public void testCheckedGet() throws ComponentLookupException { assertEquals( new TestComponent( "first" ), list.checkedGet( 0 ) ); } public void testCheckedGet_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedGet( 0 ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //int checkedIndexOf( Object value ) // throws ComponentLookupException; public void testCheckedIndexOf() throws ComponentLookupException { assertEquals( 0, list.checkedIndexOf( new TestComponent( "first" ) ) ); } public void testCheckedIndexOf_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedIndexOf( TestBadComponent.newTestInstance() ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Iterator checkedIterator() // throws ComponentLookupException; public void testCheckedIterator() throws ComponentLookupException { Iterator it = list.checkedIterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); } public void testCheckedIterator_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedIterator(); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //int checkedLastIndexOf( Object value ) // throws ComponentLookupException; public void testCheckedLastIndexOf() throws ComponentLookupException { assertEquals( list.size() - 1, list.checkedLastIndexOf( new TestComponent( "first" ) ) ); } public void testCheckedLastIndexOf_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedLastIndexOf( new TestComponent( "first" ) ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //ListIterator checkedListIterator() // throws ComponentLookupException; public void testCheckedListIterator() throws ComponentLookupException { ListIterator it = list.checkedListIterator(); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "second" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertFalse( it.hasPrevious() ); } public void testCheckedListIterator_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedListIterator(); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //ListIterator checkedListIterator( int index ) // throws ComponentLookupException; public void testCheckedListIterator_WithIndex() throws ComponentLookupException { ListIterator it = list.checkedListIterator( 1 ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "second" ), it.next() ); assertTrue( it.hasNext() ); assertEquals( new TestComponent( "first" ), it.next() ); assertFalse( it.hasNext() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "second" ), it.previous() ); // should allow iterating back PREVIOUS to the initial index in the list order... assertTrue( it.hasPrevious() ); assertEquals( new TestComponent( "first" ), it.previous() ); assertFalse( it.hasPrevious() ); } public void testCheckedListIterator_WithIndex_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedListIterator( 1 ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //List checkedSubList( int fromIndex, int toIndex ) // throws ComponentLookupException; public void testCheckedSubList() throws ComponentLookupException { assertEquals( new TestComponent( "first" ), list.checkedSubList( 0, 1 ).get( 0 ) ); assertEquals( new TestComponent( "second" ), list.checkedSubList( 1, 2 ).get( 0 ) ); assertEquals( new TestComponent( "first" ), list.checkedSubList( 2, 3 ).get( 0 ) ); } public void testCheckedSubList_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedSubList( 1, 2 ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Object[] checkedToArray() // throws ComponentLookupException; public void testCheckedToArray() throws ComponentLookupException { Object[] test = { new TestComponent( "first" ), new TestComponent( "second" ), new TestComponent( "first" ) }; assertTrue( Arrays.equals( test, list.checkedToArray() ) ); } public void testCheckedToArray_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedToArray(); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } //Object[] checkedToArray( Object[] array ) // throws ComponentLookupException; public void testCheckedToArray_WithInputArray() throws ComponentLookupException { TestComponent[] test = { new TestComponent( "first" ), new TestComponent( "second" ), new TestComponent( "first" ) }; assertTrue( Arrays.equals( test, (TestComponent[]) list.checkedToArray( new TestComponent[]{} ) ) ); } public void testCheckedToArray_WithInputArray_FailOnBadComponentInit() { ActiveList list = constructKnownBadActiveList(); try { list.checkedToArray( new TestComponent[]{} ); fail( "Should throw ComponentLookupException when one or more components fails to load." ); } catch ( ComponentLookupException e ) { // expected } } } plexus-active-collections-1.0~beta2/src/main/0000755000175000017500000000000011240615034021240 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/0000755000175000017500000000000011240615034022161 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/org/0000755000175000017500000000000011240615034022750 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/0000755000175000017500000000000011240615034024543 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/0000755000175000017500000000000011240615034026063 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/0000755000175000017500000000000011240615034030401 5ustar twernertwernerplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveList.java0000644000175000017500000001143310600616650033321 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ListIterator; /** * Collection with {@link List} semantics, which is backed by a {@link PlexusContainer} instance, * and retrieves a fresh batch of elements for each method call. *
* NOTE: All active collections are immutable, and will throw an * {@link UnsupportedOperationException} if a mutator method is called. * * @author jdcasey * */ public interface ActiveList extends ActiveCollection, List { String ROLE = ActiveList.class.getName(); /** * Same as {@link List#contains(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ boolean checkedContains( Object value ) throws ComponentLookupException; /** * Same as {@link List#containsAll(Collection)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ boolean checkedContainsAll( Collection collection ) throws ComponentLookupException; /** * Same as {@link List#get(int)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Object checkedGet( int index ) throws ComponentLookupException; /** * Same as {@link List#indexOf(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ int checkedIndexOf( Object value ) throws ComponentLookupException; /** * Same as {@link List#iterator()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Iterator checkedIterator() throws ComponentLookupException; /** * Same as {@link List#lastIndexOf(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ int checkedLastIndexOf( Object value ) throws ComponentLookupException; /** * Same as {@link List#listIterator()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ ListIterator checkedListIterator() throws ComponentLookupException; /** * Same as {@link List#listIterator(int)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ ListIterator checkedListIterator( int index ) throws ComponentLookupException; /** * Same as {@link List#subList(int, int)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ List checkedSubList( int fromIndex, int toIndex ) throws ComponentLookupException; /** * Same as {@link List#toArray()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Object[] checkedToArray() throws ComponentLookupException; /** * Same as {@link List#toArray(Object[])}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Object[] checkedToArray( Object[] array ) throws ComponentLookupException; } plexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveMap.java0000644000175000017500000000562710600616650033133 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Collection; import java.util.Map; import java.util.Set; /** * Type of {@link Map}, which is backed by a {@link PlexusContainer} instance, and retrieves a * fresh batch of elements for each method call. Entries consist of * component-role-hint -> component-instance. *
* NOTE: All active collections are immutable, and will throw an * {@link UnsupportedOperationException} if a mutator method is called. * * @author jdcasey * */ public interface ActiveMap extends ActiveCollection, Map { String ROLE = ActiveMap.class.getName(); /** * Same as {@link Map#containsKey(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ boolean checkedContainsKey( Object key ) throws ComponentLookupException; /** * Same as {@link Map#containsValue(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ boolean checkedContainsValue( Object value ) throws ComponentLookupException; /** * Same as {@link Map#entrySet()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Set checkedEntrySet() throws ComponentLookupException; /** * Same as {@link Map#get(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Object checkedGet( Object key ) throws ComponentLookupException; /** * Same as {@link Map#keySet(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Set checkedKeySet() throws ComponentLookupException; /** * Same as {@link Map#values(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ Collection checkedValues() throws ComponentLookupException; } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveSet.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveSet.j0000644000175000017500000000452610600616650033763 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import java.util.Collection; import java.util.Iterator; public class DefaultActiveSet extends AbstractActiveSet implements ActiveSet, Contextualizable, LogEnabled { public DefaultActiveSet() { // used for plexus init. } public DefaultActiveSet( PlexusContainer container, Class role ) { super( container, role.getName() ); } public DefaultActiveSet( PlexusContainer container, String role ) { super( container, role ); } public boolean contains( Object value ) { return getSet().contains( value ); } public boolean containsAll( Collection collection ) { return getSet().containsAll( collection ); } public boolean isEmpty() { return getSet().isEmpty(); } public Iterator iterator() { return getSet().iterator(); } public int size() { return getSet().size(); } public Object[] toArray() { return getSet().toArray(); } public Object[] toArray( Object[] array ) { return getSet().toArray( array ); } public boolean checkedContains( Object value ) throws ComponentLookupException { return checkedGetSet().contains( value ); } public boolean checkedContainsAll( Collection collection ) throws ComponentLookupException { return checkedGetSet().containsAll( collection ); } public boolean checkedIsEmpty() throws ComponentLookupException { return checkedGetSet().isEmpty(); } public Iterator checkedIterator() throws ComponentLookupException { return checkedGetSet().iterator(); } public int checkedSize() throws ComponentLookupException { return checkedGetSet().size(); } public Object[] checkedToArray() throws ComponentLookupException { return checkedGetSet().toArray(); } public Object[] checkedToArray( Object[] array ) throws ComponentLookupException { return checkedGetSet().toArray( array ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveCollection.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveCollection.j0000644000175000017500000000356510600616650034020 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; /** * Represents a collection-style view of a {@link PlexusContainer} instance, which retrieves a fresh * batch of component elements for each method call. This interface DOES NOT implement {@link Collection}, * since it is used as a common parent for active {@link List}, {@link Set}, and {@link Map} * implementations. *
* NOTE: All active collections are immutable, and will throw an * {@link UnsupportedOperationException} if a mutator method is called. * * @author jdcasey * */ public interface ActiveCollection { /** * Retrive the role, or type of component, which is collected in the current instance. The current * collection will only "contain" elements that specify this role in their component definitions. */ String getRole(); /** * Same semantics as {@link Collection#isEmpty()} or {@link Map#isEmpty()}. */ boolean isEmpty(); /** * Same semantics as {@link Collection#isEmpty()} or {@link Map#isEmpty()}, except this method * will throw a {@link ComponentLookupException} if one or more of the elements collected here * fails during lookup. */ boolean checkedIsEmpty() throws ComponentLookupException; /** * Same semantics as {@link Collection#size()} or {@link Map#size()}. */ int size(); /** * Same semantics as {@link Collection#size()} or {@link Map#size()}, except this method * will throw a {@link ComponentLookupException} if one or more of the elements collected here * fails during lookup. */ int checkedSize() throws ComponentLookupException; } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveSet.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveSet.0000644000175000017500000000544710600616650033773 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.Logger; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; public abstract class AbstractActiveSet implements ActiveSet { // configuration. private String role; private PlexusContainer container; private Logger logger; protected AbstractActiveSet() { // used for plexus init. } protected AbstractActiveSet( PlexusContainer container, String role ) { this.container = container; this.role = role; this.logger = container.getLoggerManager().getLoggerForComponent( ActiveSet.ROLE ); } public boolean add( Object arg0 ) { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } public boolean addAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } public void clear() { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } public boolean remove( Object o ) { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } public boolean removeAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } public boolean retainAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveSet implementations are not mutable." ); } protected final Logger getLogger() { return logger; } protected final Set getSet() { try { return checkedGetSet(); } catch ( ComponentLookupException e ) { logger.debug( "Failed to lookup map for role: " + role, e ); } return Collections.EMPTY_SET; } protected final Set checkedGetSet() throws ComponentLookupException { return new LinkedHashSet( container.lookupList( role ) ); } public final String getRole() { return role; } protected final void setRole( String role ) { this.role = role; } public final void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } public final void enableLogging( Logger logger ) { this.logger = logger; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ProtoCollection.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ProtoCollection.ja0000644000175000017500000000256310601760025034043 0ustar twernertwernerpackage org.codehaus.plexus.collections; /** * Represents an undifferentiated ActiveCollection instance, with the same configuration (role). * This is another workaround for applications that use plexus-container-default versions less than * 1.0-alpha-22, since this proto-collection can be injected without causing conflict with the existing * collection-detection code in the container. Dependent components can then call getActiveMap|List|Set * and retrieve the instance, which has been preconfigured. * * @author jdcasey * */ public interface ProtoCollection { String ROLE = ProtoCollection.class.getName(); /** * Retrieve the role of components to be collected by any of the active collections created here. */ String getCollectedRole(); /** * Retrieve an {@link ActiveMap} instance that contains components matching the role given by * {@link ProtoCollection#getCollectedRole()}. */ ActiveMap getActiveMap(); /** * Retrieve an {@link ActiveList} instance that contains components matching the role given by * {@link ProtoCollection#getCollectedRole()}. */ ActiveList getActiveList(); /** * Retrieve an {@link ActiveSet} instance that contains components matching the role given by * {@link ProtoCollection#getCollectedRole()}. */ ActiveSet getActiveSet(); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveList.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveList.0000644000175000017500000000763010600616650033770 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ListIterator; public class DefaultActiveList extends AbstractActiveList implements ActiveList, Contextualizable, LogEnabled { public DefaultActiveList() { // used for plexus init. } public DefaultActiveList( PlexusContainer container, Class role ) { super( container, role.getName() ); } public DefaultActiveList( PlexusContainer container, String role ) { super( container, role ); } public boolean checkedContains( Object value ) throws ComponentLookupException { return checkedGetList().contains( value ); } public boolean checkedContainsAll( Collection collection ) throws ComponentLookupException { return checkedGetList().containsAll( collection ); } public Object checkedGet( int index ) throws ComponentLookupException { return checkedGetList().get( index ); } public int checkedIndexOf( Object value ) throws ComponentLookupException { return checkedGetList().indexOf( value ); } public boolean checkedIsEmpty() throws ComponentLookupException { return checkedGetList().isEmpty(); } public Iterator checkedIterator() throws ComponentLookupException { return checkedGetList().iterator(); } public int checkedLastIndexOf( Object value ) throws ComponentLookupException { return checkedGetList().lastIndexOf( value ); } public ListIterator checkedListIterator() throws ComponentLookupException { return checkedGetList().listIterator(); } public ListIterator checkedListIterator( int index ) throws ComponentLookupException { return checkedGetList().listIterator( index ); } public int checkedSize() throws ComponentLookupException { return checkedGetList().size(); } public List checkedSubList( int fromIndex, int toIndex ) throws ComponentLookupException { return checkedGetList().subList( fromIndex, toIndex ); } public Object[] checkedToArray() throws ComponentLookupException { return checkedGetList().toArray(); } public Object[] checkedToArray( Object[] array ) throws ComponentLookupException { return checkedGetList().toArray( array ); } public boolean contains( Object value ) { return getList().contains( value ); } public boolean containsAll( Collection collection ) { return getList().containsAll( collection ); } public Object get( int index ) { return getList().get( index ); } public int indexOf( Object value ) { return getList().indexOf( value ); } public boolean isEmpty() { return getList().isEmpty(); } public Iterator iterator() { return getList().iterator(); } public int lastIndexOf( Object value ) { return getList().lastIndexOf( value ); } public ListIterator listIterator() { return getList().listIterator(); } public ListIterator listIterator( int index ) { return getList().listIterator( index ); } public int size() { return getList().size(); } public List subList( int fromIndex, int toIndex ) { return getList().subList( fromIndex, toIndex ); } public Object[] toArray() { return getList().toArray(); } public Object[] toArray( Object[] array ) { return getList().toArray( array ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveMap.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveMap.0000644000175000017500000000505710600616650033752 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import java.util.Collections; import java.util.Map; public abstract class AbstractActiveMap implements ActiveMap, Contextualizable, LogEnabled { private String role; private PlexusContainer container; private Logger logger; protected AbstractActiveMap() { // used for plexus component init. } protected AbstractActiveMap( PlexusContainer container, String role ) { this.container = container; this.role = role; this.logger = container.getLoggerManager().getLoggerForComponent( ActiveMap.ROLE ); } public void clear() { throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); } public Object put( Object arg0, Object arg1 ) { throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); } public void putAll( Map arg0 ) { throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); } public Object remove( Object key ) { throw new UnsupportedOperationException( "ActiveMap implementations are not mutable." ); } protected final Logger getLogger() { return logger; } protected final Map getMap() { try { return checkedGetMap(); } catch ( ComponentLookupException e ) { logger.debug( "Failed to lookup map for role: " + role, e ); } return Collections.EMPTY_MAP; } protected final Map checkedGetMap() throws ComponentLookupException { return container.lookupMap( role ); } public final String getRole() { return role; } protected final void setRole( String role ) { this.role = role; } public final void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } public final void enableLogging( Logger logger ) { this.logger = logger; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveCollectionManager.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveColle0000644000175000017500000000266010601547075034040 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; /** * @plexus.component role="org.codehaus.plexus.collections.ActiveCollectionManager" role-hint="default" * * @author jdcasey * */ public class DefaultActiveCollectionManager implements ActiveCollectionManager, Contextualizable { private PlexusContainer container; public ActiveList getActiveList( String role ) { return new DefaultActiveList( container, role ); } public ActiveMap getActiveMap( String role ) { return new DefaultActiveMap( container, role ); } public ActiveSet getActiveSet( String role ) { return new DefaultActiveSet( container, role ); } public void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } public ActiveList getActiveList( Class role ) { return getActiveList( role.getName() ); } public ActiveMap getActiveMap( Class role ) { return getActiveMap( role.getName() ); } public ActiveSet getActiveSet( Class role ) { return getActiveSet( role.getName() ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveMap.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultActiveMap.j0000644000175000017500000000476610600616650033753 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import java.util.Collection; import java.util.Set; public class DefaultActiveMap extends AbstractActiveMap implements ActiveMap, Contextualizable, LogEnabled { public DefaultActiveMap() { //used for plexus init. } public DefaultActiveMap( PlexusContainer container, Class role ) { super( container, role.getName() ); } public DefaultActiveMap( PlexusContainer container, String role ) { super( container, role ); } public boolean containsKey( Object key ) { return getMap().containsKey( key ); } public boolean containsValue( Object value ) { return getMap().containsValue( value ); } public Set entrySet() { return getMap().entrySet(); } public Object get( Object key ) { return getMap().get( key ); } public boolean isEmpty() { return getMap().isEmpty(); } public Set keySet() { return getMap().keySet(); } public int size() { return getMap().size(); } public Collection values() { return getMap().values(); } public boolean checkedContainsKey( Object key ) throws ComponentLookupException { return checkedGetMap().containsKey( key ); } public boolean checkedContainsValue( Object value ) throws ComponentLookupException { return checkedGetMap().containsValue( value ); } public Set checkedEntrySet() throws ComponentLookupException { return checkedGetMap().entrySet(); } public Object checkedGet( Object key ) throws ComponentLookupException { return checkedGetMap().get( key ); } public boolean checkedIsEmpty() throws ComponentLookupException { return checkedGetMap().isEmpty(); } public Set checkedKeySet() throws ComponentLookupException { return checkedGetMap().keySet(); } public int checkedSize() throws ComponentLookupException { return checkedGetMap().size(); } public Collection checkedValues() throws ComponentLookupException { return checkedGetMap().values(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveCollectionManager.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveCollectionMa0000644000175000017500000000465410601760025034043 0ustar twernertwernerpackage org.codehaus.plexus.collections; /** * Manager interface provided for backward compatibility to apps using plexus-container-default with * versions under 1.0-alpha-22. This is necessary because the active collections in this project * implement Map, List, and Set...three interfaces which trigger the container in older versions to * attempt to find multiple components of the specified role (in this case, it'd be ActiveMap|Set|List), * and assign all of them as a single requirement on the dependent component. To work around these * cases, code in older applications can use a requirement on this manager, then ask the manager for * the active collection of choice. It's a little less dynamic, but should still work well. * * @author jdcasey * */ public interface ActiveCollectionManager { String ROLE = ActiveCollectionManager.class.getName(); /** * Retrieve an {@link ActiveMap} instance that contains the components of the given role. */ ActiveMap getActiveMap( String role ); /** * Retrieve an {@link ActiveList} instance that contains the components of the given role. */ ActiveList getActiveList( String role ); /** * Retrieve an {@link ActiveSet} instance that contains the components of the given role. */ ActiveSet getActiveSet( String role ); /** * Retrieve an {@link ActiveMap} instance that contains the components of the given role. NOTE: * the role which is used is actually the class-name, not the class...so, here ROLE = role.getName(). * * @param role the class whose name we will use as the role for the components to retrieve. */ ActiveMap getActiveMap( Class role ); /** * Retrieve an {@link ActiveList} instance that contains the components of the given role. NOTE: * the role which is used is actually the class-name, not the class...so, here ROLE = role.getName(). * * @param role the class whose name we will use as the role for the components to retrieve. */ ActiveList getActiveList( Class role ); /** * Retrieve an {@link ActiveSet} instance that contains the components of the given role. NOTE: * the role which is used is actually the class-name, not the class...so, here ROLE = role.getName(). * * @param role the class whose name we will use as the role for the components to retrieve. */ ActiveSet getActiveSet( Class role ); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveList.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/AbstractActiveList0000644000175000017500000000652710600616650034075 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.Logger; import java.util.Collection; import java.util.Collections; import java.util.List; public abstract class AbstractActiveList implements ActiveList { private String role; private PlexusContainer container; private Logger logger; protected AbstractActiveList() { // used for plexus init. } protected AbstractActiveList( PlexusContainer container, String role ) { this.container = container; this.role = role; this.logger = container.getLoggerManager().getLoggerForComponent( ActiveList.ROLE ); } public boolean add( Object arg0 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public void add( int arg0, Object arg1 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public boolean addAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public boolean addAll( int arg0, Collection arg1 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public void clear() { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public boolean remove( Object o ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public Object remove( int index ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public boolean removeAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public boolean retainAll( Collection arg0 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } public Object set( int arg0, Object arg1 ) { throw new UnsupportedOperationException( "ActiveList implementations are not mutable." ); } protected final List checkedGetList() throws ComponentLookupException { return container.lookupList( role ); } protected final List getList() { try { return checkedGetList(); } catch ( ComponentLookupException e ) { logger.debug( "Failed to lookup map for role: " + role, e ); } return Collections.EMPTY_LIST; } public final String getRole() { return role; } protected final void setRole( String role ) { this.role = role; } public final void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } protected final Logger getLogger() { return logger; } public final void enableLogging( Logger logger ) { this.logger = logger; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultProtoCollection.javaplexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/DefaultProtoCollec0000644000175000017500000000237510601760025034066 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; public class DefaultProtoCollection implements ProtoCollection, Contextualizable { private String role; private PlexusContainer container; public DefaultProtoCollection( PlexusContainer container, String role ) { this.container = container; this.role = role; } public DefaultProtoCollection() { // used for plexus init. } public ActiveList getActiveList() { return new DefaultActiveList( container, role ); } public ActiveMap getActiveMap() { return new DefaultActiveMap( container, role ); } public ActiveSet getActiveSet() { return new DefaultActiveSet( container, role ); } public String getCollectedRole() { return role; } public void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } } plexus-active-collections-1.0~beta2/src/main/java/org/codehaus/plexus/collections/ActiveSet.java0000644000175000017500000000507510600616650033146 0ustar twernertwernerpackage org.codehaus.plexus.collections; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Collection; import java.util.Iterator; import java.util.Set; /** * Collection with {@link Set} semantics, which is backed by a {@link PlexusContainer} instance, * and retrieves a fresh batch of elements for each method call. *
* NOTE: All active collections are immutable, and will throw an * {@link UnsupportedOperationException} if a mutator method is called. * * @author jdcasey * */ public interface ActiveSet extends ActiveCollection, Set { String ROLE = ActiveSet.class.getName(); /** * Same as {@link Set#contains(Object)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ public boolean checkedContains( Object value ) throws ComponentLookupException; /** * Same as {@link Set#containsAll(Collection)}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ public boolean checkedContainsAll( Collection collection ) throws ComponentLookupException; /** * Same as {@link Set#iterator()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ public Iterator checkedIterator() throws ComponentLookupException; /** * Same as {@link Set#toArray()}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ public Object[] checkedToArray() throws ComponentLookupException; /** * Same as {@link Set#toArray(Object[])}, except this method will throw a * {@link ComponentLookupException} if one or more elements in the set fail during lookup. * * @throws ComponentLookupException if one or more elements of the set fail during lookup. */ public Object[] checkedToArray( Object[] array ) throws ComponentLookupException; } plexus-active-collections-1.0~beta2/pom.xml0000644000175000017500000000534010756451403021055 0ustar twernertwerner 4.0.0 plexus-components org.codehaus.plexus 1.1.6 plexus-active-collections 1.0-beta-2 Plexus Container-Backed Active Collections org.codehaus.plexus plexus-component-api 1.0-alpha-22 provided org.codehaus.plexus plexus-container-default 1.0-alpha-22 junit junit 3.8.1 test maven-surefire-plugin **/TestComponent.java **/TestBadComponent.java **/*TCK.java org.codehaus.plexus plexus-maven-plugin 1.3 create-component-descriptor descriptor scm:svn:http://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-2 scm:svn:https://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-2