diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 5d88481c4..1e2355828 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,6 +1,14 @@ Plexus Containers Release Notes ========================= +Plexus Containers 2.2.0 +--------------------- +Plexus Containers 2.2.0 requires Java 8 and Maven 3.2.5+ + +### Improvements +* Drop deprecated plexus-container-default artefact +* Upgrade ASM to 9.6 + Plexus Containers 2.1.1 --------------------- Plexus Containers 2.1.1 requires Java 7 and Maven 3.2.5+ diff --git a/plexus-container-default/pom.xml b/plexus-container-default/pom.xml deleted file mode 100644 index 162ab0a48..000000000 --- a/plexus-container-default/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - 4.0.0 - - - org.codehaus.plexus - plexus-containers - 2.2.0-SNAPSHOT - - - plexus-container-default - - Plexus :: Default Container (deprecated) - The Plexus IoC container API and its default implementation. - - - 2.7.0 - 4.24 - - - - - - org.codehaus.plexus - plexus-classworlds - ${classWorldsVersion} - - - org.codehaus.plexus - plexus-utils - ${plexusUtilsVersion} - - - org.apache.xbean - xbean-reflect - ${xbeanReflectVersion} - - - junit - junit - 4.13.2 - - - - - - - org.codehaus.plexus - plexus-utils - - - org.codehaus.plexus - plexus-classworlds - - - org.apache.xbean - xbean-reflect - - - junit - junit - - - - - - - maven-surefire-plugin - - - **/Test*.java - **/Abstract*.java - - - - - org.codehaus.modello - modello-maven-plugin - - 1.11 - - - src/main/mdo/components.mdo - src/main/mdo/plexus.mdo - - 1.3.0 - - - - xsd-site - - xsd - - pre-site - - ${basedir}/target/generated-site/resources/xsd - - - - descriptor-site - - xdoc - - pre-site - - 1.0.0 - - - - - - - diff --git a/plexus-container-default/src/it/multi-plexus.xml/pom.xml b/plexus-container-default/src/it/multi-plexus.xml/pom.xml deleted file mode 100644 index b0ef52ebb..000000000 --- a/plexus-container-default/src/it/multi-plexus.xml/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - 4.0.0 - plexus - plexus-integrationTest-multiplePlexusXmls - 1.0-SNAPSHOT - - - - plexus - plexus-testFodder-componentWithPlexusXml - 1.0 - - - plexus - plexus-container-default - 1.0-alpha-3-SNAPSHOT - test - - - junit - junit - 3.8.1 - test - - - - \ No newline at end of file diff --git a/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/Component.java b/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/Component.java deleted file mode 100644 index a72741dd0..000000000 --- a/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/Component.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.codehaus.plexus.test.it.multiplx; - -/* - * 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. - */ - -public interface Component -{ - - public static final String ROLE = Component.class.getName(); - - public String testValue(String input); - -} diff --git a/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/ComponentImpl.java b/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/ComponentImpl.java deleted file mode 100644 index 8a8a0942f..000000000 --- a/plexus-container-default/src/it/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/ComponentImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.test.it.multiplx; - -/* - * 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. - */ - -public class ComponentImpl - implements Component -{ - - public String testValue( String input ) - { - return "test using: " + input; - } - -} diff --git a/plexus-container-default/src/it/multi-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml b/plexus-container-default/src/it/multi-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml deleted file mode 100644 index 5a5c048a5..000000000 --- a/plexus-container-default/src/it/multi-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - org.codehaus.plexus.test.it.multiplx.Component - org.codehaus.plexus.test.it.multiplx.ComponentImpl - - - \ No newline at end of file diff --git a/plexus-container-default/src/it/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/multiplx/ComponentLookupTest.java b/plexus-container-default/src/it/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/multiplx/ComponentLookupTest.java deleted file mode 100644 index e426e8cbf..000000000 --- a/plexus-container-default/src/it/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/multiplx/ComponentLookupTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.test.it.multiplx; - -import org.codehaus.plexus.PlexusTestCase; - -/* - * 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. - */ - -public class ComponentLookupTest - extends PlexusTestCase -{ - - public void testShouldFindComponentFromHereAndComponentFromDependency() throws Exception - { - Object fromHere = lookup(Component.ROLE); - assertNotNull(fromHere); - - Object fromDependency = lookup("org.codehaus.plexus.test.fodder.withplx.TestComponent"); - assertNotNull(fromDependency); - } - -} diff --git a/plexus-container-default/src/it/plexus-its/pom.xml b/plexus-container-default/src/it/plexus-its/pom.xml deleted file mode 100644 index 57db21f64..000000000 --- a/plexus-container-default/src/it/plexus-its/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.its - plexus-its - jar - 1.0-SNAPSHOT - plexus-its - http://maven.apache.org - - - org.codehaus.plexus - plexus-container-default - 1.0-alpha-41-SNAPSHOT - - - junit - junit - 3.8.1 - test - - - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.5 - - - - descriptor - - - - - - - - diff --git a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/App.java b/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/App.java deleted file mode 100644 index 92592e330..000000000 --- a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/App.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.codehaus.plexus.its; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.logging.Logger; - -/** @author Jason van Zyl */ -public interface App -{ - PlexusContainer getContainer(); - - Logger getLogger(); -} diff --git a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultApp.java b/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultApp.java deleted file mode 100644 index 098af87da..000000000 --- a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultApp.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.its; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.logging.Logger; - -/** - * @plexus.component role-hint="standard" - */ -public class DefaultApp - implements App -{ - /** @plexus.requirement */ - private PlexusContainer container; - - /** @plexus.requirement */ - private Logger logger; - - public PlexusContainer getContainer() - { - return container; - } - - public Logger getLogger() - { - return logger; - } -} diff --git a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultLogEnabledApp.java b/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultLogEnabledApp.java deleted file mode 100644 index 2cc6e3946..000000000 --- a/plexus-container-default/src/it/plexus-its/src/main/java/org/codehaus/plexus/its/DefaultLogEnabledApp.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.codehaus.plexus.its; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; - -/** - * @plexus.component role-hint="log-enabled" - */ -public class DefaultLogEnabledApp - extends AbstractLogEnabled - implements App -{ - /** @plexus.requirement */ - private PlexusContainer container; - - public PlexusContainer getContainer() - { - return container; - } - - public Logger getLogger() - { - return getLogger(); - } -} \ No newline at end of file diff --git a/plexus-container-default/src/it/plexus-its/src/test/java/org/codehaus/plexus/its/AppTest.java b/plexus-container-default/src/it/plexus-its/src/test/java/org/codehaus/plexus/its/AppTest.java deleted file mode 100644 index 31b51a913..000000000 --- a/plexus-container-default/src/it/plexus-its/src/test/java/org/codehaus/plexus/its/AppTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.its; - -import org.codehaus.plexus.PlexusTestCase; - -/** - * Unit test for simple DefaultApp. - */ -public class AppTest - extends PlexusTestCase -{ - public void testApp() - throws Exception - { - App app = (App) lookup( App.class.getName(), "standard" ); - - assertNotNull( app.getContainer() ); - - assertNotNull( app.getLogger() ); - - assertEquals( App.class.getName(), app.getLogger().getName() ); - - App logEnabledApp = (App) lookup( App.class.getName(), "log-enabled" ); - - assertNotNull( logEnabledApp ); - - assertEquals( App.class.getName(), app.getLogger().getName() ); - } -} diff --git a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/pom.xml b/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/pom.xml deleted file mode 100644 index f36e24aed..000000000 --- a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/pom.xml +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - plexus - plexus-testFodder-componentWithPlexusXml - 1.0-SNAPSHOT - \ No newline at end of file diff --git a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponent.java b/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponent.java deleted file mode 100644 index 47995e3f0..000000000 --- a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.codehaus.plexus.test.fodder.withplx; - -/* - * 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. - */ - -public interface TestComponent -{ - - public String testValueOf(String input); - -} diff --git a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponentImpl.java b/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponentImpl.java deleted file mode 100644 index 09f2d14e4..000000000 --- a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponentImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.test.fodder.withplx; - -/* - * 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. - */ - -public class TestComponentImpl - implements TestComponent -{ - - public String testValueOf( String input ) - { - return "output from: " + input; - } - -} diff --git a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml b/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml deleted file mode 100644 index 7006a2074..000000000 --- a/plexus-container-default/src/it/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/plexus.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - org.codehaus.plexus.test.fodder.withplx.TestComponent - org.codehaus.plexus.test.fodder.withplx.TestComponentImpl - - - \ No newline at end of file diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java b/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java deleted file mode 100644 index fe0cb37dd..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2009 Codehaus 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 java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Queue; -import java.util.Set; - -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; - -public class ClassRealmUtil { - - public static Set getContextRealms(ClassWorld world) { - Set realms = new LinkedHashSet(); - - for (ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - classLoader != null; - classLoader = classLoader.getParent()) { - if (classLoader instanceof ClassRealm) { - realms.add((ClassRealm) classLoader); - - Queue queue = new LinkedList(); - queue.add((ClassRealm) classLoader); - - while (!queue.isEmpty()) { - ClassRealm realm = queue.remove(); - - Collection importRealms = realm.getImportRealms(); - for (ClassRealm importRealm : importRealms) { - if (realms.add(importRealm)) { - queue.add(importRealm); - } - } - - ClassRealm parentRealm = realm.getParentRealm(); - if (parentRealm != null && realms.add(parentRealm)) { - queue.add(parentRealm); - } - } - } - } - - if (world != null) { - for (Iterator it = realms.iterator(); it.hasNext(); ) { - ClassRealm realm = it.next(); - if (realm.getWorld() != world) { - it.remove(); - } - } - } - - return realms; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java b/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java deleted file mode 100644 index 3e7dc22da..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.manager.ComponentManagerFactory; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * @author Jason van Zyl - * @author Kenney Westerhof - * @author Dain Sundstrom - */ -public interface ComponentRegistry { - void registerComponentManagerFactory(ComponentManagerFactory componentManagerFactory); - - void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException; - - ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint); - - @Deprecated - ComponentDescriptor getComponentDescriptor(String role, String roleHint, ClassRealm realm); - - List> getComponentDescriptorList(Class type, String role); - - Map> getComponentDescriptorMap(Class type, String role); - - T lookup(Class type, String role, String roleHint) throws ComponentLookupException; - - T lookup(ComponentDescriptor componentDescriptor) throws ComponentLookupException; - - List lookupList(Class type, String role, List hints) throws ComponentLookupException; - - Map lookupMap(Class type, String role, List hints) throws ComponentLookupException; - - void release(Object component) throws ComponentLifecycleException; - - void removeComponentRealm(ClassRealm classRealm) throws PlexusContainerException; - - void dispose(); - - void addComponent(T component, String role, String roleHint); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/ContainerConfiguration.java b/plexus-container-default/src/main/java/org/codehaus/plexus/ContainerConfiguration.java deleted file mode 100644 index 2e1ab9f71..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/ContainerConfiguration.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.codehaus.plexus; - -import java.net.URL; -import java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.discovery.ComponentDiscoverer; -import org.codehaus.plexus.component.discovery.ComponentDiscovererManager; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; -import org.codehaus.plexus.component.factory.ComponentFactoryManager; -import org.codehaus.plexus.component.repository.ComponentRepository; -import org.codehaus.plexus.configuration.source.ConfigurationSource; -import org.codehaus.plexus.container.initialization.ContainerInitializationPhase; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; - -/** - * @author Jason van Zyl - */ -public interface ContainerConfiguration { - ContainerConfiguration setName(String name); - - String getName(); - - ContainerConfiguration setContext(Map context); - - Map getContext(); - - ContainerConfiguration setClassWorld(ClassWorld classWorld); - - ClassWorld getClassWorld(); - - ContainerConfiguration setRealm(ClassRealm realm); - - ClassRealm getRealm(); - - // - // Configuration - // - ContainerConfiguration setContainerConfiguration(String configuration); - - String getContainerConfiguration(); - - ContainerConfiguration setContainerConfigurationURL(URL configuration); - - URL getContainerConfigurationURL(); - - // Programmatic Container Initialization and Setup - - // Much of this setup and initialization can be completely hidden. It's probably not likely - // someone will need to change these core components, but rather adding things like different - // factories, and component managers. - - // Container initialization phases - - ContainerInitializationPhase[] getInitializationPhases(); - - // Component lookup manager - - // Component discoverer manager - - ContainerConfiguration addComponentDiscoverer(ComponentDiscoverer componentDiscoverer); - - ContainerConfiguration addComponentDiscoveryListener(ComponentDiscoveryListener componentDiscoveryListener); - - ContainerConfiguration setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager); - - ComponentDiscovererManager getComponentDiscovererManager(); - - // Component factory manager - - ContainerConfiguration setComponentFactoryManager(ComponentFactoryManager componentFactoryManager); - - ComponentFactoryManager getComponentFactoryManager(); - - // Component manager manager - - // Component repository - - ContainerConfiguration setComponentRepository(ComponentRepository componentRepository); - - ComponentRepository getComponentRepository(); - - // Component composer - - // Lifecycle handler manager - - ContainerConfiguration addLifecycleHandler(LifecycleHandler lifecycleHandler); - - ContainerConfiguration setLifecycleHandlerManager(LifecycleHandlerManager lifecycleHandlerManager); - - LifecycleHandlerManager getLifecycleHandlerManager(); - - // Configuration Sources - - ContainerConfiguration setConfigurationSource(ConfigurationSource configurationSource); - - ConfigurationSource getConfigurationSource(); - - ContainerConfiguration addComponentDiscoverer(Class componentDiscoverer); - - ContainerConfiguration addComponentDiscoveryListener(Class componentDiscoveryListener); - - List getComponentDiscoverers(); - - List getComponentDiscoveryListeners(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java b/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java deleted file mode 100644 index d63cfa48d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java +++ /dev/null @@ -1,526 +0,0 @@ -package org.codehaus.plexus; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.component.manager.ComponentManagerFactory; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRepository; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; -import org.codehaus.plexus.lifecycle.UndefinedLifecycleHandlerException; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.StringUtils; - -import static org.codehaus.plexus.component.CastUtils.isAssignableFrom; - -public class DefaultComponentRegistry implements ComponentRegistry { - private static final String DEFAULT_INSTANTIATION_STRATEGY = "singleton"; - - private final MutablePlexusContainer container; - private final ComponentRepository repository; - private final LifecycleHandlerManager lifecycleHandlerManager; - private final Logger logger; - - private boolean disposingComponents; - - private final Map componentManagerFactories = - Collections.synchronizedMap(new TreeMap()); - - private final Map> componentManagers = new TreeMap>(); - private final Map> componentManagersByComponent = - new IdentityHashMap>(); - - private final Map unmanagedComponents = new TreeMap(); - - public DefaultComponentRegistry( - MutablePlexusContainer container, - ComponentRepository repository, - LifecycleHandlerManager lifecycleHandlerManager) { - this.container = container; - this.repository = repository; - this.lifecycleHandlerManager = lifecycleHandlerManager; - logger = container.getLogger(); - } - - public void dispose() { - List> managers; - synchronized (this) { - managers = new ArrayList>(componentManagers.values()); - componentManagers.clear(); - componentManagersByComponent.clear(); - unmanagedComponents.clear(); - - disposingComponents = true; - } - - // reverse sort the managers by startId - Collections.sort(managers, new Comparator>() { - public int compare(ComponentManager left, ComponentManager right) { - if (left.getStartId() < right.getStartId()) { - return 1; - } else if (left.getStartId() == right.getStartId()) { - return 0; - } else { - return -1; - } - } - }); - - // Call dispose callback outside of synchronized lock to avoid deadlocks - try { - for (ComponentManager componentManager : managers) { - try { - componentManager.dispose(); - } catch (Exception e) { - // todo dain use a monitor instead of a logger - logger.error("Error while disposing component manager. Continuing with the rest", e); - } - } - } finally { - synchronized (this) { - disposingComponents = false; - } - } - } - - public void registerComponentManagerFactory(ComponentManagerFactory componentManagerFactory) { - componentManagerFactories.put(componentManagerFactory.getId(), componentManagerFactory); - } - - public void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException { - repository.addComponentDescriptor(componentDescriptor); - } - - @SuppressWarnings("unchecked") - public synchronized void addComponent(T component, String role, String roleHint) { - ComponentDescriptor descriptor = new ComponentDescriptor(component.getClass(), null); - descriptor.setRole(role); - descriptor.setRoleHint(roleHint); - - Key key = new Key(descriptor.getRealm(), role, roleHint); - - unmanagedComponents.put(key, component); - } - - public ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint) { - return repository.getComponentDescriptor(type, role, roleHint); - } - - @Deprecated - public ComponentDescriptor getComponentDescriptor(String role, String roleHint, ClassRealm realm) { - return repository.getComponentDescriptor(role, roleHint, realm); - } - - public Map> getComponentDescriptorMap(Class type, String role) { - return repository.getComponentDescriptorMap(type, role); - } - - public List> getComponentDescriptorList(Class type, String role) { - return repository.getComponentDescriptorList(type, role); - } - - public T lookup(Class type, String role, String roleHint) throws ComponentLookupException { - // verify arguments - if (type == null) { - throw new NullPointerException("type is null"); - } - if (role == null) { - throw new NullPointerException("role is null"); - } - if (roleHint == null) { - roleHint = ""; - } - - return getComponent(type, role, roleHint, null); - } - - public T lookup(ComponentDescriptor componentDescriptor) throws ComponentLookupException { - return getComponent( - componentDescriptor.getRoleClass(), - componentDescriptor.getRole(), - componentDescriptor.getRoleHint(), - componentDescriptor); - } - - public Map lookupMap(Class type, String role, List roleHints) - throws ComponentLookupException { - // verify arguments - if (type == null) { - throw new NullPointerException("type is null"); - } - if (role == null) { - throw new NullPointerException("role is null"); - } - - // if no hints provided, get all valid hints for this role - Map components = new LinkedHashMap(); - if (roleHints == null) { - Map> componentDescriptors = getComponentDescriptorMap(type, role); - for (Entry> entry : componentDescriptors.entrySet()) { - String roleHint = entry.getKey(); - ComponentDescriptor componentDescriptor = entry.getValue(); - // todo dain catch the exception... it isn't the callers problem when one component in a collection - // fails - T component = getComponent(type, role, roleHint, componentDescriptor); - components.put(roleHint, component); - } - } else { - for (String roleHint : roleHints) { - // todo dain catch the exception... it isn't the callers problem when one component in a collection - // fails - T component = getComponent(type, role, roleHint, null); - components.put(roleHint, component); - } - } - - return components; - } - - public List lookupList(Class type, String role, List roleHints) throws ComponentLookupException { - // verify arguments - if (type == null) { - throw new NullPointerException("type is null"); - } - if (role == null) { - throw new NullPointerException("role is null"); - } - - // if no hints provided, get all valid hints for this role - List components = new ArrayList(); - if (roleHints == null) { - List> componentDescriptors = getComponentDescriptorList(type, role); - for (ComponentDescriptor componentDescriptor : componentDescriptors) { - // todo dain catch the exception... it isn't the callers problem when one component in a collection - // fails - T component = getComponent(type, role, componentDescriptor.getRoleHint(), componentDescriptor); - components.add(component); - } - } else { - for (String roleHint : roleHints) { - // todo dain catch the exception... it isn't the callers problem when one component in a collection - // fails - T component = getComponent(type, role, roleHint, null); - components.add(component); - } - } - - return components; - } - - public void release(Object component) throws ComponentLifecycleException { - if (component == null) { - return; - } - - // get the component manager - ComponentManager componentManager; - synchronized (this) { - componentManager = componentManagersByComponent.get(component); - if (componentManager == null) { - // This needs to be tracked down but the user doesn't need to see this - // during the maven bootstrap this logger is null. - // logger.debug( "Component manager not found for returned component. Ignored. component=" + component - // ); - return; - } - } - - // release the component from the manager - componentManager.release(component); - - // only drop the reference to this component if there are no other uses of the component - // multiple uses of a component is common with singleton beans - if (componentManager.getConnections() <= 0) { - synchronized (this) { - componentManagersByComponent.remove(component); - } - } - } - - public void removeComponentRealm(ClassRealm classRealm) throws PlexusContainerException { - repository.removeComponentRealm(classRealm); - - List> dispose = new ArrayList>(); - try { - synchronized (this) { - for (Iterator>> it = - componentManagers.entrySet().iterator(); - it.hasNext(); ) { - Entry> entry = it.next(); - Key key = entry.getKey(); - - ComponentManager componentManager = entry.getValue(); - - if (key.realm.equals(classRealm)) { - dispose.add(componentManager); - it.remove(); - } else { - componentManager.dissociateComponentRealm(classRealm); - } - } - } - - // Call dispose callback outside of synchronized lock to avoid deadlocks - for (ComponentManager componentManager : dispose) { - componentManager.dispose(); - } - } catch (ComponentLifecycleException e) { - throw new PlexusContainerException("Failed to dissociate component realm: " + classRealm.getId(), e); - } - } - - private T getComponent(Class type, String role, String roleHint, ComponentDescriptor descriptor) - throws ComponentLookupException { - // lookup for unmanaged components first - - T component = this.getUnmanagedComponent( - role, roleHint); // weird syntax due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954 - - if (component != null) { - return component; - } - - ComponentManager componentManager = getComponentManager(type, role, roleHint, descriptor); - - // Get instance from manager... may result in creation - try { - component = componentManager.getComponent(); - synchronized (this) { - componentManagersByComponent.put(component, componentManager); - } - return component; - } catch (ComponentInstantiationException e) { - throw new ComponentLookupException( - "Unable to lookup component '" + componentManager.getRole() + "', it could not be created.", - componentManager.getRole(), - componentManager.getRoleHint(), - componentManager.getRealm(), - e); - } catch (ComponentLifecycleException e) { - throw new ComponentLookupException( - "Unable to lookup component '" + componentManager.getRole() + "', it could not be started.", - componentManager.getRole(), - componentManager.getRoleHint(), - componentManager.getRealm(), - e); - } - } - - @SuppressWarnings("unchecked") - private synchronized T getUnmanagedComponent(String role, String roleHint) { - Set realms = getSearchRealms(true); - - if (realms != null) { - // ignore unmanaged components, they are not associated with realms - // but lookup realm is provided via thread context classloader - return null; - } else { - if (StringUtils.isEmpty(roleHint)) { - roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; - } - - return (T) unmanagedComponents.get(new Key(null, role, roleHint)); - } - } - - private synchronized ComponentManager getComponentManager( - Class type, String role, String roleHint, ComponentDescriptor descriptor) - throws ComponentLookupException { - if (disposingComponents) { - throw new ComponentLookupException("ComponentRegistry is not active", role, roleHint); - } - - if (descriptor == null) { - descriptor = getComponentDescriptor(type, role, roleHint); - } - - ComponentManager componentManager = null; - - if (descriptor != null) { - componentManager = getComponentManager(type, role, descriptor.getRoleHint(), descriptor.getRealm()); - } else { - componentManager = getComponentManager(type, role, roleHint); - } - - if (componentManager == null) { - // we need to create a component manager, but first we must have a descriptor - if (descriptor == null) { - descriptor = getComponentDescriptor(type, role, roleHint); - if (descriptor == null) { - throw new ComponentLookupException( - "Component descriptor cannot be found in the component repository", role, roleHint); - } - // search also into descriptor realm as the key of a created component is per descriptor realm - componentManager = getComponentManager(type, role, descriptor.getRoleHint(), descriptor.getRealm()); - } - - if (componentManager == null) { - componentManager = createComponentManager(descriptor, role, descriptor.getRoleHint()); - } - } - - return componentManager; - } - - @SuppressWarnings("unchecked") - private ComponentManager getComponentManager(Class type, String role, String roleHint) { - Set realms = getSearchRealms(false); - - // return the component in the first realm - for (ClassRealm realm : realms) { - ComponentManager manager = componentManagers.get(new Key(realm, role, roleHint)); - if (manager != null && isAssignableFrom(type, manager.getType())) { - return (ComponentManager) manager; - } - } - return null; - } - - @SuppressWarnings("unchecked") - private ComponentManager getComponentManager(Class type, String role, String roleHint, ClassRealm realm) { - ComponentManager manager = componentManagers.get(new Key(realm, role, roleHint)); - if (manager != null && isAssignableFrom(type, manager.getType())) { - return (ComponentManager) manager; - } - return null; - } - - @SuppressWarnings("unchecked") - private Set getSearchRealms(boolean specifiedOnly) { - // determine realms to search - Set realms = ClassRealmUtil.getContextRealms(container.getClassWorld()); - - if (realms.isEmpty()) { - if (specifiedOnly) { - return null; - } - - realms.addAll(container.getClassWorld().getRealms()); - } - - return realms; - } - - private ComponentManager createComponentManager( - ComponentDescriptor descriptor, String role, String roleHint) throws ComponentLookupException { - // Get the ComponentManagerFactory - String instantiationStrategy = descriptor.getInstantiationStrategy(); - if (instantiationStrategy == null) { - instantiationStrategy = DEFAULT_INSTANTIATION_STRATEGY; - } - ComponentManagerFactory componentManagerFactory = componentManagerFactories.get(instantiationStrategy); - if (componentManagerFactory == null) { - throw new ComponentLookupException( - "Unsupported instantiation strategy: " + instantiationStrategy, - role, - roleHint, - descriptor.getRealm()); - } - - // Get the LifecycleHandler - LifecycleHandler lifecycleHandler; - try { - lifecycleHandler = lifecycleHandlerManager.getLifecycleHandler(descriptor.getLifecycleHandler()); - } catch (UndefinedLifecycleHandlerException e) { - throw new ComponentLookupException( - "Undefined lifecycle handler: " + descriptor.getLifecycleHandler(), - role, - roleHint, - descriptor.getRealm()); - } - - // Create the ComponentManager - ComponentManager componentManager = - componentManagerFactory.createComponentManager(container, lifecycleHandler, descriptor, role, roleHint); - - // Add componentManager to indexes - Key key = new Key(descriptor.getRealm(), role, roleHint); - componentManagers.put(key, componentManager); - - return componentManager; - } - - private static class Key implements Comparable { - private final ClassRealm realm; - private final String role; - private final String roleHint; - private final int hashCode; - - private Key(ClassRealm realm, String role, String roleHint) { - this.realm = realm; - - if (role == null) { - role = "null"; - } - this.role = role; - - if (roleHint == null) { - roleHint = "null"; - } - this.roleHint = roleHint; - - int hashCode; - hashCode = (realm != null ? realm.hashCode() : 0); - hashCode = 31 * hashCode + role.hashCode(); - hashCode = 31 * hashCode + roleHint.hashCode(); - this.hashCode = hashCode; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Key key = (Key) o; - - return !(realm != null ? !realm.equals(key.realm) : key.realm != null) - && role.equals(key.role) - && roleHint.equals(key.roleHint); - } - - public int hashCode() { - return hashCode; - } - - public String toString() { - return realm + "/" + role + "/" + roleHint; - } - - public int compareTo(Key o) { - int value; - if (realm != null) { - value = o.realm == null ? -1 : realm.getId().compareTo(o.realm.getId()); - } else { - value = o.realm == null ? 0 : 1; - } - - if (value == 0) { - value = role.compareTo(o.role); - if (value == 0) { - value = roleHint.compareTo(o.roleHint); - } - } - return value; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultContainerConfiguration.java b/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultContainerConfiguration.java deleted file mode 100644 index ef4bb65fb..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultContainerConfiguration.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.codehaus.plexus; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.discovery.ComponentDiscoverer; -import org.codehaus.plexus.component.discovery.ComponentDiscovererManager; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; -import org.codehaus.plexus.component.discovery.DefaultComponentDiscoverer; -import org.codehaus.plexus.component.discovery.DefaultComponentDiscovererManager; -import org.codehaus.plexus.component.discovery.PlexusXmlComponentDiscoverer; -import org.codehaus.plexus.component.factory.ComponentFactoryManager; -import org.codehaus.plexus.component.factory.DefaultComponentFactoryManager; -import org.codehaus.plexus.component.repository.ComponentRepository; -import org.codehaus.plexus.component.repository.DefaultComponentRepository; -import org.codehaus.plexus.configuration.source.ConfigurationSource; -import org.codehaus.plexus.container.initialization.ContainerInitializationPhase; -import org.codehaus.plexus.container.initialization.InitializeComponentDiscovererManagerPhase; -import org.codehaus.plexus.container.initialization.InitializeComponentFactoryManagerPhase; -import org.codehaus.plexus.container.initialization.InitializeComponentRegistryPhase; -import org.codehaus.plexus.container.initialization.InitializeContainerConfigurationSourcePhase; -import org.codehaus.plexus.container.initialization.InitializeLoggerManagerPhase; -import org.codehaus.plexus.container.initialization.InitializeSystemPropertiesPhase; -import org.codehaus.plexus.container.initialization.InitializeUserConfigurationSourcePhase; -import org.codehaus.plexus.lifecycle.BasicLifecycleHandler; -import org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.ConfigurablePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.ContextualizePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.DisposePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.LogDisablePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.LogEnablePhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartPhase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StopPhase; - -/** @author Jason van Zyl */ -public class DefaultContainerConfiguration implements ContainerConfiguration { - private String name; - - private Map context; - - private ClassWorld classWorld; - - private ClassRealm realm; - - private String containerConfiguration; - - private URL containerConfigurationURL; - - private ConfigurationSource configurationSource; - - private List componentDiscoverers = new ArrayList(); - - private List componentDiscoveryListeners = new ArrayList(); - - public ContainerConfiguration setName(String name) { - this.name = name; - - return this; - } - - public ContainerConfiguration setContext(Map context) { - this.context = context; - - return this; - } - - public ContainerConfiguration setClassWorld(ClassWorld classWorld) { - this.classWorld = classWorld; - - return this; - } - - public ContainerConfiguration setRealm(ClassRealm realm) { - this.realm = realm; - - return this; - } - - public ContainerConfiguration setContainerConfiguration(String containerConfiguration) { - this.containerConfiguration = containerConfiguration; - - return this; - } - - public String getContainerConfiguration() { - return containerConfiguration; - } - - public ContainerConfiguration setContainerConfigurationURL(URL containerConfiguration) { - this.containerConfigurationURL = containerConfiguration; - - return this; - } - - public URL getContainerConfigurationURL() { - return containerConfigurationURL; - } - - public String getName() { - return name; - } - - public Map getContext() { - return context; - } - - public ClassWorld getClassWorld() { - return classWorld; - } - - public ClassRealm getRealm() { - return realm; - } - - // Programmatic Container Initialization and Setup - - public ContainerConfiguration setInitializationPhases(ContainerInitializationPhase[] initializationPhases) { - this.initializationPhases = initializationPhases; - - return this; - } - - public ContainerInitializationPhase[] getInitializationPhases() { - return initializationPhases; - } - - private ContainerInitializationPhase[] initializationPhases = { - new InitializeComponentRegistryPhase(), - new InitializeComponentFactoryManagerPhase(), - new InitializeContainerConfigurationSourcePhase(), - new InitializeLoggerManagerPhase(), - new InitializeSystemPropertiesPhase(), - new InitializeComponentDiscovererManagerPhase(), - new InitializeUserConfigurationSourcePhase() - }; - - // Component discoverer - - private ComponentDiscovererManager componentDiscovererManager; - - public ContainerConfiguration addComponentDiscoveryListener(ComponentDiscoveryListener componentDiscoveryListener) { - getComponentDiscovererManager().registerComponentDiscoveryListener(componentDiscoveryListener); - - return this; - } - - public ContainerConfiguration addComponentDiscoverer(ComponentDiscoverer componentDiscoverer) { - ((DefaultComponentDiscovererManager) getComponentDiscovererManager()) - .addComponentDiscoverer(componentDiscoverer); - - return this; - } - - public ContainerConfiguration addComponentDiscoverer(Class clazz) { - componentDiscoverers.add(clazz); - return this; - } - - public ContainerConfiguration addComponentDiscoveryListener(Class clazz) { - componentDiscoveryListeners.add(clazz); - return this; - } - - public List getComponentDiscoverers() { - return componentDiscoverers; - } - - public List getComponentDiscoveryListeners() { - return componentDiscoveryListeners; - } - - public ContainerConfiguration setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager) { - this.componentDiscovererManager = componentDiscovererManager; - - return this; - } - - public ComponentDiscovererManager getComponentDiscovererManager() { - if (componentDiscovererManager == null) { - componentDiscovererManager = new DefaultComponentDiscovererManager(); - - ((DefaultComponentDiscovererManager) componentDiscovererManager) - .addComponentDiscoverer(new DefaultComponentDiscoverer()); - - ((DefaultComponentDiscovererManager) componentDiscovererManager) - .addComponentDiscoverer(new PlexusXmlComponentDiscoverer()); - } - - return componentDiscovererManager; - } - - private ComponentFactoryManager componentFactoryManager; - - public ComponentFactoryManager getComponentFactoryManager() { - if (componentFactoryManager == null) { - componentFactoryManager = new DefaultComponentFactoryManager(); - } - - return componentFactoryManager; - } - - public ContainerConfiguration setComponentFactoryManager(ComponentFactoryManager componentFactoryManager) { - this.componentFactoryManager = componentFactoryManager; - - return this; - } - - private ComponentRepository componentRepository; - - public ContainerConfiguration setComponentRepository(ComponentRepository componentRepository) { - this.componentRepository = componentRepository; - - return this; - } - - public ComponentRepository getComponentRepository() { - if (componentRepository == null) { - componentRepository = new DefaultComponentRepository(); - } - - return componentRepository; - } - - // Lifecycle handler manager - - private LifecycleHandlerManager lifecycleHandlerManager; - - public ContainerConfiguration addLifecycleHandler(LifecycleHandler lifecycleHandler) { - getLifecycleHandlerManager().addLifecycleHandler(lifecycleHandler); - - return this; - } - - public ContainerConfiguration setLifecycleHandlerManager(LifecycleHandlerManager lifecycleHandlerManager) { - this.lifecycleHandlerManager = lifecycleHandlerManager; - - return this; - } - - public LifecycleHandlerManager getLifecycleHandlerManager() { - if (lifecycleHandlerManager == null) { - lifecycleHandlerManager = new DefaultLifecycleHandlerManager(); - - // Plexus - LifecycleHandler plexus = new BasicLifecycleHandler("plexus"); - // Begin - plexus.addBeginSegment(new LogEnablePhase()); - plexus.addBeginSegment(new ContextualizePhase()); - // plexus.addBeginSegment( new AutoConfigurePhase() ); - plexus.addBeginSegment(new InitializePhase()); - plexus.addBeginSegment(new StartPhase()); - // End - plexus.addEndSegment(new StopPhase()); - plexus.addEndSegment(new DisposePhase()); - plexus.addEndSegment(new LogDisablePhase()); - lifecycleHandlerManager.addLifecycleHandler(plexus); - - // Basic - LifecycleHandler basic = new BasicLifecycleHandler("basic"); - // Begin - basic.addBeginSegment(new LogEnablePhase()); - basic.addBeginSegment(new ContextualizePhase()); - // basic.addBeginSegment( new AutoConfigurePhase() ); - basic.addBeginSegment(new InitializePhase()); - basic.addBeginSegment(new StartPhase()); - // End - basic.addEndSegment(new StopPhase()); - basic.addEndSegment(new DisposePhase()); - basic.addEndSegment(new LogDisablePhase()); - lifecycleHandlerManager.addLifecycleHandler(basic); - - // Plexus configurable - LifecycleHandler plexusConfigurable = new BasicLifecycleHandler("plexus-configurable"); - // Begin - plexusConfigurable.addBeginSegment(new LogEnablePhase()); - plexusConfigurable.addBeginSegment(new ContextualizePhase()); - plexusConfigurable.addBeginSegment(new ConfigurablePhase()); - plexusConfigurable.addBeginSegment(new InitializePhase()); - plexusConfigurable.addBeginSegment(new StartPhase()); - // End - plexusConfigurable.addEndSegment(new StopPhase()); - plexusConfigurable.addEndSegment(new DisposePhase()); - plexusConfigurable.addEndSegment(new LogDisablePhase()); - lifecycleHandlerManager.addLifecycleHandler(plexusConfigurable); - - // Passive - LifecycleHandler passive = new BasicLifecycleHandler("passive"); - lifecycleHandlerManager.addLifecycleHandler(passive); - - // Bootstrap - LifecycleHandler bootstrap = new BasicLifecycleHandler("bootstrap"); - bootstrap.addBeginSegment(new ContextualizePhase()); - lifecycleHandlerManager.addLifecycleHandler(bootstrap); - } - - return lifecycleHandlerManager; - } - - // Configuration Sources - - public ContainerConfiguration setConfigurationSource(ConfigurationSource configurationSource) { - this.configurationSource = configurationSource; - - return this; - } - - public ConfigurationSource getConfigurationSource() { - return configurationSource; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java deleted file mode 100644 index 775b78d6c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java +++ /dev/null @@ -1,788 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.discovery.ComponentDiscoverer; -import org.codehaus.plexus.component.discovery.ComponentDiscovererManager; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; -import org.codehaus.plexus.component.factory.ComponentFactoryManager; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.configuration.PlexusConfigurationMerger; -import org.codehaus.plexus.configuration.source.ConfigurationSource; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.container.initialization.ContainerInitializationContext; -import org.codehaus.plexus.container.initialization.ContainerInitializationPhase; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.context.ContextMapAdapter; -import org.codehaus.plexus.context.DefaultContext; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.InterpolationFilterReader; -import org.codehaus.plexus.util.ReaderFactory; - -import static org.codehaus.plexus.PlexusConstants.PLEXUS_DEFAULT_HINT; -import static org.codehaus.plexus.component.CastUtils.cast; - -/** - * Default implementation of PlexusContainer and MutablePlexusContainer. - * @author Jason van Zyl - * @author Kenney Westerhof - */ -public class DefaultPlexusContainer extends AbstractLogEnabled implements MutablePlexusContainer { - protected static final String DEFAULT_CONTAINER_NAME = "default"; - - protected static final String DEFAULT_REALM_NAME = "plexus.core"; - - /** - * Arbitrary data associated with the container. Data in the container has highest precedence when configuring - * a component to create. - */ - protected Context containerContext; - - protected PlexusConfiguration configuration; - - // todo: don't use a reader - protected Reader configurationReader; - - protected ClassWorld classWorld; - - protected ClassRealm containerRealm; - - // ---------------------------------------------------------------------------- - // Core components - // ---------------------------------------------------------------------------- - - private ComponentRegistry componentRegistry; - - /** - * Simple index (registry) of ComponentDiscovers and ComponentDiscoveryListener. - */ - protected ComponentDiscovererManager componentDiscovererManager; - - /** - * Trivial class to look-up ComponentFactory instances in this container. - */ - protected ComponentFactoryManager componentFactoryManager; - - /** - * Generic logger interface. - */ - protected LoggerManager loggerManager; - - /** - * Converts a ComponentDescriptor into PlexusConfiguration. - */ - protected ConfigurationSource configurationSource; - - // ---------------------------------------------------------------------------- - // - // ---------------------------------------------------------------------------- - - // TODO: Is there a more threadpool-friendly way to do this? - private ThreadLocal lookupRealm = new ThreadLocal(); - - public void addComponent(Object component, String role) { - addComponent(component, role, PLEXUS_DEFAULT_HINT); - } - - public void addComponent(T component, Class role, String roleHint) { - addComponent(component, role.getName(), roleHint); - } - - public void addComponent(Object component, String role, String roleHint) { - if (roleHint == null) { - roleHint = PLEXUS_DEFAULT_HINT; - } - - getComponentRegistry().addComponent(component, role, roleHint); - } - - public ClassRealm setLookupRealm(ClassRealm realm) { - ClassRealm oldRealm = lookupRealm.get(); - - lookupRealm.set(realm); - - return oldRealm; - } - - public ClassRealm getLookupRealm() { - return lookupRealm.get(); - } - - // ---------------------------------------------------------------------- - // Constructors - // ---------------------------------------------------------------------- - - public DefaultPlexusContainer() throws PlexusContainerException { - construct(new DefaultContainerConfiguration()); - } - - public DefaultPlexusContainer(ContainerConfiguration c) throws PlexusContainerException { - construct(c); - } - - public ClassRealm createChildRealm(String id) { - try { - return containerRealm.createChildRealm(id); - } catch (DuplicateRealmException e) { - try { - return classWorld.getRealm(id); - } catch (NoSuchRealmException e1) { - return null; - } - } - } - - private void construct(ContainerConfiguration c) throws PlexusContainerException { - configurationSource = c.getConfigurationSource(); - - // ---------------------------------------------------------------------------- - // ClassWorld - // ---------------------------------------------------------------------------- - - classWorld = c.getClassWorld(); - - // Make sure we have a valid ClassWorld - if (classWorld == null) { - classWorld = - new ClassWorld(DEFAULT_REALM_NAME, Thread.currentThread().getContextClassLoader()); - } - - containerRealm = c.getRealm(); - - if (containerRealm == null) { - try { - containerRealm = classWorld.getRealm(DEFAULT_REALM_NAME); - } catch (NoSuchRealmException e) { - containerRealm = (ClassRealm) classWorld.getRealms().iterator().next(); - - if (containerRealm == null) { - System.err.println("No container realm! Expect errors."); - - new Throwable().printStackTrace(); - } - } - } - - setLookupRealm(containerRealm); - - // ---------------------------------------------------------------------------- - // Context - // ---------------------------------------------------------------------------- - - if (c.getContext() != null) { - containerContext = new DefaultContext(c.getContext()); - } else { - containerContext = new DefaultContext(); - } - - // ---------------------------------------------------------------------------- - // Configuration - // ---------------------------------------------------------------------------- - - InputStream in = null; - - if (c.getContainerConfiguration() != null) { - in = toStream(c.getContainerConfiguration()); - } - - try { - if (c.getContainerConfigurationURL() != null) { - in = c.getContainerConfigurationURL().openStream(); - } - } catch (IOException e) { - throw new PlexusContainerException("Error reading configuration URL", e); - } - - try { - configurationReader = in == null ? null : ReaderFactory.newXmlReader(in); - } catch (IOException e) { - throw new PlexusContainerException("Error reading configuration file", e); - } - - try { - initialize(c); - - start(); - } finally { - IOUtil.close(configurationReader); - } - - for (Class clazz : c.getComponentDiscoverers()) { - try { - ComponentDiscoverer cd = (ComponentDiscoverer) lookup(clazz); - componentDiscovererManager.addComponentDiscoverer(cd); - } catch (ComponentLookupException e) { - } - } - - for (Class clazz : c.getComponentDiscoveryListeners()) { - try { - ComponentDiscoveryListener cdl = (ComponentDiscoveryListener) lookup(clazz); - componentDiscovererManager.registerComponentDiscoveryListener(cdl); - } catch (ComponentLookupException e) { - } - } - } - - // ---------------------------------------------------------------------------- - // Lookup - // ---------------------------------------------------------------------------- - - private Class getInterfaceClass(String role, String hint) { - ComponentDescriptor cd; - - if (hint == null) { - cd = getComponentDescriptor(role); - } else { - cd = getComponentDescriptor(role, hint); - } - - if (cd != null) { - try { - ClassRealm realm = getLookupRealm(); - - if (realm != null) { - return realm.loadClass(role); - } else { - ClassLoader loader = cd.getImplementationClass().getClassLoader(); - - if (loader != null) { - return loader.loadClass(role); - } - } - } catch (ClassNotFoundException e) { - return Object.class; - } - } - - return Object.class; - } - - private Class getRoleClass(String role) { - return getInterfaceClass(role, null); - } - - private Class getRoleClass(String role, String hint) { - return getInterfaceClass(role, hint); - } - - public Object lookup(String role) throws ComponentLookupException { - return componentRegistry.lookup(getRoleClass(role), role, ""); - } - - public Object lookup(String role, String roleHint) throws ComponentLookupException { - return componentRegistry.lookup(getRoleClass(role, roleHint), role, roleHint); - } - - public T lookup(Class type) throws ComponentLookupException { - return componentRegistry.lookup(type, type.getName(), ""); - } - - public T lookup(Class type, String roleHint) throws ComponentLookupException { - return componentRegistry.lookup(type, type.getName(), roleHint); - } - - public T lookup(Class type, String role, String roleHint) throws ComponentLookupException { - return componentRegistry.lookup(type, role, roleHint); - } - - public T lookup(ComponentDescriptor componentDescriptor) throws ComponentLookupException { - return componentRegistry.lookup(componentDescriptor); - } - - public List lookupList(String role) throws ComponentLookupException { - return cast(componentRegistry.lookupList(getRoleClass(role), role, null)); - } - - public List lookupList(String role, List roleHints) throws ComponentLookupException { - return cast(componentRegistry.lookupList(getRoleClass(role), role, roleHints)); - } - - public List lookupList(Class type) throws ComponentLookupException { - return componentRegistry.lookupList(type, type.getName(), null); - } - - public List lookupList(Class type, List roleHints) throws ComponentLookupException { - return componentRegistry.lookupList(type, type.getName(), roleHints); - } - - public Map lookupMap(String role) throws ComponentLookupException { - return cast(componentRegistry.lookupMap(getRoleClass(role), role, null)); - } - - public Map lookupMap(String role, List roleHints) throws ComponentLookupException { - return cast(componentRegistry.lookupMap(getRoleClass(role), role, roleHints)); - } - - public Map lookupMap(Class type) throws ComponentLookupException { - return componentRegistry.lookupMap(type, type.getName(), null); - } - - public Map lookupMap(Class type, List roleHints) throws ComponentLookupException { - return componentRegistry.lookupMap(type, type.getName(), roleHints); - } - - // ---------------------------------------------------------------------- - // Component Descriptor Lookup - // ---------------------------------------------------------------------- - - public boolean hasComponent(String role) { - return componentRegistry.getComponentDescriptor(Object.class, role, "") != null; - } - - public boolean hasComponent(String role, String roleHint) { - return componentRegistry.getComponentDescriptor(Object.class, role, roleHint) != null; - } - - public boolean hasComponent(Class type) { - return componentRegistry.getComponentDescriptor(type, type.getName(), "") != null; - } - - public boolean hasComponent(Class type, String roleHint) { - return componentRegistry.getComponentDescriptor(type, type.getName(), roleHint) != null; - } - - public boolean hasComponent(Class type, String role, String roleHint) { - return componentRegistry.getComponentDescriptor(type, role, roleHint) != null; - } - - public ComponentDescriptor getComponentDescriptor(String role) { - return componentRegistry.getComponentDescriptor(Object.class, role, ""); - } - - public ComponentDescriptor getComponentDescriptor(String role, String roleHint) { - return componentRegistry.getComponentDescriptor(Object.class, role, roleHint); - } - - public ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint) { - return componentRegistry.getComponentDescriptor(type, role, roleHint); - } - - public Map> getComponentDescriptorMap(String role) { - return cast(componentRegistry.getComponentDescriptorMap(Object.class, role)); - } - - public Map> getComponentDescriptorMap(Class type, String role) { - return componentRegistry.getComponentDescriptorMap(type, role); - } - - public List> getComponentDescriptorList(String role) { - return cast(componentRegistry.getComponentDescriptorList(Object.class, role)); - } - - public List> getComponentDescriptorList(Class type, String role) { - return componentRegistry.getComponentDescriptorList(type, role); - } - - public void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException { - if (componentDescriptor.getRealm() == null) { - componentDescriptor.setRealm(this.containerRealm); - // throw new ComponentImplementationNotFoundException( "ComponentDescriptor is missing realmId" ); - } - componentRegistry.addComponentDescriptor(componentDescriptor); - } - - // ---------------------------------------------------------------------- - // Component Release - // ---------------------------------------------------------------------- - - public void release(Object component) throws ComponentLifecycleException { - componentRegistry.release(component); - } - - public void releaseAll(Map components) throws ComponentLifecycleException { - for (Object component : components.values()) { - release(component); - } - } - - public void releaseAll(List components) throws ComponentLifecycleException { - for (Object component : components) { - release(component); - } - } - - // ---------------------------------------------------------------------- - // Lifecycle Management - // ---------------------------------------------------------------------- - - protected void initialize(ContainerConfiguration containerConfiguration) throws PlexusContainerException { - try { - initializeConfiguration(containerConfiguration); - - initializePhases(containerConfiguration); - - containerContext.put(PlexusConstants.PLEXUS_KEY, this); - - discoverComponents(getContainerRealm()); - - PlexusConfiguration[] loadOnStartComponents = - getConfiguration().getChild("load-on-start").getChildren("component"); - - getLogger().debug("Found " + loadOnStartComponents.length + " components to load on start"); - - ClassLoader prevCl = Thread.currentThread().getContextClassLoader(); - - try { - for (PlexusConfiguration loadOnStartComponent : loadOnStartComponents) { - String role = loadOnStartComponent.getChild("role").getValue(null); - - String roleHint = loadOnStartComponent.getChild("role-hint").getValue(null); - - if (role == null) { - throw new PlexusContainerException("Missing 'role' element from load-on-start."); - } - - if (roleHint == null) { - roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; - } - - if (roleHint.equals("*")) { - getLogger().info("Loading on start all components with [role]: " + "[" + role + "]"); - - lookupList(role); - } else { - getLogger().info("Loading on start [role,roleHint]: " + "[" + role + "," + roleHint + "]"); - - lookup(role, roleHint); - } - } - } catch (ComponentLookupException e) { - throw new PlexusContainerException("Error looking up load-on-start component.", e); - } finally { - Thread.currentThread().setContextClassLoader(prevCl); - } - - } catch (ContextException e) { - throw new PlexusContainerException("Error processing configuration", e); - } catch (PlexusConfigurationException e) { - throw new PlexusContainerException("Error configuring components", e); - } catch (IOException e) { - throw new PlexusContainerException("Error reading configuration file", e); - } catch (CycleDetectedInComponentGraphException e) { - throw new PlexusContainerException("Cycle detected in component graph in the system: ", e); - } - } - - protected void initializePhases(ContainerConfiguration containerConfiguration) throws PlexusContainerException { - ContainerInitializationPhase[] initPhases = containerConfiguration.getInitializationPhases(); - - ContainerInitializationContext initializationContext = new ContainerInitializationContext( - this, classWorld, containerRealm, configuration, containerConfiguration); - - for (ContainerInitializationPhase phase : initPhases) { - try { - phase.execute(initializationContext); - } catch (Exception e) { - throw new PlexusContainerException( - "Error initializaing container in " + phase.getClass().getName() + ".", e); - } - } - } - - protected void start() throws PlexusContainerException { - // XXX this is called after initializeConfiguration - is this correct? - configuration = null; - } - - public void dispose() { - try { - componentRegistry.dispose(); - - boolean needToDisposeRealm = false; - - try { - containerRealm.setParentRealm(null); - - if (needToDisposeRealm) { - classWorld.disposeRealm(containerRealm.getId()); - } - } catch (NoSuchRealmException e) { - getLogger().debug("Failed to dispose realm."); - } - } finally { - lookupRealm.set(null); - } - } - - public void addContextValue(Object key, Object value) { - containerContext.put(key, value); - } - - // ---------------------------------------------------------------------- - // Misc Configuration - // ---------------------------------------------------------------------- - - public ClassWorld getClassWorld() { - return classWorld; - } - - public void setClassWorld(ClassWorld classWorld) { - this.classWorld = classWorld; - } - - public ClassRealm getContainerRealm() { - return containerRealm; - } - - public void setContainerRealm(ClassRealm containerRealm) { - this.containerRealm = containerRealm; - } - - // ---------------------------------------------------------------------- - // Context - // ---------------------------------------------------------------------- - - public Context getContext() { - return containerContext; - } - - // ---------------------------------------------------------------------- - // Configuration - // ---------------------------------------------------------------------- - - // TODO: put this in a separate helper class and turn into a component if possible, too big. - - protected void initializeConfiguration(ContainerConfiguration c) - throws PlexusConfigurationException, ContextException, IOException { - // We need an empty plexus configuration for merging. This is a function of removing the - // plexus-boostrap.xml file. - configuration = new XmlPlexusConfiguration("plexus"); - - if (configurationReader != null) { - // User userConfiguration - - PlexusConfiguration userConfiguration = PlexusTools.buildConfiguration( - "", getInterpolationConfigurationReader(configurationReader)); - - // Merger of bootstrapConfiguration and user userConfiguration - - configuration = PlexusConfigurationMerger.merge(userConfiguration, configuration); - } - } - - protected Reader getInterpolationConfigurationReader(Reader reader) { - return new InterpolationFilterReader(reader, new ContextMapAdapter(containerContext)); - } - - public Logger getLogger() { - return super.getLogger(); - } - - // ---------------------------------------------------------------------- - // Discovery - // ---------------------------------------------------------------------- - - public void registerComponentDiscoveryListener(ComponentDiscoveryListener listener) { - componentDiscovererManager.registerComponentDiscoveryListener(listener); - } - - public void removeComponentDiscoveryListener(ComponentDiscoveryListener listener) { - componentDiscovererManager.removeComponentDiscoveryListener(listener); - } - - // ---------------------------------------------------------------------------- - // Mutable Container Interface - // ---------------------------------------------------------------------------- - - public ComponentRegistry getComponentRegistry() { - return componentRegistry; - } - - public void setComponentRegistry(ComponentRegistry componentRegistry) { - this.componentRegistry = componentRegistry; - } - - public ComponentDiscovererManager getComponentDiscovererManager() { - return componentDiscovererManager; - } - - public void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager) { - this.componentDiscovererManager = componentDiscovererManager; - } - - public ComponentFactoryManager getComponentFactoryManager() { - return componentFactoryManager; - } - - public void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager) { - this.componentFactoryManager = componentFactoryManager; - } - - // Configuration - - public PlexusConfiguration getConfiguration() { - return configuration; - } - - public void setConfiguration(PlexusConfiguration configuration) { - this.configuration = configuration; - } - - // ---------------------------------------------------------------------------- - // Component Realms - // ---------------------------------------------------------------------------- - - public ClassRealm getComponentRealm(String realmId) { - ClassRealm realm = null; - - try { - realm = classWorld.getRealm(realmId); - } catch (NoSuchRealmException e) { - // This should never happen: when a component is discovered, it is discovered from a realm and - // it is at that point the realm id is assigned to the component descriptor. - } - - if (realm == null) { - // The core components need the container realm. - realm = containerRealm; - } - - return realm; - } - - public void removeComponentRealm(ClassRealm realm) throws PlexusContainerException { - if (getContainerRealm().getId().equals(realm.getId())) { - throw new IllegalArgumentException("Cannot remove container realm: " + realm.getId() - + "\n(trying to remove container realm as if it were a component realm)."); - } - - componentRegistry.removeComponentRealm(realm); - - ClassRealm lookupRealm = getLookupRealm(); - if ((lookupRealm != null) && lookupRealm.getId().equals(realm.getId())) { - setLookupRealm(getContainerRealm()); - } - } - - private InputStream toStream(String resource) throws PlexusContainerException { - if (resource == null) { - return null; - } - - String relativeResource = resource; - if (resource.startsWith("/")) { - relativeResource = resource.substring(1); - } - - InputStream is = getClass().getClassLoader().getResourceAsStream(relativeResource); - - if (is == null) { - try { - return new FileInputStream(resource); - } catch (FileNotFoundException e) { - return null; - } - } - - return is; - } - - /** - * Utility method to get a default lookup realm for a component. - */ - public ClassRealm getLookupRealm(Object component) { - if (component.getClass().getClassLoader() instanceof ClassRealm) { - return ((ClassRealm) component.getClass().getClassLoader()); - } else { - return getLookupRealm(); - } - } - - public void setConfigurationSource(ConfigurationSource configurationSource) { - this.configurationSource = configurationSource; - } - - public ConfigurationSource getConfigurationSource() { - return configurationSource; - } - - public LoggerManager getLoggerManager() { - // TODO Auto-generated method stub - return loggerManager; - } - - public void setLoggerManager(LoggerManager loggerManager) { - this.loggerManager = loggerManager; - } - - // Discovery - - public List> discoverComponents(ClassRealm realm) - throws PlexusConfigurationException, CycleDetectedInComponentGraphException { - return discoverComponents(realm, null); - } - - public List> discoverComponents(ClassRealm realm, Object data) - throws PlexusConfigurationException, CycleDetectedInComponentGraphException { - List componentSetDescriptors = new ArrayList(); - - List> discoveredComponentDescriptors = new ArrayList>(); - - for (ComponentDiscoverer componentDiscoverer : - getComponentDiscovererManager().getComponentDiscoverers()) { - for (ComponentSetDescriptor componentSetDescriptor : - componentDiscoverer.findComponents(getContext(), realm)) { - // Here we should collect all the urls - // do the interpolation against the context - // register all the components - // allow interception and replacement of the components - - componentSetDescriptors.add(componentSetDescriptor); - - // Fire the event - ComponentDiscoveryEvent event = new ComponentDiscoveryEvent(componentSetDescriptor, data); - - componentDiscovererManager.fireComponentDiscoveryEvent(event); - - for (ComponentDescriptor componentDescriptor : componentSetDescriptor.getComponents()) { - addComponentDescriptor(componentDescriptor); - - discoveredComponentDescriptors.add(componentDescriptor); - } - } - } - - return discoveredComponentDescriptors; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/DuplicateChildContainerException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/DuplicateChildContainerException.java deleted file mode 100644 index 73a1683bb..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/DuplicateChildContainerException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DuplicateChildContainerException extends PlexusContainerException { - - private final String parent; - private final String child; - - public DuplicateChildContainerException(String parent, String child) { - super("Cannot create child container, because child named \'" + child + "\' already exists in parent \'" - + parent + "\'."); - - this.parent = parent; - - this.child = child; - } - - public String getParent() { - return parent; - } - - public String getChild() { - return child; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/MutablePlexusContainer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/MutablePlexusContainer.java deleted file mode 100644 index 3db732a2b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/MutablePlexusContainer.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.discovery.ComponentDiscovererManager; -import org.codehaus.plexus.component.factory.ComponentFactoryManager; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.source.ConfigurationSource; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; - -/** - * @author Jason van Zyl - */ -public interface MutablePlexusContainer extends PlexusContainer { - // Core Components - - ComponentRegistry getComponentRegistry(); - - void setComponentRegistry(ComponentRegistry componentRegistry); - - ComponentDiscovererManager getComponentDiscovererManager(); - - void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager); - - ComponentFactoryManager getComponentFactoryManager(); - - void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager); - - LoggerManager getLoggerManager(); - - void setLoggerManager(LoggerManager loggerManager); - - Logger getLogger(); - - void setConfigurationSource(ConfigurationSource configurationSource); - - ConfigurationSource getConfigurationSource(); - - // Configuration - - void setConfiguration(PlexusConfiguration configuration); - - PlexusConfiguration getConfiguration(); - - ClassRealm getComponentRealm(String realmId); - - ClassWorld getClassWorld(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusConstants.java b/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusConstants.java deleted file mode 100644 index 5577a5d3f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusConstants.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public abstract class PlexusConstants { - /** Key used to retrieve the plexus container from the containerContext. */ - public static final String PLEXUS_KEY = "plexus"; - - /** The role-hint to use for components or lookups that do not specify a role.*/ - public static final String PLEXUS_DEFAULT_HINT = "default"; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java deleted file mode 100644 index 1b713f75f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java +++ /dev/null @@ -1,435 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.context.Context; - -/** - * PlexusContainer is the entry-point for loading and accessing other - * components. - */ -public interface PlexusContainer { - String ROLE = PlexusContainer.class.getName(); - - // ------------------------------------------------------------------------ - // Lookup - // ------------------------------------------------------------------------ - - /** - * Looks up and returns a component object with the given unique key or role. - * @param role a unique key for the desired component - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - Object lookup(String role) throws ComponentLookupException; - - /** - * Looks up and returns a component object with the given unique role/role-hint combination. - * @param role a non-unique key for the desired component - * @param roleHint a hint for the desired component implementation - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - Object lookup(String role, String roleHint) throws ComponentLookupException; - - /** - * Looks up and returns a component object with the given unique key or role. - * @param type the unique type of the component within the container - * @param The type. - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - T lookup(Class type) throws ComponentLookupException; - - /** - * Looks up and returns a component object with the given unique role/role-hint combination. - * @param type the non-unique type of the component - * @param roleHint a hint for the desired component implementation - * @param The type. - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - T lookup(Class type, String roleHint) throws ComponentLookupException; - - /** - * Looks up and returns a component object with the given unique role/role-hint combination. - * @param type the non-unique type of the component - * @param role a non-unique key for the desired component - * @param roleHint a hint for the desired component implementation - * @param The type. - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - T lookup(Class type, String role, String roleHint) throws ComponentLookupException; - - /** - * Looks up and returns a component object matching the given component descriptor. - * @param componentDescriptor the descriptor of the component - * @param The type. - * @return a Plexus component object - * @throws ComponentLookupException in case of lookup error. - */ - T lookup(ComponentDescriptor componentDescriptor) throws ComponentLookupException; - - /** - * Looks up and returns a List of component objects with the given role. - * @param role a non-unique key for the desired components - * @return a List of component objects - * @throws ComponentLookupException in case of lookup error. - */ - List lookupList(String role) throws ComponentLookupException; - - /** - * Looks up and returns a List of component objects with the given role. - * @param role a non-unique key for the desired components - * @param roleHints the list of hints. - * @return a List of component objects - * @throws ComponentLookupException in case of lookup error. - */ - List lookupList(String role, List roleHints) throws ComponentLookupException; - - /** - * Looks up and returns a List of component objects with the given role. - * @param type the non-unique type of the components - * @param The type. - * @return a List of component objects - * @throws ComponentLookupException in case of lookup error. - */ - List lookupList(Class type) throws ComponentLookupException; - - /** - * Looks up and returns a List of component objects with the given role. - * @param type the non-unique type of the components - * @param roleHints the list of hints. - * @param The type. - * @return a List of component objects - * @throws ComponentLookupException in case of lookup error. - */ - List lookupList(Class type, List roleHints) throws ComponentLookupException; - - /** - * Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. - * @param role a non-unique key for the desired components - * @return a Map of component objects - * @throws ComponentLookupException in case of lookup error. - */ - Map lookupMap(String role) throws ComponentLookupException; - - /** - * Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. - * @param role a non-unique key for the desired components - * @param roleHints the list of hints. - * @return a Map of component objects - * @throws ComponentLookupException in case of lookup error. - */ - Map lookupMap(String role, List roleHints) throws ComponentLookupException; - - /** - * Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. - * @param type the non-unique type of the components - * @param The type. - * @return a Map of component objects - * @throws ComponentLookupException in case of lookup error. - */ - Map lookupMap(Class type) throws ComponentLookupException; - - /** - * Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. - * @param type the non-unique type of the components - * @param roleHints the list of hints. - * @param The type. - * @return a Map of component objects - * @throws ComponentLookupException in case of lookup error. - */ - Map lookupMap(Class type, List roleHints) throws ComponentLookupException; - - // ---------------------------------------------------------------------- - // Component Descriptor Lookup - // ---------------------------------------------------------------------- - - /** - * Returns the ComponentDescriptor with the given component role and the default role hint. - * Searches up the hierarchy until one is found, null if none is found. - * @param role a unique role for the desired component's descriptor - * @return the ComponentDescriptor with the given component role - */ - ComponentDescriptor getComponentDescriptor(String role); - - /** - * Returns the ComponentDescriptor with the given component role and hint. - * Searches up the hierarchy until one is found, null if none is found. - * @param role a unique role for the desired component's descriptor - * @param roleHint a hint showing which implementation should be used - * @return the ComponentDescriptor with the given component role - */ - ComponentDescriptor getComponentDescriptor(String role, String roleHint); - - /** - * Returns the ComponentDescriptor with the given component role and hint. - * Searches up the hierarchy until one is found, null if none is found. - * @param type the Java type of the desired component - * @param role a unique role for the desired component's descriptor - * @param roleHint a hint showing which implementation should be used - * @param The type. - * @return the ComponentDescriptor with the given component role - */ - ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint); - - /** - * Returns a Map of ComponentDescriptors with the given role, keyed by role-hint. Searches up the hierarchy until - * all are found, an empty Map if none are found. - * @param role a non-unique key for the desired components - * @return a Map of component descriptors keyed by role-hint - */ - Map> getComponentDescriptorMap(String role); - - /** - * Returns a Map of ComponentDescriptors with the given role, keyed by role-hint. Searches up the hierarchy until - * all are found, an empty Map if none are found. - * @param type the Java type of the desired components - * @param role a non-unique key for the desired components - * @param The type. - * @return a Map of component descriptors keyed by role-hint - */ - Map> getComponentDescriptorMap(Class type, String role); - - /** - * Returns a List of ComponentDescriptors with the given role. Searches up the hierarchy until all are found, an - * empty List if none are found. - * @param role a non-unique key for the desired components - * @return a List of component descriptors - */ - List> getComponentDescriptorList(String role); - - /** - * Returns a List of ComponentDescriptors with the given role. Searches up the hierarchy until all are found, an - * empty List if none are found. - * @param type the Java type of the desired components - * @param role a non-unique key for the desired components - * @param The type. - * @return a List of component descriptors - */ - List> getComponentDescriptorList(Class type, String role); - - /** - * Adds a component descriptor to this container. componentDescriptor should have realmId set. - * @param componentDescriptor {@link ComponentDescriptor} - * @throws CycleDetectedInComponentGraphException In case of an error. - */ - void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException; - - /** - * Releases the component from the container. This is dependent upon how the implementation manages the component, - * but usually enacts some standard lifecycle shutdown procedure on the component. In every case, the component is - * no longer accessible from the container (unless another is created). - * @param component the plexus component object to release - * @throws ComponentLifecycleException in case of an error. - */ - void release(Object component) throws ComponentLifecycleException; - - /** - * Releases all Mapped component values from the container. - * @see PlexusContainer#release( Object component ) - * @param components Map of plexus component objects to release - * @throws ComponentLifecycleException in case of an error. - */ - void releaseAll(Map components) throws ComponentLifecycleException; - - /** - * Releases all Listed components from the container. - * @see PlexusContainer#release( Object component ) - * @param components List of plexus component objects to release - * @throws ComponentLifecycleException in case of an error. - */ - void releaseAll(List components) throws ComponentLifecycleException; - - /** - * Returns true if this container has the keyed component. - * @param role a non-unique key for the desired component - * @return true if this container has the keyed component - */ - boolean hasComponent(String role); - - /** - * Returns true if this container has a component with the given role/role-hint. - * @param role a non-unique key for the desired component - * @param roleHint a hint for the desired component implementation - * @return true if this container has a component with the given role/role-hint - */ - boolean hasComponent(String role, String roleHint); - - /** - * Returns true if this container has a component with the given role/role-hint. - * @param type the non-unique type of the component - * @return true if this container has a component with the given role/role-hint - */ - boolean hasComponent(Class type); - - /** - * Returns true if this container has a component with the given role/role-hint. - * @param type the non-unique type of the component - * @param roleHint a hint for the desired component implementation - * @return true if this container has a component with the given role/role-hint - */ - boolean hasComponent(Class type, String roleHint); - - /** - * Returns true if this container has a component with the given role/role-hint. - * @param type the non-unique type of the component - * @param role a non-unique key for the desired component - * @param roleHint a hint for the desired component implementation - * @return true if this container has a component with the given role/role-hint - */ - boolean hasComponent(Class type, String role, String roleHint); - - /** - * Disposes of this container, which in turn disposes all of it's components. This container should also remove - * itself from the container hierarchy. - */ - void dispose(); - - // ---------------------------------------------------------------------- - // Context - // ---------------------------------------------------------------------- - - /** - * Add a key/value pair to this container's Context. - * @param key any unique object valid to the Context's implementation - * @param value any object valid to the Context's implementation - */ - void addContextValue(Object key, Object value); - - /** - * Returns this container's context. A Context is a simple data store used to hold values which may alter the - * execution of the Container. - * @return this container's context. - */ - Context getContext(); - - /** - * Returns the Classworld's ClassRealm of this Container, which acts as the default parent for all contained - * components. - * @return the ClassRealm of this Container - */ - ClassRealm getContainerRealm(); - - // ---------------------------------------------------------------------- - // Discovery - // ---------------------------------------------------------------------- - - /** - * Adds the listener to this container. ComponentDiscoveryListeners have the ability to respond to various - * ComponentDiscoverer events. - * @param listener A listener which responds to different ComponentDiscoveryEvents - */ - void registerComponentDiscoveryListener(ComponentDiscoveryListener listener); - - /** - * Removes the listener from this container. - * @param listener A listener to remove - */ - void removeComponentDiscoveryListener(ComponentDiscoveryListener listener); - - /** - * Discovers components in the given realm. - * @param childRealm {@link ClassRealm} - * @return list {@link ComponentDescriptor} - * @throws PlexusConfigurationException in case of an error. - * @throws CycleDetectedInComponentGraphException in case of an error. - */ - List> discoverComponents(ClassRealm childRealm) - throws PlexusConfigurationException, CycleDetectedInComponentGraphException; - - /** - * Discovers components in the given realm. - * @param realm the {@link ClassRealm}. - * @param data The data. - * @return list {@link ComponentDescriptor} - * @throws PlexusConfigurationException in case of an error. - * @throws CycleDetectedInComponentGraphException in case of an error. - */ - List> discoverComponents(ClassRealm realm, Object data) - throws PlexusConfigurationException, CycleDetectedInComponentGraphException; - - // ---------------------------------------------------------------------------- - // Component/Plugin ClassRealm creation - // ---------------------------------------------------------------------------- - - ClassRealm createChildRealm(String id); - - ClassRealm getComponentRealm(String realmId); - - /** - * Dissociate the realm with the specified id from the container. This will - * remove all components contained in the realm from the component repository. - * - * @param componentRealm Realm to remove from the container. - * @throws PlexusContainerException {@link PlexusContainerException}. - */ - void removeComponentRealm(ClassRealm componentRealm) throws PlexusContainerException; - - /** - * Returns the lookup realm for this container, which is either - * the container realm or the realm set by {@link MutablePlexusContainer#setLookupRealm(ClassRealm)}. - * @return {@link ClassRealm} - */ - ClassRealm getLookupRealm(); - - /** - * Sets the lookup realm to use for lookup calls that don't have a ClassRealm parameter. - * @param realm the new realm to use. - * @return The previous lookup realm. It is advised to set it back once the old-style lookups have completed. - */ - ClassRealm setLookupRealm(ClassRealm realm); - - /** - * XXX ideally i'd like to place this in a plexus container specific utility class. - * - * Utility method to retrieve the lookup realm for a component instance. - * If the component's classloader is a ClassRealm, that realm is returned, - * otherwise the result of getLookupRealm is returned. - * @param component The component. - * @return {@link ClassRealm} - */ - ClassRealm getLookupRealm(Object component); - - void addComponent(Object component, String role) throws CycleDetectedInComponentGraphException; - - /** - * Adds live component instance to this container. - * - * Component instance is not associated with any class realm and will - * be ignored during lookup is lookup realm is provided using thread context - * classloader. - * @param component The component. - * @param role The role. - * @param roleHint The hint. - * @param The type. - */ - void addComponent(T component, Class role, String roleHint); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java deleted file mode 100644 index 89ca080a1..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Container execution exception. - * - * @author Brett Porter - */ -public class PlexusContainerException extends Exception { - private static final long serialVersionUID = 2213861902264275451L; - - /** - * Construct a new PlexusContainerException instance. - * @param message exception message - * @param throwable causing exception to chain - */ - public PlexusContainerException(String message, Throwable throwable) { - super(message, throwable); - } - - /** - * Construct a new PlexusContainerException instance. - * @param message exception message - */ - public PlexusContainerException(String message) { - super(message); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java deleted file mode 100644 index 29316b77e..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java +++ /dev/null @@ -1,250 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; -import java.io.InputStream; - -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupRuntimeException; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.DefaultContext; -import org.junit.After; -import org.junit.Before; - -import static org.junit.Assert.fail; - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - * @author Michal Maczka - */ -public abstract class PlexusJUnit4TestCase { - private PlexusContainer container; - - private static String basedir; - - @Before - public void beforeTest() throws Exception { - basedir = getBasedir(); - } - - protected void setupContainer() { - // ---------------------------------------------------------------------------- - // Context Setup - // ---------------------------------------------------------------------------- - - DefaultContext context = new DefaultContext(); - - context.put("basedir", getBasedir()); - - customizeContext(context); - - boolean hasPlexusHome = context.contains("plexus.home"); - - if (!hasPlexusHome) { - File f = getTestFile("target/plexus-home"); - - if (!f.isDirectory()) { - f.mkdir(); - } - - context.put("plexus.home", f.getAbsolutePath()); - } - - // ---------------------------------------------------------------------------- - // Configuration - // ---------------------------------------------------------------------------- - - String config = getCustomConfigurationName(); - - ContainerConfiguration containerConfiguration = - new DefaultContainerConfiguration().setName("test").setContext(context.getContextData()); - - if (config != null) { - containerConfiguration.setContainerConfiguration(config); - } else { - String resource = getConfigurationName(null); - - containerConfiguration.setContainerConfiguration(resource); - } - - customizeContainerConfiguration(containerConfiguration); - - try { - container = new DefaultPlexusContainer(containerConfiguration); - } catch (PlexusContainerException e) { - e.printStackTrace(); - fail("Failed to create plexus container."); - } - } - - /** - * Allow custom test case implementations do augment the default container configuration before - * executing tests. - * - * @param containerConfiguration The configuration - */ - protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {} - - protected void customizeContext(Context context) {} - - protected PlexusConfiguration customizeComponentConfiguration() { - return null; - } - - @After - public void afterTest() throws Exception { - if (container != null) { - container.dispose(); - - container = null; - } - } - - protected PlexusContainer getContainer() { - if (container == null) { - setupContainer(); - } - - return container; - } - - protected InputStream getConfiguration() { - return getConfiguration(null); - } - - protected InputStream getConfiguration(String subname) { - return getResourceAsStream(getConfigurationName(subname)); - } - - protected String getCustomConfigurationName() { - return null; - } - - /** - * Allow the retrieval of a container configuration that is based on the name - * of the test class being run. So if you have a test class called org.foo.FunTest, then - * this will produce a resource name of org/foo/FunTest.xml which would be used to - * configure the Plexus container before running your test. - * - * @param subname the subname (not used) - * @return A configuration name - */ - protected String getConfigurationName(String subname) { - return getClass().getName().replace('.', '/') + ".xml"; - } - - protected InputStream getResourceAsStream(String resource) { - return getClass().getResourceAsStream(resource); - } - - protected ClassLoader getClassLoader() { - return getClass().getClassLoader(); - } - - // ---------------------------------------------------------------------- - // Container access - // ---------------------------------------------------------------------- - - protected Object lookup(String componentKey) { - try { - return getContainer().lookup(componentKey); - } catch (ComponentLookupException e) { - throw new ComponentLookupRuntimeException(e); - } - } - - protected Object lookup(String role, String roleHint) throws ComponentLookupRuntimeException { - try { - return getContainer().lookup(role, roleHint); - } catch (ComponentLookupException e) { - throw new ComponentLookupRuntimeException(e); - } - } - - protected T lookup(Class componentClass) throws ComponentLookupRuntimeException { - try { - return getContainer().lookup(componentClass); - } catch (ComponentLookupException e) { - throw new ComponentLookupRuntimeException(e); - } - } - - protected T lookup(Class componentClass, String roleHint) throws ComponentLookupRuntimeException { - try { - return getContainer().lookup(componentClass, roleHint); - } catch (ComponentLookupException e) { - throw new ComponentLookupRuntimeException(e); - } - } - - protected void release(Object component) throws Exception { - getContainer().release(component); - } - - // ---------------------------------------------------------------------- - // Helper methods for sub classes - // ---------------------------------------------------------------------- - - public static File getTestFile(String path) { - return new File(getBasedir(), path); - } - - public static File getTestFile(String basedir, String path) { - File basedirFile = new File(basedir); - - if (!basedirFile.isAbsolute()) { - basedirFile = getTestFile(basedir); - } - - return new File(basedirFile, path); - } - - public static String getTestPath(String path) { - return getTestFile(path).getAbsolutePath(); - } - - public static String getTestPath(String basedir, String path) { - return getTestFile(basedir, path).getAbsolutePath(); - } - - public static String getBasedir() { - if (basedir != null) { - return basedir; - } - - basedir = System.getProperty("basedir"); - - if (basedir == null) { - basedir = new File("").getAbsolutePath(); - } - - return basedir; - } - - public String getTestConfiguration() { - return getTestConfiguration(getClass()); - } - - public static String getTestConfiguration(Class clazz) { - String s = clazz.getName().replace('.', '/'); - - return s.substring(0, s.indexOf("$")) + ".xml"; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java deleted file mode 100644 index e41806f5e..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; -import java.io.InputStream; - -import junit.framework.TestCase; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.DefaultContext; - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - * @author Michal Maczka - */ -public abstract class PlexusTestCase extends TestCase { - private PlexusContainer container; - - private static String basedir; - - protected void setUp() throws Exception { - basedir = getBasedir(); - } - - @SuppressWarnings("ResultOfMethodCallIgnored") - protected void setupContainer() { - // ---------------------------------------------------------------------------- - // Context Setup - // ---------------------------------------------------------------------------- - - DefaultContext context = new DefaultContext(); - - context.put("basedir", getBasedir()); - - customizeContext(context); - - boolean hasPlexusHome = context.contains("plexus.home"); - - if (!hasPlexusHome) { - File f = getTestFile("target/plexus-home"); - - if (!f.isDirectory()) { - f.mkdir(); - } - - context.put("plexus.home", f.getAbsolutePath()); - } - - // ---------------------------------------------------------------------------- - // Configuration - // ---------------------------------------------------------------------------- - - String config = getCustomConfigurationName(); - - ContainerConfiguration containerConfiguration = - new DefaultContainerConfiguration().setName("test").setContext(context.getContextData()); - - if (config != null) { - containerConfiguration.setContainerConfiguration(config); - } else { - String resource = getConfigurationName(null); - - containerConfiguration.setContainerConfiguration(resource); - } - - customizeContainerConfiguration(containerConfiguration); - - try { - container = new DefaultPlexusContainer(containerConfiguration); - } catch (PlexusContainerException e) { - e.printStackTrace(); - fail("Failed to create plexus container."); - } - } - - /** - * Allow custom test case implementations do augment the default container configuration before - * executing tests. - * - * @param containerConfiguration {@link ContainerConfiguration}. - */ - protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {} - - protected void customizeContext(Context context) {} - - protected PlexusConfiguration customizeComponentConfiguration() { - return null; - } - - protected void tearDown() throws Exception { - if (container != null) { - container.dispose(); - - container = null; - } - } - - protected PlexusContainer getContainer() { - if (container == null) { - setupContainer(); - } - - return container; - } - - protected InputStream getConfiguration() throws Exception { - return getConfiguration(null); - } - - protected InputStream getConfiguration(String subname) throws Exception { - return getResourceAsStream(getConfigurationName(subname)); - } - - protected String getCustomConfigurationName() { - return null; - } - - /** - * Allow the retrieval of a container configuration that is based on the name - * of the test class being run. So if you have a test class called org.foo.FunTest, then - * this will produce a resource name of org/foo/FunTest.xml which would be used to - * configure the Plexus container before running your test. - * - * @param subname the subname - * @return A configruation name - */ - protected String getConfigurationName(String subname) { - return getClass().getName().replace('.', '/') + ".xml"; - } - - protected InputStream getResourceAsStream(String resource) { - return getClass().getResourceAsStream(resource); - } - - protected ClassLoader getClassLoader() { - return getClass().getClassLoader(); - } - - // ---------------------------------------------------------------------- - // Container access - // ---------------------------------------------------------------------- - - @SuppressWarnings("unchecked") - protected T lookup(String componentKey) throws Exception { - return (T) getContainer().lookup(componentKey); - } - - @SuppressWarnings("unchecked") - protected T lookup(String role, String roleHint) throws Exception { - return (T) getContainer().lookup(role, roleHint); - } - - protected T lookup(Class componentClass) throws Exception { - return getContainer().lookup(componentClass); - } - - protected T lookup(Class componentClass, String roleHint) throws Exception { - return getContainer().lookup(componentClass, roleHint); - } - - protected void release(Object component) throws Exception { - getContainer().release(component); - } - - // ---------------------------------------------------------------------- - // Helper methods for sub classes - // ---------------------------------------------------------------------- - - public static File getTestFile(String path) { - return new File(getBasedir(), path); - } - - public static File getTestFile(String basedir, String path) { - File basedirFile = new File(basedir); - - if (!basedirFile.isAbsolute()) { - basedirFile = getTestFile(basedir); - } - - return new File(basedirFile, path); - } - - public static String getTestPath(String path) { - return getTestFile(path).getAbsolutePath(); - } - - public static String getTestPath(String basedir, String path) { - return getTestFile(basedir, path).getAbsolutePath(); - } - - public static String getBasedir() { - if (basedir != null) { - return basedir; - } - - basedir = System.getProperty("basedir"); - - if (basedir == null) { - basedir = new File("").getAbsolutePath(); - } - - return basedir; - } - - public String getTestConfiguration() { - return getTestConfiguration(getClass()); - } - - public static String getTestConfiguration(Class clazz) { - String s = clazz.getName().replace('.', '/'); - - return s.substring(0, s.indexOf("$")) + ".xml"; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/CastUtils.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/CastUtils.java deleted file mode 100644 index 3c57179f4..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/CastUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.codehaus.plexus.component; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.xbean.recipe.RecipeHelper; - -@SuppressWarnings({"unchecked", "UnusedDeclaration"}) -public final class CastUtils { - private CastUtils() { - // utility class, never constructed - } - - public static Map cast(Map p) { - return (Map) p; - } - - public static Map cast(Map p, Class t, Class u) { - return (Map) p; - } - - public static Collection cast(Collection p) { - return (Collection) p; - } - - public static Collection cast(Collection p, Class cls) { - return (Collection) p; - } - - public static List cast(List p) { - return (List) p; - } - - public static List cast(List p, Class cls) { - return (List) p; - } - - public static Iterator cast(Iterator p) { - return (Iterator) p; - } - - public static Iterator cast(Iterator p, Class cls) { - return (Iterator) p; - } - - public static Set cast(Set p) { - return (Set) p; - } - - public static Set cast(Set p, Class cls) { - return (Set) p; - } - - public static Map.Entry cast(Map.Entry p) { - return (Map.Entry) p; - } - - public static Map.Entry cast(Map.Entry p, Class pc, Class uc) { - return (Map.Entry) p; - } - - // todo remove when recipe helper accecpts nulls - public static boolean isAssignableFrom(Class expected, Class actual) { - return actual != null && RecipeHelper.isAssignableFrom(expected, actual); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/MapOrientedComponent.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/MapOrientedComponent.java deleted file mode 100644 index aaa108907..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/MapOrientedComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.codehaus.plexus.component; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Map; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.repository.ComponentRequirement; - -public interface MapOrientedComponent { - - void addComponentRequirement(ComponentRequirement requirementDescriptor, Object requirementValue) - throws ComponentConfigurationException; - - void setComponentConfiguration(Map componentConfiguration) throws ComponentConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/AbstractComponentBuildListener.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/AbstractComponentBuildListener.java deleted file mode 100644 index a6ecd66f6..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/AbstractComponentBuildListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2001-2006 Codehaus 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. - */ -package org.codehaus.plexus.component.builder; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public abstract class AbstractComponentBuildListener implements ComponentBuildListener { - public void beforeComponentCreate(ComponentDescriptor componentDescriptor, ClassRealm realm) {} - - public void componentCreated(ComponentDescriptor componentDescriptor, Object component, ClassRealm realm) {} - - public void componentConfigured(ComponentDescriptor componentDescriptor, Object component, ClassRealm realm) {} -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuildListener.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuildListener.java deleted file mode 100644 index 9ec6e7ee1..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuildListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2001-2006 Codehaus 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. - */ -package org.codehaus.plexus.component.builder; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public interface ComponentBuildListener { - - void beforeComponentCreate(ComponentDescriptor componentDescriptor, ClassRealm realm); - - void componentCreated(ComponentDescriptor componentDescriptor, Object component, ClassRealm realm); - - void componentConfigured(ComponentDescriptor componentDescriptor, Object component, ClassRealm realm); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuilder.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuilder.java deleted file mode 100644 index 99bbdd158..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/ComponentBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2001-2006 Codehaus 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. - */ -package org.codehaus.plexus.component.builder; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; - -public interface ComponentBuilder { - - T build(ComponentDescriptor descriptor, ClassRealm realm, ComponentBuildListener listener) - throws ComponentInstantiationException, ComponentLifecycleException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java deleted file mode 100644 index 950c7986d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright 2001-2006 Codehaus 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. - */ -package org.codehaus.plexus.component.builder; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.xbean.recipe.AbstractRecipe; -import org.apache.xbean.recipe.ConstructionException; -import org.apache.xbean.recipe.ObjectRecipe; -import org.apache.xbean.recipe.Option; -import org.apache.xbean.recipe.RecipeHelper; -import org.codehaus.plexus.ComponentRegistry; -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.MapOrientedComponent; -import org.codehaus.plexus.component.collections.ComponentList; -import org.codehaus.plexus.component.collections.ComponentMap; -import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ComponentConfigurator; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.composite.MapConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup; -import org.codehaus.plexus.component.configurator.converters.special.ClassRealmConverter; -import org.codehaus.plexus.component.configurator.expression.DefaultExpressionEvaluator; -import org.codehaus.plexus.component.factory.ComponentFactory; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.factory.java.JavaComponentFactory; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRequirement; -import org.codehaus.plexus.component.repository.ComponentRequirementList; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; -import org.codehaus.plexus.util.StringUtils; - -import static org.apache.xbean.recipe.RecipeHelper.toClass; - -public class XBeanComponentBuilder implements ComponentBuilder { - private static final ThreadLocal>> STACK = - new ThreadLocal>>() { - protected LinkedHashSet> initialValue() { - return new LinkedHashSet>(); - } - }; - - private ComponentManager componentManager; - - public XBeanComponentBuilder() {} - - public XBeanComponentBuilder(ComponentManager componentManager) { - setComponentManager(componentManager); - } - - public ComponentManager getComponentManager() { - return componentManager; - } - - public void setComponentManager(ComponentManager componentManager) { - this.componentManager = componentManager; - } - - protected MutablePlexusContainer getContainer() { - return componentManager.getContainer(); - } - - public T build(ComponentDescriptor descriptor, ClassRealm realm, ComponentBuildListener listener) - throws ComponentInstantiationException, ComponentLifecycleException { - LinkedHashSet> stack = STACK.get(); - if (stack.contains(descriptor)) { - // create list of circularity - List> circularity = new ArrayList>(stack); - circularity.subList(circularity.indexOf(descriptor), circularity.size()); - circularity.add(descriptor); - - // nice circularity message - String message = "Creation circularity: "; - for (ComponentDescriptor componentDescriptor : circularity) { - message += "\n\t[" + componentDescriptor.getRole() + ", " + componentDescriptor.getRoleHint() + "]"; - } - throw new ComponentInstantiationException(message); - } - stack.add(descriptor); - try { - if (listener != null) { - listener.beforeComponentCreate(descriptor, realm); - } - - T component = createComponentInstance(descriptor, realm); - - if (listener != null) { - listener.componentCreated(descriptor, component, realm); - } - - startComponentLifecycle(component, realm); - - if (listener != null) { - listener.componentConfigured(descriptor, component, realm); - } - - return component; - } finally { - stack.remove(descriptor); - } - } - - protected T createComponentInstance(ComponentDescriptor descriptor, ClassRealm realm) - throws ComponentInstantiationException, ComponentLifecycleException { - MutablePlexusContainer container = getContainer(); - if (realm == null) { - realm = descriptor.getRealm(); - } - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(realm); - try { - ObjectRecipe recipe; - - T instance; - ComponentFactory componentFactory = - container.getComponentFactoryManager().findComponentFactory(descriptor.getComponentFactory()); - if (JavaComponentFactory.class.equals(componentFactory.getClass())) { - // xbean-reflect will create object and do injection - recipe = createObjectRecipe(null, descriptor, realm); - instance = (T) recipe.create(); - } else { - // todo figure out how to easily let xbean use the factory to construct the component - // use object factory to construct component and then inject into that object - instance = (T) componentFactory.newInstance(descriptor, realm, container); - recipe = createObjectRecipe(instance, descriptor, realm); - recipe.setProperties(instance); - } - - // todo figure out how to easily let xbean do this map oriented stuff (if it is actually used in plexus) - if (instance instanceof MapOrientedComponent) { - MapOrientedComponent mapOrientedComponent = (MapOrientedComponent) instance; - processMapOrientedComponent(descriptor, mapOrientedComponent, realm); - } - - return instance; - } catch (Exception e) { - throw new ComponentLifecycleException( - "Error constructing component " + descriptor.getHumanReadableKey(), e); - } catch (LinkageError e) { - throw new ComponentLifecycleException( - "Error constructing component " + descriptor.getHumanReadableKey(), e); - } finally { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public ObjectRecipe createObjectRecipe(T instance, ComponentDescriptor descriptor, ClassRealm realm) - throws ComponentInstantiationException, PlexusConfigurationException { - String factoryMethod = null; - String[] constructorArgNames = null; - Class[] constructorArgTypes = null; - - Class implClass = (instance != null) ? instance.getClass() : descriptor.getImplementationClass(); - - if (implClass == null || implClass == Object.class) { - // if the descriptor could not load the class, it's time to report this up to the caller now - try { - realm.loadClass(descriptor.getImplementation()); - } catch (ClassNotFoundException e) { - throw new ComponentInstantiationException( - "Could not load implementation class for component " + descriptor.getHumanReadableKey() - + " from class realm " + realm, - e); - } catch (LinkageError e) { - throw new ComponentInstantiationException( - "Could not load implementation class for component " + descriptor.getHumanReadableKey() - + " from class realm " + realm, - e); - } - } - - ObjectRecipe recipe = new ObjectRecipe(implClass, factoryMethod, constructorArgNames, constructorArgTypes); - recipe.allow(Option.FIELD_INJECTION); - recipe.allow(Option.PRIVATE_PROPERTIES); - - // MapOrientedComponents don't get normal injection - if (!MapOrientedComponent.class.isAssignableFrom(implClass)) { - for (ComponentRequirement requirement : descriptor.getRequirements()) { - String name = requirement.getFieldName(); - RequirementRecipe requirementRecipe = - new RequirementRecipe(descriptor, requirement, getContainer(), name == null); - - if (name != null) { - recipe.setProperty(name, requirementRecipe); - } else { - recipe.setAutoMatchProperty(requirement.getRole(), requirementRecipe); - } - } - - // add configuration data - if (shouldConfigure(descriptor)) { - PlexusConfiguration configuration = descriptor.getConfiguration(); - if (configuration != null) { - for (String name : configuration.getAttributeNames()) { - String value; - try { - value = configuration.getAttribute(name); - } catch (PlexusConfigurationException e) { - throw new ComponentInstantiationException("Error getting value for attribute " + name, e); - } - name = fromXML(name); - recipe.setProperty(name, value); - } - for (PlexusConfiguration child : configuration.getChildren()) { - String name = child.getName(); - name = fromXML(name); - if (StringUtils.isNotEmpty(child.getValue(null))) { - recipe.setProperty(name, child.getValue()); - } else { - recipe.setProperty(name, new PlexusConfigurationRecipe(child)); - } - } - } - } - } - return recipe; - } - - protected boolean shouldConfigure(ComponentDescriptor descriptor) { - String configuratorId = descriptor.getComponentConfigurator(); - - if (StringUtils.isEmpty(configuratorId)) { - return true; - } - - try { - ComponentConfigurator componentConfigurator = - getContainer().lookup(ComponentConfigurator.class, configuratorId); - return componentConfigurator == null - || componentConfigurator.getClass().equals(BasicComponentConfigurator.class); - } catch (ComponentLookupException e) { - } - - return true; - } - - protected String fromXML(String elementName) { - return StringUtils.lowercaseFirstLetter(StringUtils.removeAndHump(elementName, "-")); - } - - protected void startComponentLifecycle(Object component, ClassRealm realm) throws ComponentLifecycleException { - try { - componentManager.start(component); - } catch (PhaseExecutionException e) { - throw new ComponentLifecycleException("Error starting component", e); - } - } - - public static class RequirementRecipe extends AbstractRecipe { - private ComponentDescriptor componentDescriptor; - private ComponentRequirement requirement; - private MutablePlexusContainer container; - private boolean autoMatch; - - public RequirementRecipe( - ComponentDescriptor componentDescriptor, - ComponentRequirement requirement, - MutablePlexusContainer container, - boolean autoMatch) { - this.componentDescriptor = componentDescriptor; - this.requirement = requirement; - this.container = container; - this.autoMatch = autoMatch; - } - - public boolean canCreate(Type expectedType) { - if (!autoMatch) { - return true; - } - - Class propertyType = toClass(expectedType); - - // Never auto match array, map or collection - if (propertyType.isArray() - || Map.class.isAssignableFrom(propertyType) - || Collection.class.isAssignableFrom(propertyType) - || requirement instanceof ComponentRequirementList) { - return false; - } - - // if the type to be created is an instance of the expected type, return true - try { - ComponentRegistry componentRegistry = container.getComponentRegistry(); - - return componentRegistry.getComponentDescriptor( - propertyType, requirement.getRole(), requirement.getRoleHint()) - != null; - } catch (Exception e) { - } - - return false; - } - - @Override - protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException { - Class propertyType = toClass(expectedType); - - try { - String role = requirement.getRole(); - List roleHints = null; - if (requirement instanceof ComponentRequirementList) { - roleHints = ((ComponentRequirementList) requirement).getRoleHints(); - } - - Object assignment; - if (propertyType.isArray()) { - assignment = new ArrayList(container.lookupList(role, roleHints)); - } - - // Map.class.isAssignableFrom( clazz ) doesn't make sense, since Map.class doesn't really - // have a meaningful superclass. - else { - if (Map.class.equals(propertyType)) { - // todo this is a lazy map - - // get component type - Type keyType = Object.class; - Type valueType = Object.class; - Type[] typeParameters = RecipeHelper.getTypeParameters(Collection.class, expectedType); - if (typeParameters != null && typeParameters.length == 2) { - if (typeParameters[0] instanceof Class) { - keyType = typeParameters[0]; - } - if (typeParameters[1] instanceof Class) { - valueType = typeParameters[1]; - } - } - - // todo verify key type is String - - assignment = new ComponentMap( - container, - toClass(valueType), - role, - roleHints, - componentDescriptor.getHumanReadableKey()); - } - // List.class.isAssignableFrom( clazz ) doesn't make sense, since List.class doesn't really - // have a meaningful superclass other than Collection.class, which we'll handle next. - else if (List.class.equals(propertyType)) { - // todo this is a lazy list - - // get component type - Type[] typeParameters = RecipeHelper.getTypeParameters(Collection.class, expectedType); - Type componentType = Object.class; - if (typeParameters != null - && typeParameters.length == 1 - && typeParameters[0] instanceof Class) { - componentType = typeParameters[0]; - } - - assignment = new ComponentList( - container, - toClass(componentType), - role, - roleHints, - componentDescriptor.getHumanReadableKey()); - } - // Set.class.isAssignableFrom( clazz ) doesn't make sense, since Set.class doesn't really - // have a meaningful superclass other than Collection.class, and that would make this - // if-else cascade unpredictable (both List and Set extend Collection, so we'll put another - // check in for Collection.class. - else if (Set.class.equals(propertyType) || Collection.class.isAssignableFrom(propertyType)) { - // todo why isn't this lazy as above? - assignment = container.lookupMap(role, roleHints); - } else if (Logger.class.equals(propertyType)) { - // todo magic reference - assignment = container.getLoggerManager().getLoggerForComponent(componentDescriptor.getRole()); - } else if (PlexusContainer.class.equals(propertyType)) { - // todo magic reference - assignment = container; - } else { - String roleHint = requirement.getRoleHint(); - assignment = container.lookup(propertyType, role, roleHint); - } - } - - return assignment; - } catch (ComponentLookupException e) { - if (requirement.isOptional()) { - return null; - } - - throw new ConstructionException( - "Composition failed of field " + requirement.getFieldName() + " " - + "in object of type " + componentDescriptor.getImplementation() - + " because the requirement " - + requirement + " was missing)", - e); - } - } - - @Override - public String toString() { - return "RequirementRecipe[fieldName=" + requirement.getFieldName() + ", role=" - + componentDescriptor.getRole() + "]"; - } - } - - private class PlexusConfigurationRecipe extends AbstractRecipe { - private final PlexusConfiguration child; - - public PlexusConfigurationRecipe(PlexusConfiguration child) { - this.child = child; - } - - public boolean canCreate(Type type) { - try { - ConverterLookup lookup = createConverterLookup(); - lookup.lookupConverterForType(toClass(type)); - return true; - } catch (ComponentConfigurationException e) { - return false; - } - } - - @Override - protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException { - try { - ConverterLookup lookup = createConverterLookup(); - ConfigurationConverter converter = lookup.lookupConverterForType(toClass(expectedType)); - - // todo this will not work for static factories - ObjectRecipe caller = (ObjectRecipe) RecipeHelper.getCaller(); - Class parentClass = toClass(caller.getType()); - - Object value = converter.fromConfiguration( - lookup, - child, - toClass(expectedType), - parentClass, - Thread.currentThread().getContextClassLoader(), - new DefaultExpressionEvaluator()); - return value; - } catch (ComponentConfigurationException e) { - throw new ConstructionException("Unable to convert configuration for property " + child.getName() - + " to " + toClass(expectedType).getName()); - } - } - - private ConverterLookup createConverterLookup() { - ClassRealm realm = (ClassRealm) Thread.currentThread().getContextClassLoader(); - ConverterLookup lookup = new DefaultConverterLookup(); - lookup.registerConverter(new ClassRealmConverter(realm)); - return lookup; - } - } - - private void processMapOrientedComponent( - ComponentDescriptor descriptor, MapOrientedComponent mapOrientedComponent, ClassRealm realm) - throws ComponentConfigurationException, ComponentLookupException { - MutablePlexusContainer container = getContainer(); - - for (ComponentRequirement requirement : descriptor.getRequirements()) { - String role = requirement.getRole(); - String hint = requirement.getRoleHint(); - String mappingType = requirement.getFieldMappingType(); - - Object value; - - // if the hint is not empty (and not default), we don't care about mapping type... - // it's a single-value, not a collection. - if (StringUtils.isNotEmpty(hint) && !hint.equals(PlexusConstants.PLEXUS_DEFAULT_HINT)) { - value = container.lookup(role, hint); - } else if ("single".equals(mappingType)) { - value = container.lookup(role, hint); - } else if ("map".equals(mappingType)) { - value = container.lookupMap(role); - } else if ("set".equals(mappingType)) { - value = new HashSet(container.lookupList(role)); - } else { - value = container.lookup(role, hint); - } - - mapOrientedComponent.addComponentRequirement(requirement, value); - } - - MapConverter converter = new MapConverter(); - ConverterLookup converterLookup = new DefaultConverterLookup(); - DefaultExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator(); - PlexusConfiguration configuration = container.getConfigurationSource().getConfiguration(descriptor); - - if (configuration != null) { - Map context = (Map) converter.fromConfiguration( - converterLookup, configuration, null, null, realm, expressionEvaluator, null); - - mapOrientedComponent.setComponentConfiguration(context); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java deleted file mode 100644 index bd1bd0593..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.codehaus.plexus.component.collections; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** @author Jason van Zyl */ - -// We need to have the collection notified when a new implementation of a given role has -// been added to the container. We probably need some options so that we know when new -// component descriptors have been added to the system, and an option to keep the collection -// up-to-date when new implementations are added. -// -// NOTE: This includes component additions, but also component purges from the -// container, as when a component realm is disposed -// (and PlexusContainer.removeComponentRealm(..) is called). -public abstract class AbstractComponentCollection { - /** The reference to the PlexusContainer */ - protected MutablePlexusContainer container; - - /** The type of the components held by this collection*/ - protected final Class componentType; - - /** The role of the components we are holding in this Collection. */ - protected String role; - - /** The role hint of the components we are holding in this Collection. */ - protected List roleHints; - - /** The component that requires this collection of components */ - protected String hostComponent; - - /** Used to log errors in the component lookup process. */ - protected Logger logger; - - private ClassLoader tccl; - private Collection realms; - - private Map> componentDescriptorMap; - private final ClassWorld world; - - public AbstractComponentCollection( - final MutablePlexusContainer container, - final Class componentType, - final String role, - final List roleHints, - final String hostComponent) { - this.container = container; - - this.componentType = componentType; - - this.role = role; - - this.roleHints = roleHints; - - this.hostComponent = hostComponent; - - logger = container.getLoggerManager().getLoggerForComponent(role); - - world = container.getContainerRealm().getWorld(); - } - - private boolean realmsHaveChanged() { - return (tccl != Thread.currentThread().getContextClassLoader()) - || (realms == null) - || (!realms.equals(world.getRealms())); - } - - protected synchronized Map> getComponentDescriptorMap() { - checkUpdate(); - - return componentDescriptorMap; - } - - @SuppressWarnings("unchecked") - protected boolean checkUpdate() { - if (componentDescriptorMap != null && !realmsHaveChanged()) { - return false; - } - - tccl = Thread.currentThread().getContextClassLoader(); - Collection fromWorld = world.getRealms(); - if (fromWorld == null || fromWorld.isEmpty()) { - realms = null; - } else { - realms = new HashSet(fromWorld); - } - - Map> componentMap = container.getComponentDescriptorMap(componentType, role); - Map> newComponentDescriptors = - new HashMap>(componentMap.size() * 2); - - if (roleHints != null && !roleHints.isEmpty()) { - for (String roleHint : roleHints) { - ComponentDescriptor componentDescriptor = componentMap.get(roleHint); - if (componentDescriptor != null) { - newComponentDescriptors.put(roleHint, componentDescriptor); - } - } - } else { - newComponentDescriptors.putAll(componentMap); - } - - if (componentDescriptorMap == null || !newComponentDescriptors.equals(componentDescriptorMap)) { - componentDescriptorMap = newComponentDescriptors; - - return true; - } - - return false; - } - - protected T lookup(ComponentDescriptor componentDescriptor) { - T component = null; - - try { - if (componentDescriptor != null) { - component = container.lookup(componentDescriptor); - } - } catch (ComponentLookupException e) { - logger.debug( - "Failed to lookup a member of active collection with role: " + role + " and role-hint: " - + componentDescriptor.getRoleHint(), - e); - } - - return component; - } - - public synchronized void clear() { - releaseAllCallback(); - - componentDescriptorMap = null; - - tccl = null; - realms = null; - } - - protected abstract void releaseAllCallback(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java deleted file mode 100644 index 6db2e8ea4..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java +++ /dev/null @@ -1,223 +0,0 @@ -package org.codehaus.plexus.component.collections; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; - -/** - * @author Jason van Zyl FIXME: [jdcasey] We need to review the efficiency (in speed and memory) of this collection... - */ -public class ComponentList extends AbstractComponentCollection implements List { - private List components; - - public ComponentList( - MutablePlexusContainer container, - Class type, - String role, - List roleHints, - String hostComponent) { - super(container, type, role, roleHints, hostComponent); - } - - public int size() { - return getComponentDescriptorMap().size(); - } - - public boolean isEmpty() { - return getComponentDescriptorMap().isEmpty(); - } - - public boolean contains(Object object) { - return getList().contains(object); - } - - public Iterator iterator() { - return getList().iterator(); - } - - public Object[] toArray() { - return getList().toArray(); - } - - public X[] toArray(X[] ts) { - return getList().toArray(ts); - } - - public synchronized boolean add(T object) { - getList().add(object); - - /* - * PLX-352 This is strictly to support the hack in the Ant Run plugin that tries to poke in a custom converter. - * We need a better way to register converters to plexus and not hit the default converter lookup directly. - * throw new UnsupportedOperationException( "You cannot modify this list. This list is a requirement of " + - * hostComponent + " and managed by the container." ); - */ - - return true; - } - - public boolean remove(Object object) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public boolean containsAll(Collection collection) { - return getList().containsAll(collection); - } - - public boolean addAll(Collection collection) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public boolean addAll(int i, Collection collection) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public synchronized boolean removeAll(Collection collection) { - return getList().removeAll(collection); - } - - public synchronized boolean retainAll(Collection collection) { - return getList().retainAll(collection); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof List)) { - return false; - } - - List other = (List) o; - return getList().equals(other); - } - - public int hashCode() { - return getList().hashCode(); - } - - public T get(int i) { - return getList().get(i); - } - - public T set(int i, T object) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public void add(int i, T object) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public T remove(int i) { - throw new UnsupportedOperationException("You cannot modify this list. This list is a requirement of " - + hostComponent + " and managed by the container."); - } - - public int indexOf(Object object) { - return getList().indexOf(object); - } - - public int lastIndexOf(Object object) { - return getList().lastIndexOf(object); - } - - public ListIterator listIterator() { - return getList().listIterator(); - } - - public ListIterator listIterator(int index) { - return getList().listIterator(index); - } - - public List subList(int fromIndex, int toIndex) { - return getList().subList(fromIndex, toIndex); - } - - private synchronized List getList() { - // NOTE: If we cache the component map, we have a problem with releasing any of the - // components in this map...we need to be able to release them all. - if ((components == null) || checkUpdate()) { - List componentList = new ArrayList(); - - Map> descriptorMap = getComponentDescriptorMap(); - - if (roleHints != null) { - // we must follow the order in roleHints - for (String roleHint : roleHints) { - ComponentDescriptor componentDescriptor = descriptorMap.get(roleHint); - - T component = lookup(componentDescriptor); - - if (component != null) { - componentList.add(component); - } - } - } else { - for (Entry> entry : descriptorMap.entrySet()) { - ComponentDescriptor componentDescriptor = entry.getValue(); - - T component = lookup(componentDescriptor); - - if (component != null) { - componentList.add(component); - } - } - } - components = componentList; - } - - return components; - } - - @Override - protected boolean checkUpdate() { - if (super.checkUpdate()) { - components = null; - - return true; - } - - return false; - } - - protected void releaseAllCallback() { - if (components != null) { - try { - container.releaseAll(components); - } catch (ComponentLifecycleException e) { - logger.debug("Error releasing components in active collection: " + e.getMessage(), e); - } - - components = null; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java deleted file mode 100644 index 740a4f5f2..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.codehaus.plexus.component.collections; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; - -/** - * @author Jason van Zyl FIXME: [jdcasey] We need to review the efficiency (in speed and memory) of this collection... - */ -public class ComponentMap extends AbstractComponentCollection implements Map { - private Map components; - - private Map customAdditions = new LinkedHashMap(); - - public ComponentMap( - MutablePlexusContainer container, - Class type, - String role, - List roleHints, - String hostComponent) { - super(container, type, role, roleHints, hostComponent); - } - - public int size() { - return getComponentDescriptorMap().size(); - } - - public boolean isEmpty() { - return getComponentDescriptorMap().isEmpty(); - } - - public boolean containsKey(Object key) { - return getComponentDescriptorMap().containsKey(key); - } - - public boolean containsValue(Object value) { - return getMap().containsValue(value); - } - - public T get(Object k) { - return getMap().get(k); - } - - public synchronized T put(String key, T value) { - logger.warn("Custom " - + role - + " implementations should NOT be added directly to this Map. Instead, add them as Plexus components."); - - T prev = customAdditions.put(key, value); - if (prev == null) { - prev = getComponentMap().get(key); - } - - return prev; - } - - public synchronized void putAll(Map map) { - logger.warn("Custom " - + role - + " implementations should NOT be added directly to this Map. Instead, add them as Plexus components."); - - customAdditions.putAll(map); - } - - public Set keySet() { - return getMap().keySet(); - } - - public Collection values() { - return getMap().values(); - } - - public Set> entrySet() { - return getMap().entrySet(); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Map)) { - return false; - } - - Map object = (Map) o; - return getMap().equals(object); - } - - public int hashCode() { - return getMap().hashCode(); - } - - public synchronized T remove(Object key) { - logger.warn( - "Items in this Map should NOT be removed directly. If the matching entry is a component, it will NOT be removed."); - - if (key instanceof String) { - if (customAdditions.containsKey(key)) { - return customAdditions.remove(key); - } - } - - return null; - } - - private synchronized Map getMap() { - Map result = getComponentMap(); - - if (!customAdditions.isEmpty()) { - result.putAll(customAdditions); - } - - return result; - } - - private synchronized Map getComponentMap() { - if ((components == null) || checkUpdate()) { - Map componentMap = new LinkedHashMap(); - - Map> descriptorMap = getComponentDescriptorMap(); - - if (roleHints != null) { - // we must follow the order given in roleHints - for (String roleHint : roleHints) { - ComponentDescriptor componentDescriptor = descriptorMap.get(roleHint); - - T component = lookup(componentDescriptor); - - if (component != null) { - componentMap.put(roleHint, component); - } - } - } else { - for (Entry> entry : descriptorMap.entrySet()) { - String roleHint = entry.getKey(); - - ComponentDescriptor componentDescriptor = entry.getValue(); - - T component = lookup(componentDescriptor); - - if (component != null) { - componentMap.put(roleHint, component); - } - } - } - components = componentMap; - } - - return components; - } - - @Override - protected boolean checkUpdate() { - if (super.checkUpdate()) { - components = null; - - return true; - } - - return false; - } - - protected void releaseAllCallback() { - if (components != null) { - try { - container.releaseAll(components); - } catch (ComponentLifecycleException e) { - logger.debug("Error releasing components in active collection: " + e.getMessage(), e); - } - - components = null; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java deleted file mode 100644 index bea3da55f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** - * @author Jason van Zyl - * @author Michal Maczka - */ -public interface CompositionResolver { - public static final char SEPARATOR_CHAR = ':'; - - /** - * @param componentDescriptor {@link ComponentDescriptor}. - * @throws CycleDetectedInComponentGraphException when cycle is detected - */ - void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException; - - /** - * Returns the list of names of components which are required - * by the component of given role and roleHint. - * The names returned are in the form role:hint, where : is defined in SEPARATOR_CHAR. - * - * @param role The name of the component - * @param roleHint The implementation hint of the component - * @return The list of components which are required by given component - */ - List getRequirements(String role, String roleHint); - - /** - * Returns the list of names of components which are using the component. - * of given role and roleHint. - * The names returned are in the form role:hint, where : is defined in SEPARATOR_CHAR. - * - * @param role The name of the component - * @param roleHint The implementation hint of the component - * @return The list of components which are requiring given component - */ - List findRequirements(String role, String roleHint); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java deleted file mode 100644 index f2398fdc7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Thrown when component composition goes awry. - * - * @author Jason van Zyl - * @author Michal Maczka - */ -public class CycleDetectedInComponentGraphException extends Exception { - private static final long serialVersionUID = -5587124702588800322L; - - /** - * Construct a new CompositionException instance. - * - * @param message The detail message for this exception. - */ - public CycleDetectedInComponentGraphException(String message) { - super(message); - } - - /** - * Construct a new CompositionException instance. - * - * @param message The detail message for this exception. - * @param throwable the root cause of the exception - */ - public CycleDetectedInComponentGraphException(String message, Throwable throwable) { - super(message, throwable); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java deleted file mode 100644 index 9ed986ebd..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRequirement; -import org.codehaus.plexus.component.repository.ComponentRequirementList; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.dag.CycleDetectedException; -import org.codehaus.plexus.util.dag.DAG; - -/** - * @author Jason van Zyl - * @author Michal Maczka - */ -public class DefaultCompositionResolver implements CompositionResolver { - private DAG dag = new DAG(); - - public void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException { - String key = getDAGKey(componentDescriptor.getRole(), componentDescriptor.getRoleHint()); - - List requirements = componentDescriptor.getRequirements(); - - for (ComponentRequirement requirement : requirements) { - try { - if (requirement instanceof ComponentRequirementList) { - for (String hint : ((ComponentRequirementList) requirement).getRoleHints()) { - dag.addEdge(key, getDAGKey(requirement.getRole(), hint)); - } - } else { - dag.addEdge(key, getDAGKey(requirement.getRole(), requirement.getRoleHint())); - } - } catch (CycleDetectedException e) { - throw new CycleDetectedInComponentGraphException("Cyclic requirement detected", e); - } - } - } - - /** - * @see org.codehaus.plexus.component.composition.CompositionResolver#getRequirements(String,String) - */ - public List getRequirements(String role, String roleHint) { - return dag.getChildLabels(getDAGKey(role, roleHint)); - } - - /** - * @see org.codehaus.plexus.component.composition.CompositionResolver#findRequirements(String,String) - */ - public List findRequirements(String role, String roleHint) { - return dag.getParentLabels(getDAGKey(role, roleHint)); - } - - private String getDAGKey(String role, String roleHint) { - return role - + SEPARATOR_CHAR - + (StringUtils.isNotEmpty(roleHint) ? roleHint : PlexusConstants.PLEXUS_DEFAULT_HINT); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java deleted file mode 100644 index bfd22a553..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Michal Maczka - */ -public class UndefinedComponentComposerException extends Exception { - public UndefinedComponentComposerException(String message) { - super(message); - } - - public UndefinedComponentComposerException(String message, Throwable cause) { - super(message, cause); - } - - public UndefinedComponentComposerException(Throwable cause) { - super(cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java deleted file mode 100644 index 320747827..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.codehaus.classworlds.ClassRealmAdapter; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup; -import org.codehaus.plexus.component.configurator.expression.DefaultExpressionEvaluator; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Brett Porter - */ -public abstract class AbstractComponentConfigurator implements ComponentConfigurator { - /** - * This is being instantiated here because there are old component factories (beanshell) that directly access - * the converterLookup but do not yet state the ConverterLookup as a requirement in the component metadata. - * Once these are wired up as standard components properly then we won't have to instantiate the - * converter lookup here and we can let the container do it. - * - */ - protected ConverterLookup converterLookup = new DefaultConverterLookup(); - - public void configureComponent(Object component, PlexusConfiguration configuration, ClassRealm containerRealm) - throws ComponentConfigurationException { - configureComponent(component, configuration, new DefaultExpressionEvaluator(), containerRealm); - } - - public void configureComponent( - Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm) - throws ComponentConfigurationException { - configureComponent(component, configuration, expressionEvaluator, containerRealm, null); - } - - public void configureComponent( - final Object component, - final PlexusConfiguration configuration, - final ExpressionEvaluator expressionEvaluator, - final ClassRealm containerRealm, - final ConfigurationListener listener) - throws ComponentConfigurationException { - // ---------------------------------------------------------------------------- - // For compatibility with old ComponentFactories that use old ClassWorlds - // ---------------------------------------------------------------------------- - - final org.codehaus.classworlds.ClassRealm cr = ClassRealmAdapter.getInstance(containerRealm); - - Method method; - - try { - try { - method = getClass() - .getMethod( - "configureComponent", - Object.class, - PlexusConfiguration.class, - ExpressionEvaluator.class, - org.codehaus.classworlds.ClassRealm.class, - ConfigurationListener.class); - method.invoke(this, component, configuration, expressionEvaluator, cr, listener); - } catch (final NoSuchMethodException e) { - method = getClass() - .getMethod( - "configureComponent", - Object.class, - PlexusConfiguration.class, - ExpressionEvaluator.class, - org.codehaus.classworlds.ClassRealm.class); - method.invoke(this, component, configuration, expressionEvaluator, cr); - } - } catch (final InvocationTargetException e) { - if (e.getCause() instanceof ComponentConfigurationException) { - throw (ComponentConfigurationException) e.getCause(); - } else if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } else if (e.getCause() instanceof Error) { - throw (Error) e.getCause(); - } - throw new ComponentConfigurationException( - "Incompatible configurator " + getClass().getName(), e); - } catch (final Exception e) { - throw new ComponentConfigurationException( - "Incompatible configurator " + getClass().getName(), e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java deleted file mode 100644 index 671d4311a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; -import org.codehaus.plexus.component.configurator.converters.special.ClassRealmConverter; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Jason van Zyl - * @author Michal Maczka - */ -public class BasicComponentConfigurator extends AbstractComponentConfigurator { - public void configureComponent( - Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm, - ConfigurationListener listener) - throws ComponentConfigurationException { - // ---------------------------------------------------------------------- - // We should probably take into consideration the realm that the component - // came from in order to load the correct classes. - // ---------------------------------------------------------------------- - - converterLookup.registerConverter(new ClassRealmConverter(containerRealm)); - - ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); - - converter.processConfiguration( - converterLookup, component, containerRealm, configuration, expressionEvaluator, listener); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java deleted file mode 100644 index 3c5331f10..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ComponentConfigurationException extends Exception { - private PlexusConfiguration failedConfiguration; - - public ComponentConfigurationException(String message) { - super(message); - } - - public ComponentConfigurationException(String message, Throwable cause) { - super(message, cause); - } - - public ComponentConfigurationException(Throwable cause) { - super(cause); - } - - public ComponentConfigurationException(PlexusConfiguration failedConfiguration, String message) { - super(message); - this.failedConfiguration = failedConfiguration; - } - - public ComponentConfigurationException(PlexusConfiguration failedConfiguration, String message, Throwable cause) { - super(message, cause); - this.failedConfiguration = failedConfiguration; - } - - public ComponentConfigurationException(PlexusConfiguration failedConfiguration, Throwable cause) { - super(cause); - this.failedConfiguration = failedConfiguration; - } - - public void setFailedConfiguration(PlexusConfiguration failedConfiguration) { - this.failedConfiguration = failedConfiguration; - } - - public PlexusConfiguration getFailedConfiguration() { - return failedConfiguration; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java deleted file mode 100644 index 9e53e9de7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Jason van Zyl - */ -public interface ComponentConfigurator { - String ROLE = ComponentConfigurator.class.getName(); - - void configureComponent(Object component, PlexusConfiguration configuration, ClassRealm containerRealm) - throws ComponentConfigurationException; - - void configureComponent( - Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm) - throws ComponentConfigurationException; - - void configureComponent( - Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm, - ConfigurationListener listener) - throws ComponentConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java deleted file mode 100644 index 3a881122b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004-5, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * Listen for configuration changes on an object. - * - * @author Brett Porter - */ -public interface ConfigurationListener { - /** - * Notify the listener that a field has been set using its setter. - * @param fieldName the field - * @param value the value set - * @param target the target object - */ - void notifyFieldChangeUsingSetter(String fieldName, Object value, Object target); - - /** - * Notify the listener that a field has been set using private field injection. - * @param fieldName the field - * @param value the value set - * @param target the target object - */ - void notifyFieldChangeUsingReflection(String fieldName, Object value, Object target); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/MapOrientedComponentConfigurator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/MapOrientedComponentConfigurator.java deleted file mode 100644 index 547c3814f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/MapOrientedComponentConfigurator.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -import java.util.Map; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.MapOrientedComponent; -import org.codehaus.plexus.component.configurator.converters.composite.MapConverter; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/* - * 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. - */ - -public class MapOrientedComponentConfigurator extends AbstractComponentConfigurator { - - public void configureComponent( - Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm, - ConfigurationListener listener) - throws ComponentConfigurationException { - if (!(component instanceof MapOrientedComponent)) { - throw new ComponentConfigurationException( - "This configurator can only process implementations of " + MapOrientedComponent.class.getName()); - } - - MapConverter converter = new MapConverter(); - - Map context = (Map) converter.fromConfiguration( - converterLookup, configuration, null, null, containerRealm, expressionEvaluator, listener); - - ((MapOrientedComponent) component).setComponentConfiguration(context); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java deleted file mode 100644 index 380bbb4d7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.util.StringUtils; - -/** - * @author Michal Maczka - */ -public abstract class AbstractConfigurationConverter implements ConfigurationConverter { - private static final String IMPLEMENTATION = "implementation"; - - /** - * We will check if user has provided a hint which class should be used for given field. - * So we will check if something like {@code } is present in configuraion. - * If 'implementation' hint was provided we will try to load correspoding class - * If we are unable to do so error will be reported - * @param type {@link Class}. - * @param configuration {@link PlexusConfiguration}. - * @param classLoader {@link ClassLoader}. - * @return The class. - * @throws ComponentConfigurationException in case of an error. - */ - protected Class getClassForImplementationHint( - Class type, PlexusConfiguration configuration, ClassLoader classLoader) - throws ComponentConfigurationException { - Class retValue = type; - - String implementation = configuration.getAttribute(IMPLEMENTATION, null); - - if (implementation != null) { - try { - retValue = classLoader.loadClass(implementation); - - } catch (ClassNotFoundException e) { - String msg = "ClassNotFoundException: Class name which was explicitly given in configuration using" - + " 'implementation' attribute: '" + implementation + "' cannot be loaded"; - - throw new ComponentConfigurationException(msg, e); - } catch (UnsupportedClassVersionError e) { - String msg = "UnsupportedClassVersionError: Class name which was explicitly given in configuration" - + " using 'implementation' attribute: '" + implementation + "' cannot be loaded"; - - throw new ComponentConfigurationException(msg, e); - } catch (LinkageError e) { - String msg = "LinkageError: Class name which was explicitly given in configuration using" - + " 'implementation' attribute: '" + implementation + "' cannot be loaded"; - - throw new ComponentConfigurationException(msg, e); - } - } - - return retValue; - } - - protected Class loadClass(String classname, ClassLoader classLoader) throws ComponentConfigurationException { - Class retValue; - - try { - retValue = classLoader.loadClass(classname); - } catch (ClassNotFoundException e) { - throw new ComponentConfigurationException("Error loading class '" + classname + "'", e); - } - - return retValue; - } - - protected Object instantiateObject(String classname, ClassLoader classLoader) - throws ComponentConfigurationException { - Class clazz = loadClass(classname, classLoader); - - return instantiateObject(clazz); - } - - protected Object instantiateObject(Class clazz) throws ComponentConfigurationException { - Object retValue; - - try { - retValue = clazz.newInstance(); - - return retValue; - } catch (IllegalAccessException e) { - throw new ComponentConfigurationException("Class '" + clazz.getName() + "' cannot be instantiated", e); - } catch (InstantiationException e) { - throw new ComponentConfigurationException("Class '" + clazz.getName() + "' cannot be instantiated", e); - } - } - - // first-name --> firstName - protected String fromXML(String elementName) { - return StringUtils.lowercaseFirstLetter(StringUtils.removeAndHump(elementName, "-")); - } - - // firstName --> first-name - protected String toXML(String fieldName) { - return StringUtils.addAndDeHump(fieldName); - } - - protected Object fromExpression( - PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, Class type) - throws ComponentConfigurationException { - Object v = fromExpression(configuration, expressionEvaluator); - - if (v != null) { - if (!type.isAssignableFrom(v.getClass())) { - String msg = "Cannot assign configuration entry '" + configuration.getName() + "' to '" + type - + "' from '" + configuration.getValue(null) + "', which is of type " + v.getClass(); - throw new ComponentConfigurationException(configuration, msg); - } - } - return v; - } - - protected Object fromExpression(PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException { - Object v = null; - String value = configuration.getValue(null); - if (value != null && value.length() > 0) { - // Object is provided by an expression - // This seems a bit ugly... canConvert really should return false in this instance, but it doesn't have the - // configuration to know better - try { - v = expressionEvaluator.evaluate(value); - } catch (ExpressionEvaluationException e) { - String msg = "Error evaluating the expression '" + value + "' for configuration value '" - + configuration.getName() + "'"; - throw new ComponentConfigurationException(configuration, msg, e); - } - } - if (v == null) { - value = configuration.getAttribute("default-value", null); - if (value != null && value.length() > 0) { - try { - v = expressionEvaluator.evaluate(value); - } catch (ExpressionEvaluationException e) { - String msg = "Error evaluating the expression '" + value + "' for configuration value '" - + configuration.getName() + "'"; - throw new ComponentConfigurationException(configuration, msg, e); - } - } - } - return v; - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException { - return fromConfiguration( - converterLookup, configuration, type, baseType, classLoader, expressionEvaluator, null); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java deleted file mode 100644 index f448f0e80..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters; - -/* - * Copyright 2005-2007 Codehaus 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 java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.util.ReflectionUtils; - -/** @author Kenney Westerhof */ -public class ComponentValueSetter { - private Object object; - - private String fieldName; - - private ConverterLookup lookup; - - private Method setter; - - private Class setterParamType; - - private ConfigurationConverter setterTypeConverter; - - private Field field; - - private Class fieldType; - - private ConfigurationConverter fieldTypeConverter; - - private ConfigurationListener listener; - - public ComponentValueSetter(String fieldName, Object object, ConverterLookup lookup) - throws ComponentConfigurationException { - this(fieldName, object, lookup, null); - } - - public ComponentValueSetter(String fieldName, Object object, ConverterLookup lookup, ConfigurationListener listener) - throws ComponentConfigurationException { - this.fieldName = fieldName; - this.object = object; - this.lookup = lookup; - this.listener = listener; - - if (object == null) { - throw new ComponentConfigurationException("Component is null"); - } - - initSetter(); - - initField(); - - if (setter == null && field == null) { - throw new ComponentConfigurationException( - "Cannot find setter nor field in " + object.getClass().getName() + " for '" + fieldName + "'"); - } - - if (setterTypeConverter == null && fieldTypeConverter == null) { - throw new ComponentConfigurationException("Cannot find converter for " + setterParamType.getName() - + (fieldType != null && !fieldType.equals(setterParamType) ? " or " + fieldType.getName() : "")); - } - } - - private void initSetter() { - setter = ReflectionUtils.getSetter(fieldName, object.getClass()); - - if (setter == null) { - return; - } - - setterParamType = setter.getParameterTypes()[0]; - - try { - setterTypeConverter = lookup.lookupConverterForType(setterParamType); - } catch (ComponentConfigurationException e) { - // ignore, handle later - } - } - - private void initField() { - field = ReflectionUtils.getFieldByNameIncludingSuperclasses(fieldName, object.getClass()); - - if (field == null) { - return; - } - - fieldType = field.getType(); - - try { - fieldTypeConverter = lookup.lookupConverterForType(fieldType); - } catch (ComponentConfigurationException e) { - // ignore, handle later - } - } - - private void setValueUsingField(Object value) throws ComponentConfigurationException { - try { - boolean wasAccessible = field.isAccessible(); - - if (!wasAccessible) { - field.setAccessible(true); - } - - if (listener != null) { - listener.notifyFieldChangeUsingReflection(fieldName, value, object); - } - - field.set(object, value); - - if (!wasAccessible) { - field.setAccessible(false); - } - } catch (IllegalAccessException e) { - throw new ComponentConfigurationException("Cannot access field: " + field, e); - } catch (IllegalArgumentException e) { - throw new ComponentConfigurationException( - "Cannot assign value '" + value + "' (type: " + value.getClass() + ") to " + field, e); - } - } - - private void setValueUsingSetter(Object value) throws ComponentConfigurationException { - if (setterParamType == null || setter == null) { - throw new ComponentConfigurationException("No setter found"); - } - - String exceptionInfo = object.getClass().getName() + "." + setter.getName() + "( " - + setterParamType.getClass().getName() + " )"; - - if (listener != null) { - listener.notifyFieldChangeUsingSetter(fieldName, value, object); - } - - try { - setter.invoke(object, new Object[] {value}); - } catch (IllegalAccessException e) { - throw new ComponentConfigurationException("Cannot access method: " + exceptionInfo, e); - } catch (IllegalArgumentException e) { - throw new ComponentConfigurationException( - "Invalid parameter supplied while setting '" + value + "' to " + exceptionInfo, e); - } catch (InvocationTargetException e) { - throw new ComponentConfigurationException( - "Setter " + exceptionInfo + " threw exception when called with parameter '" + value + "': " - + e.getTargetException().getMessage(), - e); - } - } - - public void configure(PlexusConfiguration config, ClassLoader classLoader, ExpressionEvaluator evaluator) - throws ComponentConfigurationException { - Object value = null; - - // try setter converter + method first - - if (setterTypeConverter != null) { - try { - value = setterTypeConverter.fromConfiguration( - lookup, config, setterParamType, object.getClass(), classLoader, evaluator, listener); - - if (value != null) { - setValueUsingSetter(value); - - return; - } - } catch (ComponentConfigurationException e) { - if (fieldTypeConverter == null - || fieldTypeConverter.getClass().equals(setterTypeConverter.getClass())) { - throw e; - } - } - } - - // try setting field using value found with method - // converter, if present. - - ComponentConfigurationException savedEx = null; - - if (value != null) { - try { - setValueUsingField(value); - return; - } catch (ComponentConfigurationException e) { - savedEx = e; - } - } - - // either no value or setting went wrong. Try - // new converter. - - value = fieldTypeConverter.fromConfiguration( - lookup, config, fieldType, object.getClass(), classLoader, evaluator, listener); - - if (value != null) { - setValueUsingField(value); - } - // FIXME: need this? - else if (savedEx != null) { - throw savedEx; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ConfigurationConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ConfigurationConverter.java deleted file mode 100644 index d161d026c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ConfigurationConverter.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public interface ConfigurationConverter { - boolean canConvert(Class type); - - /** - * @param converterLookup Repository of available converters - * @param configuration {@link PlexusConfiguration} - * @param type the type of object to read - * @param baseType the type of object the the source is - * @param classLoader ClassLoader which should be used for loading classes - * @param expressionEvaluator the expression evaluator to use for expressions - * @return the object - * @throws ComponentConfigurationException in case of an error. - * TODO: a better way, instead of baseType, would be to pass in a factory for new classes that could be based from the given package - */ - Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException; - - /** - * @param converterLookup Repository of available converters - * @param configuration {@link PlexusConfiguration} - * @param type the type of object to read - * @param baseType the type of object the the source is - * @param classLoader ClassLoader which should be used for loading classes - * @param expressionEvaluator the expression evaluator to use for expressions - * @param listener {@link ConfigurationListener}. - * @return the object - * @throws ComponentConfigurationException in case of an error. - * TODO: a better way, instead of baseType, would be to pass in a factory for new classes that could be based from the given package - */ - Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java deleted file mode 100644 index 1bd7bcbe8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - */ -public abstract class AbstractBasicConverter extends AbstractConfigurationConverter { - protected abstract Object fromString(String str) throws ComponentConfigurationException; - - protected Object fromExpression( - PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, Class type) - throws ComponentConfigurationException { - Object v = null; - - String value = configuration.getValue(null); - - if (value != null && value.length() > 0) { - // Object is provided by an expression - // This seems a bit ugly... canConvert really should return false in this instance, but it doesn't have the - // configuration to know better - try { - if (expressionEvaluator instanceof TypeAwareExpressionEvaluator) { - v = ((TypeAwareExpressionEvaluator) expressionEvaluator).evaluate(value, type); - } else { - v = expressionEvaluator.evaluate(value); - } - } catch (ExpressionEvaluationException e) { - String msg = "Error evaluating the expression '" + value + "' for configuration value '" - + configuration.getName() + "'"; - throw new ComponentConfigurationException(configuration, msg, e); - } - } - - if (v == null) { - value = configuration.getAttribute("default-value", null); - - if (value != null && value.length() > 0) { - try { - if (expressionEvaluator instanceof TypeAwareExpressionEvaluator) { - v = ((TypeAwareExpressionEvaluator) expressionEvaluator).evaluate(value, type); - } else { - v = expressionEvaluator.evaluate(value); - } - } catch (ExpressionEvaluationException e) { - String msg = "Error evaluating the expression '" + value + "' for configuration value '" - + configuration.getName() + "'"; - throw new ComponentConfigurationException(configuration, msg, e); - } - } - } - - /* - * NOTE: We don't check the type here which would be ugly to do correctly (e.g. value=Short -> type=int), the - * reflective setter/field injection will fail by itself when the type didn't match. - */ - - return v; - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - if (configuration.getChildCount() > 0) { - throw new ComponentConfigurationException("When configuring a basic element the configuration cannot " - + "contain any child elements. " + "Configuration element '" + configuration.getName() + "'."); - } - - Object retValue = fromExpression(configuration, expressionEvaluator, type); - - if (retValue instanceof String) { - try { - retValue = fromString((String) retValue); - } catch (ComponentConfigurationException e) { - if (e.getFailedConfiguration() == null) { - e.setFailedConfiguration(configuration); - } - - throw e; - } - } - - return retValue; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/BooleanConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/BooleanConverter.java deleted file mode 100644 index 7ac6aeb38..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/BooleanConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class BooleanConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(boolean.class) || type.equals(Boolean.class); - } - - public Object fromString(String str) { - return str.equals("true") ? Boolean.TRUE : Boolean.FALSE; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java deleted file mode 100644 index da0fd57cc..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class ByteConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(byte.class) || type.equals(Byte.class); - } - - public Object fromString(String str) { - return (byte) Integer.parseInt(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java deleted file mode 100644 index 4d0af27c9..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class CharConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(char.class) || type.equals(Character.class); - } - - public Object fromString(String str) { - return str.charAt(0); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ClassConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ClassConverter.java deleted file mode 100644 index 77ae3b1ef..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ClassConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.component.configurator.ComponentConfigurationException; - -/** - * @author Brett Porter - */ -public class ClassConverter extends AbstractBasicConverter { - public boolean canConvert(Class type) { - return type.equals(Class.class); - } - - public Object fromString(String str) throws ComponentConfigurationException { - try { - return Class.forName(str); - } catch (ClassNotFoundException e) { - throw new ComponentConfigurationException("Unable to find class in conversion", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/Converter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/Converter.java deleted file mode 100644 index b5e61c328..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/Converter.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * Translates the String representation of a class into - * an instance of the class and vice versa - * - */ -public interface Converter { - boolean canConvert(Class type); - - /** - * Parses a given String and return - * - * @param str String representation of the class - * @return an instance of the class - */ - Object fromString(String str); - - String toString(Object obj); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java deleted file mode 100644 index 710b39da6..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateConverter extends AbstractBasicConverter { - /*** - * @todo DateFormat is not thread safe! - */ - private static final DateFormat[] formats = { - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S a"), new SimpleDateFormat("yyyy-MM-dd HH:mm:ssa") - }; - - public boolean canConvert(Class type) { - return type.equals(Date.class); - } - - public Object fromString(String str) { - for (DateFormat format : formats) { - try { - return format.parse(str); - } catch (ParseException e) { - // no worries, let's try the next format. - } - } - - return null; - } - - public String toString(Object obj) { - Date date = (Date) obj; - return formats[0].format(date); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DoubleConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DoubleConverter.java deleted file mode 100644 index 9037251e7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DoubleConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class DoubleConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(double.class) || type.equals(Double.class); - } - - public Object fromString(String str) { - return Double.valueOf(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java deleted file mode 100644 index b4d62381a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Benjamin Bentmann - */ -public class EnumConverter extends AbstractConfigurationConverter { - - public boolean canConvert(Class type) { - return type.isEnum(); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - if (configuration.getChildCount() > 0) { - throw new ComponentConfigurationException("When configuring a basic element the configuration cannot " - + "contain any child elements. " + "Configuration element '" + configuration.getName() + "'."); - } - - Object retValue = fromExpression(configuration, expressionEvaluator); - - if (retValue instanceof String) { - try { - retValue = Enum.valueOf(type, (String) retValue); - } catch (RuntimeException e) { - throw new ComponentConfigurationException( - "Cannot assign value " + retValue + " to property " + configuration.getName() + " of " - + baseType.getName() + ": " + e.getMessage(), - e); - } - } - - return retValue; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java deleted file mode 100644 index 69ebb4ddb..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.io.File; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Brett Porter - */ -public class FileConverter extends AbstractBasicConverter { - public boolean canConvert(Class type) { - return type.equals(File.class); - } - - public Object fromString(String str) { - str = str.replace('\\', File.separatorChar).replace('/', File.separatorChar); - return new File(str); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - File f = (File) super.fromConfiguration( - converterLookup, configuration, type, baseType, classLoader, expressionEvaluator, listener); - - if (f != null) { - // Hmmm... is this cheating? Can't think of a better way right now - return expressionEvaluator.alignToBaseDirectory(f); - } else { - return null; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FloatConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FloatConverter.java deleted file mode 100644 index 38db43779..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FloatConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class FloatConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(float.class) || type.equals(Float.class); - } - - public Object fromString(String str) { - return Float.valueOf(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/IntConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/IntConverter.java deleted file mode 100644 index 19f422846..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/IntConverter.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class IntConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(int.class) || type.equals(Integer.class); - } - - public Object fromString(String str) throws ComponentConfigurationException { - try { - return Integer.valueOf(str); - } catch (NumberFormatException e) { - throw new ComponentConfigurationException("Not a number: '" + str + "'", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/LongConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/LongConverter.java deleted file mode 100644 index c549bc417..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/LongConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class LongConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(long.class) || type.equals(Long.class); - } - - public Object fromString(String str) { - return Long.valueOf(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ShortConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ShortConverter.java deleted file mode 100644 index 6fba68c08..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ShortConverter.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class ShortConverter extends AbstractBasicConverter { - - public boolean canConvert(Class type) { - return type.equals(short.class) || type.equals(Short.class); - } - - public Object fromString(String str) { - return Short.valueOf(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringBufferConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringBufferConverter.java deleted file mode 100644 index 2a42198b5..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringBufferConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class StringBufferConverter extends AbstractBasicConverter { - public boolean canConvert(Class type) { - return type.equals(StringBuffer.class); - } - - public Object fromString(String str) { - return new StringBuffer(str); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringConverter.java deleted file mode 100644 index 0a72a9834..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class StringConverter extends AbstractBasicConverter { - public boolean canConvert(Class type) { - return type.equals(String.class); - } - - public Object fromString(String str) { - return str; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java deleted file mode 100644 index 39b84143f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007 the original author or authors. - * - * 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. - */ - -package org.codehaus.plexus.component.configurator.converters.basic; - -import java.net.URI; -import java.net.URISyntaxException; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; - -/** - * Converter for {@link URI} objects. - * - */ -public class UriConverter extends AbstractBasicConverter { - public boolean canConvert(final Class type) { - assert type != null; - - return type.equals(URI.class); - } - - public Object fromString(final String str) throws ComponentConfigurationException { - assert str != null; - - try { - return new URI(str); - } catch (URISyntaxException e) { - throw new ComponentConfigurationException("Unable to convert to URI: " + str, e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UrlConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UrlConverter.java deleted file mode 100644 index 05ef952c8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UrlConverter.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.basic; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.net.MalformedURLException; -import java.net.URL; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; - -/** - * @author Brett Porter - */ -public class UrlConverter extends AbstractBasicConverter { - public boolean canConvert(Class type) { - return type.equals(URL.class); - } - - public Object fromString(String str) throws ComponentConfigurationException { - try { - return new URL(str); - } catch (MalformedURLException e) { - throw new ComponentConfigurationException("Unable to convert '" + str + "' to an URL", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java deleted file mode 100644 index aded3b09c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.List; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.util.StringUtils; - -/** - * @author Kenney Westerhof - */ -public class ArrayConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - return type.isArray(); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - Object retValue = fromExpression(configuration, expressionEvaluator, type); - if (retValue != null) { - return retValue; - } - - List values = new ArrayList(); - - for (int i = 0; i < configuration.getChildCount(); i++) { - PlexusConfiguration childConfiguration = configuration.getChild(i); - - String configEntry = childConfiguration.getName(); - - String name = fromXML(configEntry); - - Class childType = getClassForImplementationHint(null, childConfiguration, classLoader); - - // check if the name is a fully qualified classname - - if (childType == null && name.indexOf('.') > 0) { - try { - childType = classLoader.loadClass(name); - } catch (ClassNotFoundException e) { - // doesn't exist - continue processing - } - } - - if (childType == null) { - // try to find the class in the package of the baseType - // (which is the component being configured) - - String baseTypeName = baseType.getName(); - - int lastDot = baseTypeName.lastIndexOf('.'); - - String className; - - if (lastDot == -1) { - className = name; - } else { - String basePackage = baseTypeName.substring(0, lastDot); - className = basePackage + "." + StringUtils.capitalizeFirstLetter(name); - } - - try { - childType = classLoader.loadClass(className); - } catch (ClassNotFoundException e) { - // doesn't exist, continue processing - } - } - - // finally just try the component type of the array - - if (childType == null) { - childType = type.getComponentType(); - } - - ConfigurationConverter converter = converterLookup.lookupConverterForType(childType); - - Object object = converter.fromConfiguration( - converterLookup, - childConfiguration, - childType, - baseType, - classLoader, - expressionEvaluator, - listener); - - values.add(object); - } - - try { - return values.toArray((Object[]) Array.newInstance(type.getComponentType(), 0)); - } catch (ArrayStoreException e) { - throw new ComponentConfigurationException("Cannot assign configuration values to array of type " - + type.getComponentType().getName() + ": " + values); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java deleted file mode 100644 index 46a6bc003..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.util.StringUtils; - -/** - * @author Michal Maczka - */ -public class CollectionConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - return Collection.class.isAssignableFrom(type) && !Map.class.isAssignableFrom(type); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - Object retValue = fromExpression(configuration, expressionEvaluator, type); - if (retValue != null) { - return retValue; - } - - Class implementation = getClassForImplementationHint(null, configuration, classLoader); - - if (implementation != null) { - retValue = instantiateObject(implementation); - } else { - // we can have 2 cases here: - // - provided collection class which is not abstract - // like Vector, ArrayList, HashSet - so we will just instantantiate it - // - we have an abtract class so we have to use default collection type - int modifiers = type.getModifiers(); - - if (Modifier.isAbstract(modifiers)) { - retValue = getDefaultCollection(type); - } else { - try { - retValue = type.newInstance(); - } catch (IllegalAccessException e) { - String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " - + type + " object failed: " + e.getMessage(); - - throw new ComponentConfigurationException(msg, e); - } catch (InstantiationException e) { - String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " - + type + " object failed: " + e.getMessage(); - - throw new ComponentConfigurationException(msg, e); - } - } - } - // now we have collection and we have to add some objects to it - - for (int i = 0; i < configuration.getChildCount(); i++) { - PlexusConfiguration c = configuration.getChild(i); - // Object o = null; - - String configEntry = c.getName(); - - String name = fromXML(configEntry); - - Class childType = getClassForImplementationHint(null, c, classLoader); - - if (childType == null && name.indexOf('.') > 0) { - try { - childType = classLoader.loadClass(name); - } catch (ClassNotFoundException e) { - // not found, continue processing - } - } - - if (childType == null) { - // Some classloaders don't create Package objects for classes - // so we have to resort to slicing up the class name - - String baseTypeName = baseType.getName(); - - int lastDot = baseTypeName.lastIndexOf('.'); - - String className; - - if (lastDot == -1) { - className = name; - } else { - String basePackage = baseTypeName.substring(0, lastDot); - - className = basePackage + "." + StringUtils.capitalizeFirstLetter(name); - } - - try { - childType = classLoader.loadClass(className); - } catch (ClassNotFoundException e) { - if (c.getChildCount() == 0) { - // If no children, try a String. - // TODO: If we had generics we could try that instead - or could the component descriptor list - // an impl? - childType = String.class; - } else { - throw new ComponentConfigurationException("Error loading class '" + className + "'", e); - } - } - } - - ConfigurationConverter converter = converterLookup.lookupConverterForType(childType); - - Object object = converter.fromConfiguration( - converterLookup, c, childType, baseType, classLoader, expressionEvaluator, listener); - - Collection collection = (Collection) retValue; - collection.add(object); - } - - return retValue; - } - - protected Collection getDefaultCollection(Class collectionType) { - Collection retValue = null; - - if (List.class.isAssignableFrom(collectionType)) { - retValue = new ArrayList(); - } else if (SortedSet.class.isAssignableFrom(collectionType)) { - retValue = new TreeSet(); - } else if (Set.class.isAssignableFrom(collectionType)) { - retValue = new HashSet(); - } - - return retValue; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java deleted file mode 100644 index d5cebe3ed..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * Converter for java.util.Properties. - * - * @author Michal Maczka - */ -public class MapConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - return Map.class.isAssignableFrom(type) && !Properties.class.isAssignableFrom(type); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - Object retValue; - - String expression = configuration.getValue(null); - - if (expression == null) { - expression = configuration.getAttribute("default-value", null); - } - - if (expression == null) { - Map map = new TreeMap(); - - PlexusConfiguration[] children = configuration.getChildren(); - - for (PlexusConfiguration child : children) { - String name = child.getName(); - - map.put(name, fromExpression(child, expressionEvaluator)); - } - retValue = map; - } else { - retValue = fromExpression(configuration, expressionEvaluator); - } - return retValue; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java deleted file mode 100644 index 5d4bb6964..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Collection; -import java.util.Dictionary; -import java.util.Map; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.ComponentValueSetter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Michal Maczka - */ -public class ObjectWithFieldsConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - boolean retValue = true; - - if (Dictionary.class.isAssignableFrom(type)) { - retValue = false; - } else if (Map.class.isAssignableFrom(type)) { - retValue = false; - } else if (Collection.class.isAssignableFrom(type)) { - retValue = false; - } - - return retValue; - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - Object retValue = fromExpression(configuration, expressionEvaluator, type); - - if (retValue == null) { - try { - // it is a "composite" - we compose it from its children. It does not have a value of its own - Class implementation = getClassForImplementationHint(type, configuration, classLoader); - - if (type == implementation && type.isInterface() && configuration.getChildCount() <= 0) { - return null; - } - - retValue = instantiateObject(implementation); - - processConfiguration( - converterLookup, retValue, classLoader, configuration, expressionEvaluator, listener); - } catch (ComponentConfigurationException e) { - if (e.getFailedConfiguration() == null) { - e.setFailedConfiguration(configuration); - } - - throw e; - } - } - return retValue; - } - - public void processConfiguration( - ConverterLookup converterLookup, Object object, ClassLoader classLoader, PlexusConfiguration configuration) - throws ComponentConfigurationException { - processConfiguration(converterLookup, object, classLoader, configuration, null); - } - - public void processConfiguration( - ConverterLookup converterLookup, - Object object, - ClassLoader classLoader, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException { - processConfiguration(converterLookup, object, classLoader, configuration, expressionEvaluator, null); - } - - public void processConfiguration( - ConverterLookup converterLookup, - Object object, - ClassLoader classLoader, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - int items = configuration.getChildCount(); - - for (int i = 0; i < items; i++) { - PlexusConfiguration childConfiguration = configuration.getChild(i); - - String elementName = childConfiguration.getName(); - - ComponentValueSetter valueSetter = - new ComponentValueSetter(fromXML(elementName), object, converterLookup, listener); - - valueSetter.configure(childConfiguration, classLoader, expressionEvaluator); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java deleted file mode 100644 index d8723994f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * Converter for org.codehaus.plexus.configuration.PlexusConfiguration - * - * @author Michal Maczka - */ -public class PlexusConfigurationConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - return PlexusConfiguration.class.isAssignableFrom(type); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - return configuration; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java deleted file mode 100644 index b6a6463a1..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.composite; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Properties; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * Converter for java.util.Properties. - * - * @author Michal Maczka - */ -public class PropertiesConverter extends AbstractConfigurationConverter { - public boolean canConvert(Class type) { - return Properties.class.isAssignableFrom(type); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - - Object retValueInterpolated = fromExpression(configuration, expressionEvaluator, type); - if (retValueInterpolated != null) { - return retValueInterpolated; - } - - String element = configuration.getName(); - - Properties retValue = new Properties(); - - PlexusConfiguration[] children = configuration.getChildren("property"); - - if (children != null && children.length > 0) { - for (PlexusConfiguration child : children) { - addEntry(retValue, element, child, expressionEvaluator); - } - } - - return retValue; - } - - private void addEntry( - Properties properties, - String element, - PlexusConfiguration property, - ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException { - Object name = fromExpression(property.getChild("name"), expressionEvaluator); - - if (name == null) { - String msg = "Trying to convert the configuration element: '" + element - + "', missing child element 'name' for property."; - - throw new ComponentConfigurationException(msg); - } - - Object value = fromExpression(property.getChild("value"), expressionEvaluator); - - if (value == null) { - properties.setProperty(name.toString(), ""); - } else { - properties.setProperty(name.toString(), value.toString()); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java deleted file mode 100644 index 2696d75bc..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.lookup; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; - -/** @version $Id$ */ -public interface ConverterLookup { - void registerConverter(ConfigurationConverter converter); - - ConfigurationConverter lookupConverterForType(Class type) throws ComponentConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java deleted file mode 100644 index e8afde898..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.lookup; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.basic.BooleanConverter; -import org.codehaus.plexus.component.configurator.converters.basic.ByteConverter; -import org.codehaus.plexus.component.configurator.converters.basic.CharConverter; -import org.codehaus.plexus.component.configurator.converters.basic.DateConverter; -import org.codehaus.plexus.component.configurator.converters.basic.DoubleConverter; -import org.codehaus.plexus.component.configurator.converters.basic.EnumConverter; -import org.codehaus.plexus.component.configurator.converters.basic.FileConverter; -import org.codehaus.plexus.component.configurator.converters.basic.FloatConverter; -import org.codehaus.plexus.component.configurator.converters.basic.IntConverter; -import org.codehaus.plexus.component.configurator.converters.basic.LongConverter; -import org.codehaus.plexus.component.configurator.converters.basic.ShortConverter; -import org.codehaus.plexus.component.configurator.converters.basic.StringBufferConverter; -import org.codehaus.plexus.component.configurator.converters.basic.StringConverter; -import org.codehaus.plexus.component.configurator.converters.basic.UriConverter; -import org.codehaus.plexus.component.configurator.converters.basic.UrlConverter; -import org.codehaus.plexus.component.configurator.converters.composite.ArrayConverter; -import org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter; -import org.codehaus.plexus.component.configurator.converters.composite.MapConverter; -import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; -import org.codehaus.plexus.component.configurator.converters.composite.PlexusConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.composite.PropertiesConverter; - -public class DefaultConverterLookup implements ConverterLookup { - private final List converters = new ArrayList(); - - private final List customConverters = new CopyOnWriteArrayList(); - - private final Map, ConfigurationConverter> converterMap = - new ConcurrentHashMap, ConfigurationConverter>(); - - public DefaultConverterLookup() { - registerDefaultBasicConverters(); - - registerDefaultCompositeConverters(); - } - - public synchronized void registerConverter(ConfigurationConverter converter) { - customConverters.add(converter); - } - - protected void registerDefaultConverter(ConfigurationConverter converter) { - converters.add(converter); - } - - public ConfigurationConverter lookupConverterForType(Class type) throws ComponentConfigurationException { - ConfigurationConverter retValue = converterMap.get(type); - - if (retValue == null) { - if (customConverters != null) { - retValue = findConverterForType(customConverters, type); - } - - if (retValue == null) { - retValue = findConverterForType(converters, type); - } - - if (retValue == null) { - // this is highly irregular - throw new ComponentConfigurationException("Configuration converter lookup failed for type: " + type); - } - - converterMap.put(type, retValue); - } - - return retValue; - } - - private ConfigurationConverter findConverterForType(List converters, Class type) { - for (ConfigurationConverter converter : converters) { - if (converter.canConvert(type)) { - return converter; - } - } - - return null; - } - - private void registerDefaultBasicConverters() { - registerDefaultConverter(new BooleanConverter()); - - registerDefaultConverter(new ByteConverter()); - - registerDefaultConverter(new CharConverter()); - - registerDefaultConverter(new DoubleConverter()); - - registerDefaultConverter(new FloatConverter()); - - registerDefaultConverter(new IntConverter()); - - registerDefaultConverter(new LongConverter()); - - registerDefaultConverter(new ShortConverter()); - - registerDefaultConverter(new StringBufferConverter()); - - registerDefaultConverter(new StringConverter()); - - registerDefaultConverter(new DateConverter()); - - registerDefaultConverter(new FileConverter()); - - registerDefaultConverter(new UrlConverter()); - - registerDefaultConverter(new UriConverter()); - - registerDefaultConverter(new EnumConverter()); - } - - private void registerDefaultCompositeConverters() { - registerDefaultConverter(new MapConverter()); - - registerDefaultConverter(new ArrayConverter()); - - registerDefaultConverter(new CollectionConverter()); - - registerDefaultConverter(new PropertiesConverter()); - - registerDefaultConverter(new PlexusConfigurationConverter()); - - // this converter should be always registred as the last one - registerDefaultConverter(new ObjectWithFieldsConverter()); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java deleted file mode 100644 index 9c2c2cdae..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.codehaus.plexus.component.configurator.converters.special; - -import org.codehaus.classworlds.ClassRealmAdapter; -import org.codehaus.classworlds.ClassRealmReverseAdapter; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * ConfigurationConverter to set up ClassRealm component fields. - * - * @author Kenney Westerhof - */ -public class ClassRealmConverter extends AbstractConfigurationConverter { - public static final String ROLE = ConfigurationConverter.class.getName(); - - private ClassRealm classRealm; - - /** - * Constructs this ClassRealmConverter with the given ClassRealm. - * If there's a way to automatically configure this component - * using the current classrealm, this method can go away. - * - * @param classRealm {@link ClassRealm}. - */ - public ClassRealmConverter(ClassRealm classRealm) { - setClassRealm(classRealm); - } - - @Deprecated - public ClassRealmConverter(final org.codehaus.classworlds.ClassRealm classRealm) { - setClassRealm(classRealm); - } - - public void setClassRealm(final ClassRealm classRealm) { - this.classRealm = classRealm; - } - - @Deprecated - public void setClassRealm(final org.codehaus.classworlds.ClassRealm classRealm) { - if (classRealm.getClassLoader() instanceof ClassRealm) { - setClassRealm((ClassRealm) classRealm.getClassLoader()); - } else { - setClassRealm(ClassRealmReverseAdapter.getInstance(classRealm)); - } - } - - public boolean canConvert(Class type) { - // backwards compatibility for old ClassWorld fields - return org.codehaus.classworlds.ClassRealm.class.isAssignableFrom(type) - || ClassRealm.class.isAssignableFrom(type); - } - - public Object fromConfiguration( - ConverterLookup converterLookup, - PlexusConfiguration configuration, - Class type, - Class baseType, - ClassLoader classLoader, - ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { - Object retValue = fromExpression(configuration, expressionEvaluator, type); - - if (retValue == null) { - retValue = classRealm; - } - - // backwards compatibility for old ClassWorld fields - if (retValue instanceof ClassRealm && org.codehaus.classworlds.ClassRealm.class.isAssignableFrom(type)) { - retValue = ClassRealmAdapter.getInstance((ClassRealm) retValue); - } - - return retValue; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java deleted file mode 100644 index f6fed31de..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.component.configurator.expression; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; - -/** - * Evaluate an expression. - * - * @author Brett Porter - */ -public class DefaultExpressionEvaluator implements ExpressionEvaluator { - /** - * Evaluate an expression. - * - * @param expression the expression - * @return the value of the expression - */ - public Object evaluate(String expression) { - return expression; - } - - public File alignToBaseDirectory(File file) { - return file; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java deleted file mode 100644 index 78b7ca313..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.component.configurator.expression; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that occurs during the evaluation of an expression. - * - * @author Brett Porter - */ -public class ExpressionEvaluationException extends Exception { - public ExpressionEvaluationException(String message) { - super(message); - } - - public ExpressionEvaluationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java deleted file mode 100644 index f14d96937..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.codehaus.plexus.component.configurator.expression; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; - -/** - * Evaluate an expression. - * - * @author Brett Porter - */ -public interface ExpressionEvaluator { - String ROLE = ExpressionEvaluator.class.getName(); - - /** - * Evaluate an expression. - * - * @param expression the expression - * @return the value of the expression - * @throws ExpressionEvaluationException in case of an error. - */ - Object evaluate(String expression) throws ExpressionEvaluationException; - - /** - * Align a given path to the base directory that can be evaluated by this expression evaluator, if known. - * - * @param file the file - * @return the aligned file - */ - File alignToBaseDirectory(File file); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java deleted file mode 100644 index 871999c6a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.codehaus.plexus.component.configurator.expression; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Evaluate an expression. - * - * @author Brett Porter - */ -public interface TypeAwareExpressionEvaluator extends ExpressionEvaluator { - - /** - * Evaluate an expression. The optional type provided to this method is a hint (not a requirement) for the evaluator - * to resolve the expression to a compatible value. The evaluator is not expected to perform any conversion but - * rather filter out incompatible values from its result. - * - * @param expression the expression - * @param type The expected type of expression result, may be {@code null}. - * @return the value of the expression - * @throws ExpressionEvaluationException in case of an error. - */ - Object evaluate(String expression, Class type) throws ExpressionEvaluationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java deleted file mode 100644 index 71f75a009..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.IOException; -import java.io.Reader; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextMapAdapter; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.InterpolationFilterReader; -import org.codehaus.plexus.util.ReaderFactory; - -// TODO: this should be a default strategy of searching through classloaders. a discoverer should really not have to be -// concerned finding a particular resource and how to turn it into a set of component descriptors. - -/** - * @author Jason van Zyl - */ -public abstract class AbstractResourceBasedComponentDiscoverer implements ComponentDiscoverer { - protected abstract String getComponentDescriptorLocation(); - - protected abstract ComponentSetDescriptor createComponentDescriptors(Reader reader, String source, ClassRealm realm) - throws PlexusConfigurationException; - - public List findComponents(Context context, ClassRealm realm) - throws PlexusConfigurationException { - List componentSetDescriptors = new ArrayList(); - - Enumeration resources; - - try { - resources = realm.getResources(getComponentDescriptorLocation()); - } catch (IOException e) { - throw new PlexusConfigurationException("Unable to retrieve resources for: " - + getComponentDescriptorLocation() + " in class realm: " + realm.getId()); - } - - for (URL url : Collections.list(resources)) { - Reader reader = null; - - try { - URLConnection conn = url.openConnection(); - - conn.setUseCaches(false); - - conn.connect(); - - reader = ReaderFactory.newXmlReader(conn.getInputStream()); - - InterpolationFilterReader interpolationFilterReader = - new InterpolationFilterReader(reader, new ContextMapAdapter(context)); - - ComponentSetDescriptor componentSetDescriptor = - createComponentDescriptors(interpolationFilterReader, url.toString(), realm); - - componentSetDescriptors.add(componentSetDescriptor); - } catch (IOException ex) { - throw new PlexusConfigurationException("Error reading configuration " + url, ex); - } finally { - IOUtil.close(reader); - } - } - - return componentSetDescriptors; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AnnotationBasedComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AnnotationBasedComponentDiscoverer.java deleted file mode 100644 index 3b0230685..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AnnotationBasedComponentDiscoverer.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/** - * Component discoverer which relies on annotation information to define component definitions. - * - * @author jvanzyl - */ -public interface AnnotationBasedComponentDiscoverer extends ComponentDiscoverer {} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoverer.java deleted file mode 100644 index f3c63e1bb..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoverer.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.context.Context; - -/** - * @author Jason van Zyl - */ -public interface ComponentDiscoverer { - List findComponents(Context context, ClassRealm classRealm) - throws PlexusConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscovererManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscovererManager.java deleted file mode 100644 index c4a72eb02..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscovererManager.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -/** - * ComponentDiscovererManager is a simple index (registry) of ComponentDiscovers and ComponentDiscoveryListener. - */ -public interface ComponentDiscovererManager { - void addComponentDiscoverer(ComponentDiscoverer componentDiscoverer); - - List getComponentDiscoverers(); - - // todo dain change this to Set (requires change to maven) - Map getComponentDiscoveryListeners(); - - void registerComponentDiscoveryListener(ComponentDiscoveryListener listener); - - void removeComponentDiscoveryListener(ComponentDiscoveryListener listener); - - void fireComponentDiscoveryEvent(ComponentDiscoveryEvent event); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java deleted file mode 100644 index a47ce3f12..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.component.repository.ComponentSetDescriptor; - -/** - * Signals to a ComponentDiscoveryListener that an event has taken place - * involving a set of components. It is up to the Listener to decide what - * to do with that information. - */ -public class ComponentDiscoveryEvent { - private ComponentSetDescriptor componentSetDescriptor; - - private Object data; - - /** - * Constructs a ComponentDiscoveryEvent with a set of - * ComponentDescriptors. - * @param componentSetDescriptor a set of ComponentDescriptors - */ - public ComponentDiscoveryEvent(ComponentSetDescriptor componentSetDescriptor) { - this.componentSetDescriptor = componentSetDescriptor; - } - - public ComponentDiscoveryEvent(ComponentSetDescriptor componentSetDescriptor, Object data) { - this.componentSetDescriptor = componentSetDescriptor; - this.data = data; - } - - /** - * Returns this event's set of ComponentDescriptors. - * @return this event's set of ComponentDescriptors - */ - public ComponentSetDescriptor getComponentSetDescriptor() { - return componentSetDescriptor; - } - - public Object getData() { - return data; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryListener.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryListener.java deleted file mode 100644 index 02ce760ae..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * A listener which responds in some way to component discovery by a PlexusContainer. - */ -public interface ComponentDiscoveryListener { - /** - * Signals to this listener that a component has been discovered. - * @param event the event that signals what components have been discovered - */ - void componentDiscovered(ComponentDiscoveryEvent event); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscoverer.java deleted file mode 100644 index 40a040825..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscoverer.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.Reader; -import java.util.ArrayList; -import java.util.List; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; - -/** - * @author Jason van Zyl - */ -public class DefaultComponentDiscoverer extends AbstractResourceBasedComponentDiscoverer { - public String getComponentDescriptorLocation() { - return "META-INF/plexus/components.xml"; - } - - public ComponentSetDescriptor createComponentDescriptors( - Reader componentDescriptorReader, String source, ClassRealm realm) throws PlexusConfigurationException { - PlexusConfiguration componentDescriptorConfiguration = - PlexusTools.buildConfiguration(source, componentDescriptorReader); - - ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor(); - - List> componentDescriptors = new ArrayList>(); - - PlexusConfiguration[] componentConfigurations = - componentDescriptorConfiguration.getChild("components").getChildren("component"); - - for (PlexusConfiguration componentConfiguration : componentConfigurations) { - ComponentDescriptor componentDescriptor; - try { - componentDescriptor = PlexusTools.buildComponentDescriptor(componentConfiguration, realm); - } catch (PlexusConfigurationException e) { - // This is not the most accurate of exceptions as the only real case where this exception - // will be thrown is when the implementation class of the component sited cannot be loaded. - // In the case where role and implementation classes do not exist then we just shouldn't - // create the component descriptor. All information should be taken from annotations which - // will be correct, so in the case we can't load the class it must be coming from and older - // hand written descriptor which is incorrect. - - continue; - } - - componentDescriptor.setSource(source); - - componentDescriptor.setComponentType("plexus"); - - componentDescriptor.setComponentSetDescriptor(componentSetDescriptor); - - componentDescriptors.add(componentDescriptor); - } - - componentSetDescriptor.setComponents(componentDescriptors); - - componentSetDescriptor.setSource(source); - - return componentSetDescriptor; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscovererManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscovererManager.java deleted file mode 100644 index 6ed22f80d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscovererManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class DefaultComponentDiscovererManager implements ComponentDiscovererManager { - private final List componentDiscoverers = new ArrayList(); - - // todo dain change this to LinkedHashSet (requires change to maven) - private final Map listeners = - new LinkedHashMap(); - - public synchronized void addComponentDiscoverer(ComponentDiscoverer discoverer) { - componentDiscoverers.add(discoverer); - } - - // todo this is not thread safe... we are returning the raw collection - public synchronized List getComponentDiscoverers() { - return componentDiscoverers; - } - - // Listeners - - // todo this is not thread safe... we are returning the raw collection - public synchronized Map getComponentDiscoveryListeners() { - return listeners; - } - - public synchronized void registerComponentDiscoveryListener(ComponentDiscoveryListener listener) { - if (!listeners.containsKey(listener)) { - listeners.put(listener, new Object()); - } - } - - public synchronized void removeComponentDiscoveryListener(ComponentDiscoveryListener listener) { - listeners.remove(listener); - } - - public void fireComponentDiscoveryEvent(ComponentDiscoveryEvent event) { - Set listeners; - synchronized (this) { - listeners = this.listeners.keySet(); - } - - for (ComponentDiscoveryListener listener : listeners) { - listener.componentDiscovered(event); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java deleted file mode 100644 index a2e7135e5..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * - */ -public class DiscoveryListenerDescriptor { - private String role; - - private String roleHint; - - public String getRole() { - return role; - } - - public String getRoleHint() { - return roleHint; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/PlexusXmlComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/PlexusXmlComponentDiscoverer.java deleted file mode 100644 index e812c0d00..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/PlexusXmlComponentDiscoverer.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.Reader; -import java.util.Arrays; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; - -public class PlexusXmlComponentDiscoverer extends AbstractResourceBasedComponentDiscoverer { - public String getComponentDescriptorLocation() { - return "META-INF/plexus/plexus.xml"; - } - - @Override - protected ComponentSetDescriptor createComponentDescriptors(Reader reader, String source, ClassRealm realm) - throws PlexusConfigurationException { - ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor(); - - PlexusConfiguration configuration = PlexusTools.buildConfiguration(source, reader); - - if (configuration != null) { - PlexusConfiguration[] componentConfigurations = - configuration.getChild("components").getChildren("component"); - - for (PlexusConfiguration componentConfiguration : componentConfigurations) { - ComponentDescriptor componentDescriptor; - - try { - componentDescriptor = PlexusTools.buildComponentDescriptor(componentConfiguration, realm); - - if (componentDescriptor == null) { - continue; - } - } catch (PlexusConfigurationException e) { - throw new PlexusConfigurationException( - "Cannot build component descriptor from resource found in:\n" - + Arrays.asList(realm.getURLs()), - e); - } - - componentDescriptor.setComponentType("plexus"); - - componentDescriptor.setComponentSetDescriptor(componentSetDescriptor); - - componentSetDescriptor.addComponentDescriptor(componentDescriptor); - } - } - - return componentSetDescriptor; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ResourceBasedComponentDiscoverer.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ResourceBasedComponentDiscoverer.java deleted file mode 100644 index 02edfb1fa..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ResourceBasedComponentDiscoverer.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/** - * Component discoverer which relies on the metadata for the components residing in a resource that - * can be found in a classloader. - * - * @author jvanzyl - */ -public interface ResourceBasedComponentDiscoverer extends ComponentDiscoverer { - String getComponentDescriptorLocation(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java deleted file mode 100644 index 68bce9d94..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.classworlds.ClassRealmAdapter; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** - * - * - * @author Jason van Zyl - * - */ -public abstract class AbstractComponentFactory implements ComponentFactory { - // This is for backward compatibility - private String id; - - public Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException { - // for backward-compatibility with the old component factories delegate to the old-style method - return newInstance(componentDescriptor, ClassRealmAdapter.getInstance(classRealm), container); - } - - protected Object newInstance( - ComponentDescriptor componentDescriptor, - org.codehaus.classworlds.ClassRealm classRealm, - PlexusContainer container) - throws ComponentInstantiationException { - throw new IllegalStateException(getClass().getName() + " does not implement component creation."); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java deleted file mode 100644 index d4545b9a8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** A ServiceFactory is responsible for instantiating a component. - * - * @author Jason van Zyl - * @author Michal Maczka - * - * @version $Id$ - */ -public interface ComponentFactory { - /** Component role. */ - static String ROLE = ComponentFactory.class.getName(); - - String getId(); - - Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java deleted file mode 100644 index 7f6a36add..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentFactoryManager { - ComponentFactory findComponentFactory(String id) throws UndefinedComponentFactoryException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java deleted file mode 100644 index a226a160f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Michal Maczka - * - */ -public class ComponentInstantiationException extends Exception { - public ComponentInstantiationException(String message) { - super(message); - } - - public ComponentInstantiationException(String message, Throwable cause) { - super(message, cause); - } - - public ComponentInstantiationException(Throwable cause) { - super(cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java deleted file mode 100644 index 5db9fc347..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.factory.java.JavaComponentFactory; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; - -/** - * @author Jason van Zyl - */ -public class DefaultComponentFactoryManager implements ComponentFactoryManager, Contextualizable { - private ComponentFactory defaultComponentFactory = new JavaComponentFactory(); - - private PlexusContainer container; - - public ComponentFactory findComponentFactory(String id) throws UndefinedComponentFactoryException { - if (id == null || id.equals("java")) { - return defaultComponentFactory; - } - - try { - return container.lookup(ComponentFactory.class, id); - } catch (ComponentLookupException e) { - throw new UndefinedComponentFactoryException("Specified component factory cannot be found: " + id); - } - } - - public void contextualize(Context context) throws ContextException { - container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java deleted file mode 100644 index a1b50e748..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class UndefinedComponentFactoryException extends Exception { - public UndefinedComponentFactoryException(String message) { - super(message); - } - - public UndefinedComponentFactoryException(String message, Throwable cause) { - super(message, cause); - } - - public UndefinedComponentFactoryException(Throwable cause) { - super(cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java deleted file mode 100644 index 82250064d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.codehaus.plexus.component.factory.java; - -/* - * Copyright 2001-2006 Codehaus 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 java.lang.reflect.Modifier; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.factory.AbstractComponentFactory; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** - * Component Factory for components written in Java Language which have default no parameter constructor - * - * @author Jason van Zyl - * @author Michal Maczka - */ -public class JavaComponentFactory extends AbstractComponentFactory { - public String getId() { - return "java"; - } - - public Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException { - Class implementationClass = null; - - try { - String implementation = componentDescriptor.getImplementation(); - - implementationClass = classRealm.loadClass(implementation); - - int modifiers = implementationClass.getModifiers(); - - if (Modifier.isInterface(modifiers)) { - throw new ComponentInstantiationException( - "Cannot instantiate implementation '" + implementation + "' because the class is a interface."); - } - - if (Modifier.isAbstract(modifiers)) { - throw new ComponentInstantiationException( - "Cannot instantiate implementation '" + implementation + "' because the class is abstract."); - } - - Object instance = implementationClass.newInstance(); - - return instance; - } catch (InstantiationException e) { - // PLXAPI: most probably cause of this is the implementation class not having - // a default constructor. - throw makeException(classRealm, componentDescriptor, implementationClass, e); - } catch (ClassNotFoundException e) { - throw makeException(classRealm, componentDescriptor, implementationClass, e); - } catch (IllegalAccessException e) { - throw makeException(classRealm, componentDescriptor, implementationClass, e); - } catch (LinkageError e) { - throw makeException(classRealm, componentDescriptor, implementationClass, e); - } - } - - private ComponentInstantiationException makeException( - ClassRealm componentClassRealm, - ComponentDescriptor componentDescriptor, - Class implementationClass, - Throwable e) { - // ---------------------------------------------------------------------- - // Display the realm when there is an error, We should probably return a string here so we - // can incorporate this into the error message for easy debugging. - // ---------------------------------------------------------------------- - - String msg; - - if (componentClassRealm == null) { - msg = "classRealm is null for " + componentDescriptor; - } else { - msg = "Could not instantiate component: " + componentDescriptor.getHumanReadableKey() + " realm: " - + componentClassRealm.getId(); - } - - return new ComponentInstantiationException(msg, e); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/AbstractComponentManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/AbstractComponentManager.java deleted file mode 100644 index 381a8ab6d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/AbstractComponentManager.java +++ /dev/null @@ -1,203 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.builder.AbstractComponentBuildListener; -import org.codehaus.plexus.component.builder.ComponentBuilder; -import org.codehaus.plexus.component.builder.XBeanComponentBuilder; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -public abstract class AbstractComponentManager implements ComponentManager { - protected final MutablePlexusContainer container; - - private final ClassRealm realm; - - protected final ComponentDescriptor componentDescriptor; - - private final Class type; - - private final String role; - - private final String roleHint; - - protected final ComponentBuilder builder = new XBeanComponentBuilder(this); - - private final LifecycleHandler lifecycleHandler; - - /** - * Contains a mapping from singleton instances to the realms - * they were used to configure with. This realm will be used to - * call all lifecycle methods. - * This will define a synchronized map, make sure to synchronize the map when iterating. - */ - protected final Map componentContextRealms = - Collections.synchronizedMap(new HashMap()); - - private int connections; - - private long startId; - - public AbstractComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint) { - if (container == null) { - throw new NullPointerException("container is null"); - } - this.container = container; - - if (lifecycleHandler == null) { - throw new NullPointerException("lifecycleHandler is null"); - } - this.lifecycleHandler = lifecycleHandler; - - if (componentDescriptor == null) { - throw new NullPointerException("componentDescriptor is null"); - } - this.componentDescriptor = componentDescriptor; - - if (role == null) { - throw new NullPointerException("role is null"); - } - this.role = role; - - if (roleHint == null) { - throw new NullPointerException("roleHint is null"); - } - this.roleHint = roleHint; - - this.realm = componentDescriptor.getRealm(); - - this.type = componentDescriptor.getImplementationClass(); - } - - public ComponentDescriptor getComponentDescriptor() { - return componentDescriptor; - } - - public Class getType() { - return type; - } - - public ClassRealm getRealm() { - return realm; - } - - public String getRole() { - return role; - } - - public String getRoleHint() { - return roleHint; - } - - public LifecycleHandler getLifecycleHandler() { - return lifecycleHandler; - } - - protected void incrementConnectionCount() { - connections++; - } - - protected void decrementConnectionCount() { - connections--; - } - - protected boolean connected() { - return connections > 0; - } - - public int getConnections() { - return connections; - } - - // ---------------------------------------------------------------------- - // Lifecylce Management - // ---------------------------------------------------------------------- - - public void start(Object component) throws PhaseExecutionException { - startId = NEXT_START_ID.getAndIncrement(); - getLifecycleHandler().start(component, this, componentDescriptor.getRealm()); - } - - /** - * @deprecated for internal use only.. will be removed - */ - public long getStartId() { - return startId; - } - - protected T createComponentInstance() throws ComponentInstantiationException, ComponentLifecycleException { - return builder.build(componentDescriptor, realm, new AbstractComponentBuildListener() { - public void componentCreated( - ComponentDescriptor componentDescriptor, Object component, ClassRealm realm) { - componentContextRealms.put(component, realm); - } - }); - } - - protected void endComponentLifecycle(Object component) throws ComponentLifecycleException { - ClassRealm contextRealm = componentContextRealms.remove(component); - if (contextRealm == null) { - contextRealm = container.getLookupRealm(component); - } - - try { - getLifecycleHandler().end(component, this, contextRealm); - } catch (PhaseExecutionException e) { - throw new ComponentLifecycleException("Error ending component lifecycle", e); - } - } - - public MutablePlexusContainer getContainer() { - return container; - } - - public Logger getLogger() { - return container.getLogger(); - } - - public void dissociateComponentRealm(ClassRealm realm) throws ComponentLifecycleException { - synchronized (componentContextRealms) { - for (Iterator> iterator = - componentContextRealms.entrySet().iterator(); - iterator.hasNext(); ) { - Entry entry = iterator.next(); - ClassRealm componentRealm = entry.getValue(); - - if (componentRealm.getId().equals(realm.getId())) { - iterator.remove(); - } - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java deleted file mode 100644 index c79ca59bd..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.concurrent.atomic.AtomicLong; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -/** - * Manages a component manager. - * Determines when a component is shutdown, and when it's started up. Each - * manager deals with only one component class, though may handle multiple - * instances of this class. - * - * @author Jason van Zyl - * - */ -public interface ComponentManager { - String ROLE = ComponentManager.class.getName(); - - /** - * @deprecated for internal use only.. will be removed - */ - AtomicLong NEXT_START_ID = new AtomicLong(1); - - int getConnections(); - - /** - * @return {@link LifecycleHandler}. - * @deprecated use start instead - */ - LifecycleHandler getLifecycleHandler(); - - void dispose() throws ComponentLifecycleException; - - void release(Object component) throws ComponentLifecycleException; - - T getComponent() throws ComponentInstantiationException, ComponentLifecycleException; - - ComponentDescriptor getComponentDescriptor(); - - Class getType(); - - String getRole(); - - String getRoleHint(); - - MutablePlexusContainer getContainer(); - - void dissociateComponentRealm(ClassRealm realm) throws ComponentLifecycleException; - - ClassRealm getRealm(); - - void start(Object component) throws PhaseExecutionException; - - /** - * @return The start id. - * @deprecated for internal use only.. will be removed - */ - long getStartId(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManagerFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManagerFactory.java deleted file mode 100644 index ae8aaf05f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManagerFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.component.manager; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.lifecycle.LifecycleHandler; - -public interface ComponentManagerFactory { - /** - * Gets the unique identifier of this ComponentManagerFactory. This id is the instantiation strategy specified - * in a component descriptor. - * @return the unique identifier and instantiation strategy name - */ - String getId(); - - /** - * Creates a new component manager for the specified component descriptor. - * @param container {@link MutablePlexusContainer}. - * @param lifecycleHandler {@link LifecycleHandler}. - * @param componentDescriptor {@link ComponentDescriptor} - * @param role The role. - * @param roleHint The hint for the role. - * @param The type. - * @return {@link ComponentManager} - */ - ComponentManager createComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java deleted file mode 100644 index 1abd43c08..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.lifecycle.LifecycleHandler; - -/** - * Creates a new component manager for every lookup - * - * @author Jason van Zyl - * - */ -public class PerLookupComponentManager extends AbstractComponentManager { - public PerLookupComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint) { - super(container, lifecycleHandler, componentDescriptor, role, roleHint); - } - - public void dispose() {} - - public T getComponent() throws ComponentInstantiationException, ComponentLifecycleException { - T component = createComponentInstance(); - - return component; - } - - public void release(Object component) throws ComponentLifecycleException { - decrementConnectionCount(); - endComponentLifecycle(component); - // non cleanup map references for per-lookup cause leak - componentContextRealms.remove(component); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManagerFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManagerFactory.java deleted file mode 100644 index 414a5f0e0..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManagerFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.component.manager; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.lifecycle.LifecycleHandler; - -public class PerLookupComponentManagerFactory implements ComponentManagerFactory { - public String getId() { - return "per-lookup"; - } - - @SuppressWarnings({"RawUseOfParameterizedType"}) - public ComponentManager createComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint) { - return new PerLookupComponentManager(container, lifecycleHandler, componentDescriptor, role, roleHint); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManager.java deleted file mode 100644 index e0ff6c2a8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManager.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.lifecycle.LifecycleHandler; - -/** - * This ensures a component is only used as a singleton, and is only shutdown when the container - * shuts down. - * - * @author Jason van Zyl - */ -public class SingletonComponentManager extends AbstractComponentManager { - private T singleton; - - public SingletonComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint) { - super(container, lifecycleHandler, componentDescriptor, role, roleHint); - } - - public synchronized void release(Object component) throws ComponentLifecycleException { - if (singleton == component) { - dispose(); - } - } - - public synchronized void dispose() throws ComponentLifecycleException { - if (singleton != null) { - endComponentLifecycle(singleton); - singleton = null; - } - } - - public synchronized T getComponent() throws ComponentInstantiationException, ComponentLifecycleException { - if (singleton == null) { - singleton = createComponentInstance(); - } - - incrementConnectionCount(); - - return singleton; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManagerFactory.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManagerFactory.java deleted file mode 100644 index 60c12f239..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/SingletonComponentManagerFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.component.manager; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.lifecycle.LifecycleHandler; - -public class SingletonComponentManagerFactory implements ComponentManagerFactory { - public String getId() { - return "singleton"; - } - - @SuppressWarnings({"RawUseOfParameterizedType"}) - public ComponentManager createComponentManager( - MutablePlexusContainer container, - LifecycleHandler lifecycleHandler, - ComponentDescriptor componentDescriptor, - String role, - String roleHint) { - return new SingletonComponentManager(container, lifecycleHandler, componentDescriptor, role, roleHint); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java deleted file mode 100644 index b91f2499f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - */ -public class UndefinedComponentManagerException extends Exception { - public UndefinedComponentManagerException(String message) { - super(message); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java deleted file mode 100644 index e440ba371..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * This represents a project which this component depends upon to function - * properly, for example, a required jar file. See Apache Maven for an - * example of a dependency in action. - * - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public class ComponentDependency { - private static final String DEAULT_DEPENDENCY_TYPE = "jar"; - - private String groupId; - - private String artifactId; - - private String type = DEAULT_DEPENDENCY_TYPE; - - private String version; - - /** - * Gets a key for an artifact, which is an alias for a specific - * project timeline in a group. - * @return a key for an artifact - */ - public String getArtifactId() { - return artifactId; - } - - /** - * Sets the dependency's artifact ID. - * @param artifactId the artifact ID - */ - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - /** - * Gets a key for a group, which represents a set of artifacts timelines. - * @return a key for a group - */ - public String getGroupId() { - return groupId; - } - - /** - * Sets the dependency's group ID. - * @param groupId the group ID - */ - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - /** - * Gets the type of dependency, for example a "jar". - * @return the type of dependency - */ - public String getType() { - return type; - } - - /** - * Sets the dependency project's type. - * @param type the dependency's type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Returns a specific point in a project's timeline. - * i.e. version 1, or 2.1.4 - * @return a specific point in a project's timeline - */ - public String getVersion() { - return version; - } - - /** - * Sets the point in a project's development timeline - * @param version the project's version - */ - public void setVersion(String version) { - this.version = version; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - - sb.append("groupId = ") - .append(groupId) - .append(", artifactId = ") - .append(artifactId) - .append(", version = ") - .append(version) - .append(", type = ") - .append(type); - - return sb.toString(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java deleted file mode 100644 index 2f4eb096a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java +++ /dev/null @@ -1,628 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * Component instantiation description. - * - * @author Jason van Zyl - * @author bob mcwhirter - * @author Michal Maczka - */ -public class ComponentDescriptor { - private String alias = null; - - private String role = null; - - private Class roleClass; - - private String roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; - - private String implementation; - - private Class implementationClass; - - private String version; - - private String componentType; - - private PlexusConfiguration configuration; - - private String instantiationStrategy; - - private String lifecycleHandler; - - private String componentProfile; - - private final List requirements = new ArrayList(); - - private String componentFactory; - - private String componentComposer; - - private String componentConfigurator; - - private String description; - - private ClassRealm realm; - - // ---------------------------------------------------------------------- - // These two fields allow for the specification of an isolated class realm - // and dependencies that might be specified in a component configuration - // setup by a user i.e. this is here to allow isolation for components - // that are not picked up by the discovery mechanism. - // ---------------------------------------------------------------------- - - private boolean isolatedRealm; - - // ---------------------------------------------------------------------- - - private ComponentSetDescriptor componentSetDescriptor; - - private String source; - - // ---------------------------------------------------------------------- - // Instance methods - // ---------------------------------------------------------------------- - - public ComponentDescriptor() {} - - public ComponentDescriptor(Class implementationClass, ClassRealm realm) { - this.implementationClass = implementationClass; - this.implementation = implementationClass.getName(); - this.realm = realm; - } - - /** - * The location this information came from (descriptor file URI). - * @param source The source of the descriptor. - */ - public void setSource(String source) { - this.source = source; - } - - /** - * The location this information came from (descriptor file URI). - * @return The source. - */ - public String getSource() { - return source; - } - - /** - * Returns a human-friendly key, suitable for display. - * - * @return a human-friendly key - */ - public String getHumanReadableKey() { - StringBuilder key = new StringBuilder(); - - key.append("role: '").append(getRole()).append("'"); - - key.append(", implementation: '").append(getImplementation()).append("'"); - - if (roleHint != null) { - key.append(", role hint: '").append(getRoleHint()).append("'"); - } - - if (alias != null) { - key.append(", alias: '").append(getAlias()).append("'"); - } - - return key.toString(); - } - - /** - * Returns an alias for this component. An alias as an alternate name other than the normal key. - * - * @return an alias for this component - */ - public String getAlias() { - return alias; - } - - /** - * Sets the alias for this component. - * - * @param alias alternate name to set - */ - public void setAlias(String alias) { - this.alias = alias; - } - - /** - * Returns the role of this component. - * - * @return the role of this component - */ - public String getRole() { - return role; - } - - public Class getRoleClass() { - attemptRoleLoad(); - - if (roleClass == null) { - return (Class) Object.class; - } - return (Class) roleClass; - } - - private void attemptRoleLoad() { - if (roleClass == null && getRole() != null && getRealm() != null) { - try { - roleClass = (Class) getRealm().loadClass(getRole()); - Thread.currentThread(); - } catch (Throwable ignored) { - Thread.currentThread(); - } - } - } - - /** - * Sets the role of this component. - * - * @param role this component's role - */ - public void setRole(String role) { - this.role = role; - - // reload role class - roleClass = null; - attemptRoleLoad(); - } - - public void setRoleClass(Class roleClass) { - this.roleClass = roleClass; - - if (roleClass == null) { - role = null; - } else { - role = roleClass.getName(); - } - } - - /** - * Returns the role-hint of this component. - * - * @return the role-hint of this component - */ - public String getRoleHint() { - return roleHint; - } - - /** - * Sets the role-hint of this component. Pasing null will set the hint to the default value. - * - * @param roleHint this component's role-hint - */ - public void setRoleHint(String roleHint) { - if ((roleHint == null) || roleHint.trim().equals("")) { - this.roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; - } else { - this.roleHint = roleHint; - } - } - - /** - * Returns the implementation of this componet. Implementation is a string denoting a FQCN in normal Java - * components, or some other name or file for other component factory implementations. - * - * @return the implementation of this componet's role. - */ - public String getImplementation() { - return implementation; - } - - /** - * Sets the implementation of this componet. - * - * @param implementation string denoting a FQCN in normal Java components, or some other name or file for other - * component factory implementations - */ - public void setImplementation(String implementation) { - this.implementation = implementation; - - // reload implementation class - implementationClass = null; - attemptImplementationLoad(); - } - - /** - * Returns the implementation class of this componet, or null if the implementation class can not be loaded. - * - * @return the implementation of this componet's role. - */ - public Class getImplementationClass() { - attemptImplementationLoad(); - - if (implementationClass == null) { - return (Class) Object.class; - } - return (Class) implementationClass; - } - - private void attemptImplementationLoad() { - if (implementationClass == null && getImplementation() != null && getRealm() != null) { - try { - implementationClass = (Class) getRealm().loadClass(getImplementation()); - Thread.currentThread(); - } catch (Throwable ignored) { - Thread.currentThread(); - } - } - } - - public void setImplementationClass(Class implementationClass) { - this.implementationClass = implementationClass; - if (implementationClass == null) { - implementation = null; - } else { - implementation = implementationClass.getName(); - } - } - - /** - * Returns a specific point in a components's project timeline. i.e. version 1, or 2.1.4 - * - * @return a specific point in a components's project timeline - */ - public String getVersion() { - return version; - } - - /** - * Sets the point in a components's project development timeline - * - * @param version the components's version - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Returns the type of this component. - * - * @return the type of this component - */ - public String getComponentType() { - return componentType; - } - - /** - * Sets this component's type. - * - * @param componentType the type to set - */ - public void setComponentType(String componentType) { - this.componentType = componentType; - } - - /** - * Returns the type of instantiation strategy for this component. - * - * @return the type of instantiation strategy for this component - */ - public String getInstantiationStrategy() { - return instantiationStrategy; - } - - /** - * Returns configuration values defined for this component. - * - * @return configuration values defined for this component - */ - public PlexusConfiguration getConfiguration() { - return configuration; - } - - /** - * Sets the configuration hierarchy for this component. - * - * @param configuration the configuration hierarchy to set - */ - public void setConfiguration(PlexusConfiguration configuration) { - this.configuration = configuration; - } - - /** - * Returns true if this component has a configuration. - * - * @return true if this component has a configuration - */ - public boolean hasConfiguration() { - return configuration != null; - } - - /** - * Returns the lifecycle-handler for this component. - * - * @return the lifecycle-handler for this component - */ - public String getLifecycleHandler() { - return lifecycleHandler; - } - - /** - * Sets the lifecycle-handler for this component. For example, "basic", "passive", "bootstrap". - * - * @param lifecycleHandler the lifecycle handler string to set - */ - public void setLifecycleHandler(String lifecycleHandler) { - this.lifecycleHandler = lifecycleHandler; - } - - public String getComponentProfile() { - return componentProfile; - } - - public void setComponentProfile(String componentProfile) { - this.componentProfile = componentProfile; - } - - /** - * Add a project requirement to this component. - * - * @param requirement the requirement to add - */ - public void addRequirement(ComponentRequirement requirement) { - this.requirements.add(requirement); - } - - /** - * Add a project requirement to this component. - * - * @param requirement the requirement to add - */ - public void addRequirement(ComponentRequirement... requirement) { - this.requirements.addAll(Arrays.asList(requirement)); - } - - /** - * Adds a list of requirements to this component. - * - * @param requirements the requirements to add - */ - public void addRequirements(List requirements) { - this.requirements.addAll(requirements); - } - - /** - * Remove a project requirement from this component. - * - * @param requirement the requirement to remove - */ - public void removeRequirement(ComponentRequirement... requirement) { - this.requirements.removeAll(Arrays.asList(requirement)); - } - - /** - * Removes a list of requirements from this component. - * - * @param requirements the requirements to remove - */ - public void removeRequirements(List requirements) { - this.requirements.removeAll(requirements); - } - - /** - * Returns all project requirements of this component. - * - * @return all project requirements of this component - */ - public List getRequirements() { - return Collections.unmodifiableList(requirements); - } - - /** - * Returns an id of the factory used to create this component. - * - * @return an id of the factory used to create this component - */ - public String getComponentFactory() { - return componentFactory; - } - - /** - * Sets the id of the factory to use to create this component. For example, "jruby" will use a JRuby factory. - * - * @param componentFactory The componentFactor. - */ - public void setComponentFactory(String componentFactory) { - this.componentFactory = componentFactory; - } - - /** - * Returns the ID of the type of composer this component will use. For example, "setter" or "field" for the - * different types of dependency injection. - * - * @return the ID of the type of composer this component will use - */ - public String getComponentComposer() { - return componentComposer; - } - - /** - * Sets a representation of the composer this component uses. - * - * @param componentComposer string representation of the composer to use - */ - public void setComponentComposer(String componentComposer) { - this.componentComposer = componentComposer; - } - - /** - * Return a human-readable description of this component. - * - * @return a human-readable description of this component - */ - public String getDescription() { - return description; - } - - /** - * Sets a description of this component for users to read. - * - * @param description a human-readable description of this component - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Sets the instantiation-strategy for this component. For example, "container". - * - * @param instantiationStrategy The strategy. - */ - public void setInstantiationStrategy(String instantiationStrategy) { - this.instantiationStrategy = instantiationStrategy; - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - /** - * Returns true if this may be in an isolated classrealm. - * - * @return true if this may be in an isolated classrealm - */ - public boolean isIsolatedRealm() { - return isolatedRealm; - } - - /** - * Sets the component set descriptor of components and dependencies for this component. - * - * @param componentSetDescriptor the component set descriptor of components and dependencies - */ - public void setComponentSetDescriptor(ComponentSetDescriptor componentSetDescriptor) { - this.componentSetDescriptor = componentSetDescriptor; - } - - /** - * Returns the component set descriptor. - * - * @return the component set descriptor - */ - public ComponentSetDescriptor getComponentSetDescriptor() { - return componentSetDescriptor; - } - - /** - * Sets that this component may be in an isolated classrealm. - * - * @param isolatedRealm true if this component may be in an isolated classrealm - */ - public void setIsolatedRealm(boolean isolatedRealm) { - this.isolatedRealm = isolatedRealm; - } - - /** - * Returns the type of component configurator for this project. For example "basic" for normal, or "map-oriented" - * for map oriented components. - * - * @return the type of component configurator for this project - */ - public String getComponentConfigurator() { - return componentConfigurator; - } - - /** - * Sets the type of component configurator for this project. - * - * @param componentConfigurator The component configurator. - */ - public void setComponentConfigurator(String componentConfigurator) { - this.componentConfigurator = componentConfigurator; - } - - /** - * The ClassRealm that this component lives under. - * - * @return ClassRealm that this component lives under - */ - public ClassRealm getRealm() { - return realm; - } - - /** - * Set the ClassRealm that this component lives under. - * - * @param realm the ClassRealm that this component lives under - */ - public void setRealm(ClassRealm realm) { - this.realm = realm; - - // reload implementation class - implementationClass = null; - attemptImplementationLoad(); - - // reload role class - roleClass = null; - attemptRoleLoad(); - } - - public String toString() { - return getClass().getName() + " [role: '" + getRole() + "', hint: '" + getRoleHint() + "', realm: " - + (realm == null ? "NULL" : "'" + realm + "'") + "]"; - } - - // Component identity established here! - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof ComponentDescriptor)) { - return false; - } - - ComponentDescriptor that = (ComponentDescriptor) other; - - return eq(getRole(), that.getRole()) - && eq(getRoleHint(), that.getRoleHint()) - && eq(getRealm(), that.getRealm()); - } - - private static boolean eq(T o1, T o2) { - return (o1 != null) ? o1.equals(o2) : o2 == null; - } - - public int hashCode() { - int hash = 17; - - hash = hash * 31 + hash(getRole()); - hash = hash * 31 + hash(getRoleHint()); - hash = hash * 31 + hash(getRealm()); - - return hash; - } - - private static int hash(Object obj) { - return (obj != null) ? obj.hashCode() : 0; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java deleted file mode 100644 index ca735ebaa..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; - -public interface ComponentRepository { - void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException; - - ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint); - - @Deprecated - ComponentDescriptor getComponentDescriptor(String role, String roleHint, ClassRealm realm); - - Map> getComponentDescriptorMap(Class type, String role); - - List> getComponentDescriptorList(Class type, String role); - - void removeComponentRealm(ClassRealm classRealm); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java deleted file mode 100644 index aa6a10dd8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * This represents a component this is required by another component. - * - * @author Michal Maczka - */ -public class ComponentRequirement { - private String role; - - private String roleHint = ""; - - private String fieldName; - - private String fieldMappingType; - - private boolean optional; - - /** - * Returns the field name that this component requirement will inject. - * @return the field name that this component requirement will inject - */ - public String getFieldName() { - return fieldName; - } - - /** - * Sets the name of the field that will be populated by the required - * component. - * @param fieldName the name of the field to be populated - */ - public void setFieldName(String fieldName) { - this.fieldName = fieldName; - } - - /** - * Returns the role of the required component. - * @return the role of the required component - */ - public String getRole() { - return role; - } - - /** - * Sets the role of the require component. - * @param role the required component's role - */ - public void setRole(String role) { - this.role = role; - } - - /** - * Returns the role-hint of the required component. - * @return the role-hint of the required component - */ - public String getRoleHint() { - return roleHint; - } - - /** - * Sets the role-hint of the require component. - * Passing null or an empty string will match any available implementation. - * @param roleHint the required component's role-hint - */ - public void setRoleHint(String roleHint) { - this.roleHint = (roleHint != null) ? roleHint : ""; - } - - /** - * Returns the type of the field this component requirement will inject. - * @return the type of the field this component requirement will inject - */ - public String getFieldMappingType() { - return fieldMappingType; - } - - /** - * Sets the type of the field that will be populated by the required - * component. - * @param fieldType the type of the field to be populated - */ - public void setFieldMappingType(String fieldType) { - this.fieldMappingType = fieldType; - } - - /** - * Whether this component requirement is optional and needs not be satisfied - * - * @return {@code true} if the requested component may be missing, {@code false} if the component is mandatory. - * @since 1.3.0 - */ - public boolean isOptional() { - return optional; - } - - /** - * Controls whether a failure to satisfy this requirement can be tolerated by host component or whether construction - * of the host component should also fail. - * - * @param optional {@code true} if the requested component may be missing, {@code false} if the component is - * mandatory. - * @since 1.3.0 - */ - public void setOptional(boolean optional) { - this.optional = optional; - } - - public String toString() { - return "ComponentRequirement{" + "role='" - + getRole() + "'" + ", " + "roleHint='" - + getRoleHint() + "', " + "fieldName='" - + getFieldName() + "'" + "}"; - } - - /** - * Returns a human-friendly key, suitable for display. - * @return a human-friendly key - */ - public String getHumanReadableKey() { - StringBuilder key = new StringBuilder(); - - key.append("role: '").append(getRole()).append("'"); - - if (getRoleHint() != null) { - key.append(", role-hint: '").append(getRoleHint()).append("'. "); - } - - if (getFieldName() != null) { - key.append(", field name: '").append(getFieldName()).append("' "); - } - - return key.toString(); - } - - public boolean equals(Object other) { - if (other instanceof ComponentRequirement) { - String myId = role + ":" + roleHint; - - ComponentRequirement req = (ComponentRequirement) other; - String otherId = req.role + ":" + req.roleHint; - - return myId.equals(otherId); - } - - return false; - } - - public int hashCode() { - return (role + ":" + roleHint).hashCode(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java deleted file mode 100644 index 288a1f766..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.component.repository; - -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * - * @author Andrew Williams - * @since 1.0 - */ -public class ComponentRequirementList extends ComponentRequirement { - private List roleHints; - - public List getRoleHints() { - return roleHints; - } - - public void setRoleHints(List roleHints) { - this.roleHints = roleHints; - } - - public String getRoleHint() { - StringBuilder buffer = new StringBuilder(); - for (String hint : roleHints) { - if (buffer.length() > 0) { - buffer.append(","); - } - - buffer.append(hint); - } - - return buffer.toString(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java deleted file mode 100644 index 53c21455b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.List; - -/** - * Contains a set of ComponentDescriptors and the set's dependencies. - * - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public class ComponentSetDescriptor { - // This field is not currently used in Maven, or Plexus - private String id; - - /** The source location of this component source descriptor */ - private String source; - - /** Flag to indicate whether this component should be loaded in a realm/classloader of its own. */ - private boolean isolatedRealm; - - /** The component descriptors that can be found within this component set descriptor. */ - private final List> components = new ArrayList>(); - - /** The dependencies that are required by the set of components found in this component set descriptor. */ - private final List dependencies = new ArrayList(); - - /** - * Returns a list of components in this set. - * @return a list of components - */ - public List> getComponents() { - return components; - } - - /** - * Add a new ComponentDescriptor to this set. - * @param cd the ComponentDescriptor to add - */ - public void addComponentDescriptor(ComponentDescriptor cd) { - components.add(cd); - } - - /** - * Sets a List of components as this set's contents. - * @param components the List of components to set - */ - public void setComponents(List> components) { - this.components.clear(); - this.components.addAll(components); - } - - /** - * Returns a List of dependencies of this set of components. - * @return a List of dependencies of this set of components - */ - public List getDependencies() { - return dependencies; - } - - /** - * Add a depenency to this set's contents. - * @param cd the ComponentDependency to add - */ - public void addDependency(ComponentDependency cd) { - dependencies.add(cd); - } - - /** - * Sets a List of dependencies as this set's component dependencies. - * @param dependencies the List of components to set - */ - public void setDependencies(List dependencies) { - this.dependencies.clear(); - this.dependencies.addAll(dependencies); - } - - /** - * Sets that this set of components may be in an isolated classrealm. - * @param isolatedRealm true if this set of components may be in an - * isolated classrealm - */ - public void setIsolatedRealm(boolean isolatedRealm) { - this.isolatedRealm = isolatedRealm; - } - - /** - * Returns true if this set may be in an isolated classrealm. - * @return true if this set may be in an isolated classrealm - */ - public boolean isIsolatedRealm() { - return isolatedRealm; - } - - /** - * Returns the identifier of this set. - * @return the identifier of this set - */ - public String getId() { - return id; - } - - /** - * Sets the identifier of this set. - * @param id the identifier to set - */ - public void setId(String id) { - this.id = id; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - - sb.append("Component Descriptor: "); - - for (ComponentDescriptor cd : components) { - sb.append(cd.getHumanReadableKey()).append("\n"); - } - - sb.append("---"); - - return sb.toString(); - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java deleted file mode 100644 index 44e0e1106..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.codehaus.plexus.ClassRealmUtil; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CompositionResolver; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.composition.DefaultCompositionResolver; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.StringUtils; - -import static org.codehaus.plexus.component.CastUtils.isAssignableFrom; - -/** - * @author Jason van Zyl - */ -public class DefaultComponentRepository extends AbstractLogEnabled implements ComponentRepository { - private final Map>>>> index = - new LinkedHashMap>>>>(); - - private final CompositionResolver compositionResolver = new DefaultCompositionResolver(); - - public DefaultComponentRepository() {} - - // ---------------------------------------------------------------------- - // Accessors - // ---------------------------------------------------------------------- - - private Map>> getComponentDescriptors(String role) { - // verify arguments - if (role == null) { - throw new NullPointerException("role is null"); - } - - // determine realms to search - Set realms = ClassRealmUtil.getContextRealms(null); - if (realms.isEmpty()) { - realms.addAll(index.keySet()); - } - - // Get all valid component descriptors - Map>> roleHintIndex = - new LinkedHashMap>>(); - for (ClassRealm realm : realms) { - SortedMap>>> roleIndex = index.get(realm); - if (roleIndex != null) { - Map>> descriptors = roleIndex.get(role); - if (descriptors != null) { - for (Entry>> descriptor : descriptors.entrySet()) { - Set> componentDescriptors = roleHintIndex.get(descriptor.getKey()); - if (componentDescriptors == null) { - componentDescriptors = new LinkedHashSet>(); - roleHintIndex.put(descriptor.getKey(), componentDescriptors); - } - componentDescriptors.addAll(descriptor.getValue()); - } - } - } - } - return Collections.unmodifiableMap(roleHintIndex); - } - - public ComponentDescriptor getComponentDescriptor(Class type, String role, String roleHint) { - Map>> roleHintIndex = getComponentDescriptors(role); - - Collection> descriptors; - - if (StringUtils.isNotEmpty(roleHint)) { - // specific role hint -> get only those - descriptors = roleHintIndex.get(roleHint); - } else { - // missing role hint -> get all (wildcard) - Collection> allDescriptors = new ArrayList>(); - - descriptors = roleHintIndex.get(PlexusConstants.PLEXUS_DEFAULT_HINT); - if (descriptors != null) { - allDescriptors.addAll(descriptors); - } - - for (String hint : roleHintIndex.keySet()) { - descriptors = roleHintIndex.get(hint); - if (descriptors != null) { - allDescriptors.addAll(descriptors); - } - } - - descriptors = allDescriptors; - } - - if (descriptors != null) { - for (ComponentDescriptor descriptor : descriptors) { - Class implClass = descriptor.getImplementationClass(); - if (isAssignableFrom(type, implClass) || Object.class == implClass && role.equals(type.getName())) { - return (ComponentDescriptor) descriptor; - } - } - } - - return null; - } - - public Map> getComponentDescriptorMap(Class type, String role) { - Map> descriptors = new TreeMap>(); - for (Set> componentDescriptors : - getComponentDescriptors(role).values()) { - for (ComponentDescriptor descriptor : componentDescriptors) { - if (!descriptors.containsKey(descriptor.getRoleHint()) - && isAssignableFrom(type, descriptor.getImplementationClass())) { - descriptors.put(descriptor.getRoleHint(), (ComponentDescriptor) descriptor); - } - } - } - return descriptors; - } - - public List> getComponentDescriptorList(Class type, String role) { - List> descriptors = new ArrayList>(); - for (Set> componentDescriptors : - getComponentDescriptors(role).values()) { - for (ComponentDescriptor descriptor : componentDescriptors) { - if (isAssignableFrom(type, descriptor.getImplementationClass())) { - descriptors.add((ComponentDescriptor) descriptor); - } - } - } - return descriptors; - } - - @Deprecated - public ComponentDescriptor getComponentDescriptor(String role, String roleHint, ClassRealm realm) { - // find all realms from our realm to the root realm - Set realms = new HashSet(); - for (ClassRealm r = realm; r != null; r = r.getParentRealm()) { - realms.add(r); - } - - // get the component descriptors by roleHint - for (ComponentDescriptor componentDescriptor : - getComponentDescriptors(role).get(roleHint)) { - // return the first descriptor from our target realms - if (realms.contains(componentDescriptor.getRealm())) { - return componentDescriptor; - } - } - - return null; - } - - public void removeComponentRealm(ClassRealm classRealm) { - index.remove(classRealm); - } - - // ---------------------------------------------------------------------- - // Lifecylce Management - // ---------------------------------------------------------------------- - - // ---------------------------------------------------------------------- - // Component Descriptor processing. - // ---------------------------------------------------------------------- - - public void addComponentDescriptor(ComponentDescriptor componentDescriptor) - throws CycleDetectedInComponentGraphException { - ClassRealm classRealm = componentDescriptor.getRealm(); - SortedMap>>> roleIndex = index.get(classRealm); - if (roleIndex == null) { - roleIndex = new TreeMap>>>(); - index.put(classRealm, roleIndex); - } - - String role = componentDescriptor.getRole(); - Map>> roleHintIndex = roleIndex.get(role); - if (roleHintIndex == null) { - roleHintIndex = new LinkedHashMap>>(); - roleIndex.put(role, roleHintIndex); - } - String roleHint = componentDescriptor.getRoleHint(); - Set> componentDescriptors = roleHintIndex.get(roleHint); - if (componentDescriptors == null) { - componentDescriptors = new LinkedHashSet>(); - roleHintIndex.put(roleHint, componentDescriptors); - } - componentDescriptors.add(componentDescriptor); - - compositionResolver.addComponentDescriptor(componentDescriptor); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java deleted file mode 100644 index ea0139e46..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentConfigurationException extends Exception { - private static final long serialVersionUID = -921278352685045303L; - - /** - * Construct a new ComponentConfigurationException instance. - * @param message exception message - */ - public ComponentConfigurationException(String message) { - super(message); - } - - /** - * Construct a new ComponentConfigurationException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentConfigurationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java deleted file mode 100644 index 9e6110ca0..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentDescriptorUnmarshallingException extends Exception { - private static final long serialVersionUID = 6991583130117543536L; - - /** - * Construct a new ComponentDescriptorUnmarshallingException instance. - * @param message exception message - */ - public ComponentDescriptorUnmarshallingException(String message) { - super(message); - } - - /** - * Construct a new ComponentDescriptorUnmarshallingException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentDescriptorUnmarshallingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java deleted file mode 100644 index efa578293..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - * - */ -public class ComponentImplementationNotFoundException extends Exception { - private static final long serialVersionUID = -9171668987729438489L; - - /** - * Construct a new ComponentImplementationNotFoundException instance. - * @param message exception message - */ - public ComponentImplementationNotFoundException(String message) { - super(message); - } - - /** - * Construct a new ComponentImplementationNotFoundException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentImplementationNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java deleted file mode 100644 index b030be9c9..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentLifecycleException extends Exception { - private static final long serialVersionUID = 146489359157036908L; - - /** - * Construct a new ComponentLifecycleException instance. - * @param message exception message - */ - public ComponentLifecycleException(String message) { - super(message); - } - - /** - * Construct a new ComponentLifecycleException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentLifecycleException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java deleted file mode 100644 index 0cd7b2ece..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * The exception which is thrown by a component repository when - * the requested component cannot be found. - * - * @author Jason van Zyl - */ -public class ComponentLookupException extends Exception { - private String LS = System.getProperty("line.separator"); - - private String role; - - private String roleHint; - - private ClassRealm realm; - - public ComponentLookupException(String message, String role, String roleHint) { - super(message); - - this.role = role; - - this.roleHint = roleHint; - } - - public ComponentLookupException(String message, String role, String roleHint, Throwable cause) { - super(message, cause); - - this.role = role; - - this.roleHint = roleHint; - } - - public ComponentLookupException(String message, String role, String roleHint, ClassRealm realm) { - super(message); - - this.role = role; - - this.roleHint = roleHint; - - this.realm = realm; - } - - public ComponentLookupException(String message, String role, String roleHint, ClassRealm realm, Throwable cause) { - super(message, cause); - - this.role = role; - - this.roleHint = roleHint; - - this.realm = realm; - } - - public String getMessage() { - StringBuilder sb = new StringBuilder() - .append(super.getMessage()) - .append(LS) - .append(" role: ") - .append(role) - .append(LS) - .append(" roleHint: ") - .append(roleHint) - .append(LS) - .append("classRealm: "); - - if (realm != null) { - sb.append(realm.getId()).append(LS); - ByteArrayOutputStream os = new ByteArrayOutputStream(1024); - PrintStream ps = new PrintStream(os); - realm.display(ps); - sb.append(os.toString()); - } else { - sb.append("none specified"); - } - - return sb.toString(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java deleted file mode 100644 index f544921ab..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * The exception which is thrown by a component repository when - * the requested component cannot be found. - * - * @author Kristian Rosenvold - */ -public class ComponentLookupRuntimeException extends RuntimeException { - public ComponentLookupRuntimeException(ComponentLookupException cause) { - super(cause); - } - - public String getMessage() { - return getCause().getMessage(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java deleted file mode 100644 index a0bbda0a7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentManagerImplementationNotFoundException extends Exception { - private static final long serialVersionUID = 2365017114180373632L; - - /** - * Construct a new ComponentManagerImplementationNotFoundException instance. - * @param message exception message - */ - public ComponentManagerImplementationNotFoundException(String message) { - super(message); - } - - /** - * Construct a new ComponentManagerImplementationNotFoundException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentManagerImplementationNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java deleted file mode 100644 index 529af0c9c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentProfileException extends Exception { - private static final long serialVersionUID = -4099483467183306853L; - - /** - * Construct a new ComponentProfileException instance. - * @param message exception message - */ - public ComponentProfileException(String message) { - super(message); - } - - /** - * Construct a new ComponentProfileException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentProfileException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java deleted file mode 100644 index 3074821c7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.repository.exception; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when the class(es) required for a component - * implementation are not available. - * - * @author Jason van Zyl - */ -public class ComponentRepositoryException extends Exception { - private static final long serialVersionUID = 3698017788731736736L; - - /** - * Construct a new ComponentRepositoryException instance. - * @param message exception message - */ - public ComponentRepositoryException(String message) { - super(message); - } - - /** - * Construct a new ComponentRepositoryException instance. - * @param message exception message - * @param cause causing exception to chain - */ - public ComponentRepositoryException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java deleted file mode 100644 index c7263ea87..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java +++ /dev/null @@ -1,258 +0,0 @@ -package org.codehaus.plexus.component.repository.io; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.IOException; -import java.io.PrintStream; -import java.io.Reader; -import java.io.StringReader; -import java.util.LinkedList; -import java.util.List; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDependency; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRequirement; -import org.codehaus.plexus.component.repository.ComponentRequirementList; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.configuration.io.XmlPlexusConfigurationReader; - -/** - * @author Jason van Zyl - */ -public class PlexusTools { - public static PlexusConfiguration buildConfiguration(String resourceName, Reader configuration) - throws PlexusConfigurationException { - try { - XmlPlexusConfigurationReader reader = new XmlPlexusConfigurationReader(); - - PlexusConfiguration result = reader.read(configuration); - - return result; - } catch (PlexusConfigurationException e) { - throw new PlexusConfigurationException( - "PlexusConfigurationException building configuration from: " + resourceName, e); - } catch (IOException e) { - throw new PlexusConfigurationException("IO error building configuration from: " + resourceName, e); - } - } - - public static PlexusConfiguration buildConfiguration(String configuration) throws PlexusConfigurationException { - return buildConfiguration("", new StringReader(configuration)); - } - - public static ComponentDescriptor buildComponentDescriptor(String configuration, ClassRealm realm) - throws PlexusConfigurationException { - return buildComponentDescriptor(buildConfiguration(configuration), realm); - } - - public static ComponentDescriptor buildComponentDescriptor(PlexusConfiguration configuration) - throws PlexusConfigurationException { - return buildComponentDescriptorImpl(configuration, null); - } - - public static ComponentDescriptor buildComponentDescriptor(PlexusConfiguration configuration, ClassRealm realm) - throws PlexusConfigurationException { - if (realm == null) { - throw new NullPointerException("realm is null"); - } - - return buildComponentDescriptorImpl(configuration, realm); - } - - private static ComponentDescriptor buildComponentDescriptorImpl( - PlexusConfiguration configuration, ClassRealm realm) throws PlexusConfigurationException { - String implementation = configuration.getChild("implementation").getValue(); - if (implementation == null) { - throw new PlexusConfigurationException("implementation is null"); - } - - ComponentDescriptor cd; - try { - if (realm != null) { - Class implementationClass = realm.loadClass(implementation); - cd = new ComponentDescriptor(implementationClass, realm); - } else { - cd = new ComponentDescriptor(); - cd.setImplementation(implementation); - } - } catch (Throwable e) { - throw new PlexusConfigurationException( - "Can not load implementation class " + implementation + " from realm " + realm, e); - } - - cd.setRole(configuration.getChild("role").getValue()); - - cd.setRoleHint(configuration.getChild("role-hint").getValue()); - - cd.setVersion(configuration.getChild("version").getValue()); - - cd.setComponentType(configuration.getChild("component-type").getValue()); - - cd.setInstantiationStrategy( - configuration.getChild("instantiation-strategy").getValue()); - - cd.setLifecycleHandler(configuration.getChild("lifecycle-handler").getValue()); - - cd.setComponentProfile(configuration.getChild("component-profile").getValue()); - - cd.setComponentComposer(configuration.getChild("component-composer").getValue()); - - cd.setComponentConfigurator( - configuration.getChild("component-configurator").getValue()); - - cd.setComponentFactory(configuration.getChild("component-factory").getValue()); - - cd.setDescription(configuration.getChild("description").getValue()); - - cd.setAlias(configuration.getChild("alias").getValue()); - - String s = configuration.getChild("isolated-realm").getValue(); - - if (s != null) { - cd.setIsolatedRealm(s.equals("true") ? true : false); - } - - // ---------------------------------------------------------------------- - // Here we want to look for directives for inlining external - // configurations. we probably want to take them from files or URLs. - // ---------------------------------------------------------------------- - - cd.setConfiguration(configuration.getChild("configuration")); - - // ---------------------------------------------------------------------- - // Requirements - // ---------------------------------------------------------------------- - - PlexusConfiguration[] requirements = - configuration.getChild("requirements").getChildren("requirement"); - - for (PlexusConfiguration requirement : requirements) { - ComponentRequirement cr; - - PlexusConfiguration[] hints = requirement.getChild("role-hints").getChildren("role-hint"); - if (hints != null && hints.length > 0) { - cr = new ComponentRequirementList(); - - List hintList = new LinkedList(); - for (PlexusConfiguration hint : hints) { - hintList.add(hint.getValue()); - } - - ((ComponentRequirementList) cr).setRoleHints(hintList); - } else { - cr = new ComponentRequirement(); - - cr.setRoleHint(requirement.getChild("role-hint").getValue()); - } - - cr.setRole(requirement.getChild("role").getValue()); - - cr.setOptional(Boolean.parseBoolean(requirement.getChild("optional").getValue())); - - cr.setFieldName(requirement.getChild("field-name").getValue()); - - cd.addRequirement(cr); - } - - return cd; - } - - public static ComponentSetDescriptor buildComponentSet(PlexusConfiguration c) throws PlexusConfigurationException { - return buildComponentSet(c, null); - } - - public static ComponentSetDescriptor buildComponentSet(PlexusConfiguration c, ClassRealm realm) - throws PlexusConfigurationException { - ComponentSetDescriptor csd = new ComponentSetDescriptor(); - - // ---------------------------------------------------------------------- - // Components - // ---------------------------------------------------------------------- - - PlexusConfiguration[] components = c.getChild("components").getChildren("component"); - - for (PlexusConfiguration component : components) { - csd.addComponentDescriptor(buildComponentDescriptorImpl(component, realm)); - } - - // ---------------------------------------------------------------------- - // Dependencies - // ---------------------------------------------------------------------- - - PlexusConfiguration[] dependencies = c.getChild("dependencies").getChildren("dependency"); - - for (PlexusConfiguration d : dependencies) { - ComponentDependency cd = new ComponentDependency(); - - cd.setArtifactId(d.getChild("artifact-id").getValue()); - - cd.setGroupId(d.getChild("group-id").getValue()); - - String type = d.getChild("type").getValue(); - if (type != null) { - cd.setType(type); - } - - cd.setVersion(d.getChild("version").getValue()); - - csd.addDependency(cd); - } - - return csd; - } - - public static void writeConfiguration(PrintStream out, PlexusConfiguration configuration) - throws PlexusConfigurationException { - writeConfiguration(out, configuration, ""); - } - - private static void writeConfiguration(PrintStream out, PlexusConfiguration configuration, String indent) - throws PlexusConfigurationException { - out.print(indent + "<" + configuration.getName()); - String[] atts = configuration.getAttributeNames(); - - if (atts.length > 0) { - for (String att : atts) { - out.print("\n" + indent + " " + att + "='" + configuration.getAttribute(att) + "'"); - } - } - - PlexusConfiguration[] pc = configuration.getChildren(); - - if ((configuration.getValue() != null && configuration.getValue().trim().length() > 0) || pc.length > 0) { - out.print(">" - + (configuration.getValue() == null - ? "" - : configuration.getValue().trim())); - - if (pc.length > 0) { - out.println(); - for (PlexusConfiguration aPc : pc) { - writeConfiguration(out, aPc, indent + " "); - } - out.print(indent); - } - - out.println(""); - } else { - out.println("/>"); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java deleted file mode 100644 index bbad08ac7..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - */ -public class DefaultPlexusConfiguration implements PlexusConfiguration { - - private String name; - - private String value; - - private Map attributes; - - private Map> childMap; - - private List childList; - - protected DefaultPlexusConfiguration() { - this("configuration"); - } - - protected DefaultPlexusConfiguration(String name) { - this(name, null); - } - - protected DefaultPlexusConfiguration(String name, String value) { - super(); - - this.name = name; - - this.value = value; - - this.attributes = new LinkedHashMap(); - - this.childMap = new LinkedHashMap>(); - - this.childList = new ArrayList(); - } - - // ---------------------------------------------------------------------- - // Name handling - // ---------------------------------------------------------------------- - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - // ---------------------------------------------------------------------- - // Value handling - // ---------------------------------------------------------------------- - - public String getValue() { - return value; - } - - public String getValue(String defaultValue) { - String value = getValue(); - - if (value == null) { - value = defaultValue; - } - - return value; - } - - public void setValue(String val) { - value = val; - } - - public PlexusConfiguration setValueAndGetSelf(String val) { - setValue(val); - - return this; - } - - // ---------------------------------------------------------------------- - // Attribute handling - // ---------------------------------------------------------------------- - public void setAttribute(String name, String value) { - attributes.put(name, value); - } - - public String getAttribute(String name) { - return attributes.get(name); - } - - public String getAttribute(String name, String defaultValue) { - String value = getAttribute(name); - - if (value == null) { - value = defaultValue; - } - - return value; - } - - public String[] getAttributeNames() { - return attributes.keySet().toArray(new String[attributes.size()]); - } - - // ---------------------------------------------------------------------- - // Child handling - // ---------------------------------------------------------------------- - - public PlexusConfiguration getChild(String name) { - return getChild(name, true); - } - - public PlexusConfiguration getChild(int i) { - return childList.get(i); - } - - public PlexusConfiguration getChild(String name, boolean createChild) { - List childs = childMap.get(name); - - boolean noneFound = (childs == null || childs.size() == 0); - - if (noneFound && createChild) { - addChild(name); - - return getChild(name, false); - } else if (noneFound && !createChild) { - return null; - } else { - return childs.get(0); - } - } - - public PlexusConfiguration[] getChildren() { - return childList.toArray(new PlexusConfiguration[childList.size()]); - } - - public PlexusConfiguration[] getChildren(String name) { - List childs = new ArrayList(); - - List childList = childMap.get(name); - - if (childList != null) { - childs.addAll(childList); - } - - return childs.toArray(new PlexusConfiguration[childs.size()]); - } - - public void addChild(PlexusConfiguration child) { - childList.add(child); - - List children = childMap.get(child.getName()); - if (children == null) { - childMap.put(child.getName(), children = new ArrayList()); - } - - children.add(child); - } - - public PlexusConfiguration addChild(String name) { - // we are using reflection to try to create same class childs as parent is, - // since many Maven and Maven plugins stuff casts the incoming result of this call - // to the evil XmlPlexusConfiguration - PlexusConfiguration child = null; - - try { - child = getClass().newInstance(); - - child.setName(name); - } catch (Exception e) { - // we have a PlexusConfiguration that has no constructor(name) - child = new DefaultPlexusConfiguration(name); - } - - addChild(child); - - return this; - } - - public PlexusConfiguration addChild(String name, String value) { - PlexusConfiguration child = new DefaultPlexusConfiguration(name, value); - - addChild(child); - - return this; - } - - public int getChildCount() { - return this.childList.size(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusComponentDescriptorMerger.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusComponentDescriptorMerger.java deleted file mode 100644 index 286ee31d8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusComponentDescriptorMerger.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.codehaus.plexus.configuration; - -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRequirement; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * - * @author Kenney Westerhof - * - */ -public class PlexusComponentDescriptorMerger { - /** - * Merges override and target, where target is updated with override. - * @param override {@link ComponentDescriptor} - * @param target {@link ComponentDescriptor}. - */ - public static void merge(ComponentDescriptor override, ComponentDescriptor target) { - if (override.getImplementation() != null) { - target.setImplementation(override.getImplementation()); - } - - mergeRequirements(override, target); - - mergeConfiguration(override, target); - - // TODO: other getters/setters. - } - - private static void mergeConfiguration(ComponentDescriptor override, ComponentDescriptor target) { - // try to parse the override dom. If this fails, do not update anything and keep - // the original target configuration. - Xpp3Dom overrideDom; - - try { - - overrideDom = Xpp3DomBuilder.build( - new StringReader(override.getConfiguration().toString())); - } catch (XmlPullParserException e1) { - return; - } catch (IOException e1) { - return; - } - - // try to parse the target dom. if this fails, replace it with the override configuration, - // dom, otherwise merge it. - - Xpp3Dom targetDom = null; - - if (target.getConfiguration() != null) { - try { - targetDom = Xpp3DomBuilder.build( - new StringReader(target.getConfiguration().toString())); - } catch (XmlPullParserException e1) { - } catch (IOException e1) { - } - } - - if (targetDom != null) { - Xpp3Dom.mergeXpp3Dom(overrideDom, targetDom); - } else { - targetDom = overrideDom; - } - - target.setConfiguration(new XmlPlexusConfiguration(targetDom)); - } - - private static void mergeRequirements(ComponentDescriptor override, ComponentDescriptor target) { - List toAdd = new ArrayList(); - List toRemove = new ArrayList(); - - for (ComponentRequirement sourceReq : override.getRequirements()) { - for (ComponentRequirement targetReq : target.getRequirements()) { - // if a fieldName is specified, only override target requirements - // that also have a fieldname. - if (sourceReq.getFieldName() != null) { - if (sourceReq.getFieldName().equals(targetReq.getFieldName())) { - toRemove.add(targetReq); - toAdd.add(sourceReq); - break; - } - } else if (targetReq.getFieldName() == null) { - // no fieldnames specified - just check for the role; hints may be - // overriden too. - - if (sourceReq.getRole().equals(targetReq.getRole())) { - toRemove.add(targetReq); - toAdd.add(sourceReq); - } - } - } - } - - target.removeRequirements(toRemove); - target.addRequirements(toAdd); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfiguration.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfiguration.java deleted file mode 100644 index d68924fda..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfiguration.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * A configuration data hierarchy for configuring aspects of plexus. For - * example, to populate a ComponentDescriptor. Implementation of - * PlexusConfiguration may be populated by any means, for example, by XML file. - */ -public interface PlexusConfiguration { - // ---------------------------------------------------------------------- - // Name handling - // ---------------------------------------------------------------------- - - /** - * Returns the name of this configuration. - * @return the name of this configuration - */ - String getName(); - - /** - * Sets the name of this configuration. - * @param name The name of the configuration. - */ - void setName(String name); - - // ---------------------------------------------------------------------- - // Value handling - // ---------------------------------------------------------------------- - - /** - * Returns the value of this configuration. - * @return the value of this configuration - * @throws PlexusConfigurationException in case of an error. - */ - String getValue() throws PlexusConfigurationException; - - /** - * Returns the value of this configuration, or default if one cannot be - * found. - * @param defaultValue value to return if none is found - * @return the value of this configuration - */ - String getValue(String defaultValue); - - /** - * Set the value of a configuration element. - * @param value The value of the configuration element. - */ - void setValue(String value); - - /** - * Set the value of a configuration element and return the PlexusConfiguration object - * so that further operations can be carried out. - * @param value set the value. - * @return {@link PlexusConfiguration} - */ - PlexusConfiguration setValueAndGetSelf(String value); - - // ---------------------------------------------------------------------- - // Attribute handling - // ---------------------------------------------------------------------- - - /** - * Sets an attribute on this configuration. - * @param name name of the attribute - * @param value the value of the attribute. - */ - void setAttribute(String name, String value); - - /** - * Returns an array of attribute names. - * @return an array of attribute names - */ - String[] getAttributeNames(); - - /** - * Returns the value of the named attribute. - * @param paramName The name of the attribute. - * @return the value of the named attribute - * @throws PlexusConfigurationException in case of an error. - */ - String getAttribute(String paramName) throws PlexusConfigurationException; - - /** - * Returns the value of the named attribute, or default if one cannot be - * found. - * @param name The name of the attribute. - * @param defaultValue value to return if none is found - * @return the value of the named attribute - */ - String getAttribute(String name, String defaultValue); - - // ---------------------------------------------------------------------- - // Child handling - // ---------------------------------------------------------------------- - - /** - * Returns the child configuration of the given name. - * @param child the name of the child to return - * @return the child configuration of the given name - */ - PlexusConfiguration getChild(String child); - - /** - * Returns the child configuration at the given location. - * @param i the position of the child under this configuration - * @return the child configuration at the given location - */ - PlexusConfiguration getChild(int i); - - /** - * Returns the child configuration of the given name. - * @param child the name of the child to return - * @param createChild true if a new child should be create, if none found - * @return the child configuration of the given name, or new child if - * created - */ - PlexusConfiguration getChild(String child, boolean createChild); - - /** - * Returns an array of all child configurations. - * @return an array of all child configurations - */ - PlexusConfiguration[] getChildren(); - - /** - * Returns an array of all child configurations with the given name. - * @param name the name of the children configurations to return - * @return an array of all child configurations with the given name - */ - PlexusConfiguration[] getChildren(String name); - - /** - * Adds a configuration under this configuration, which acts as - * a parent. - * @param configuration the child configuration to add - */ - void addChild(PlexusConfiguration configuration); - - /** - * Add a child element with a given name and return the newly created element. - * @param name The name of the element. - * @return {@link PlexusConfiguration} - */ - PlexusConfiguration addChild(String name); - - /** - * Add a child element with a given name, and given value and return the - * newly created element. - * @param name The name of the child element. - * @param value The value of the child element. - * @return {@link PlexusConfiguration} - */ - PlexusConfiguration addChild(String name, String value); - - /** - * Returns the number of directly children under this configuration. - * @return the number of directly children under this configuration. - */ - int getChildCount(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationException.java deleted file mode 100644 index 69e84fd93..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationException.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception that is thrown when an expected configuration value encounters - * problems loading correctly. - */ -public class PlexusConfigurationException extends Exception { - private static final long serialVersionUID = 7559886640184983689L; - - /** - * Construct a new PlexusConfigurationException instance. - * @param message exception message - */ - public PlexusConfigurationException(String message) { - this(message, null); - } - - /** - * Construct a new PlexusConfigurationException instance. - * @param message exception message - * @param throwable causing exception to chain - */ - public PlexusConfigurationException(String message, Throwable throwable) { - super(message, throwable); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java deleted file mode 100644 index ab782da05..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java +++ /dev/null @@ -1,309 +0,0 @@ -package org.codehaus.plexus.configuration; - -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * TODO: This merger explicity uses the XML implementation of the plexus configuration but - * it must work for configurations coming from any source. - */ -public class PlexusConfigurationMerger { - // -----------------------------------+----------------------------------------------------------------- - // E L E M E N T | - // -----------------------------------+----------------------------------------------------------------- - // load-on-start | user - // -----------------------------------+----------------------------------------------------------------- - // system-properties | user - // -----------------------------------+----------------------------------------------------------------- - // configurations-directory | user - // -----------------------------------+----------------------------------------------------------------- - // logging | user wins - // -----------------------------------+----------------------------------------------------------------- - // component-repository | user wins - // -----------------------------------+----------------------------------------------------------------- - // resources | user wins, but system resources show through - // -----------------------------------+----------------------------------------------------------------- - // component-manager-manager | user wins, but system resources show through - // -----------------------------------+----------------------------------------------------------------- - // component-discoverer-manager | user wins, but system resources show through - // -----------------------------------+----------------------------------------------------------------- - // component-factory-manager | user wins, but system resources show through - // -----------------------------------+----------------------------------------------------------------- - // lifecycle-handler-manager | user wins, but system lifecycles show through - // -----------------------------------+----------------------------------------------------------------- - // component-composer-manager | user wins, but system lifecycles show through - // -----------------------------------+----------------------------------------------------------------- - // components | user - // -----------------------------------+----------------------------------------------------------------- - - public static PlexusConfiguration merge(PlexusConfiguration user, PlexusConfiguration system) { - PlexusConfiguration mergedConfiguration = new XmlPlexusConfiguration("plexus"); - - // ---------------------------------------------------------------------- - // Load on start - // ---------------------------------------------------------------------- - - PlexusConfiguration loadOnStart = user.getChild("load-on-start"); - - if (loadOnStart.getChildCount() != 0) { - mergedConfiguration.addChild(loadOnStart); - } - - // ---------------------------------------------------------------------- - // System properties - // ---------------------------------------------------------------------- - - PlexusConfiguration systemProperties = user.getChild("system-properties"); - - if (systemProperties.getChildCount() != 0) { - mergedConfiguration.addChild(systemProperties); - } - - // ---------------------------------------------------------------------- - // Configurations directory - // ---------------------------------------------------------------------- - - PlexusConfiguration[] configurationsDirectories = user.getChildren("configurations-directory"); - - if (configurationsDirectories.length != 0) { - for (PlexusConfiguration configurationsDirectory : configurationsDirectories) { - mergedConfiguration.addChild(configurationsDirectory); - } - } - - // ---------------------------------------------------------------------- - // Logging - // ---------------------------------------------------------------------- - - PlexusConfiguration logging = user.getChild("logging"); - - if (logging.getChildCount() != 0) { - mergedConfiguration.addChild(logging); - } else { - mergedConfiguration.addChild(system.getChild("logging")); - } - - // ---------------------------------------------------------------------- - // Container initialization phases - // ---------------------------------------------------------------------- - - mergedConfiguration.addChild(system.getChild("container-initialization")); - - mergedConfiguration.addChild(system.getChild("component-lookup-manager")); - - // ---------------------------------------------------------------------- - // Component repository - // ---------------------------------------------------------------------- - - PlexusConfiguration componentRepository = user.getChild("component-repository"); - - if (componentRepository.getChildCount() != 0) { - mergedConfiguration.addChild(componentRepository); - } else { - mergedConfiguration.addChild(system.getChild("component-repository")); - } - - // ---------------------------------------------------------------------- - // Resources - // ---------------------------------------------------------------------- - - copyResources(system, mergedConfiguration); - - copyResources(user, mergedConfiguration); - - // ---------------------------------------------------------------------- - // Component manager manager - // ---------------------------------------------------------------------- - - PlexusConfiguration componentManagerManager = user.getChild("component-manager-manager"); - - if (componentManagerManager.getChildCount() != 0) { - mergedConfiguration.addChild(componentManagerManager); - - copyComponentManagers(system.getChild("component-manager-manager"), componentManagerManager); - } else { - mergedConfiguration.addChild(system.getChild("component-manager-manager")); - } - - // ---------------------------------------------------------------------- - // Component discoverer manager - // ---------------------------------------------------------------------- - - PlexusConfiguration componentDiscovererManager = user.getChild("component-discoverer-manager"); - - if (componentDiscovererManager.getChildCount() != 0) { - mergedConfiguration.addChild(componentDiscovererManager); - - copyComponentDiscoverers(system.getChild("component-discoverer-manager"), componentDiscovererManager); - } else { - mergedConfiguration.addChild(system.getChild("component-discoverer-manager")); - } - - // ---------------------------------------------------------------------- - // Component factory manager - // ---------------------------------------------------------------------- - - PlexusConfiguration componentFactoryManager = user.getChild("component-factory-manager"); - - if (componentFactoryManager.getChildCount() != 0) { - mergedConfiguration.addChild(componentFactoryManager); - - copyComponentFactories(system.getChild("component-factory-manager"), componentFactoryManager); - } else { - mergedConfiguration.addChild(system.getChild("component-factory-manager")); - } - - // ---------------------------------------------------------------------- - // Lifecycle handler managers - // ---------------------------------------------------------------------- - - PlexusConfiguration lifecycleHandlerManager = user.getChild("lifecycle-handler-manager"); - - if (lifecycleHandlerManager.getChildCount() != 0) { - mergedConfiguration.addChild(lifecycleHandlerManager); - - copyLifecycles(system.getChild("lifecycle-handler-manager"), lifecycleHandlerManager); - } else { - mergedConfiguration.addChild(system.getChild("lifecycle-handler-manager")); - } - - // ---------------------------------------------------------------------- - // Component factory manager - // ---------------------------------------------------------------------- - - PlexusConfiguration componentComposerManager = user.getChild("component-composer-manager"); - - if (componentComposerManager.getChildCount() != 0) { - mergedConfiguration.addChild(componentComposerManager); - - copyComponentComposers(system.getChild("component-composer-manager"), componentComposerManager); - } else { - mergedConfiguration.addChild(system.getChild("component-composer-manager")); - } - - // ---------------------------------------------------------------------- - // Components - // ---------------------------------------------------------------------- - // We grab the system components first and then add the user defined - // components so that user defined components will win. When component - // descriptors are processed the last definition wins because the component - // descriptors are stored in a Map in the component repository. - // ---------------------------------------------------------------------- - - PlexusConfiguration components = system.getChild("components"); - - mergedConfiguration.addChild(components); - - copyComponents(user.getChild("components"), components); - - return mergedConfiguration; - } - - private static void copyResources(PlexusConfiguration source, PlexusConfiguration destination) { - PlexusConfiguration handlers[] = source.getChild("resources").getChildren(); - - PlexusConfiguration dest = destination.getChild("resources"); - - for (PlexusConfiguration handler : handlers) { - dest.addChild(handler); - } - } - - private static void copyComponentManagers(PlexusConfiguration source, PlexusConfiguration destination) { - try { - PlexusConfiguration id = destination.getChild("default-component-manager-id"); - - String sid = source.getChild("default-component-manager-id").getValue(); - - if (id.getValue() == null) { - id.setValue(sid); - } - } catch (PlexusConfigurationException e) { - // do nothing - } - - PlexusConfiguration handlers[] = source.getChild("component-managers").getChildren("component-manager"); - - PlexusConfiguration dest = destination.getChild("component-managers"); - - for (PlexusConfiguration handler : handlers) { - dest.addChild(handler); - } - } - - private static void copyComponentDiscoverers(PlexusConfiguration source, PlexusConfiguration destination) { - PlexusConfiguration handlers[] = - source.getChild("component-discoverers").getChildren("component-discoverer"); - - PlexusConfiguration dest = destination.getChild("component-discoverers"); - - for (PlexusConfiguration handler : handlers) { - dest.addChild(handler); - } - } - - private static void copyComponentFactories(PlexusConfiguration source, PlexusConfiguration destination) { - PlexusConfiguration handlers[] = source.getChild("component-factories").getChildren("component-factory"); - - PlexusConfiguration dest = destination.getChild("component-factories"); - - for (PlexusConfiguration handler : handlers) { - dest.addChild(handler); - } - } - - private static void copyComponentComposers(PlexusConfiguration source, PlexusConfiguration destination) { - try { - PlexusConfiguration id = destination.getChild("default-component-composer-id"); - - String sid = source.getChild("default-component-composer-id").getValue(); - - if (id.getValue() == null) { - id.setValue(sid); - } - } catch (PlexusConfigurationException e) { - // do nothing - } - - PlexusConfiguration composers[] = source.getChild("component-composers").getChildren("component-composer"); - - PlexusConfiguration dest = destination.getChild("component-composers"); - - for (PlexusConfiguration composer : composers) { - dest.addChild(composer); - } - } - - private static void copyLifecycles(PlexusConfiguration source, PlexusConfiguration destination) { - PlexusConfiguration handlers[] = source.getChild("lifecycle-handlers").getChildren("lifecycle-handler"); - - PlexusConfiguration dest = destination.getChild("lifecycle-handlers"); - - for (PlexusConfiguration handler : handlers) { - dest.addChild(handler); - } - } - - private static void copyComponents(PlexusConfiguration source, PlexusConfiguration destination) { - PlexusConfiguration components[] = source.getChildren("component"); - - for (PlexusConfiguration component : components) { - destination.addChild(component); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationResourceException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationResourceException.java deleted file mode 100644 index 3573560ab..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationResourceException.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class PlexusConfigurationResourceException extends Exception { - public PlexusConfigurationResourceException(String message) { - super(message); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationReader.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationReader.java deleted file mode 100644 index 8a93b239d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationReader.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; - -public interface PlexusConfigurationReader { - public PlexusConfiguration read(Reader reader) throws IOException, PlexusConfigurationException; - - public PlexusConfiguration read(InputStream inputStream) throws IOException, PlexusConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationWriter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationWriter.java deleted file mode 100644 index 1eb1df0ae..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/PlexusConfigurationWriter.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public interface PlexusConfigurationWriter { - void write(Writer writer, PlexusConfiguration configuration) throws IOException; - - void write(OutputStream outputStream, PlexusConfiguration configuration) throws IOException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReader.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReader.java deleted file mode 100644 index dd19a99b8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReader.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; - -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -public class XmlPlexusConfigurationReader implements PlexusConfigurationReader { - - public PlexusConfiguration read(InputStream inputStream) throws IOException, PlexusConfigurationException { - return read(new InputStreamReader(inputStream)); - } - - public PlexusConfiguration read(Reader reader) throws IOException, PlexusConfigurationException { - try { - Xpp3Dom dom = Xpp3DomBuilder.build(reader); - - return new XmlPlexusConfiguration(dom); - } catch (XmlPullParserException e) { - throw new PlexusConfigurationException( - "Failed to parse configuration resource!\nError was: \'" + e.getLocalizedMessage() + "\'", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java deleted file mode 100644 index 7221981bf..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; - -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public class XmlPlexusConfigurationWriter implements PlexusConfigurationWriter { - - public void write(OutputStream outputStream, PlexusConfiguration configuration) throws IOException { - write(new OutputStreamWriter(outputStream), configuration); - } - - public void write(Writer writer, PlexusConfiguration configuration) throws IOException { - int depth = 0; - - display(configuration, writer, depth); - } - - private void display(PlexusConfiguration c, Writer w, int depth) throws IOException { - int count = c.getChildCount(); - - if (count == 0) { - displayTag(c, w, depth); - } else { - indent(depth, w); - w.write('<'); - w.write(c.getName()); - - attributes(c, w); - - w.write('>'); - w.write('\n'); - - for (int i = 0; i < count; i++) { - PlexusConfiguration child = c.getChild(i); - - display(child, w, depth + 1); - } - - indent(depth, w); - w.write('<'); - w.write('/'); - w.write(c.getName()); - w.write('>'); - w.write('\n'); - } - } - - private void displayTag(PlexusConfiguration c, Writer w, int depth) throws IOException { - String value = c.getValue(null); - - if (value != null) { - indent(depth, w); - w.write('<'); - w.write(c.getName()); - - attributes(c, w); - - w.write('>'); - w.write(c.getValue(null)); - w.write('<'); - w.write('/'); - w.write(c.getName()); - w.write('>'); - w.write('\n'); - } else { - indent(depth, w); - w.write('<'); - w.write(c.getName()); - - attributes(c, w); - - w.write('/'); - w.write('>'); - w.write("\n"); - } - } - - private void attributes(PlexusConfiguration c, Writer w) throws IOException { - String[] names = c.getAttributeNames(); - - for (String name : names) { - w.write(' '); - w.write(name); - w.write('='); - w.write('"'); - w.write(c.getAttribute(name, null)); - w.write('"'); - } - } - - private void indent(int depth, Writer w) throws IOException { - for (int i = 0; i < depth; i++) { - w.write(' '); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java deleted file mode 100644 index 09fc5934b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import java.util.List; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * A configuration source that delegates to any number of underlying configuration sources. If you are an application - * author and want to create a custom source of configuration for the components in your application then you would most - * likely want to create a chained configuration source where you can decide the order of processing, but still have the - * container perform its default behavior. - * - * @author Jason van Zyl - */ -public class ChainedConfigurationSource implements ConfigurationSource { - private List configurationSources; - - public ChainedConfigurationSource(List configurationSources) { - this.configurationSources = configurationSources; - } - - public PlexusConfiguration getConfiguration(ComponentDescriptor componentDescriptor) { - for (Object configurationSource1 : configurationSources) { - ConfigurationSource configurationSource = (ConfigurationSource) configurationSource1; - - PlexusConfiguration configuration = configurationSource.getConfiguration(componentDescriptor); - - if (configuration != null) { - return configuration; - } - } - - return null; - } - - public List getConfigurationSources() { - return configurationSources; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ConfigurationSource.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ConfigurationSource.java deleted file mode 100644 index 25ec1f765..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ConfigurationSource.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * A source for component configurations which may reside outside the configuration within a component descriptor. A - * common usecase for this is to create a unified configuration for a set of components. For an application it is more - * convenient to present the user with a single configuration, instead of making users work directly with a Plexus - * configuration file which exposes component details including implementation, and wiring information. - * - * @author Jason van Zyl - */ -public interface ConfigurationSource { - String ROLE = ConfigurationSource.class.getName(); - - PlexusConfiguration getConfiguration(ComponentDescriptor componentDescriptor); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ContainerConfigurationSource.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ContainerConfigurationSource.java deleted file mode 100644 index 63ae94f1f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ContainerConfigurationSource.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** @author Jason van Zyl */ -public class ContainerConfigurationSource implements ConfigurationSource { - public PlexusConfiguration getConfiguration(ComponentDescriptor componentDescriptor) { - if (componentDescriptor.hasConfiguration()) { - return componentDescriptor.getConfiguration(); - } - - return null; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java b/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java deleted file mode 100644 index 05825fcac..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.codehaus.plexus.configuration.xml; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.IOException; -import java.io.StringWriter; - -import org.codehaus.plexus.configuration.DefaultPlexusConfiguration; -import org.codehaus.plexus.configuration.io.XmlPlexusConfigurationWriter; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - */ -public class XmlPlexusConfiguration extends DefaultPlexusConfiguration { - public XmlPlexusConfiguration() { - super(); - } - - public XmlPlexusConfiguration(String name) { - super(name); - } - - public XmlPlexusConfiguration(String name, String value) { - super(name, value); - } - - public XmlPlexusConfiguration(Xpp3Dom dom) { - super(dom.getName(), dom.getValue()); - - // attrs - String[] attributes = dom.getAttributeNames(); - - for (String attribute : attributes) { - setAttribute(attribute, dom.getAttribute(attribute)); - } - - // children - int childCount = dom.getChildCount(); - for (int i = 0; i < childCount; i++) { - addChild(new XmlPlexusConfiguration(dom.getChild(i))); - } - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - public String toString() { - StringWriter sw = new StringWriter(); - - XmlPlexusConfigurationWriter xw = new XmlPlexusConfigurationWriter(); - - try { - xw.write(sw, this); - } catch (IOException e) { - // will not happen with StringWriter - } - - return sw.toString(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractContainerInitializationPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractContainerInitializationPhase.java deleted file mode 100644 index 69b656b14..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractContainerInitializationPhase.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - */ -public abstract class AbstractContainerInitializationPhase implements ContainerInitializationPhase {} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractCoreComponentInitializationPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractCoreComponentInitializationPhase.java deleted file mode 100644 index fd6709d46..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/AbstractCoreComponentInitializationPhase.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** @author Jason van Zyl */ -public abstract class AbstractCoreComponentInitializationPhase extends AbstractContainerInitializationPhase { - public void execute(ContainerInitializationContext context) throws ContainerInitializationException { - initializeCoreComponent(context); - } - - protected abstract void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationContext.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationContext.java deleted file mode 100644 index c2536e4cb..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationContext.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Jason van Zyl - */ -public class ContainerInitializationContext { - private DefaultPlexusContainer container; - - ClassWorld classWorld; - - ClassRealm containerRealm; - - PlexusConfiguration containerXmlConfiguration; - - ContainerConfiguration containerConfiguration; - - public ContainerInitializationContext( - DefaultPlexusContainer container, - ClassWorld classWorld, - ClassRealm containerRealm, - PlexusConfiguration configuration, - ContainerConfiguration containerConfiguration) { - this.container = container; - - this.classWorld = classWorld; - - this.containerRealm = containerRealm; - - this.containerXmlConfiguration = configuration; - - this.containerConfiguration = containerConfiguration; - } - - public DefaultPlexusContainer getContainer() { - return container; - } - - public ClassWorld getClassWorld() { - return classWorld; - } - - public ClassRealm getContainerRealm() { - return containerRealm; - } - - public PlexusConfiguration getContainerXmlConfiguration() { - return containerXmlConfiguration; - } - - public ContainerConfiguration getContainerConfiguration() { - return containerConfiguration; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationException.java deleted file mode 100644 index 9571143e9..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationException.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - */ -public class ContainerInitializationException extends Exception { - public ContainerInitializationException(String id) { - super(id); - } - - public ContainerInitializationException(String id, Throwable throwable) { - super(id, throwable); - } - - public ContainerInitializationException(Throwable throwable) { - super(throwable); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationPhase.java deleted file mode 100644 index cc030d93d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/ContainerInitializationPhase.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - */ -public interface ContainerInitializationPhase { - String ROLE = ContainerInitializationPhase.class.getName(); - - void execute(ContainerInitializationContext context) throws ContainerInitializationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentDiscovererManagerPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentDiscovererManagerPhase.java deleted file mode 100644 index 22e85fe6a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentDiscovererManagerPhase.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.component.discovery.ComponentDiscovererManager; -import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; - -/** - * @author Jason van Zyl - */ -public class InitializeComponentDiscovererManagerPhase extends AbstractCoreComponentInitializationPhase { - public void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException { - ComponentDiscovererManager componentDiscovererManager = - context.getContainerConfiguration().getComponentDiscovererManager(); - - context.getContainer().setComponentDiscovererManager(componentDiscovererManager); - - for (ComponentDiscoveryListener listener : - componentDiscovererManager.getComponentDiscoveryListeners().keySet()) { - try { - // This is a hack until we have completely live components - - context.getContainer() - .addComponent(listener, listener.getClass().getName()); - - context.getContainer().getComponentDiscovererManager().removeComponentDiscoveryListener(listener); - - ComponentDiscoveryListener cdl = context.getContainer().lookup(listener.getClass()); - - context.getContainer().getComponentDiscovererManager().registerComponentDiscoveryListener(cdl); - } catch (Exception e) { - throw new ContainerInitializationException("Error initializing component discovery listener.", e); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentFactoryManagerPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentFactoryManagerPhase.java deleted file mode 100644 index a02de88ec..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentFactoryManagerPhase.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.component.factory.ComponentFactoryManager; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; - -/** - * @author Jason van Zyl - */ -public class InitializeComponentFactoryManagerPhase extends AbstractCoreComponentInitializationPhase { - public void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException { - ComponentFactoryManager componentFactoryManager = - context.getContainerConfiguration().getComponentFactoryManager(); - - if (componentFactoryManager instanceof Contextualizable) { - // TODO: this is wrong here jvz. - context.getContainer().getContext().put(PlexusConstants.PLEXUS_KEY, context.getContainer()); - - try { - ((Contextualizable) componentFactoryManager) - .contextualize(context.getContainer().getContext()); - } catch (ContextException e) { - throw new ContainerInitializationException("Error contextualization component factory manager.", e); - } - } - - context.getContainer().setComponentFactoryManager(componentFactoryManager); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java deleted file mode 100644 index 8188c8624..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.ComponentRegistry; -import org.codehaus.plexus.DefaultComponentRegistry; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.manager.PerLookupComponentManagerFactory; -import org.codehaus.plexus.component.manager.SingletonComponentManagerFactory; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRepository; -import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; - -/** - * @author Jason van Zyl - */ -public class InitializeComponentRegistryPhase implements ContainerInitializationPhase { - public void execute(ContainerInitializationContext context) throws ContainerInitializationException { - ComponentRepository repository = getComponentRepository(context); - - LifecycleHandlerManager lifecycleHandlerManager = getLifecycleHandlerManager(context); - - ComponentRegistry componentRegistry = - new DefaultComponentRegistry(context.getContainer(), repository, lifecycleHandlerManager); - - componentRegistry.registerComponentManagerFactory(new PerLookupComponentManagerFactory()); - - componentRegistry.registerComponentManagerFactory(new SingletonComponentManagerFactory()); - - context.getContainer().setComponentRegistry(componentRegistry); - } - - private ComponentRepository getComponentRepository(ContainerInitializationContext context) - throws ContainerInitializationException { - ComponentRepository repository = context.getContainerConfiguration().getComponentRepository(); - - // Add the components defined in the container xml configuration - try { - PlexusConfiguration configuration = context.getContainerXmlConfiguration(); - - PlexusConfiguration[] componentConfigurations = - configuration.getChild("components").getChildren("component"); - for (PlexusConfiguration componentConfiguration : componentConfigurations) { - ComponentDescriptor componentDescriptor = PlexusTools.buildComponentDescriptor( - componentConfiguration, context.getContainer().getContainerRealm()); - componentDescriptor.setRealm(context.getContainer().getContainerRealm()); - repository.addComponentDescriptor(componentDescriptor); - } - } catch (PlexusConfigurationException e) { - throw new ContainerInitializationException( - "Error initializing component repository: " + "Cannot unmarshall component descriptor: ", e); - } catch (CycleDetectedInComponentGraphException e) { - throw new ContainerInitializationException( - "A cycle has been detected in the components of the system: ", e); - } - - return repository; - } - - private LifecycleHandlerManager getLifecycleHandlerManager(ContainerInitializationContext context) { - LifecycleHandlerManager lifecycleHandlerManager = - context.getContainerConfiguration().getLifecycleHandlerManager(); - lifecycleHandlerManager.initialize(); - return lifecycleHandlerManager; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeContainerConfigurationSourcePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeContainerConfigurationSourcePhase.java deleted file mode 100644 index d7877716c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeContainerConfigurationSourcePhase.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.configuration.source.ConfigurationSource; -import org.codehaus.plexus.configuration.source.ContainerConfigurationSource; - -/** - * @author Jason van Zyl - * @author cstamas - */ -public class InitializeContainerConfigurationSourcePhase extends AbstractCoreComponentInitializationPhase { - public void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException { - ConfigurationSource configurationSource = context.getContainer().getConfigurationSource(); - - // ---------------------------------------------------------------------- - // The configurationSource may have been set programmatically so we need - // to check. If it hasn't then we will add the default container config source. - // ---------------------------------------------------------------------- - - if (configurationSource == null) { - // adding default source for container to enable lookups - context.getContainer().setConfigurationSource(new ContainerConfigurationSource()); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java deleted file mode 100644 index 5f635f9fc..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; -import org.codehaus.plexus.logging.console.ConsoleLoggerManager; - -/** @author Jason van Zyl */ -public class InitializeLoggerManagerPhase extends AbstractCoreComponentInitializationPhase { - public void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException { - LoggerManager loggerManager = context.getContainer().getLoggerManager(); - - // ---------------------------------------------------------------------- - // The logger manager may have been set programmatically so we need - // to check. If it hasn't then we will try to look up a logger manager - // that may have been specified in the plexus.xml file. If that doesn't - // work then we'll programmatcially stuff in the console logger. - // ---------------------------------------------------------------------- - - if (loggerManager == null) { - try { - loggerManager = context.getContainer().lookup(LoggerManager.class); - } catch (ComponentLookupException e) { - ComponentDescriptor cd = new ComponentDescriptor(); - - cd.setRole(LoggerManager.ROLE); - - cd.setRoleHint(PlexusConstants.PLEXUS_DEFAULT_HINT); - - cd.setImplementation(ConsoleLoggerManager.class.getName()); - - try { - context.getContainer().addComponentDescriptor(cd); - } catch (CycleDetectedInComponentGraphException cre) { - throw new ContainerInitializationException("Error setting up logging manager.", cre); - } - - loggerManager = new ConsoleLoggerManager("info"); - } - - context.getContainer().setLoggerManager(loggerManager); - } - - Logger logger = loggerManager.getLoggerForComponent(PlexusContainer.class.getName()); - - context.getContainer().enableLogging(logger); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java deleted file mode 100644 index 52b2ebdff..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Jason van Zyl - */ -public class InitializeSystemPropertiesPhase extends AbstractContainerInitializationPhase { - public void execute(ContainerInitializationContext context) throws ContainerInitializationException { - PlexusConfiguration[] systemProperties = context.getContainerXmlConfiguration() - .getChild("system-properties") - .getChildren("property"); - - for (PlexusConfiguration systemProperty : systemProperties) { - String name = systemProperty.getAttribute("name", null); - - String value = systemProperty.getAttribute("value", null); - - if (name == null) { - throw new ContainerInitializationException("Missing 'name' attribute in 'property' tag. "); - } - - if (value == null) { - throw new ContainerInitializationException("Missing 'value' attribute in 'property' tag. "); - } - - System.getProperties().setProperty(name, value); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java deleted file mode 100644 index 7d6a0461b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.codehaus.plexus.container.initialization; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.List; - -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.configuration.source.ChainedConfigurationSource; -import org.codehaus.plexus.configuration.source.ConfigurationSource; - -/** - * @author Jason van Zyl - * @author cstamas - */ -public class InitializeUserConfigurationSourcePhase extends AbstractCoreComponentInitializationPhase { - public void initializeCoreComponent(ContainerInitializationContext context) - throws ContainerInitializationException { - ConfigurationSource existingConfigurationSource = context.getContainer().getConfigurationSource(); - - try { - // is the user overriding the ConfigurationSource (role-hint: default) or only extending it? - if (context.getContainer().hasComponent(ConfigurationSource.class, PlexusConstants.PLEXUS_DEFAULT_HINT)) { - // overriding - - ConfigurationSource cs = context.getContainer().lookup(ConfigurationSource.class); - - // swap the user provided configuration source with current one - context.getContainer().setConfigurationSource(cs); - } else { - // extending - List userConfigurationSources = - context.getContainer().lookupList(ConfigurationSource.class); - - if (userConfigurationSources.size() > 0) { - List configurationSources = - new ArrayList(userConfigurationSources.size() + 1); - - // adding user provied ones to be able to interfere - configurationSources.addAll(userConfigurationSources); - - // at the end adding the container source, to make sure config will be returned - // from plexus.xml if no user interference is given - configurationSources.add(existingConfigurationSource); - - ConfigurationSource configurationSource = new ChainedConfigurationSource(configurationSources); - - context.getContainer().setConfigurationSource(configurationSource); - } - - // register the default source, either the chained or the existing one as default - ComponentDescriptor cd = new ComponentDescriptor(); - - cd.setRole(ConfigurationSource.ROLE); - - cd.setRoleHint(PlexusConstants.PLEXUS_DEFAULT_HINT); - - cd.setImplementationClass( - context.getContainer().getConfigurationSource().getClass()); - - try { - context.getContainer().addComponentDescriptor(cd); - } catch (CycleDetectedInComponentGraphException cre) { - throw new ContainerInitializationException("Error setting up configuration source.", cre); - } - } - - } catch (ComponentLookupException e) { - throw new ContainerInitializationException("Error setting up user configuration source.", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/context/Context.java b/plexus-container-default/src/main/java/org/codehaus/plexus/context/Context.java deleted file mode 100644 index c03373590..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/context/Context.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.codehaus.plexus.context; - -import java.util.Map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Context is a Map of arbitrary data associated with the container. - */ -public interface Context { - /** - * Returns true if this context contains a value for the specified key. - * - * @param key the key to search - * @return true if the key was found; false otherwise - */ - boolean contains(Object key); - - /** - * Returns the value of the key. If the key can't be found it will throw a exception. - * - * @param key the key of the value to look up. - * @return returns the value associated with the key - * @throws ContextException if the key doesn't exist - */ - Object get(Object key) throws ContextException; - - /** - * Utility method to retrieve containerContext data. - * The returned Map is an unmodifiable view. - * @return the containerContext data - * @since 1.0-alpha-18 - */ - Map getContextData(); - - /** - * Adds the item to the containerContext. - * - * @param key the key of the item - * @param value the item - * @throws IllegalStateException if this context is read-only - */ - public void put(Object key, Object value) throws IllegalStateException; - - // todo [dain] this isn't needed anymore since containers are no longer nestable - /** - * Hides the item in the containerContext. - * After remove(key) has been called, a get(key) - * will always fail, even if the parent containerContext - * has such a mapping. - * - * @param key the items key - * @throws IllegalStateException if this context is read-only - */ - void hide(Object key) throws IllegalStateException; - - /** - * Make the containerContext read-only. - * Any attempt to write to the containerContext via put() - * will result in an IllegalStateException. - */ - void makeReadOnly(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java deleted file mode 100644 index a9eea45f8..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.codehaus.plexus.context; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Exception signalling a badly formed Context. - * - * This can be thrown by Context object when a entry is not - * found. It can also be thrown manually in contextualize() - * when Component detects a malformed containerContext value. - * - * @author Avalon Development Team - * @version CVS $Revision$ $Date$ - */ -public class ContextException extends Exception { - private static final long serialVersionUID = 2030206863811644180L; - - /** - * Construct a new ContextException instance. - * - * @param message The detail message for this exception. - */ - public ContextException(final String message) { - this(message, null); - } - - /** - * Construct a new ContextException instance. - * - * @param message The detail message for this exception. - * @param throwable the root cause of the exception - */ - public ContextException(final String message, final Throwable throwable) { - super(message, throwable); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextMapAdapter.java b/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextMapAdapter.java deleted file mode 100644 index d59e856ae..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextMapAdapter.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.codehaus.plexus.context; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.HashMap; - -public class ContextMapAdapter extends HashMap { - private Context context; - - public ContextMapAdapter(Context context) { - this.context = context; - } - - public Object get(Object key) { - try { - Object value = context.get(key); - - if (value instanceof String) { - return value; - } else { - return null; - } - } catch (ContextException e) { - return null; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java b/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java deleted file mode 100644 index 17d236d5d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.codehaus.plexus.context; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Collections; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Default implementation of Context. - * - * This implementation is a static hierarchial store. It has the normal get() - * and put methods. The hide method will hide a property. When - * a property has been hidden the containerContext will not search in the parent containerContext for the value. - * - * @author Avalon Development Team - */ -public class DefaultContext implements Context { - /** - * Context data. - */ - private final ConcurrentMap contextData = new ConcurrentHashMap(); - - /** - * Is the containerContext read only. - */ - private final AtomicBoolean readOnly = new AtomicBoolean(false); - - /** - * Create an empty Context. - */ - public DefaultContext() {} - - /** - * Create a Context with specified data. The specified data is copied into the context so any subsequent updates - * to supplied map are not reflected in this context. Additionally, changes to this context are not reflected in - * the specified map. - * - * @param contextData the containerContext data - */ - public DefaultContext(Map contextData) { - if (contextData == null) { - throw new NullPointerException("contextData is null"); - } - - // check for nulls in key and value - for (Entry entry : contextData.entrySet()) { - Object key = entry.getKey(); - Object value = entry.getValue(); - if (key == null) { - throw new IllegalArgumentException("Key is null"); - } - if (value != null) { - this.contextData.put(key, value); - } - } - } - - public boolean contains(Object key) { - Object data = contextData.get(key); - - return data != null; - } - - public Object get(Object key) throws ContextException { - Object data = contextData.get(key); - - if (data == null) { - // There is no data for the key - throw new ContextException("Unable to resolve context key: " + key); - } - return data; - } - - public void put(Object key, Object value) throws IllegalStateException { - checkWriteable(); - - // check for a null key - if (key == null) { - throw new IllegalArgumentException("Key is null"); - } - - if (value == null) { - contextData.remove(key); - } else { - contextData.put(key, value); - } - } - - public void hide(Object key) throws IllegalStateException { - checkWriteable(); - - contextData.remove(key); - } - - /** - * Utility method to retrieve containerContext data - * - * @return the containerContext data - */ - public Map getContextData() { - return Collections.unmodifiableMap(contextData); - } - - /** - * Make the containerContext read-only. - * Any attempt to write to the containerContext via put() - * will result in an IllegalStateException. - */ - public void makeReadOnly() { - readOnly.set(true); - } - - /** - * Utility method to check if containerContext is writeable and if not throw exception. - * - * @throws java.lang.IllegalStateException if containerContext is read only - */ - protected void checkWriteable() throws IllegalStateException { - if (readOnly.get()) { - throw new IllegalStateException("Context is read only and can not be modified"); - } - } - - public String toString() { - return contextData.toString(); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java deleted file mode 100644 index 208906c45..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.ArrayList; -import java.util.List; - -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.Phase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -public abstract class AbstractLifecycleHandler implements LifecycleHandler { - private List beginSegment; - - private List endSegment; - - // ---------------------------------------------------------------------- - // Begin Segment - // ---------------------------------------------------------------------- - - public void addBeginSegment(Phase phase) { - if (beginSegment == null) { - beginSegment = new ArrayList(); - } - - beginSegment.add(phase); - } - - public List getBeginSegment() { - return beginSegment; - } - - public void addEndSegment(Phase phase) { - if (endSegment == null) { - endSegment = new ArrayList(); - } - - endSegment.add(phase); - } - - public List getEndSegment() { - return endSegment; - } - - // ---------------------------------------------------------------------- - // Lifecylce Management - // ---------------------------------------------------------------------- - - /** - * @deprecated - */ - public void start(Object component, ComponentManager manager) throws PhaseExecutionException { - start(component, manager, manager.getContainer().getLookupRealm(component)); - } - - /** - * Start a component's lifecycle. - */ - public void start(Object component, ComponentManager manager, ClassRealm realm) throws PhaseExecutionException { - if (segmentIsEmpty(getBeginSegment())) { - return; - } - - for (Object o : getBeginSegment()) { - Phase phase = (Phase) o; - - phase.execute(component, manager, realm); - } - } - - /** - * End a component's lifecycle. - * @deprecated - */ - public void end(Object component, ComponentManager manager) throws PhaseExecutionException { - end(component, manager, manager.getContainer().getLookupRealm(component)); - } - - /** - * End a component's lifecycle. - */ - public void end(Object component, ComponentManager manager, ClassRealm contextRealm) - throws PhaseExecutionException { - if (segmentIsEmpty(getEndSegment())) { - return; - } - - for (Object o : getEndSegment()) { - Phase phase = (Phase) o; - - phase.execute(component, manager, contextRealm); - } - } - - private boolean segmentIsEmpty(List segment) { - if (segment == null || segment.size() == 0) { - return true; - } - - return false; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/BasicLifecycleHandler.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/BasicLifecycleHandler.java deleted file mode 100644 index 73484f376..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/BasicLifecycleHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class BasicLifecycleHandler extends AbstractLifecycleHandler { - protected String id; - - public BasicLifecycleHandler(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - /** @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize */ - public void initialize() {} -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java deleted file mode 100644 index 0ae7b707c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Jason van Zyl - */ -public class DefaultLifecycleHandlerManager implements LifecycleHandlerManager { - private final ConcurrentMap lifecycleHandlers = - new ConcurrentHashMap(); - - private String defaultLifecycleHandlerId = "plexus"; - - public void addLifecycleHandler(LifecycleHandler lifecycleHandler) { - lifecycleHandlers.put(lifecycleHandler.getId(), lifecycleHandler); - } - - public void initialize() { - for (LifecycleHandler lifecycleHandler : lifecycleHandlers.values()) { - lifecycleHandler.initialize(); - } - } - - public LifecycleHandler getLifecycleHandler(String id) throws UndefinedLifecycleHandlerException { - if (id == null) { - id = defaultLifecycleHandlerId; - } - - LifecycleHandler lifecycleHandler = lifecycleHandlers.get(id); - - if (lifecycleHandler == null) { - throw new UndefinedLifecycleHandlerException("Specified lifecycle handler cannot be found: " + id); - } - - return lifecycleHandler; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandler.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandler.java deleted file mode 100644 index a462b74df..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.Phase; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -public interface LifecycleHandler { - String getId(); - - /** - * @param phase {@link Phase} - */ - void addBeginSegment(Phase phase); - - /** - * @param phase {@link Phase} - */ - void addEndSegment(Phase phase); - - /** - * @param component The component. - * @param manager The {@link ComponentManager} - * @throws PhaseExecutionException in case of an error. - * @deprecated - */ - void start(Object component, ComponentManager manager) throws PhaseExecutionException; - - /** - * @param component The component. - * @param manager The {@link ComponentManager} - * @param realm The {@link ClassRealm}. - * @throws PhaseExecutionException in case of an error. - */ - void start(Object component, ComponentManager manager, ClassRealm realm) throws PhaseExecutionException; - - /** - * @param component The component. - * @param manager The {@link ComponentManager} - * @throws PhaseExecutionException in case of an error. - * @deprecated - */ - void end(Object component, ComponentManager manager) throws PhaseExecutionException; - - /** - * - * @param component The component. - * @param manager The {@link ComponentManager} - * @param componentContextRealm the realm used to create the component, which may not be the component's realm; this - * component could have requirements that were satisfied using components from this realm. It could be - * used to lookup the same manager components that were used to start the component. - * @throws PhaseExecutionException in case of an error. - */ - void end(Object component, ComponentManager manager, ClassRealm componentContextRealm) - throws PhaseExecutionException; - - /** - * initialize. - */ - void initialize(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java deleted file mode 100644 index 44ca6b819..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * LifecycleHandlerManager is a simple index (registry) of LifecycleHandler instances. - * - * @author Jason van Zyl - * - */ -public interface LifecycleHandlerManager { - void initialize(); - - void addLifecycleHandler(LifecycleHandler lifecycleHandler); - - LifecycleHandler getLifecycleHandler(String id) throws UndefinedLifecycleHandlerException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/UndefinedLifecycleHandlerException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/UndefinedLifecycleHandlerException.java deleted file mode 100644 index 29fcfec42..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/UndefinedLifecycleHandlerException.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.lifecycle; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class UndefinedLifecycleHandlerException extends Exception { - public UndefinedLifecycleHandlerException(String message) { - super(message); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/AbstractPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/AbstractPhase.java deleted file mode 100644 index b2028361c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/AbstractPhase.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.codehaus.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -public abstract class AbstractPhase implements Phase { - /** {@inheritDoc} */ - public abstract void execute(Object component, ComponentManager manager, ClassRealm realm) - throws PhaseExecutionException; - - /** - * @param component The component. - * @param manager The {@link ComponentManager}. - * @throws PhaseExecutionException in case of an error. - * @deprecated - */ - public final void execute(Object component, ComponentManager manager) throws PhaseExecutionException { - execute(component, manager, manager.getContainer().getLookupRealm(component)); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/Phase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/Phase.java deleted file mode 100644 index fe40e5e12..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/Phase.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; - -public interface Phase { - /** - * Execute the phase. - * @param component The component. - * @param manager {@link ComponentManager} - * @param realm {@link ClassRealm} - * @throws PhaseExecutionException in case of an error. - */ - public void execute(Object component, ComponentManager manager, ClassRealm realm) throws PhaseExecutionException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java deleted file mode 100644 index b42a8de18..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public abstract class AbstractLogEnabled implements LogEnabled { - private Logger logger; - - public void enableLogging(Logger logger) { - this.logger = logger; - } - - protected Logger getLogger() { - return logger; - } - - protected void setupLogger(Object component) { - setupLogger(component, logger); - } - - protected void setupLogger(Object component, String subCategory) { - if (subCategory == null) { - throw new IllegalStateException("Logging category must be defined."); - } - - Logger logger = this.logger.getChildLogger(subCategory); - - setupLogger(component, logger); - } - - protected void setupLogger(Object component, Logger logger) { - if (component instanceof LogEnabled) { - ((LogEnabled) component).enableLogging(logger); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java deleted file mode 100644 index 8f2305fbc..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/* - * LICENSE - */ - -/** - * @author Trygve Laugstøl - */ -public abstract class AbstractLogger implements Logger { - private int threshold; - - private String name; - - public AbstractLogger(int threshold, String name) { - if (!isValidThreshold(threshold)) { - throw new IllegalArgumentException("Threshold " + threshold + " is not valid"); - } - - this.threshold = threshold; - this.name = name; - } - - public int getThreshold() { - return threshold; - } - - public void setThreshold(int threshold) { - this.threshold = threshold; - } - - public String getName() { - return name; - } - - public void debug(String message) { - debug(message, null); - } - - public boolean isDebugEnabled() { - return threshold <= LEVEL_DEBUG; - } - - public void info(String message) { - info(message, null); - } - - public boolean isInfoEnabled() { - return threshold <= LEVEL_INFO; - } - - public void warn(String message) { - warn(message, null); - } - - public boolean isWarnEnabled() { - return threshold <= LEVEL_WARN; - } - - public void error(String message) { - error(message, null); - } - - public boolean isErrorEnabled() { - return threshold <= LEVEL_ERROR; - } - - public void fatalError(String message) { - fatalError(message, null); - } - - public boolean isFatalErrorEnabled() { - return threshold <= LEVEL_FATAL; - } - - protected boolean isValidThreshold(int threshold) { - if (threshold == LEVEL_DEBUG) { - return true; - } - if (threshold == LEVEL_INFO) { - return true; - } - if (threshold == LEVEL_WARN) { - return true; - } - if (threshold == LEVEL_ERROR) { - return true; - } - if (threshold == LEVEL_FATAL) { - return true; - } - if (threshold == LEVEL_DISABLED) { - return true; - } - - return false; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java deleted file mode 100644 index 4a6c48ced..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public abstract class AbstractLoggerManager implements LoggerManager { - /** */ - public AbstractLoggerManager() {} - - public void setThreshold(String role, int threshold) { - setThreshold(role, null, threshold); - } - - public int getThreshold(String role) { - return getThreshold(role, null); - } - - public Logger getLoggerForComponent(String role) { - return getLoggerForComponent(role, null); - } - - public void returnComponentLogger(String role) { - returnComponentLogger(role, null); - } - - /** - * Creates a string key useful as keys in Map's. - * - * @param role The component role. - * @param roleHint The component role hint. - * @return Returns a string thats useful as a key for components. - */ - protected String toMapKey(String role, String roleHint) { - if (roleHint == null) { - return role; - } else { - return role + ":" + roleHint; - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java deleted file mode 100644 index 6ba3400a1..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; - -/** - * Base class for all LoggerManagers which use cache of Loggers. - * - * @author Michal Maczka - */ -public abstract class BaseLoggerManager extends AbstractLoggerManager implements Initializable { - private Map loggerCache = new HashMap(); - - private String threshold = "info"; - - private int currentThreshold; - - public void initialize() { - currentThreshold = parseThreshold(threshold); - - if (currentThreshold == -1) { - currentThreshold = Logger.LEVEL_DEBUG; - } - } - - protected int parseThreshold(String text) { - text = text.trim().toLowerCase(Locale.ENGLISH); - - if (text.equals("debug")) { - return Logger.LEVEL_DEBUG; - } else if (text.equals("info")) { - return Logger.LEVEL_INFO; - } else if (text.equals("warn")) { - return Logger.LEVEL_WARN; - } else if (text.equals("error")) { - return Logger.LEVEL_ERROR; - } else if (text.equals("fatal")) { - return Logger.LEVEL_FATAL; - } - - return -1; - } - - /** - * Sets the threshold for all new loggers. It will NOT affect the existing loggers. - *

This is usually only set once while the logger manager is configured.

- * - * @param currentThreshold The new threshold. - */ - public void setThreshold(int currentThreshold) { - this.currentThreshold = currentThreshold; - } - - /** - * Sets the threshold for all new loggers. It will NOT affect the existing loggers. - *

This is usually only set once while the logger manager is configured.

- * - * @param currentThreshold The new threshold. - */ - public void setThresholds(int currentThreshold) { - this.currentThreshold = currentThreshold; - - for (Object o : loggerCache.values()) { - Logger logger = (Logger) o; - logger.setThreshold(currentThreshold); - } - } - - /** - * Returns the current threshold for all new loggers. - * - * @return Returns the current threshold for all new loggers. - */ - public int getThreshold() { - return currentThreshold; - } - - public void setThreshold(String role, String roleHint, int threshold) { - AbstractLogger logger; - - String key = toMapKey(role, roleHint); - - logger = (AbstractLogger) loggerCache.get(key); - - if (logger == null) { - return; // nothing to do - } - - logger.setThreshold(threshold); - } - - public int getThreshold(String role, String roleHint) { - AbstractLogger logger; - - String key = toMapKey(role, roleHint); - - logger = (AbstractLogger) loggerCache.get(key); - - if (logger == null) { - return Logger.LEVEL_DEBUG; // does not return null because that could create a NPE - } - - return logger.getThreshold(); - } - - public Logger getLoggerForComponent(String role, String roleHint) { - Logger logger; - - String key = toMapKey(role, roleHint); - - logger = (Logger) loggerCache.get(key); - - if (logger != null) { - return logger; - } - - logger = createLogger(key); - - loggerCache.put(key, logger); - - return logger; - } - - protected abstract Logger createLogger(String key); - - public void returnComponentLogger(String role, String roleHint) { - Object obj; - - String key = toMapKey(role, roleHint); - - obj = loggerCache.remove(key); - - if (obj == null) { - // TODO: use a logger! - System.err.println("There was no such logger '" + key + "' " + hashCode() + "."); - } - } - - public int getActiveLoggerCount() { - return loggerCache.size(); - } - - public String getThresholdAsString() { - return threshold; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java deleted file mode 100644 index 84a6b3f2a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - */ -public interface LogEnabled { - void enableLogging(Logger logger); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java deleted file mode 100644 index 15bb4737b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public interface Logger { - /** Typecode for debugging messages. */ - int LEVEL_DEBUG = 0; - - /** Typecode for informational messages. */ - int LEVEL_INFO = 1; - - /** Typecode for warning messages. */ - int LEVEL_WARN = 2; - - /** Typecode for error messages. */ - int LEVEL_ERROR = 3; - - /** Typecode for fatal error messages. */ - int LEVEL_FATAL = 4; - - /** Typecode for disabled log levels. */ - int LEVEL_DISABLED = 5; - - void debug(String message); - - void debug(String message, Throwable throwable); - - boolean isDebugEnabled(); - - void info(String message); - - void info(String message, Throwable throwable); - - boolean isInfoEnabled(); - - void warn(String message); - - void warn(String message, Throwable throwable); - - boolean isWarnEnabled(); - - void error(String message); - - void error(String message, Throwable throwable); - - boolean isErrorEnabled(); - - void fatalError(String message); - - void fatalError(String message, Throwable throwable); - - boolean isFatalErrorEnabled(); - - Logger getChildLogger(String name); - - int getThreshold(); - - void setThreshold(int threshold); - - String getName(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java deleted file mode 100644 index 5eed77c63..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public interface LoggerManager { - String ROLE = LoggerManager.class.getName(); - - /** - * Sets the threshold for all new loggers. It will NOT affect the existing loggers. - * - * This is usually only set once while the logger manager is configured. - * - * @param threshold The new threshold. - */ - void setThreshold(int threshold); - - /** - * Returns the current threshold for all new loggers. - * - * @return Returns the current threshold for all new loggers. - */ - int getThreshold(); - - /** - * Sets the threshold for all loggers. It affects all the existing loggers - * as well as future loggers. - * - * @param threshold The new threshold. - */ - void setThresholds(int threshold); - - // The new stuff - void setThreshold(String role, int threshold); - - void setThreshold(String role, String roleHint, int threshold); - - int getThreshold(String role); - - int getThreshold(String role, String roleHint); - - Logger getLoggerForComponent(String role); - - Logger getLoggerForComponent(String role, String roleHint); - - void returnComponentLogger(String role); - - void returnComponentLogger(String role, String hint); - - int getActiveLoggerCount(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java deleted file mode 100644 index 53c5165de..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.codehaus.plexus.logging.console; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.logging.AbstractLogger; -import org.codehaus.plexus.logging.Logger; - -/** - * Logger sending everything to the standard output streams. - * This is mainly for the cases when you have a utility that - * does not have a logger to supply. - * - * @author Avalon Development Team - */ -public final class ConsoleLogger extends AbstractLogger { - public ConsoleLogger(int threshold, String name) { - super(threshold, name); - } - - public void debug(String message, Throwable throwable) { - if (isDebugEnabled()) { - System.out.print("[DEBUG] "); - System.out.println(message); - - if (null != throwable) { - throwable.printStackTrace(System.out); - } - } - } - - public void info(String message, Throwable throwable) { - if (isInfoEnabled()) { - System.out.print("[INFO] "); - System.out.println(message); - - if (null != throwable) { - throwable.printStackTrace(System.out); - } - } - } - - public void warn(String message, Throwable throwable) { - if (isWarnEnabled()) { - System.out.print("[WARNING] "); - System.out.println(message); - - if (null != throwable) { - throwable.printStackTrace(System.out); - } - } - } - - public void error(String message, Throwable throwable) { - if (isErrorEnabled()) { - System.out.print("[ERROR] "); - System.out.println(message); - - if (null != throwable) { - throwable.printStackTrace(System.out); - } - } - } - - public void fatalError(String message, Throwable throwable) { - if (isFatalErrorEnabled()) { - System.out.print("[FATAL ERROR] "); - System.out.println(message); - - if (null != throwable) { - throwable.printStackTrace(System.out); - } - } - } - - public Logger getChildLogger(String name) { - return this; - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java b/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java deleted file mode 100644 index 96c766749..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.codehaus.plexus.logging.console; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import org.codehaus.plexus.logging.AbstractLoggerManager; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; - -/** - * This is a simple logger manager that will only write the logging statements to the console. - * - * Sample configuration: - *
{@code
- * 
- *   org.codehaus.plexus.logging.ConsoleLoggerManager
- *   
- *     DEBUG
- *   
- * 
- * }
- * - * @author Jason van Zyl - * @author Trygve Laugstøl - */ -public class ConsoleLoggerManager extends AbstractLoggerManager implements LoggerManager, Initializable { - /** - * Message of this level or higher will be logged. - * - * This field is set by the plexus container thus the name is 'threshold'. The field - * currentThreshold contains the current setting of the threshold. - */ - private String threshold = "info"; - - private int currentThreshold; - - private Map loggers; - - /** The number of active loggers in use. */ - private int loggerCount; - - private boolean bootTimeLogger = false; - - public ConsoleLoggerManager() {} - - /** - * This special constructor is called directly when the container is bootstrapping itself. - * @param threshold The threshold. - */ - public ConsoleLoggerManager(String threshold) { - this.threshold = threshold; - - bootTimeLogger = true; - - initialize(); - } - - public void initialize() { - debug("Initializing ConsoleLoggerManager: " + this.hashCode() + "."); - // if ( !bootTimeLogger ) - // new Throwable().printStackTrace(System.err); - currentThreshold = parseThreshold(threshold); - - if (currentThreshold == -1) { - debug("Could not parse the threshold level: '" + threshold + "', setting to debug."); - currentThreshold = Logger.LEVEL_DEBUG; - } - - loggers = new HashMap(); - } - - public void setThreshold(int currentThreshold) { - this.currentThreshold = currentThreshold; - } - - public void setThresholds(int currentThreshold) { - this.currentThreshold = currentThreshold; - - for (Object o : loggers.values()) { - Logger logger = (Logger) o; - logger.setThreshold(currentThreshold); - } - } - - /** - * @return Returns the threshold. - */ - public int getThreshold() { - return currentThreshold; - } - - // new stuff - - public void setThreshold(String role, String roleHint, int threshold) { - ConsoleLogger logger; - String name; - - name = toMapKey(role, roleHint); - logger = (ConsoleLogger) loggers.get(name); - - if (logger == null) { - debug("Trying to set the threshold of a unknown logger '" + name + "'."); - return; // nothing to do - } - - logger.setThreshold(threshold); - } - - public int getThreshold(String role, String roleHint) { - ConsoleLogger logger; - String name; - - name = toMapKey(role, roleHint); - logger = (ConsoleLogger) loggers.get(name); - - if (logger == null) { - debug("Trying to get the threshold of a unknown logger '" + name + "'."); - return Logger.LEVEL_DEBUG; // does not return null because that could create a NPE - } - - return logger.getThreshold(); - } - - public Logger createLogger(int threshold, String name) { - return new ConsoleLogger(threshold, name); - } - - public Logger getLoggerForComponent(String role, String roleHint) { - Logger logger; - String name; - - name = toMapKey(role, roleHint); - logger = (Logger) loggers.get(name); - - if (logger != null) return logger; - - debug("Creating logger '" + name + "' " + this.hashCode() + "."); - logger = createLogger(getThreshold(), name); - loggers.put(name, logger); - - return logger; - } - - public void returnComponentLogger(String role, String roleHint) { - Object obj; - String name; - - name = toMapKey(role, roleHint); - obj = loggers.remove(name); - - if (obj == null) { - debug("There was no such logger '" + name + "' " + this.hashCode() + "."); - } else { - debug("Removed logger '" + name + "' " + this.hashCode() + "."); - } - } - - public int getActiveLoggerCount() { - return loggers.size(); - } - - private int parseThreshold(String text) { - text = text.trim().toLowerCase(Locale.ENGLISH); - - if (text.equals("debug")) { - return ConsoleLogger.LEVEL_DEBUG; - } else if (text.equals("info")) { - return ConsoleLogger.LEVEL_INFO; - } else if (text.equals("warn")) { - return ConsoleLogger.LEVEL_WARN; - } else if (text.equals("error")) { - return ConsoleLogger.LEVEL_ERROR; - } else if (text.equals("fatal")) { - return ConsoleLogger.LEVEL_FATAL; - } - - return -1; - } - - private String decodeLogLevel(int logLevel) { - switch (logLevel) { - case ConsoleLogger.LEVEL_DEBUG: - return "debug"; - case ConsoleLogger.LEVEL_INFO: - return "info"; - case ConsoleLogger.LEVEL_WARN: - return "warn"; - case ConsoleLogger.LEVEL_ERROR: - return "error"; - case ConsoleLogger.LEVEL_FATAL: - return "fatal"; - case ConsoleLogger.LEVEL_DISABLED: - return "disabled"; - default: - return "unknown"; - } - } - - /** - * Remove this method and all references when this code is verified. - * - * @param msg - */ - private void debug(String msg) { - // if ( !bootTimeLogger ) - // System.out.println( "[Console] " + msg ); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/AutoConfigurePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/AutoConfigurePhase.java deleted file mode 100644 index b30f81b9e..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/AutoConfigurePhase.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -import org.codehaus.plexus.component.configurator.ComponentConfigurator; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; -import org.codehaus.plexus.util.StringUtils; - -public class AutoConfigurePhase extends AbstractPhase { - public static final String DEFAULT_CONFIGURATOR_ID = "default"; - - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - try { - ComponentDescriptor descriptor = manager.getComponentDescriptor(); - - String configuratorId = descriptor.getComponentConfigurator(); - - if (StringUtils.isEmpty(configuratorId)) { - configuratorId = DEFAULT_CONFIGURATOR_ID; - } - - ComponentConfigurator componentConfigurator = - manager.getContainer().lookup(ComponentConfigurator.class, configuratorId); - - PlexusConfiguration configuration = - manager.getContainer().getConfigurationSource().getConfiguration(descriptor); - - if (configuration != null) { - ClassRealm realm = manager.getRealm(); - - componentConfigurator.configureComponent(object, configuration, realm); - } - } catch (ComponentLookupException e) { - throw new PhaseExecutionException( - "Unable to auto-configure component as its configurator could not be found", e); - } catch (ComponentConfigurationException e) { - throw new PhaseExecutionException("Unable to auto-configure component", e); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Configurable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Configurable.java deleted file mode 100644 index 8baa74c8d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Configurable.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; - -/** - * Configures a component. - * - * @author Dan Diephouse - */ -public interface Configurable { - void configure(PlexusConfiguration configuration) throws PlexusConfigurationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ConfigurablePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ConfigurablePhase.java deleted file mode 100644 index 859e8d384..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ConfigurablePhase.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.configuration.PlexusConfigurationException; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class ConfigurablePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof Configurable) { - try { - ((Configurable) object) - .configure(manager.getComponentDescriptor().getConfiguration()); - } catch (PlexusConfigurationException e) { - throw new PhaseExecutionException("Error occurred during phase execution", e); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java deleted file mode 100644 index 0f65882b4..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; - -/** - * @author Jason van Zyl - */ -public interface Contextualizable { - public void contextualize(Context context) throws ContextException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ContextualizePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ContextualizePhase.java deleted file mode 100644 index bf75d6981..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ContextualizePhase.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class ContextualizePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof Contextualizable) { - Context context = manager.getContainer().getContext(); - - ClassRealm origRealm = manager.getContainer().setLookupRealm(lookupRealm); - - try { - ((Contextualizable) object).contextualize(context); - } catch (ContextException e) { - throw new PhaseExecutionException("Unable to contextualize component", e); - } finally { - manager.getContainer().setLookupRealm(origRealm); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java deleted file mode 100644 index 185609725..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Disposable { - public void dispose(); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/DisposePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/DisposePhase.java deleted file mode 100644 index ad74ac072..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/DisposePhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class DisposePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Disposable) { - ((Disposable) object).dispose(); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java deleted file mode 100644 index 4d29ec728..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Initializable { - public void initialize() throws InitializationException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java deleted file mode 100644 index aaf89b521..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Indicates a problem occurred when initialising a component. - * - * @author Brett Porter - */ -public class InitializationException extends Exception { - public InitializationException(String message) { - super(message); - } - - public InitializationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializePhase.java deleted file mode 100644 index b03ffd1dd..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializePhase.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class InitializePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof Initializable) { - try { - ((Initializable) object).initialize(); - } catch (InitializationException e) { - throw new PhaseExecutionException("Error initialising component", e); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java deleted file mode 100644 index 2a4115851..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2007 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.LoggerManager; - -/** - * @author Trygve Laugstøl - */ -public class LogDisablePhase extends AbstractPhase { - public void execute(Object object, ComponentManager componentManager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof LogEnabled) { - LoggerManager loggerManager = componentManager.getContainer().getLoggerManager(); - loggerManager.returnComponentLogger(componentManager.getRole(), componentManager.getRoleHint()); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java deleted file mode 100644 index b5e301205..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2007 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; - -public class LogEnablePhase extends AbstractPhase { - public void execute(Object object, ComponentManager componentManager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof LogEnabled) { - LogEnabled logEnabled = (LogEnabled) object; - - LoggerManager loggerManager = componentManager.getContainer().getLoggerManager(); - - Logger logger = - loggerManager.getLoggerForComponent(componentManager.getRole(), componentManager.getRoleHint()); - - logEnabled.enableLogging(logger); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java deleted file mode 100644 index 0c62f936a..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Describes an error that has occurred during the execution of a phase. - * - * @author Brett Porter - */ -public class PhaseExecutionException extends Exception { - public PhaseExecutionException(String message, Throwable throwable) { - super(message, throwable); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PlexusContainerLocator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PlexusContainerLocator.java deleted file mode 100644 index 4ad39ae1c..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PlexusContainerLocator.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * A ServiceLocator for PlexusContainer. - * - * @author Dan Diephouse - */ -public class PlexusContainerLocator implements ServiceLocator { - private PlexusContainer container; - - public PlexusContainerLocator(PlexusContainer container) { - this.container = container; - } - - public Object lookup(String role) throws ComponentLookupException { - return container.lookup(role); - } - - public Object lookup(String role, String roleHint) throws ComponentLookupException { - return container.lookup(role, roleHint); - } - - public Map lookupMap(String role) throws ComponentLookupException { - return container.lookupMap(role); - } - - public List lookupList(String role) throws ComponentLookupException { - return container.lookupList(role); - } - - public void release(Object component) throws ComponentLifecycleException { - container.release(component); - } - - public void releaseAll(Map components) throws ComponentLifecycleException { - container.releaseAll(components); - } - - public void releaseAll(List components) throws ComponentLifecycleException { - container.releaseAll(components); - } - - public boolean hasComponent(String componentKey) { - return container.hasComponent(componentKey); - } - - public boolean hasComponent(String role, String roleHint) { - return container.hasComponent(role, roleHint); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ResumePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ResumePhase.java deleted file mode 100644 index 57a1d6b2b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ResumePhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class ResumePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Suspendable) { - ((Suspendable) object).resume(); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceLocator.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceLocator.java deleted file mode 100644 index 80b20177e..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceLocator.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * Provides services to components by means of a lookup. - * - * @author Dan Diephouse - */ -public interface ServiceLocator { - // ---------------------------------------------------------------------- - // Component lookup - // ---------------------------------------------------------------------- - - Object lookup(String componentKey) throws ComponentLookupException; - - Object lookup(String role, String roleHint) throws ComponentLookupException; - - Map lookupMap(String role) throws ComponentLookupException; - - List lookupList(String role) throws ComponentLookupException; - - // ---------------------------------------------------------------------- - // Component release - // ---------------------------------------------------------------------- - - void release(Object component) throws ComponentLifecycleException; - - void releaseAll(Map components) throws ComponentLifecycleException; - - void releaseAll(List components) throws ComponentLifecycleException; - - // ---------------------------------------------------------------------- - // Component discovery - // ---------------------------------------------------------------------- - - boolean hasComponent(String componentKey); - - boolean hasComponent(String role, String roleHint); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Serviceable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Serviceable.java deleted file mode 100644 index 6c0f7eedc..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Serviceable.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Indicates that a class wants a hold on a ServiceLocator. - * - * @author Dan Diephouse - */ -public interface Serviceable { - void service(ServiceLocator locator); -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceablePhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceablePhase.java deleted file mode 100644 index f648a483f..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceablePhase.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class ServiceablePhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Serviceable) { - PlexusContainer container = manager.getContainer(); - - ((Serviceable) object).service(new PlexusContainerLocator(container)); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartPhase.java deleted file mode 100644 index cbba44360..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartPhase.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class StartPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof Startable) { - try { - ((Startable) object).start(); - } catch (StartingException e) { - throw new PhaseExecutionException("Error starting component", e); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Startable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Startable.java deleted file mode 100644 index d56286124..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Startable.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface Startable { - void start() throws StartingException; - - void stop() throws StoppingException; -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java deleted file mode 100644 index ae81fd976..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Error occuring while starting a component. - * - * @author Brett Porter - */ -public class StartingException extends Exception { - public StartingException(String message) { - super(message); - } - - public StartingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StopPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StopPhase.java deleted file mode 100644 index 1acc2272b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StopPhase.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class StopPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) - throws PhaseExecutionException { - if (object instanceof Startable) { - try { - ((Startable) object).stop(); - } catch (StoppingException e) { - throw new PhaseExecutionException("Error stopping component", e); - } - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java deleted file mode 100644 index c68c5acd9..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Error occuring while starting a component. - * - * @author Brett Porter - */ -public class StoppingException extends Exception { - public StoppingException(String message) { - super(message); - } - - public StoppingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/SuspendPhase.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/SuspendPhase.java deleted file mode 100644 index 16d0f8a1d..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/SuspendPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class SuspendPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Suspendable) { - ((Suspendable) object).suspend(); - } - } -} diff --git a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspendable.java b/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspendable.java deleted file mode 100644 index ae675450b..000000000 --- a/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspendable.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.personality.plexus.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface Suspendable { - void suspend(); - - void resume(); -} diff --git a/plexus-container-default/src/main/mdo/components.mdo b/plexus-container-default/src/main/mdo/components.mdo deleted file mode 100644 index 0fb934404..000000000 --- a/plexus-container-default/src/main/mdo/components.mdo +++ /dev/null @@ -1,245 +0,0 @@ - - - - plexus-components - PlexusComponents - - This is a documentation for the Plexus Components descriptor: META-INF/plexus/components.xml.

-

An XSD is available at - http://plexus.codehaus.org/xsd/components-1.3.0.xsd. -

]]> -
- - - - ComponentSetDescriptor - javadoc.]]> - - 1.0.0+ - - - components - 1.0.0+ - - ComponentDescriptor - * - - The component descriptors that can be found within this component set descriptor. - - - dependencies - 1.0.0+ - - ComponentDependency - * - - The dependencies that are required by the set of components found in this component set descriptor. - - - - - - ComponentDescriptor - javadoc.]]> - - 1.0.0+ - - - role - 1.0.0+ - String - the role of this component. - - - role-hint - 1.0.0+ - String - the role-hint of this component. - - - implementation - 1.0.0+ - String - - the implementation of this component. Implementation is a string denoting a FQCN in normal Java - components, or some other name or file for other component factory implementations. - - - - version - 1.0.0+ - String - a specific point in a components's project timeline. i.e. version 1, or 2.1.4 - - - component-type - 1.0.0+ - String - the type of this component. - - - instantiation-strategy - 1.0.0+ - String - the type of instantiation strategy for this component: one of "per-lookup", "singleton", "keep-alive" or "poolable". - singleton - - - lifecycle-handler - 1.0.0+ - String - the lifecycle-handler for this component. For example, "basic", "passive", "bootstrap". - - - component-profile - 1.0.0+ - String - - - - component-composer - 1.0.0+ - String - - the ID of the type of composer this component will use. For example, "setter" or "field" for the - different types of dependency injection. - - - - component-configurator - 1.0.0+ - String - - the type of component configurator for this project. For example "basic" for normal, or "map-oriented" - for map oriented components. - - - - component-factory - 1.0.0+ - String - an id of the factory used to create this component. For example, "jruby" will use a JRuby factory. - - - description - 1.0.0+ - String - a human-readable description of this component. - - - alias - 1.0.0+ - String - an alias for this component. An alias is as an alternate name other than the normal key. - - - isolated-realm - 1.0.0+ - boolean - true if this may be in an isolated classrealm. - - - configuration - 1.0.0+ - DOM - configuration values defined for this component. - - - requirements - 1.0.0+ - - ComponentRequirement - * - - project requirements to this component. - - - - - ComponentRequirement - - This represents a component that is required by another component. - - 1.0.0+ - - - role - 1.0.0+ - String - the role of the required component. - - - field-name - 1.0.0+ - String - the name of the field that will be populated by the required component. - - - role-hint - 1.0.0+ - String - the role-hint of the required component. - default - - - role-hints - 1.0.0+ - - String - * - - the role-hints of the required component. - - - optional - 1.3.0+ - boolean - - Controls whether a failure to satisfy this requirement can be tolerated by host component or whether construction - of the host component should also fail. - - - - - - ComponentDependency - - - 1.0.0+ - - - artifact-id - 1.0.0+ - String - the dependency's artifact ID. - - - group-id - 1.0.0+ - String - the dependency's group ID. - - - type - 1.0.0+ - String - the type of dependency, for example a "jar". - - - version - 1.0.0+ - String - the point in a project's development timeline - - - - -
diff --git a/plexus-container-default/src/main/mdo/plexus.mdo b/plexus-container-default/src/main/mdo/plexus.mdo deleted file mode 100644 index 42d3834eb..000000000 --- a/plexus-container-default/src/main/mdo/plexus.mdo +++ /dev/null @@ -1,190 +0,0 @@ - - - - plexus-configuration - PlexusConfiguration - - This is a Work In Progress for a documentation for the Plexus Container descriptor: META-INF/plexus/plexus.xml.

-

An XSD will be available at - http://plexus.codehaus.org/xsd/plexus-1.3.0.xsd. -

-

Note that since plexus.xml is a superset of components.xml, - this documentation only focuses on elements only available in plexus.xml.

- ]]> -
- - - - PlexusDescriptor - - - see org.codehaus.plexus.configuration.PlexusConfigurationMerger - 1.0.0+ - - - load-on-start - 1.0.0+ - TBD - DOM - - - system-properties - 1.0.0+ - TBD - DOM - - - configurations-directory - 1.0.0+ - TBD - DOM - - - logging - 1.0.0+ - TBD - DOM - - - component-repository - 1.0.0+ - TBD - DOM - - - resources - 1.0.0+ - TBD - DOM - - - component-manager-manager - 1.0.0+ - TBD - DOM - - - component-discoverer-manager - 1.0.0+ - TBD - - ComponentDiscovererManager - - - - component-factory-manager - 1.0.0+ - TBD - DOM - - - lifecycle-handler-manager - 1.0.0+ - TBD - DOM - - - component-composer-manager - 1.0.0+ - TBD - DOM - - - components - 1.0.0+ - DOM - components.xml.]]> - - - - - - - ComponentDiscovererManager - org.codehaus.plexus.component.discovery.ComponentDiscovererManager - source - javadoc.]]> - - 1.0.0+ - - - implementation - 1.0.0+ - Implementation class. - String - - - listeners - 1.0.0+ - - * - ComponentDiscoveryListener - - - - component-discoverers - 1.0.0+ - - * - ComponentDiscoverer - - - - - - ComponentDiscoveryListener - org.codehaus.plexus.component.discovery.ComponentDiscoveryListener - source - javadoc.]]> - - 1.0.0+ - - - implementation - 1.0.0+ - Implementation class. - String - - - configuration - 1.0.0+ - Configuration of the class. - Content - - - - - ComponentDiscoverer - org.codehaus.plexus.component.discovery.ComponentDiscoverer - source - javadoc.]]> - - 1.0.0+ - - - implementation - 1.0.0+ - Implementation class. - String - - - configuration - 1.0.0+ - Configuration of the class. - Content - - - - -
diff --git a/plexus-container-default/src/main/resources/META-INF/plexus/components.xml b/plexus-container-default/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 3a4d4d7d1..000000000 --- a/plexus-container-default/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.codehaus.plexus.component.configurator.BasicComponentConfigurator - org.codehaus.plexus.component.configurator.ComponentConfigurator - basic - - - org.codehaus.plexus.component.configurator.MapOrientedComponentConfigurator - org.codehaus.plexus.component.configurator.ComponentConfigurator - map-oriented - - - \ No newline at end of file diff --git a/plexus-container-default/src/site/apt/index.apt b/plexus-container-default/src/site/apt/index.apt deleted file mode 100644 index 9bbe8284c..000000000 --- a/plexus-container-default/src/site/apt/index.apt +++ /dev/null @@ -1,43 +0,0 @@ - ----- - plexus-container-default - ----- - Hervé Boutemy - ----- - 2009-10-06 - ----- - -Overview - - <<>> is Plexus' (IoC) container. It is composed of: - - * its public API: the root class is - <<<{{{./apidocs/org/codehaus/plexus/PlexusContainer.html}org.codehaus.plexus.PlexusContainer}}>>>, - - * its default implementation: the root class is - <<<{{{./apidocs/org/codehaus/plexus/DefaultPlexusContainer.html}org.codehaus.plexus.DefaultPlexusContainer}}>>>. - - [] - - - Default implementation reads configuration in XML files: - - * multiple <<<{{{./plexus-components.html}META-INF/plexus/components.xml}}>>> files that declare components, - - * one <<<{{{./plexus-configuration.html}META-INF/plexus/plexus.xml}}>>> file that can be used to configure - the plexus container and runtime in addition to declaring components. - - [] - - But it is not limited to these files: Plexus container is by nature very extensible, it can be configured - programmatically too or extended to read configuration from any source. It is used for example in Maven 2 to - read plugins configuration from <<>> and instanciate Mojos downloaded from - Maven repositories. - -* Deprecated - - <<>> is replaced by: - - * {{{https://github.com/eclipse/sisu.inject}Sisu container}}, reading <<>> index files, - - * and optional {{{https://github.com/eclipse/sisu.plexus}Plexus shim <<>>}} for compatibility with legacy Plexus <<>>. - See also Plexus shim {{{https://eclipse.github.io/sisu.plexus/apidocs/reference/packages.html}javadoc}}. diff --git a/plexus-container-default/src/site/site.xml b/plexus-container-default/src/site/site.xml deleted file mode 100644 index 6561cc283..000000000 --- a/plexus-container-default/src/site/site.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java deleted file mode 100644 index 3620c21a8..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.codehaus.plexus; - -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.test.ComponentA; - -/** - * @author Trygve Laugstøl - */ -public class DefaultComponentLookupManagerTest extends PlexusTestCase { - public void testLookupsWithAndWithoutRoleHint() throws Exception { - String resource = getConfigurationName("components.xml"); - - System.out.println("resource = " + resource); - - assertNotNull(resource); - - ContainerConfiguration c = - new DefaultContainerConfiguration().setName("test").setContainerConfiguration(resource); - - DefaultPlexusContainer container = new DefaultPlexusContainer(c); - - try { - container.lookup(ComponentA.class); - - fail("Expected exception"); - } catch (ComponentLookupException e) { - // expected - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java deleted file mode 100644 index 2e191ff92..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * This is the start of the sketch which outlines some of the things - * I would like to do with components during runtime. - * - * @author Jason van Zyl - * - */ -public class DyanamicComponentKungFuTest extends TestCase { - /** - * Component additions during container operation. - * - *
    - *
  1. Add a component at runtime - *
      - *
    • Additions could be made by specifying an URL which will be compatible with Wagon - * and specifically Maven's way of using Wagon.
    • - *
    - *
  2. - * - *
  3. Configure the dynamically added component - *
      - *
    • We need to be able to deal with different flavours of components but we can focus - * on Plexus components to start with. But some components may have meta information - * and some may not like pico components. But one of the first flavours I want to - * support is phoenix components because I specifically need the FTP server.
    • - *
    - *
  4. - * - *
  5. Let the component perform its role
  6. - *
  7. Suspend the component - *
      - *
    1. Define the criteria for which we can suspend a component - *
        - *
      • When there are no client connections?
      • - *
      • Even when there are no connections and a client tries to obtain a connection what do we do?
      • - *
      • If we are in desperate need to suspend the component, say for urgent security requirement, and - * clients simply won't bugger off what do we do?
      • - *
      - *
    2. - *
    - *
  8. - * - *
  9. Reconfigure the component
  10. - * - *
  11. Resume the component
  12. - * - *
  13. Let the component perform its role
  14. - * - *
  15. Release the component
  16. - *
- * - * @throws Exception in case of a failure. - */ - public void testAdditionOfComponentDuringContainerOperation() throws Exception {} - - /** - * Component replacement during container operation. - * - * This will force the design of a mechanism where the components communicate - * with one another via a connector. In order for components to be replaced - * dynamically the components cannot be directly coupled to one another. - * - * How to decide if a component is a suitable replacement given the versions - * of the specifications of the component and any required components if the - * component is a composite component. - * - * Definitely need to simulate the connection (a MockConnection) during - * runtime to make sure that in the event something goes wrong the container - * can just refuse to allow the component substitution. This shouldn't be trial - * and error but until much field testing has occurred I'm sure there will be - * instances where miscalculations happen simply due to lack of experience and - * usage with dynamic component replacement. - * - * @throws Exception in case of a failure. - */ - public void testComponentReplacementDuringContainerOperation() throws Exception {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java deleted file mode 100644 index 3a72f9d51..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.junit.Test; -import org.junit.runner.JUnitCore; - -import static org.junit.Assert.*; - -public class PlexusJUnit4TestCaseTest { - - private static AtomicBoolean run = new AtomicBoolean(false); - - public static class MyTest extends PlexusJUnit4TestCase { - - @Test - public void yeah() { - run.set(true); - } - } - - @Test - public void runMytest() { - JUnitCore.runClasses(MyTest.class); - assertTrue(run.get()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java deleted file mode 100644 index b8d2eda24..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.codehaus.plexus; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; - -import junit.framework.TestCase; -import org.codehaus.plexus.component.discovery.DiscoveredComponent; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.test.DefaultLoadOnStartService; - -/** - * @author Jason van Zyl - */ -public class PlexusTestCaseTest extends TestCase { - private String basedir; - - public void setUp() { - basedir = System.getProperty("basedir"); - - if (basedir == null) { - basedir = new File(".").getAbsolutePath(); - } - } - - public void testPlexusTestCase() throws Exception { - PlexusTestCase tc = new PlexusTestCase() {}; - - tc.setUp(); - - try { - tc.lookup(DiscoveredComponent.class, "unknown"); - - fail("Expected ComponentLookupException."); - } catch (ComponentLookupException ex) { - assertTrue(true); - } - - // This component is discovered from src/test/META-INF/plexus/components.xml - DiscoveredComponent component = tc.lookup(DiscoveredComponent.class); - - assertNotNull(component); - - assertNotNull(tc.getClassLoader()); - - tc.tearDown(); - } - - public void testLoadOnStartComponents() throws Exception { - PlexusTestCase tc = new PlexusTestCase() { - protected String getCustomConfigurationName() { - return PlexusTestCase.getTestConfiguration(getClass()); - } - }; - - tc.setupContainer(); - - // Assert that the load on start component has started. - - assertTrue("The load on start components haven't been started.", DefaultLoadOnStartService.isStarted); - - tc.tearDown(); - } - - public void testGetFile() { - File file = PlexusTestCase.getTestFile("pom.xml"); - - assertTrue(file.exists()); - - file = PlexusTestCase.getTestFile(basedir, "pom.xml"); - - assertTrue(file.exists()); - } - - public void testGetPath() { - File file = new File(PlexusTestCase.getTestPath("pom.xml")); - - assertTrue(file.exists()); - - file = new File(PlexusTestCase.getTestPath(basedir, "pom.xml")); - - assertTrue(file.exists()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/MapOrientedComponentProcessingTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/MapOrientedComponentProcessingTest.java deleted file mode 100644 index 3fbec0dae..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/MapOrientedComponentProcessingTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.codehaus.plexus.component; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Map; - -import junit.framework.TestCase; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentRequirement; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.logging.LoggerManager; - -public class MapOrientedComponentProcessingTest extends TestCase { - - public void testShouldFindAndInitializeMapOrientedComponent() throws Exception { - PlexusContainer embedder = new DefaultPlexusContainer(); - - ComponentDescriptor descriptor = - new ComponentDescriptor(TestMapOrientedComponent.class, embedder.getContainerRealm()); - - descriptor.setRole(TestMapOrientedComponent.ROLE); - - descriptor.setImplementation(TestMapOrientedComponent.ROLE); - - descriptor.setComponentComposer("map-oriented"); - - descriptor.setComponentConfigurator("map-oriented"); - - ComponentRequirement requirement = new ComponentRequirement(); - - requirement.setFieldName("testRequirement"); - - requirement.setRole(LoggerManager.ROLE); - - descriptor.addRequirement(requirement); - - PlexusConfiguration param = new XmlPlexusConfiguration("testParameter"); - - param.setValue("testValue"); - - PlexusConfiguration configuration = new XmlPlexusConfiguration("configuration"); - - configuration.addChild(param); - - descriptor.setConfiguration(configuration); - - embedder.addComponentDescriptor(descriptor); - - TestMapOrientedComponent component = embedder.lookup(TestMapOrientedComponent.class); - - Map context = component.getContext(); - - assertTrue( - "requirement (LogManager) missing from containerContext.", - (context.get("testRequirement") instanceof LoggerManager)); - - assertEquals("parameter missing from containerContext.", "testValue", context.get("testParameter")); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/PlexusTestCaseTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/PlexusTestCaseTest.java deleted file mode 100644 index 867afa453..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/PlexusTestCaseTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.codehaus.plexus.component; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; - -public class PlexusTestCaseTest extends PlexusTestCase { - - private static final String CUSTOM_PROPERTY = "custom.property"; - private static final String CUSTOM_VALUE = "custom.value"; - - @Override - protected void customizeContext(Context context) { - super.customizeContext(context); - - context.put(CUSTOM_PROPERTY, CUSTOM_VALUE); - } - - public void testCustomizeContext() throws ContextException { - String value = (String) getContainer().getContext().get(CUSTOM_PROPERTY); - - assertEquals(CUSTOM_VALUE, value); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/TestMapOrientedComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/TestMapOrientedComponent.java deleted file mode 100644 index 3660e671a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/TestMapOrientedComponent.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.codehaus.plexus.component; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Map; -import java.util.TreeMap; - -import org.codehaus.plexus.component.repository.ComponentRequirement; - -public class TestMapOrientedComponent implements MapOrientedComponent { - - public static final String ROLE = TestMapOrientedComponent.class.getName(); - - private Map context = new TreeMap(); - - public void addComponentRequirement(ComponentRequirement requirementDescriptor, Object requirementValue) { - context.put(requirementDescriptor.getFieldName(), requirementValue); - } - - public void setComponentConfiguration(Map componentConfiguration) { - context.putAll(componentConfiguration); - } - - public Map getContext() { - return context; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java deleted file mode 100644 index 340f36f33..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class AbstractComponent implements Component { - private ComponentA componentA; - - public ComponentA getComponentA() { - return componentA; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java deleted file mode 100644 index e3528b9ec..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import junit.framework.TestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.io.PlexusTools; - -/** - * - * - * @author Jason van Zyl - * - */ -public abstract class AbstractCompositionResolverTest extends TestCase { - - /** - * - * @return {@link CompositionResolver} - */ - protected abstract CompositionResolver getCompositionResolver(); - - // ------------------------------------------------------------------------ - // - // +-------+ +-------+ - // | c1 | --------> | c2 | - // +-------+ +-------+ - // | - // | - // V - // +-------+ - // | c3 | - // +-------+ - // - // ------------------------------------------------------------------------ - public void testSimpleComponentResolution() throws Exception { - String cc1 = "" + " java.lang.String" - + " c1" - + " " - + " " - + " c2" - + " " - + " " - + " c3" - + " " - + " " - + ""; - - String cc2 = "" + " java.lang.String" - + " c2" - + ""; - - String cc3 = "" + " java.lang.String" - + " c3" - + ""; - - ClassWorld classWorld = new ClassWorld("test", Thread.currentThread().getContextClassLoader()); - ClassRealm realm = classWorld.getRealm("test"); - - CompositionResolver compositionResolver = getCompositionResolver(); - - ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor(cc1, realm); - - ComponentDescriptor c2 = PlexusTools.buildComponentDescriptor(cc2, realm); - - ComponentDescriptor c3 = PlexusTools.buildComponentDescriptor(cc3, realm); - - compositionResolver.addComponentDescriptor(c1); - - compositionResolver.addComponentDescriptor(c2); - - compositionResolver.addComponentDescriptor(c3); - - List dependencies = compositionResolver.getRequirements(c1.getRole(), c1.getRoleHint()); - - assertEquals(2, dependencies.size()); - - assertTrue(dependencies.contains(c2.getRole() + CompositionResolver.SEPARATOR_CHAR + c2.getRoleHint())); - - assertTrue(dependencies.contains(c3.getRole() + CompositionResolver.SEPARATOR_CHAR + c2.getRoleHint())); - - assertEquals(2, dependencies.size()); - } - - // ------------------------------------------------------------------------ - // - // +-------+ +-------+ - // | c1 | --------> | c2 | - // +-------+ +-------+ - // | - // | - // V - // +-------+ +-------+ - // | c3 | --------> | c4 | - // +-------+ +-------+ - // | - // | - // V - // +-------+ - // | c5 | - // +-------+ - // - // ------------------------------------------------------------------------ - public void testComplexComponentResolution() throws Exception { - String cc1 = "" + " java.lang.String" - + " c1" - + " " - + " " - + " c2" - + " " - + " " - + " c3" - + " " - + " " - + ""; - - String cc2 = "" + " java.lang.String" - + " c2" - + ""; - - String cc3 = "" + " java.lang.String" - + " c3" - + " " - + " " - + " c4" - + " " - + " " - + " c5" - + " " - + " " - + ""; - - String cc4 = "" + " java.lang.String" - + " c4" - + ""; - - String cc5 = "" + " java.lang.String" - + " c5" - + ""; - - ClassWorld classWorld = new ClassWorld("test", Thread.currentThread().getContextClassLoader()); - ClassRealm realm = classWorld.getRealm("test"); - - CompositionResolver compositionResolver = getCompositionResolver(); - - ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor(cc1, realm); - - ComponentDescriptor c2 = PlexusTools.buildComponentDescriptor(cc2, realm); - - ComponentDescriptor c3 = PlexusTools.buildComponentDescriptor(cc3, realm); - - ComponentDescriptor c4 = PlexusTools.buildComponentDescriptor(cc4, realm); - - ComponentDescriptor c5 = PlexusTools.buildComponentDescriptor(cc5, realm); - - compositionResolver.addComponentDescriptor(c1); - - compositionResolver.addComponentDescriptor(c2); - - compositionResolver.addComponentDescriptor(c3); - - compositionResolver.addComponentDescriptor(c4); - - compositionResolver.addComponentDescriptor(c5); - - List dependencies = compositionResolver.getRequirements(c1.getRole(), c1.getRoleHint()); - - assertEquals(2, dependencies.size()); - - // I just leave this at the moment as I am just 99% sure that this is not needed and not - // correct. compositionResolver.getComponentDependencies() should return only direct dependencies - // - // I will need to add a method like getSortedComponents() - // which will do topological sort of DAG and return list of ordered component which can be used - // by ComponentComposer. - // Possibility of checking if there are cycles probably also must be exposed in API (DAG has it alredy) - // and it should be used - // I can implement cycle detecting from single node (source) as after adding new component - // we don't have to probably check entire graph but we will probably have to check - // if there are cycles. - - /** - * // c5 must come before c3 - * assertTrue( dependencies.indexOf( "c5" ) < dependencies.indexOf( "c3" ) ); - * - * // c4 must come before c3 - * assertTrue( dependencies.indexOf( "c4" ) < dependencies.indexOf( "c3" ) ); - */ - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java deleted file mode 100644 index 6368a9d3d..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Component {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java deleted file mode 100644 index fea5dc33a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentA { - String ROLE = ComponentA.class.getName(); - - ComponentB getComponentB(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java deleted file mode 100644 index f9625fc06..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentB { - ComponentC getComponentC(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java deleted file mode 100644 index 1a473c2de..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentC {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java deleted file mode 100644 index 501acc81b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentD {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java deleted file mode 100644 index 9c38c6bef..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ComponentE {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java deleted file mode 100644 index 35d40705f..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -/** - * @author Michal Maczka - */ -public class ComponentF { - private ComponentA componentA; - private ComponentB componentB; - private ComponentC[] componentC; - private List componentD; - private Map componentE; - - public ComponentA getComponentA() { - return componentA; - } - - public void setComponentA(ComponentA componentA) { - this.componentA = componentA; - } - - public ComponentB getComponentB() { - return componentB; - } - - public void setComponentB(ComponentB componentB) { - this.componentB = componentB; - } - - public ComponentC[] getComponentC() { - return componentC; - } - - public void setComponentC(ComponentC[] componentC) { - this.componentC = componentC; - } - - public List getComponentD() { - return componentD; - } - - public void setComponentD(List componentD) { - this.componentD = componentD; - } - - public Map getComponentE() { - return componentE; - } - - public void setComponentE(Map componentE) { - this.componentE = componentE; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentRealmCompositionTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentRealmCompositionTest.java deleted file mode 100644 index c7c5ba920..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentRealmCompositionTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.codehaus.plexus.component.composition; - -import java.io.File; -import java.net.URL; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.classworlds.realm.ClassRealm; - -import static org.codehaus.plexus.PlexusConstants.PLEXUS_DEFAULT_HINT; - -/** @author Jason van Zyl */ -public class ComponentRealmCompositionTest extends PlexusTestCase { - // - // Component archives - // - private static final String PLUGIN_0_JAR = "src/test/test-components/plugin0-1.0-SNAPSHOT.jar"; - private static final String PLUGIN_1_JAR = "src/test/test-components/plugin1-1.0-SNAPSHOT.jar"; - private static final String COMPONENT_A_JAR = "src/test/test-components/component-a-1.0-SNAPSHOT.jar"; - private static final String COMPONENT_B_JAR = "src/test/test-components/component-b-1.0-SNAPSHOT.jar"; - private static final String COMPONENT_C_JAR = "src/test/test-components/component-c-1.0-SNAPSHOT.jar"; - private static final String ARCHIVER_JAR = "src/test/test-components/plexus-archiver-1.0-alpha-8.jar"; - - // - // Component roles - // - private static final String PLUGIN_0_ROLE = "org.codehaus.plexus.plugins.Plugin0"; - private static final String PLUGIN_1_ROLE = "org.codehaus.plexus.plugins.Plugin1"; - - // - // Component realms - // - private static final String PLUGIN_0_REALM = "plugin0Realm"; - private static final String PLUGIN_1_REALM = "plugin1Realm"; - - protected void setUp() throws Exception { - super.setUp(); - - // Create ClassRealm plugin0 with plugin0 -> A, plugin0 -> B - createClassRealm(PLUGIN_0_REALM, PLUGIN_0_JAR, COMPONENT_A_JAR, COMPONENT_B_JAR, ARCHIVER_JAR); - - // Create ClassRealm plugin1 with plugin1 -> A, plugin1 -> C - createClassRealm(PLUGIN_1_REALM, PLUGIN_1_JAR, COMPONENT_A_JAR, COMPONENT_C_JAR, ARCHIVER_JAR); - } - - /* - * We are testing that when the same component implementation exists in more then one - * realm and components depend on those implementations, that the right realm is used - * to wire up the components. - * - * An example of this in practice are Maven plugins where each plugin is loaded into - * a separate realm and the plugin may have dependencies on other components. We want - * to make sure that a requirement, say a JarArchiver, for a given component, say the - * maven-jar-plugin, is wired up with a JarArchiver taken from the same realm as the - * maven-jar-plugin and not a different realm. - */ - - public void testCompositionWhereTheSameImplementationExistsInDifferentRealms() throws Exception { - // Plugin0 - getContainer().lookup(PLUGIN_0_ROLE); - - // Plugin1 - getContainer().lookup(PLUGIN_1_ROLE); - - // Plugin0(alt) - getContainer().lookup(PLUGIN_0_ROLE, "alt"); - - // Plugin1(alt) - getContainer().lookup(PLUGIN_1_ROLE, "alt"); - } - - public void testThatASingletonComponentIntheCoreRealmWhenLookedUpInComponentRealmsYieldsTheSameInstance() - throws Exception {} - - public void testMultiRealmLookupMap() throws Exception { - Map plugin0Map = getContainer().lookupMap(PLUGIN_0_ROLE); - assertNotNull("plugin0Map is null", plugin0Map); - assertNotNull("plugin0Map does not contain a DefaultPlugin0", plugin0Map.get(PLEXUS_DEFAULT_HINT)); - assertNotNull("plugin0Map does not contain a AltPlugin0", plugin0Map.get("alt")); - assertEquals("Expected only 2 components in plugin0Map", 2, plugin0Map.size()); - - Map plugin1Map = getContainer().lookupMap(PLUGIN_1_ROLE); - assertNotNull("plugin1Map is null", plugin1Map); - assertNotNull("plugin1Map does not contain a DefaultPlugin1", plugin1Map.get(PLEXUS_DEFAULT_HINT)); - assertNotNull("plugin1Map does not contain a AltPlugin1", plugin1Map.get("alt")); - assertEquals("Expected only 2 components in plugin1Map", 2, plugin1Map.size()); - } - - public void testMultiRealmLookupList() throws Exception { - List plugin0List = getContainer().lookupList(PLUGIN_0_ROLE); - assertNotNull("plugin0List is null", plugin0List); - Map plugin0Map = mapByClassSimpleName(plugin0List); - assertNotNull("plugin0List does not contain a DefaultPlugin0", plugin0Map.get("DefaultPlugin0")); - assertNotNull("plugin0List does not contain a AltPlugin0", plugin0Map.get("AltPlugin0")); - assertEquals("Expected only 2 components in plugin0Map", 2, plugin0Map.size()); - - List plugin1List = getContainer().lookupList(PLUGIN_1_ROLE); - assertNotNull("plugin1List is null", plugin1List); - Map plugin1Map = mapByClassSimpleName(plugin1List); - assertNotNull("plugin1List does not contain a DefaultPlugin1", plugin1Map.get("DefaultPlugin1")); - assertNotNull("plugin1List does not contain a AltPlugin1", plugin1Map.get("AltPlugin1")); - assertEquals("Expected only 2 components in plugin0Map", 2, plugin1Map.size()); - } - - private ClassRealm createClassRealm(String id, String... jars) throws Exception { - // create the realm - ClassRealm classRealm = getContainer().createChildRealm(id); - - // populate the realm - for (String jar : jars) { - File file = new File(jar); - assertTrue(jar + " is not a file", file.isFile()); - - URL url = file.toURI().toURL(); - classRealm.addURL(url); - } - - // descover all component definitions in the realm and register them with the repository - getContainer().discoverComponents(classRealm); - - return classRealm; - } - - private Map mapByClassSimpleName(List objects) { - Map map = new TreeMap(); - for (Object object : objects) { - map.put(object.getClass().getSimpleName(), object); - } - return map; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java deleted file mode 100644 index b113c7e4a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Trygve Laugstøl - */ -public class ComponentWithSeveralFieldsOfTheSameType { - private ComponentE one; - - private ComponentE two; - - public ComponentE getOne() { - return one; - } - - public ComponentE getTwo() { - return two; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java deleted file mode 100644 index 708319e90..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultComponent extends AbstractComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java deleted file mode 100644 index 85da06c96..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultComponentA implements ComponentA { - private ComponentB componentB; - - private String host; - - private String port; - - // Just so we can retrieve the value of componentB for testing. */ - public ComponentB getComponentB() { - return componentB; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java deleted file mode 100644 index 71405d3e4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Jason van Zyl - * - */ -public class DefaultComponentB implements ComponentB { - private ComponentC componentC; - - public ComponentC getComponentC() { - return componentC; - } - - public void setComponentC(ComponentC componentC) { - System.out.println("Setting componentC:" + componentC); - - this.componentC = componentC; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java deleted file mode 100644 index 279f9fca3..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultComponentC implements ComponentC {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java deleted file mode 100644 index 9b8b12e72..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusTestCase; - -/** - * @author Michal Maczka - */ -public class DefaultComponentComposerManagerTest extends PlexusTestCase { - protected String getCustomConfigurationName() { - return "org/codehaus/plexus/component/composition/components.xml"; - } - - public void testComposition() throws Exception { - ComponentA componentA = lookup(ComponentA.class); - - assertNotNull(componentA); - - ComponentB componentB = componentA.getComponentB(); - - assertNotNull(componentB); - - ComponentC componentC = componentB.getComponentC(); - - assertNotNull(componentC); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java deleted file mode 100644 index 021e40dad..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultCompositionResolverTest extends AbstractCompositionResolverTest { - protected CompositionResolver getCompositionResolver() { - return new DefaultCompositionResolver(); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java deleted file mode 100644 index 2179af6be..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class AbstractComponent implements Component { - private String name; - - public String getName() { - return name; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java deleted file mode 100644 index e04e8c2bd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java +++ /dev/null @@ -1,850 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.io.File; -import java.io.StringReader; -import java.lang.annotation.ElementType; -import java.net.URI; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; - -/** - * @author Michal Maczka - */ -public abstract class AbstractComponentConfiguratorTest extends PlexusTestCase { - protected void configureComponent(Object component, ComponentDescriptor descriptor, ClassRealm realm) - throws Exception { - ComponentConfigurator cc = getComponentConfigurator(); - cc.configureComponent(component, descriptor.getConfiguration(), realm); - } - - protected void configureComponent( - Object component, ComponentDescriptor descriptor, ClassRealm realm, ExpressionEvaluator expressionEvaluator) - throws Exception { - ComponentConfigurator cc = getComponentConfigurator(); - cc.configureComponent(component, descriptor.getConfiguration(), expressionEvaluator, realm); - } - - protected abstract ComponentConfigurator getComponentConfigurator() throws Exception; - - public void testComponentConfigurator() throws Exception { - String xml = "" + " true" - + " 64" - + " -128" - + " -1" - + " 1" - + " 2" - + " 3" - + " X" - + " foo" - + " test.txt" - + " http://www.apache.org/" - + " http://maven.apache.org/" - + " " - + " jason" - + " tess" - + " " - + " " - + " jason" - + " " - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ConfigurableComponent component = new ConfigurableComponent(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals("check boolean value", true, component.getBooleanValue()); - - assertEquals("check byte value", 64, component.getByteValue()); - - assertEquals("check short value", -128, component.getShortValue()); - - assertEquals("check integer value", -1, component.getIntValue()); - - assertEquals("check float value", 1.0f, component.getFloatValue(), 0.001f); - - assertEquals("check long value", 2L, component.getLongValue()); - - assertEquals("check double value", 3.0, component.getDoubleValue(), 0.001); - - assertEquals('X', component.getCharValue()); - - assertEquals("foo", component.getStringValue()); - - assertEquals(new File("test.txt"), component.getFileValue()); - - assertEquals(new URI("http://www.apache.org/"), component.getUriValue()); - - assertEquals(new URL("http://maven.apache.org/"), component.getUrlValue()); - - List list = component.getImportantThings(); - - assertEquals(2, list.size()); - - assertEquals("jason", ((ImportantThing) list.get(0)).getName()); - - assertEquals("tess", ((ImportantThing) list.get(1)).getName()); - - // Embedded Configuration - - PlexusConfiguration c = component.getConfiguration(); - - assertEquals("jason", c.getChild("name").getValue()); - } - - public void testComponentConfiguratorWithAComponentThatProvidesSettersForConfiguration() throws Exception { - String xml = "" + " 0" + " 1" - + " 2" + " 3" - + " foo" + " " - + " jason" - + " tess" + " " - + " " + " jason" + " " + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithSetters component = new ComponentWithSetters(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals("check integer value", 0, component.getIntValue()); - - assertTrue(component.intValueSet); - - assertEquals("check float value", 1.0f, component.getFloatValue(), 0.001f); - - assertTrue(component.floatValueSet); - - assertEquals("check long value", 2L, component.getLongValue()); - - assertTrue(component.longValueSet); - - assertEquals("check double value", 3.0, component.getDoubleValue(), 0.001); - - assertTrue(component.doubleValueSet); - - assertEquals("foo", component.getStringValue()); - - assertTrue(component.stringValueSet); - - List list = component.getImportantThings(); - - assertEquals(2, list.size()); - - assertEquals("jason", ((ImportantThing) list.get(0)).getName()); - - assertEquals("tess", ((ImportantThing) list.get(1)).getName()); - - assertTrue(component.importantThingsValueSet); - - // Embedded Configuration - - PlexusConfiguration c = component.getConfiguration(); - - assertEquals("jason", c.getChild("name").getValue()); - - assertTrue(component.configurationValueSet); - } - - public void testComponentConfigurationWhereFieldsToConfigureResideInTheSuperclass() throws Exception { - String xml = "" + " jason" + "
bollywood
" + "
"; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - DefaultComponent component = new DefaultComponent(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals("jason", component.getName()); - - assertEquals("bollywood", component.getAddress()); - } - - public void testComponentConfigurationWhereFieldsAreCollections() throws Exception { - String xml = "" + " " + " " + " life" - + " " + " " + " " + " " - + " life" + " " + " " - + " " + " " - + " life" + " " + " " + " " - + " abc" + " def" + " " - + " abc" - + " abc" + - // TODO: implement List etc.. - // "" + - // " 12" + - // " 34" + - // "" + - ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithCollectionFields component = new ComponentWithCollectionFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - Vector vector = component.getVector(); - - assertEquals("life", ((ImportantThing) vector.get(0)).getName()); - - assertEquals(1, vector.size()); - - Set set = component.getHashSet(); - - assertEquals(1, set.size()); - - Object[] setContents = set.toArray(); - - assertEquals("life", ((ImportantThing) setContents[0]).getName()); - - List list = component.getList(); - - assertEquals(list.getClass(), LinkedList.class); - - assertEquals("life", ((ImportantThing) list.get(0)).getName()); - - assertEquals(1, list.size()); - - List stringList = component.getStringList(); - - assertEquals("abc", (String) stringList.get(0)); - - assertEquals("def", (String) stringList.get(1)); - - assertEquals(2, stringList.size()); - - set = component.getSet(); - - assertEquals(1, set.size()); - - set = component.getSortedSet(); - - assertEquals(1, set.size()); - } - - public void testComponentConfigurationWhereFieldsAreArrays() throws Exception { - String xml = "" + " " + " value1" - + " value2" + " " + " " - + " 42" + " 69" + " " - + " " + " Hello" - + " World!" + " " - + " " + " some string" - + " something important" - + " 303" + " " - + " " - + " http://foo.com/bar" + " file://localhost/c:/windows" + " " - + " " + " c:/windows" + " /usr/local/bin/foo.sh" - + " " + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithArrayFields component = new ComponentWithArrayFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - String[] stringArray = component.getStringArray(); - - assertEquals(2, stringArray.length); - - assertEquals("value1", stringArray[0]); - - assertEquals("value2", stringArray[1]); - - Integer[] integerArray = component.getIntegerArray(); - - assertEquals(2, integerArray.length); - - assertEquals(new Integer(42), integerArray[0]); - - assertEquals(new Integer(69), integerArray[1]); - - ImportantThing[] importantThingArray = component.getImportantThingArray(); - - assertEquals(2, importantThingArray.length); - - assertEquals("Hello", importantThingArray[0].getName()); - - assertEquals("World!", importantThingArray[1].getName()); - - Object[] objectArray = component.getObjectArray(); - - assertEquals(3, objectArray.length); - - assertEquals("some string", objectArray[0]); - - assertEquals("something important", ((ImportantThing) objectArray[1]).getName()); - - assertEquals(303, objectArray[2]); - - URL[] urls = component.getUrlArray(); - - assertEquals(new URL("http://foo.com/bar"), urls[0]); - - assertEquals(new URL("file://localhost/c:/windows"), urls[1]); - - File[] files = component.getFileArray(); - - assertEquals(new File("c:/windows"), files[0]); - - assertEquals(new File("/usr/local/bin/foo.sh"), files[1]); - } - - public void testComponentConfigurationWithCompositeFields() throws Exception { - - String xml = "" - + " " - + " I am not abstract!" + " " + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithCompositeFields component = new ComponentWithCompositeFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertNotNull(component.getThing()); - - assertEquals("I am not abstract!", component.getThing().getName()); - } - - public void testInvalidComponentConfiguration() throws Exception { - - String xml = "theName"; - - try { - PlexusTools.buildConfiguration("", new StringReader(xml)); - - fail("Should have caused an error because of the invalid XML."); - } catch (PlexusConfigurationException e) { - // Error should be caught here. - } catch (Exception e) { - fail("Should have caught the invalid plexus configuration exception."); - } - } - - public void testComponentConfigurationWithPropertiesFields() throws Exception { - - String xml = "" + " " + " " + " firstname" - + " michal" + " " + " " - + " lastname" + " maczka" + " " - + " " + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithPropertiesField component = new ComponentWithPropertiesField(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - Properties properties = component.getSomeProperties(); - - assertNotNull(properties); - - assertEquals("michal", properties.get("firstname")); - - assertEquals("maczka", properties.get("lastname")); - } - - public void testComponentConfigurationWithPropertiesFieldsWithExpression() throws Exception { - - String xml = - "" + " ${injectedProperties} " + ""; - - final Properties propertiesInterpolated = new Properties(); - propertiesInterpolated.put("firstname", "olivier"); - propertiesInterpolated.put("lastname", "lamy"); - - ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator() { - public Object evaluate(String expression) { - return propertiesInterpolated; - } - - public File alignToBaseDirectory(File file) { - return null; - } - }; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithPropertiesField component = new ComponentWithPropertiesField(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm, expressionEvaluator); - - Properties properties = component.getSomeProperties(); - - assertNotNull(properties); - - assertEquals("olivier", properties.get("firstname")); - - assertEquals("lamy", properties.get("lastname")); - } - - public void testComponentConfigurationWithPropertiesFieldsWithExpressions() throws Exception { - - String xml = "" + "" // - + "${theName}${theValue}" // - + "empty" // - + "" + ""; - - final Properties values = new Properties(); - values.put("${theName}", "test"); - values.put("${theValue}", "PASSED"); - - ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator() { - public Object evaluate(String expression) { - return values.containsKey(expression) ? values.get(expression) : expression; - } - - public File alignToBaseDirectory(File file) { - return null; - } - }; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithPropertiesField component = new ComponentWithPropertiesField(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm, expressionEvaluator); - - Properties properties = component.getSomeProperties(); - - assertNotNull(properties); - - assertEquals("PASSED", properties.get("test")); - assertEquals("", properties.get("empty")); - } - - public void testComponentConfigurationWithMapField() throws Exception { - String xml = "" + " " + " Kenney" - + " Westerhof" + " " + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithMapField component = new ComponentWithMapField(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - Map map = component.getMap(); - - assertNotNull(map); - - assertEquals("Kenney", map.get("firstName")); - - assertEquals("Westerhof", map.get("lastName")); - } - - public void testComponentConfigurationWhereFieldIsBadArray() throws Exception { - String xml = "" // - + " string" // - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithArrayFields component = new ComponentWithArrayFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - try { - configureComponent(component, descriptor, realm); - fail("Configuration did not fail"); - } catch (ComponentConfigurationException e) { - } - } - - public void testComponentConfigurationWhereFieldIsEnum() throws Exception { - String xml = "" // - + " TYPE" // - + " ONE" // - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithEnumFields component = new ComponentWithEnumFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals(ElementType.TYPE, component.getSimpleEnum()); - - assertEquals(ComponentWithEnumFields.NestedEnum.ONE, component.getNestedEnum()); - } - - public void testComponentConfigurationWithAmbiguousExpressionValue() throws Exception { - String xml = "" // - + "
${address}
" // - + "
"; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - DefaultComponent component = new DefaultComponent(); - - ExpressionEvaluator expressionEvaluator = new TypeAwareExpressionEvaluator() { - public Object evaluate(String expression) throws ExpressionEvaluationException { - return evaluate(expression, null); - } - - public File alignToBaseDirectory(File file) { - return null; - } - - public Object evaluate(String expression, Class type) throws ExpressionEvaluationException { - if (String.class == type) { - return "PASSED"; - } else { - return Boolean.FALSE; - } - } - }; - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm, expressionEvaluator); - - assertEquals("PASSED", component.getAddress()); - } - - public void testComponentConfigurationWithPrimitiveValueConversion() throws Exception { - String xml = "" // - + " ${primitive}" // - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ConfigurableComponent component = new ConfigurableComponent(); - - ExpressionEvaluator expressionEvaluator = new TypeAwareExpressionEvaluator() { - public Object evaluate(String expression) throws ExpressionEvaluationException { - return evaluate(expression, null); - } - - public File alignToBaseDirectory(File file) { - return null; - } - - public Object evaluate(String expression, Class type) throws ExpressionEvaluationException { - // java.lang.Short -> short -> int - return (short) 23; - } - }; - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm, expressionEvaluator); - - assertEquals(23, component.getIntValue()); - } - - public void testComponentConfigurationWithEmptyContentForBasicField() throws Exception { - String xml = "" // - + "
" // - + "
"; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - DefaultComponent component = new DefaultComponent(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals(null, component.getAddress()); - } - - public void testComponentConfigurationWithEmptyContentForCompositeField() throws Exception { - String xml = "" // - + " " // - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithCompositeFields component = new ComponentWithCompositeFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertNotNull(component.getBean()); - } - - public void testComponentConfigurationWithUnresolvedExpressionContentForCompositeFieldOfNonInstantiatableType() - throws Exception { - String xml = "" // - + " ${null-valued-expression}" // - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithCompositeFields component = new ComponentWithCompositeFields(); - - ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator() { - public Object evaluate(String expression) throws ExpressionEvaluationException { - return null; - } - - public File alignToBaseDirectory(File file) { - return null; - } - }; - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm, expressionEvaluator); - - assertEquals(null, component.getThing()); - } - - public void testComponentConfiguratorFileNormalizesSeparator() throws Exception { - String xml = "" + " dir/test.txt" - + " dir\\test.txt" - + ""; - - PlexusConfiguration configuration = PlexusTools.buildConfiguration("", new StringReader(xml)); - - ComponentWithArrayFields component = new ComponentWithArrayFields(); - - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setRole("role"); - - descriptor.setImplementation(component.getClass().getName()); - - descriptor.setConfiguration(configuration); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm realm = classWorld.newRealm("test", getClass().getClassLoader()); - - configureComponent(component, descriptor, realm); - - assertEquals(new File("dir", "test.txt"), component.getFileArray()[0]); - assertEquals(new File("dir", "test.txt"), component.getFileArray()[1]); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractThing.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractThing.java deleted file mode 100644 index 5e6dbda57..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractThing.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public abstract class AbstractThing {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/BasicComponentConfiguratorTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/BasicComponentConfiguratorTest.java deleted file mode 100644 index 5e4645027..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/BasicComponentConfiguratorTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public class BasicComponentConfiguratorTest extends AbstractComponentConfiguratorTest { - protected ComponentConfigurator getComponentConfigurator() throws Exception { - return new BasicComponentConfigurator(); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java deleted file mode 100644 index de3edd21a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Component {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java deleted file mode 100644 index f797ce82b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.io.File; -import java.net.URL; - -/** - * @author Kenney Westerhof - */ -public class ComponentWithArrayFields { - private String[] stringArray; - - private Integer[] integerArray; - - private ImportantThing[] importantThingArray; - - private Object[] objectArray; - - private AbstractThing[] abstractArray; - - private URL[] urlArray; - - private File[] fileArray; - - public String[] getStringArray() { - return stringArray; - } - - public Integer[] getIntegerArray() { - return integerArray; - } - - public ImportantThing[] getImportantThingArray() { - return importantThingArray; - } - - public Object[] getObjectArray() { - return objectArray; - } - - public AbstractThing[] getAbstractThingArray() { - return abstractArray; - } - - public URL[] getUrlArray() { - return urlArray; - } - - public File[] getFileArray() { - return fileArray; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java deleted file mode 100644 index 9bbb1316f..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.Vector; - -/** - * @author Michal Maczka - */ -public class ComponentWithCollectionFields { - private Vector vector; - - private HashSet hashSet; - - private List list; - - private List stringList; - - private Set set; - - private SortedSet sortedSet; - - public Vector getVector() { - return vector; - } - - public HashSet getHashSet() { - return hashSet; - } - - public List getList() { - return list; - } - - public List getStringList() { - return stringList; - } - - public Set getSet() { - return set; - } - - public SortedSet getSortedSet() { - return sortedSet; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java deleted file mode 100644 index 9dcc359ab..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * - * @author Michal Maczka - * - */ -public class ComponentWithCompositeFields { - private ThingInterface thing; - - private DefaultComponent bean; - - public ThingInterface getThing() { - return thing; - } - - public DefaultComponent getBean() { - return bean; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java deleted file mode 100644 index da964b449..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.lang.annotation.ElementType; - -/** - * @author Benjamin Bentmann - */ -public class ComponentWithEnumFields { - - public enum NestedEnum { - ONE, - TWO, - THREE, - } - - private NestedEnum nestedEnum; - - private ElementType simpleEnum; - - public NestedEnum getNestedEnum() { - return nestedEnum; - } - - public ElementType getSimpleEnum() { - return simpleEnum; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java deleted file mode 100644 index 2dac3d9d0..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Map; - -/** - * - * @author Michal Maczka - * - */ -public class ComponentWithMapField { - private Map map; - - public Map getMap() { - return map; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java deleted file mode 100644 index fef0c5b6a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Properties; - -/** - * - * @author Michal Maczka - * - */ -public class ComponentWithPropertiesField { - private Properties someProperties; - - public Properties getSomeProperties() { - return someProperties; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java deleted file mode 100644 index 8387adbd7..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.List; - -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ComponentWithSetters { - private int intValueVariable; - private float floatValueVariable; - private long longValueVariable; - private double doubleValueVariable; - private String stringValueVariable; - private List importantThingsVariable; - private PlexusConfiguration configurationVariable; - - public int getIntValue() { - return intValueVariable; - } - - public float getFloatValue() { - return floatValueVariable; - } - - public long getLongValue() { - return longValueVariable; - } - - public double getDoubleValue() { - return doubleValueVariable; - } - - public String getStringValue() { - return stringValueVariable; - } - - public List getImportantThings() { - return importantThingsVariable; - } - - public PlexusConfiguration getConfiguration() { - return configurationVariable; - } - - // ---------------------------------------------------------------------- - // setters - // ---------------------------------------------------------------------- - - boolean intValueSet; - boolean floatValueSet; - boolean longValueSet; - boolean doubleValueSet; - boolean stringValueSet; - boolean importantThingsValueSet; - boolean configurationValueSet; - - public void setIntValue(int intValue) { - this.intValueVariable = intValue; - - intValueSet = true; - } - - public void setFloatValue(float floatValue) { - this.floatValueVariable = floatValue; - - floatValueSet = true; - } - - public void setLongValue(long longValue) { - this.longValueVariable = longValue; - - longValueSet = true; - } - - public void setDoubleValue(double doubleValue) { - this.doubleValueVariable = doubleValue; - - doubleValueSet = true; - } - - public void setStringValue(String stringValue) { - this.stringValueVariable = stringValue; - - stringValueSet = true; - } - - public void setImportantThings(List importantThings) { - this.importantThingsVariable = importantThings; - - importantThingsValueSet = true; - } - - public void setConfiguration(PlexusConfiguration configuration) { - this.configurationVariable = configuration; - - configurationValueSet = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java deleted file mode 100644 index e98a465fb..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.io.File; -import java.net.URI; -import java.net.URL; -import java.util.List; - -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ConfigurableComponent { - private boolean booleanValue; - private byte byteValue; - private short shortValue; - private int intValue; - private float floatValue; - private long longValue; - private double doubleValue; - private char charValue; - private String stringValue; - private File fileValue; - private URI uriValue; - private URL urlValue; - private List importantThings; - private PlexusConfiguration configuration; - - public boolean getBooleanValue() { - return booleanValue; - } - - public int getByteValue() { - return byteValue; - } - - public int getShortValue() { - return shortValue; - } - - public int getIntValue() { - return intValue; - } - - public float getFloatValue() { - return floatValue; - } - - public long getLongValue() { - return longValue; - } - - public double getDoubleValue() { - return doubleValue; - } - - public char getCharValue() { - return charValue; - } - - public String getStringValue() { - return stringValue; - } - - public File getFileValue() { - return fileValue; - } - - public URI getUriValue() { - return uriValue; - } - - public URL getUrlValue() { - return urlValue; - } - - public List getImportantThings() { - return importantThings; - } - - public PlexusConfiguration getConfiguration() { - return configuration; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java deleted file mode 100644 index 2ac3f6a34..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultComponent extends AbstractComponent { - private String address; - - public String getAddress() { - return address; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java deleted file mode 100644 index 8506f56d4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ImportantThing extends AbstractThing implements ThingInterface { - private String name; - - public String getName() { - return name; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ThingInterface.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ThingInterface.java deleted file mode 100644 index e35a622f6..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ThingInterface.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -/* - * The MIT License - * - * Copyright (c) 2004, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -public interface ThingInterface { - String getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java deleted file mode 100644 index 08a52fac3..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.codehaus.plexus.component.configurator; - -import org.apache.xbean.recipe.ConstructionException; -import org.apache.xbean.recipe.DefaultExecutionContext; -import org.apache.xbean.recipe.ExecutionContext; -import org.apache.xbean.recipe.ObjectRecipe; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.builder.XBeanComponentBuilder; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class XBeanComponentConfiguratorTest extends AbstractComponentConfiguratorTest { - @Override - protected void configureComponent(Object component, ComponentDescriptor descriptor, ClassRealm realm) - throws Exception { - XBeanComponentBuilder componentBuilder = new XBeanComponentBuilder(); - ObjectRecipe recipe = componentBuilder.createObjectRecipe(component, descriptor, realm); - - // need a caller context - ExecutionContext executionContext = new DefaultExecutionContext(); - executionContext.push(new ObjectRecipe(component.getClass())); - - // call the recipie setProperties directly, but setup the thead state first - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(realm); - ExecutionContext.setContext(executionContext); - try { - recipe.setProperties(component); - } catch (ConstructionException e) { - throw new ComponentConfigurationException("Failed to configure component", e); - } finally { - ExecutionContext.setContext(null); - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - protected void configureComponent( - Object component, ComponentDescriptor descriptor, ClassRealm realm, ExpressionEvaluator expressionEvaluator) - throws Exception { - this.configureComponent(component, descriptor, realm); - } - - public void testComponentConfigurationWithPropertiesFieldsWithExpression() throws Exception { - // expression evalator is not supported since it is not used by normal AutoConfigurePhase - } - - public void testComponentConfigurationWithPropertiesFieldsWithExpressions() throws Exception { - // expression evalator is not supported since it is not used by normal AutoConfigurePhase - } - - public void testComponentConfigurationWithAmbiguousExpressionValue() throws Exception { - // expression evalator is not supported since it is not used by normal AutoConfigurePhase - } - - public void testComponentConfigurationWithPrimitiveValueConversion() throws Exception { - // expression evalator is not supported since it is not used by normal AutoConfigurePhase - } - - public void testComponentConfigurationWithUnresolvedExpressionContentForCompositeFieldOfNonInstantiatableType() - throws Exception { - // expression evalator is not supported since it is not used by normal AutoConfigurePhase - } - - protected ComponentConfigurator getComponentConfigurator() throws Exception { - // this should never be called because the configureComponent is overridden - throw new UnsupportedOperationException(); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java deleted file mode 100644 index 7f18ad12b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.context.DefaultContext; - -/** - * @author Jason van Zyl - * - */ -public class ComponentDiscovererTest extends PlexusTestCase { - public void testDefaultComponentDiscoverer() throws Exception { - ComponentDiscoverer componentDiscoverer = new DefaultComponentDiscoverer(); - - ClassWorld classWorld = new ClassWorld(); - - ClassRealm core = classWorld.newRealm("core"); - - File testClasses = new File(getBasedir(), "target/test-classes"); - - core.addURL(testClasses.toURL()); - - File classes = new File(getBasedir(), "target/classes"); - - core.addURL(classes.toURL()); - - List componentSetDescriptors = - componentDiscoverer.findComponents(new DefaultContext(), core); - - ComponentDescriptor componentDescriptor = byImplementation(componentSetDescriptors) - .get("org.codehaus.plexus.component.discovery.DefaultDiscoveredComponent"); - - assertNotNull("componentDescriptor is null", componentDescriptor); - - assertEquals("org.codehaus.plexus.component.discovery.DiscoveredComponent", componentDescriptor.getRole()); - - assertEquals( - "org.codehaus.plexus.component.discovery.DefaultDiscoveredComponent", - componentDescriptor.getImplementation()); - } - - private static Map> byImplementation(List descriptorSets) { - TreeMap> index = new TreeMap>(); - for (ComponentSetDescriptor descriptorSet : descriptorSets) { - for (ComponentDescriptor descriptor : descriptorSet.getComponents()) { - index.put(descriptor.getImplementation(), descriptor); - } - } - return index; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java deleted file mode 100644 index d1197a6b9..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultDiscoveredComponent implements DiscoveredComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java deleted file mode 100644 index 0c0580fa1..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.component.discovery; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface DiscoveredComponent { - String ROLE = DiscoveredComponent.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java deleted file mode 100644 index b96679973..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Michal Maczka - * @version $Id$ - */ -public interface Component {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java deleted file mode 100644 index 48686223c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ComponentImplA implements Component {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java deleted file mode 100644 index 49babe9aa..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Michal Maczka - * @version $Id$ - */ -public class ComponentImplB {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java deleted file mode 100644 index 5d98f904b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Michal Maczka - * @version $Id$ - */ -public abstract class ComponentImplC {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/DiscoveredComponentFactoryTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/DiscoveredComponentFactoryTest.java deleted file mode 100644 index 67177a86b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/DiscoveredComponentFactoryTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class DiscoveredComponentFactoryTest extends PlexusTestCase { - public void testShouldFindComponentFactoriesDefinedInBothPlexusXmlAndComponentsXml() throws Exception { - assertNotNull( - "Cannot find test component factory from plexus.xml test resource.", - lookup(ComponentFactory.class, "testFactory1")); - - assertNotNull( - "Cannot find test component factory from components.xml test resource.", - lookup(ComponentFactory.class, "testFactory2")); - } - - public void testShouldInstantiateComponentUsingFactoryDiscoveredInPlexusXml() throws Exception {} - - public void testShouldInstantiateComponentUsingFactoryDiscoveredInComponentsXml() throws Exception { - lookupTestComponent("testFactory2"); - } - - private void lookupTestComponent(String factoryId) throws Exception { - ComponentDescriptor descriptor = new ComponentDescriptor(); - - descriptor.setComponentFactory(factoryId); - - descriptor.setRole("role"); - - descriptor.setRoleHint("hint"); - - descriptor.setImplementation("something interesting"); - - getContainer().addComponentDescriptor(descriptor); - - Object component = lookup("role", "hint"); - - assertTrue(component instanceof TestFactoryResultComponent); - - assertEquals(factoryId, ((TestFactoryResultComponent) component).getFactoryId()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory1.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory1.java deleted file mode 100644 index ad120eb98..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory1.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class TestComponentFactory1 implements ComponentFactory { - - public String getId() { - return "testFactory1"; - } - - public Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException { - return new TestFactoryResultComponent(getId()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory2.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory2.java deleted file mode 100644 index 052b9a1b5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory2.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class TestComponentFactory2 implements ComponentFactory { - - public String getId() { - return "testFactory2"; - } - - public Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException { - return new TestFactoryResultComponent(getId()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestFactoryResultComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestFactoryResultComponent.java deleted file mode 100644 index ae80517d5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestFactoryResultComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.codehaus.plexus.component.factory; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class TestFactoryResultComponent { - - private final String factoryId; - - public TestFactoryResultComponent(String factoryId) { - this.factoryId = factoryId; - } - - public String getFactoryId() { - return factoryId; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java deleted file mode 100644 index 80e75a1e4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.codehaus.plexus.component.factory.java; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.component.factory.Component; -import org.codehaus.plexus.component.factory.ComponentImplA; -import org.codehaus.plexus.component.factory.ComponentImplB; -import org.codehaus.plexus.component.factory.ComponentImplC; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** - * @author Jason van Zyl - * @author Michal Maczka - */ -public class JavaComponentFactoryTest extends TestCase { - public void testComponentCreation() throws Exception { - JavaComponentFactory factory = new JavaComponentFactory(); - - ComponentDescriptor componentDescriptor = new ComponentDescriptor(); - - componentDescriptor.setRole(Component.class.getName()); - - componentDescriptor.setImplementation(ComponentImplA.class.getName()); - - ClassWorld classWorld = new ClassWorld(); - - classWorld.newRealm("core", Thread.currentThread().getContextClassLoader()); - - PlexusContainer container = new DefaultPlexusContainer(containerConfiguration(classWorld)); - - Object component = factory.newInstance(componentDescriptor, classWorld.getRealm("core"), container); - - assertNotNull(component); - } - - public void testComponentCreationWithNotMatchingRoleAndImplemenation() throws Exception { - JavaComponentFactory factory = new JavaComponentFactory(); - - ComponentDescriptor componentDescriptor = new ComponentDescriptor(); - - componentDescriptor.setRole(Component.class.getName()); - - componentDescriptor.setImplementation(ComponentImplB.class.getName()); - - ClassWorld classWorld = new ClassWorld(); - - classWorld.newRealm("core", Thread.currentThread().getContextClassLoader()); - - PlexusContainer container = new DefaultPlexusContainer(containerConfiguration(classWorld)); - - factory.newInstance(componentDescriptor, classWorld.getRealm("core"), container); - } - - public void testInstanciationOfAAbstractComponent() throws Exception { - JavaComponentFactory factory = new JavaComponentFactory(); - - ComponentDescriptor componentDescriptor = new ComponentDescriptor(); - - componentDescriptor.setRole(Component.class.getName()); - - componentDescriptor.setImplementation(ComponentImplC.class.getName()); - - ClassWorld classWorld = new ClassWorld(); - - classWorld.newRealm("core", Thread.currentThread().getContextClassLoader()); - - PlexusContainer container = new DefaultPlexusContainer(containerConfiguration(classWorld)); - - try { - factory.newInstance(componentDescriptor, classWorld.getRealm("core"), container); - - fail("Expected ComponentInstantiationException when instanciating a abstract class."); - } catch (ComponentInstantiationException ex) { - assertTrue(true); - } - } - - private ContainerConfiguration containerConfiguration(ClassWorld classWorld) { - ContainerConfiguration c = new DefaultContainerConfiguration().setClassWorld(classWorld); - - return c; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactory.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactory.java deleted file mode 100644 index 5b68cbf60..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.component.factory.nonjava; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.factory.ComponentFactory; -import org.codehaus.plexus.component.factory.ComponentInstantiationException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -/** @author Jason van Zyl */ -public class NonJavaComponentFactory implements ComponentFactory { - public String getId() { - return "nonjava"; - } - - public Object newInstance(ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container) - throws ComponentInstantiationException { - return "component"; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.java deleted file mode 100644 index 37d533a81..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.component.factory.nonjava; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.component.factory.ComponentFactory; - -/** @author Jason van Zyl */ -public class NonJavaComponentFactoryTest extends PlexusTestCase { - public void testNonJavaComponentFactory() throws Exception { - ComponentFactory factory = lookup(ComponentFactory.class, "nonjava"); - - assertNotNull(factory); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java deleted file mode 100644 index c22402336..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.codehaus.plexus.component.manager; - -import org.codehaus.plexus.PlexusTestCase; - -/** - * @author Ben Walding - */ -public class ClassicSingletonComponentManagerTest extends PlexusTestCase { - public void testSequentialLookupsReturnTheSameInstance() throws Exception { - Component a = lookup(Component.class); - - Component b = lookup(Component.class); - - Component c = lookup(Component.class); - - Component d = lookup(Component.class); - - assertTrue(a == b); - - assertTrue(a == c); - - assertTrue(a == d); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/Component.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/Component.java deleted file mode 100644 index b63639233..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/Component.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/** @author Jason van Zyl */ -public interface Component { - String ROLE = Component.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/DefaultComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/DefaultComponent.java deleted file mode 100644 index 28b5787b8..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/DefaultComponent.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/** @author Jason van Zyl */ -public class DefaultComponent implements Component {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java deleted file mode 100644 index 9bb04c1fd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; - -/** - * A slow starting component that checks that sleeps during its Start phase. - * - * Configuration: - * delay - number of milliseconds to sleep during start() - * @author Ben Walding - */ -public class SlowComponent implements Startable { - public static final String ROLE = SlowComponent.class.getName(); - - /* Number of ms to sleep during start() */ - private long delay; - - public void start() { - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - } - } - - public void stop() {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java deleted file mode 100644 index b5d8fb3f5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.codehaus.plexus.component.manager; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusTestCase; - -/** - * @author Ben Walding - */ -public class SlowComponentClassicSingletonComponentManagerTest extends PlexusTestCase { - public void testThreads1() throws Exception { - test(1); - } - - /** - * Tests that multiple concurrent threads don't acquire different components. - * @throws Exception in case of an error. - */ - public void testThreads1000() throws Exception { - test(1000); - } - - private void test(int count) throws Exception { - ComponentLookupThread components[] = new ComponentLookupThread[count]; - // Create them - for (int i = 0; i < count; i++) { - components[i] = new ComponentLookupThread(getContainer()); - } - // Start them - for (int i = 0; i < count; i++) { - components[i].start(); - } - - // Wait for them to finish - for (int i = 0; i < count; i++) { - components[i].join(10000); - } - - // Get master component - SlowComponent masterComponent = lookup(SlowComponent.class); - - // Verify them - for (int i = 0; i < count; i++) { - assertSame( - i + ":" + components[i].getComponent() + " == " + masterComponent, - masterComponent, - components[i].getComponent()); - } - } - - class ComponentLookupThread extends Thread { - final PlexusContainer container; - - private SlowComponent component; - - public ComponentLookupThread(PlexusContainer container) { - /* - * NOTE: A high priority seems to increase the likelihood of exhibiting missing synchronization. - */ - setPriority(MAX_PRIORITY); - this.container = container; - } - - public void run() { - try { - // DefaultPlexusContainer.setLookupRealm( lookupRealm ); - SlowComponent tmpComponent = container.lookup(SlowComponent.class); - - synchronized (this) { - this.component = tmpComponent; - } - } catch (Exception e) { - container.getLookupRealm().display(); - e.printStackTrace(); - } - } - - public SlowComponent getComponent() { - synchronized (this) { - return component; - } - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/DefaultComponentRegistryTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/DefaultComponentRegistryTest.java deleted file mode 100644 index 5821ba8ee..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/DefaultComponentRegistryTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.codehaus.plexus.component.registry; - -import junit.framework.TestCase; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -public class DefaultComponentRegistryTest extends TestCase { - - public void testConcurrentDisposeAndLookup() throws Exception { - final PlexusContainer plexus = new DefaultPlexusContainer(); - - ComponentDescriptor descriptor = new ComponentDescriptor( - TestSynchronizedComponent.class, plexus.getContainerRealm()); - descriptor.setRole(TestSynchronizedComponent.class.getCanonicalName()); - descriptor.setImplementation(TestSynchronizedComponent.class.getCanonicalName()); - plexus.addComponentDescriptor(descriptor); - - TestSynchronizedComponent component = plexus.lookup(TestSynchronizedComponent.class); - - class LookupThread extends Thread { - private TestSynchronizedComponent component; - - @Override - public synchronized void run() { - try { - this.component = plexus.lookup(TestSynchronizedComponent.class); - } catch (ComponentLookupException e) { - // expected - } - } - - public synchronized TestSynchronizedComponent getComponent() { - return component; - } - } - - LookupThread lookupThread = new LookupThread(); - - component.setLookupThread(lookupThread); - - plexus.dispose(); - - assertNull(lookupThread.getComponent()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/TestSynchronizedComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/TestSynchronizedComponent.java deleted file mode 100644 index 84e90e731..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/registry/TestSynchronizedComponent.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.component.registry; - -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; - -public class TestSynchronizedComponent implements Startable { - - private Thread lookupThread; - - public synchronized void start() throws StartingException {} - - public synchronized void stop() throws StoppingException { - lookupThread.start(); - try { - lookupThread.join(); - } catch (InterruptedException e) { - throw new StoppingException("Can't stop lookupThread", e); - } - } - - public synchronized void setLookupThread(Thread lookupThread) { - this.lookupThread = lookupThread; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java deleted file mode 100644 index 8e06ea351..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import junit.framework.TestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.io.PlexusTools; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ComponentDescriptorTest extends TestCase { - public void testSimpleComponentResolution() throws Exception { - String cc1 = "" + " java.lang.String" - + " c1" - + " role-hint" - + " component-profile" - + " " - + " " - + " c2" - + " " - + " " - + " c3" - + " " - + " " - + ""; - - ClassWorld classWorld = new ClassWorld("test", Thread.currentThread().getContextClassLoader()); - ClassRealm realm = classWorld.getRealm("test"); - - ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor(cc1, realm); - - assertEquals("c1", c1.getRole()); - - assertEquals("role-hint", c1.getRoleHint()); - - assertEquals("component-profile", c1.getComponentProfile()); - - List requirements = c1.getRequirements(); - - assertEquals(2, requirements.size()); - - boolean containsC2 = false; - - boolean containsC3 = false; - - for (ComponentRequirement requirement : requirements) { - if (requirement.getRole().equals("c2")) { - containsC2 = true; - } else if (requirement.getRole().equals("c3")) { - containsC3 = true; - } - } - - assertTrue(containsC2); - - assertTrue(containsC3); - } - - public void testShouldNotBeEqualWhenRolesAreSameButHintsAreDifferent() { - ComponentDescriptor desc = new ComponentDescriptor(); - desc.setRole("one"); - desc.setRoleHint("one"); - - ComponentDescriptor desc2 = new ComponentDescriptor(); - desc2.setRole("one"); - desc2.setRoleHint("two"); - - assertFalse(desc.equals(desc2)); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java deleted file mode 100644 index 95a10a8f3..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * @author Michal Maczka - */ -public class ComponentRequirementTest extends TestCase { - public void testComponentRequirement() { - ComponentRequirement requirement = new ComponentRequirement(); - requirement.setFieldName("field"); - requirement.setRole("role"); - - assertEquals("field", requirement.getFieldName()); - assertEquals("role", requirement.getRole()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java deleted file mode 100644 index 9ac15cb30..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; - -import junit.framework.TestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.io.PlexusTools; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ComponentSetTest extends TestCase { - public void testSimpleComponentResolution() throws Exception { - String xml = "" + " " - + " " - + " java.lang.String" - + " c1" - + " role-hint" - + " component-profile" - + " " - + " " - + " c2" - + " " - + " " - + " c3" - + " " - + " " - + " " - + " " - + " " - + " " - + " plexus" - + " wedgy" - + " 1.0" - + " " - + " " - + ""; - - ClassWorld classWorld = new ClassWorld("test", Thread.currentThread().getContextClassLoader()); - ClassRealm realm = classWorld.getRealm("test"); - - ComponentSetDescriptor cs = PlexusTools.buildComponentSet(PlexusTools.buildConfiguration(xml), realm); - - ComponentDescriptor c1 = cs.getComponents().get(0); - - assertEquals("c1", c1.getRole()); - - assertEquals("role-hint", c1.getRoleHint()); - - assertEquals("component-profile", c1.getComponentProfile()); - - List requirements = c1.getRequirements(); - - assertEquals(2, requirements.size()); - - boolean containsC2 = false; - - boolean containsC3 = false; - - for (ComponentRequirement requirement : requirements) { - if (requirement.getRole().equals("c2")) { - containsC2 = true; - } else if (requirement.getRole().equals("c3")) { - containsC3 = true; - } - } - - assertTrue(containsC2); - - assertTrue(containsC3); - - ComponentDependency d1 = cs.getDependencies().get(0); - - assertEquals("plexus", d1.getGroupId()); - - assertEquals("wedgy", d1.getArtifactId()); - - assertEquals("1.0", d1.getVersion()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java deleted file mode 100644 index 15ccc0548..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.component.repository; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultComponentRepositoryTest extends TestCase { - private static String configuration = "" + ""; - - public void testDefaultComponentRepository() {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java deleted file mode 100644 index 40ff32a65..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * - * - * @author Jason van Zyl - * - */ -public class ConfigurationResourceExceptionTest extends TestCase { - public void testException() { - PlexusConfigurationResourceException e = new PlexusConfigurationResourceException("bad doggy!"); - - assertEquals("bad doggy!", e.getMessage()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java deleted file mode 100644 index 574ebdf3f..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.StringReader; - -import junit.framework.TestCase; -import org.codehaus.plexus.component.repository.io.PlexusTools; - -/** - * @author Jason van Zyl - */ -public abstract class ConfigurationTestHelper extends TestCase { - public static PlexusConfiguration getTestConfiguration() throws Exception { - return PlexusTools.buildConfiguration( - "", new StringReader(ConfigurationTestHelper.getXmlConfiguration())); - } - - public static String getXmlConfiguration() { - return "" + "" - + "" - + "string" - + "0" - + "not-a-number" - + "true" - + "false" - + "not-a-boolean" - + ""; - } - - public static void testConfiguration(PlexusConfiguration c) throws Exception { - // Exercise all value/attribute retrieval methods. - - // Values - - // TODO: uncomment once maven can test the latest plexus-utils - // assertNull( c.getChild( "singleton" ).getValue( null ) ); - - // String - - assertEquals("string", c.getValue("string")); - - assertEquals("string", c.getChild("string").getValue()); - - assertEquals("string", c.getChild("ne-string").getValue("string")); - - assertNull(c.getChild("not-existing").getValue(null)); - - assertEquals("''", "'" + c.getChild("empty-element").getValue() + "'"); - - assertEquals("", c.getChild("empty-element").getValue(null)); - - // Attributes - - assertEquals("string", c.getChild("string").getAttribute("string")); - - assertEquals("attribute", c.getChild("singleton").getAttribute("attribute")); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java deleted file mode 100644 index 6db0494d3..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.codehaus.plexus.configuration; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * @author Ran Tene - */ -public final class DefaultPlexusConfigurationTest extends TestCase { - private DefaultPlexusConfiguration configuration; - - public void setUp() { - configuration = new DefaultPlexusConfiguration("a"); - } - - public void testWithHelper() throws Exception { - PlexusConfiguration c = ConfigurationTestHelper.getTestConfiguration(); - - ConfigurationTestHelper.testConfiguration(c); - } - - public void testGetValue() throws Exception { - String orgValue = "Original String"; - configuration.setValue(orgValue); - assertEquals(orgValue, configuration.getValue()); - } - - public void testGetAttribute() throws Exception { - String key = "key"; - String value = "original value"; - String defaultStr = "default"; - configuration.setAttribute(key, value); - assertEquals(value, configuration.getAttribute(key, defaultStr)); - assertEquals(defaultStr, configuration.getAttribute("newKey", defaultStr)); - } - - public void testGetChild() throws Exception { - DefaultPlexusConfiguration child = (DefaultPlexusConfiguration) configuration.getChild("child"); - - assertNotNull(child); - - child.setValue("child value"); - - assertEquals(1, configuration.getChildCount()); - - child = (DefaultPlexusConfiguration) configuration.getChild("child"); - - assertNotNull(child); - - assertEquals("child value", child.getValue()); - - assertEquals(1, configuration.getChildCount()); - } - - public void testToString() throws Exception { - // TODO: this currently works since getTestConfiguration() invokes PlexusTools.buildConfiguration() - // and it returns XmlPlexusConfiguration actually. - PlexusConfiguration c = ConfigurationTestHelper.getTestConfiguration(); - - assertEquals( - "string\n", - c.getChild("string").toString()); - - // TODO: uncomment once maven can test the latest plexus-utils - assertEquals( - "\n", - c.getChild("singleton").toString()); - } - - public void testProgrammaticConfigurationCreation() throws Exception { - String viewRoot = "/path/to/viewRoot"; - - PlexusConfiguration c = new DefaultPlexusConfiguration("configuration").addChild("viewRoot", viewRoot); - - assertEquals(viewRoot, c.getChild("viewRoot").getValue()); - } - - public void testChildOrdering() throws Exception { - PlexusConfiguration child0 = new DefaultPlexusConfiguration("child"); - PlexusConfiguration child1 = new DefaultPlexusConfiguration("child"); - PlexusConfiguration child2 = new DefaultPlexusConfiguration("special-child"); - PlexusConfiguration child3 = new DefaultPlexusConfiguration("child"); - PlexusConfiguration child4 = new DefaultPlexusConfiguration("child"); - - configuration.addChild(child0); - configuration.addChild(child1); - configuration.addChild(child2); - configuration.addChild(child3); - configuration.addChild(child4); - - assertEquals(5, configuration.getChildCount()); - assertSame(child0, configuration.getChild(0)); - assertSame(child1, configuration.getChild(1)); - assertSame(child2, configuration.getChild(2)); - assertSame(child3, configuration.getChild(3)); - assertSame(child4, configuration.getChild(4)); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReaderTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReaderTest.java deleted file mode 100644 index 2d9d02432..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationReaderTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.StringReader; - -import junit.framework.TestCase; -import org.codehaus.plexus.configuration.ConfigurationTestHelper; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public class XmlPlexusConfigurationReaderTest extends TestCase { - public void testRead() throws Exception { - StringReader sr = new StringReader(ConfigurationTestHelper.getXmlConfiguration()); - - XmlPlexusConfigurationReader reader = new XmlPlexusConfigurationReader(); - - PlexusConfiguration c = reader.read(sr); - - ConfigurationTestHelper.testConfiguration(c); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriterTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriterTest.java deleted file mode 100644 index 191b0ad61..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriterTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.codehaus.plexus.configuration.io; - -import java.io.StringReader; -import java.io.StringWriter; - -import junit.framework.TestCase; -import org.codehaus.plexus.configuration.ConfigurationTestHelper; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; - -public class XmlPlexusConfigurationWriterTest extends TestCase { - - public void testWrite() throws Exception { - PlexusConfiguration c = ConfigurationTestHelper.getTestConfiguration(); - - XmlPlexusConfigurationWriter cw = new XmlPlexusConfigurationWriter(); - - StringWriter writer = new StringWriter(); - - cw.write(writer, c); - - Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(writer.toString())); - - XmlPlexusConfiguration c1 = new XmlPlexusConfiguration(dom); - - ConfigurationTestHelper.testConfiguration(c1); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ADummyConfigurationSource.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ADummyConfigurationSource.java deleted file mode 100644 index 6a287b4c5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ADummyConfigurationSource.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public class ADummyConfigurationSource implements ConfigurationSource { - - public PlexusConfiguration getConfiguration(ComponentDescriptor componentDescriptor) { - return null; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/AnotherDummyConfigurationSource.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/AnotherDummyConfigurationSource.java deleted file mode 100644 index 1d726be04..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/AnotherDummyConfigurationSource.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -public class AnotherDummyConfigurationSource implements ConfigurationSource { - - private ConfigurationSource configurationSource; - - public PlexusConfiguration getConfiguration(ComponentDescriptor componentDescriptor) { - return null; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/DefaultConfigurationSourceTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/DefaultConfigurationSourceTest.java deleted file mode 100644 index 24432f9dd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/DefaultConfigurationSourceTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusTestCase; - -public class DefaultConfigurationSourceTest extends PlexusTestCase { - - public void testBasic() throws Exception { - // we have no plexus.xml, so the container should use the "default" source, - // which is ContainerConfigurationSource - - ConfigurationSource cs = ((MutablePlexusContainer) getContainer()).getConfigurationSource(); - - assertNotNull(cs); - - assertEquals(ContainerConfigurationSource.class.getName(), cs.getClass().getName()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.java deleted file mode 100644 index 292624c49..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusTestCase; - -public class ExtendingConfigurationSourceTest extends PlexusTestCase { - public void testBasic() throws Exception { - // we have plexus.xml with two configSources, so the container should use the "chained" case, - // which is ChainedConfigurationSource with 3 elem in list: the plexusDefaultConfig source, - // and the two user provided, in this order: ADummyConfigurationSource, AnotherDummyConfigurationSource - - ConfigurationSource cs = ((MutablePlexusContainer) getContainer()).getConfigurationSource(); - - assertNotNull(cs); - - assertEquals(ChainedConfigurationSource.class.getName(), cs.getClass().getName()); - - ChainedConfigurationSource ccs = (ChainedConfigurationSource) cs; - - // we have 3 config sources overall - assertEquals(3, ccs.getConfigurationSources().size()); - - // and the last in the source list is container source - assertEquals( - ContainerConfigurationSource.class.getName(), - ccs.getConfigurationSources().get(2).getClass().getName()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.java deleted file mode 100644 index 1b20009dc..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codehaus.plexus.configuration.source; - -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusTestCase; - -public class OverridingConfigurationSourceTest extends PlexusTestCase { - public void testBasic() throws Exception { - // we have plexus.xml with configSource that overrides the Plexus default one, so the container - // should use it instead of the "default" one - - ConfigurationSource cs = ((MutablePlexusContainer) getContainer()).getConfigurationSource(); - - assertNotNull(cs); - - assertEquals(ADummyConfigurationSource.class.getName(), cs.getClass().getName()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java deleted file mode 100644 index 18b5ab795..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.codehaus.plexus.configuration.xml; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; -import org.codehaus.plexus.configuration.ConfigurationTestHelper; -import org.codehaus.plexus.configuration.PlexusConfiguration; - -/** - * @author Ran Tene - */ -public final class XmlPlexusConfigurationTest extends TestCase { - private XmlPlexusConfiguration configuration; - - public void setUp() { - configuration = new XmlPlexusConfiguration("a"); - } - - public void testWithHelper() throws Exception { - PlexusConfiguration c = ConfigurationTestHelper.getTestConfiguration(); - - ConfigurationTestHelper.testConfiguration(c); - } - - public void testGetValue() throws Exception { - String orgValue = "Original String"; - configuration.setValue(orgValue); - assertEquals(orgValue, configuration.getValue()); - } - - public void testGetAttribute() throws Exception { - String key = "key"; - String value = "original value"; - String defaultStr = "default"; - configuration.setAttribute(key, value); - assertEquals(value, configuration.getAttribute(key, defaultStr)); - assertEquals(defaultStr, configuration.getAttribute("newKey", defaultStr)); - } - - public void testGetChild() throws Exception { - PlexusConfiguration child = (XmlPlexusConfiguration) configuration.getChild("child"); - - assertNotNull(child); - - child.setValue("child value"); - - assertEquals(1, configuration.getChildCount()); - - child = (XmlPlexusConfiguration) configuration.getChild("child"); - - assertNotNull(child); - - assertEquals("child value", child.getValue()); - - assertEquals(1, configuration.getChildCount()); - } - - public void testToString() throws Exception { - PlexusConfiguration c = ConfigurationTestHelper.getTestConfiguration(); - - assertEquals( - "string\n", - c.getChild("string").toString()); - - // TODO: uncomment once maven can test the latest plexus-utils - // assertEquals( "\n", c.getChild( "singleton" ).toString() ); - } - - public void testProgrammaticConfigurationCreation() throws Exception { - String viewRoot = "/path/to/viewRoot"; - - PlexusConfiguration c = new XmlPlexusConfiguration("configuration").addChild("viewRoot", viewRoot); - - assertEquals(viewRoot, c.getChild("viewRoot").getValue()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/context/ContextMapAdapterTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/context/ContextMapAdapterTest.java deleted file mode 100644 index a404dd108..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/context/ContextMapAdapterTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.codehaus.plexus.context; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.StringReader; -import java.io.StringWriter; - -import junit.framework.TestCase; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.InterpolationFilterReader; - -/** - * Generated by JUnitDoclet, a tool provided by ObjectFab GmbH under LGPL. - * Please see www.junitdoclet.org, www.gnu.org and www.objectfab.de for - * informations about the tool, the licence and the authors. - */ -public class ContextMapAdapterTest extends TestCase { - public ContextMapAdapterTest(String name) { - super(name); - } - - public void testInterpolation() throws Exception { - DefaultContext context = new DefaultContext(); - - context.put("name", "jason"); - - context.put("occupation", "exotic dancer"); - - ContextMapAdapter adapter = new ContextMapAdapter(context); - - assertEquals("jason", (String) adapter.get("name")); - - assertEquals("exotic dancer", (String) adapter.get("occupation")); - - assertNull(adapter.get("foo")); - } - - public void testInterpolationWithContext() throws Exception { - DefaultContext context = new DefaultContext(); - context.put("name", "jason"); - context.put("noun", "asshole"); - - String foo = "${name} is an ${noun}. ${not.interpolated}"; - - InterpolationFilterReader reader = - new InterpolationFilterReader(new StringReader(foo), new ContextMapAdapter(context)); - - StringWriter writer = new StringWriter(); - IOUtil.copy(reader, writer); - - String bar = writer.toString(); - assertEquals("jason is an asshole. ${not.interpolated}", bar); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/context/DefaultContextTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/context/DefaultContextTest.java deleted file mode 100644 index bd55956f2..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/context/DefaultContextTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.codehaus.plexus.context; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.HashMap; -import java.util.Map; - -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; - -/** - * TestCase for Context. - * - * @author Berin Loritsch - * @author Leo Sutic - */ -public class DefaultContextTest extends TestCase { - - public DefaultContextTest(String name) { - super(name); - } - - public void testContextCreationWithMap() throws Exception { - Map map = new HashMap(); - - map.put("name", "jason"); - - DefaultContext context = new DefaultContext(map); - - assertEquals("jason", (String) context.get("name")); - - assertEquals(map, context.getContextData()); - - // Test removal - context.put("name", null); - - // There is no data and no parent containerContext. - try { - context.get("name"); - } catch (ContextException e) { - // do nothing - } - } - - public void testAddContext() throws Exception { - DefaultContext context = new DefaultContext(); - context.put("key1", "value1"); - assertTrue("value1".equals(context.get("key1"))); - context.put("key1", ""); - assertTrue("".equals(context.get("key1"))); - - context.put("key1", "value1"); - context.makeReadOnly(); - - try { - context.put("key1", ""); - throw new AssertionFailedError("You are not allowed to change a value after it has been made read only"); - } catch (IllegalStateException ise) { - assertTrue("Value is null", "value1".equals(context.get("key1"))); - } - } - - public void testHiddenItems() throws ContextException { - // initalize - DefaultContext context = new DefaultContext(); - context.put("test", "test"); - - // verify inital state - assertTrue("test".equals(context.get("test"))); - - // hide value and verify - context.hide("test"); - try { - context.get("test"); - fail("The item \"test\" was hidden in the child containerContext, but could still be retrieved via get()."); - } catch (ContextException ce) { - assertTrue(true); - } - - // reset to inital state and verify - context.put("test", "test"); - assertTrue("test".equals(context.get("test"))); - - // mark context read-only and verify that item can not be hidden - context.makeReadOnly(); - try { - context.hide("test"); - fail("hide() did not throw an exception, even though the containerContext is supposed to be read-only."); - } catch (IllegalStateException ise) { - assertTrue(true); - } - - // verify state did not change in failed hide() invocation - assertTrue("test".equals(context.get("test"))); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusTestService.java b/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusTestService.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/TestServiceImpl.java b/plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/TestServiceImpl.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java deleted file mode 100644 index 21ab211b5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusTestCase; - -/** - * Abtract base class for testing implementations of the {@link LoggerManager} - * and {@link Logger} interfaces. - * - * @author Mark H. Wilkinson - * @author Trygve Laugstøl - * @version $Revision$ - */ -public abstract class AbstractLoggerManagerTest extends PlexusTestCase { - protected abstract LoggerManager createLoggerManager() throws Exception; - - public void testSetThreshold() throws Exception { - LoggerManager manager; - Logger logger1, logger2; - - manager = createLoggerManager(); - - manager.setThreshold(Logger.LEVEL_FATAL); - logger1 = manager.getLoggerForComponent("role1", "roleHint1"); - assertEquals(Logger.LEVEL_FATAL, logger1.getThreshold()); - - manager.setThreshold(Logger.LEVEL_DEBUG); - logger2 = manager.getLoggerForComponent("role2", "roleHint2"); - assertEquals(Logger.LEVEL_FATAL, logger1.getThreshold()); - assertEquals(Logger.LEVEL_DEBUG, logger2.getThreshold()); - } - - /** - * There is only one logger instance pr component even if looked up more that once. - * @throws Exception in case of an error. - */ - public void testActiveLoggerCount() throws Exception { - LoggerManager manager; - Logger b, c1_1, c1_2, c2; - - manager = getManager(Logger.LEVEL_FATAL); - assertEquals(0, manager.getActiveLoggerCount()); - - b = manager.getLoggerForComponent("b"); - assertNotNull(b); - assertEquals(1, manager.getActiveLoggerCount()); - - c1_1 = manager.getLoggerForComponent("c", "1"); - c1_2 = manager.getLoggerForComponent("c", "1"); - assertNotNull(c1_1); - assertNotNull(c1_2); - assertSame(c1_1, c1_2); - assertEquals(2, manager.getActiveLoggerCount()); - - c2 = manager.getLoggerForComponent("c", "2"); - assertNotNull(c2); - assertEquals(3, manager.getActiveLoggerCount()); - - manager.returnComponentLogger("c", "1"); - assertEquals(2, manager.getActiveLoggerCount()); - - manager.returnComponentLogger("c", "2"); - manager.returnComponentLogger("c", "2"); - manager.returnComponentLogger("c", "1"); - assertEquals(1, manager.getActiveLoggerCount()); - - manager.returnComponentLogger("b"); - assertEquals(0, manager.getActiveLoggerCount()); - } - - public void testDebugLevelConfiguration() throws Exception { - LoggerManager manager = getManager(Logger.LEVEL_DEBUG); - - Logger logger = extractLogger(manager); - - checkDebugLevel(logger); - - logger = extractLogger(manager); - - checkDebugLevel(logger); - } - - public void testInfoLevelConfiguration() throws Exception { - LoggerManager manager = getManager(Logger.LEVEL_INFO); - - Logger logger = extractLogger(manager); - - checkInfoLevel(logger); - - logger = extractLogger(manager); - - checkInfoLevel(logger); - } - - public void testWarnLevelConfiguration() throws Exception { - LoggerManager manager = getManager(Logger.LEVEL_WARN); - - Logger logger = extractLogger(manager); - - checkWarnLevel(logger); - - logger = extractLogger(manager); - - checkWarnLevel(logger); - } - - public void testErrorLevelConfiguration() throws Exception { - LoggerManager manager = getManager(Logger.LEVEL_ERROR); - - Logger logger = extractLogger(manager); - - checkErrorLevel(logger); - - logger = extractLogger(manager); - - checkErrorLevel(logger); - } - - public void testFatalLevelConfiguration() throws Exception { - LoggerManager manager = getManager(Logger.LEVEL_FATAL); - - Logger logger = extractLogger(manager); - - checkFatalLevel(logger); - - logger = extractLogger(manager); - - checkFatalLevel(logger); - } - - private LoggerManager getManager(int threshold) throws Exception { - LoggerManager manager = createLoggerManager(); - - manager.setThreshold(threshold); - - assertNotNull(manager); - - return manager; - } - /* - private Logger extractRootLogger( LoggerManager manager ) - { - Logger logger = manager.getRootLogger(); - - assertNotNull( logger ); - - return logger; - } - */ - private Logger extractLogger(LoggerManager manager) { - Logger logger = manager.getLoggerForComponent("foo"); - - assertNotNull(logger); - assertEquals("foo", logger.getName()); - - return logger; - } - - private void checkDebugLevel(Logger logger) { - assertTrue("debug enabled", logger.isDebugEnabled()); - assertTrue("info enabled", logger.isInfoEnabled()); - assertTrue("warn enabled", logger.isWarnEnabled()); - assertTrue("error enabled", logger.isErrorEnabled()); - assertTrue("fatal enabled", logger.isFatalErrorEnabled()); - } - - private void checkInfoLevel(Logger logger) { - assertFalse("debug disabled", logger.isDebugEnabled()); - assertTrue("info enabled", logger.isInfoEnabled()); - assertTrue("warn enabled", logger.isWarnEnabled()); - assertTrue("error enabled", logger.isErrorEnabled()); - assertTrue("fatal enabled", logger.isFatalErrorEnabled()); - } - - private void checkWarnLevel(Logger logger) { - assertFalse("debug disabled", logger.isDebugEnabled()); - assertFalse("info disabled", logger.isInfoEnabled()); - assertTrue("warn enabled", logger.isWarnEnabled()); - assertTrue("error enabled", logger.isErrorEnabled()); - assertTrue("fatal enabled", logger.isFatalErrorEnabled()); - } - - private void checkErrorLevel(Logger logger) { - assertFalse("debug disabled", logger.isDebugEnabled()); - assertFalse("info disabled", logger.isInfoEnabled()); - assertFalse("warn disabled", logger.isWarnEnabled()); - assertTrue("error enabled", logger.isErrorEnabled()); - assertTrue("fatal enabled", logger.isFatalErrorEnabled()); - } - - private void checkFatalLevel(Logger logger) { - assertFalse("debug disabled", logger.isDebugEnabled()); - assertFalse("info disabled", logger.isInfoEnabled()); - assertFalse("warn disabled", logger.isWarnEnabled()); - assertFalse("error disabled", logger.isErrorEnabled()); - assertTrue("fatal enabled", logger.isFatalErrorEnabled()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java deleted file mode 100644 index 96b93048b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusTestCase; - -// TODO: this test will get nuked, this needs to be done programmatically - -/** - * @author Trygve Laugstøl - */ -public class CustomLoggerManagerTest extends PlexusTestCase { - public void testBasic() throws Exception { - LoggerManager manager = lookup(LoggerManager.class); - - assertNotNull(manager); - - assertEquals(MockLoggerManager.class.getName(), manager.getClass().getName()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java deleted file mode 100644 index 26e0cbc25..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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 junit.framework.TestCase; - -/** - * - * @author peter at realityforge.org Peter Donald - */ -public class LogEnabledTest extends TestCase { - public void testGetLogger() throws Exception { - MockLogEnabled logEnabled = new MockLogEnabled(); - MockLogger logger = new MockLogger("base"); - logEnabled.enableLogging(logger); - assertEquals("logger", logger, logEnabled.getLogger()); - } - - public void testSetupLoggerOnLogEnabled() throws Exception { - MockLogEnabled logEnabled = new MockLogEnabled(); - MockLogEnabled childLogEnabled = new MockLogEnabled(); - MockLogger logger = new MockLogger("base"); - logEnabled.enableLogging(logger); - logEnabled.setupLogger(childLogEnabled); - assertEquals("logEnabled.logger", logger, logEnabled.getLogger()); - assertEquals("childLogEnabled.logger", logger, childLogEnabled.getLogger()); - } - - public void testSetupLoggerOnNonLogEnabled() throws Exception { - MockLogEnabled logEnabled = new MockLogEnabled(); - MockLogger logger = new MockLogger("base"); - logEnabled.enableLogging(logger); - logEnabled.setupLogger(new Object()); - } - - public void testSetupLoggerWithNameOnLogEnabled() throws Exception { - MockLogEnabled logEnabled = new MockLogEnabled(); - MockLogEnabled childLogEnabled = new MockLogEnabled(); - MockLogger logger = new MockLogger("base"); - logEnabled.enableLogging(logger); - logEnabled.setupLogger(childLogEnabled, "child"); - assertEquals("logEnabled.logger", logger, logEnabled.getLogger()); - assertEquals("childLogEnabled.logger.name", "base.child", ((MockLogger) childLogEnabled.getLogger()).getName()); - } - - public void testSetupLoggerWithNullName() throws Exception { - MockLogEnabled logEnabled = new MockLogEnabled(); - MockLogEnabled childLogEnabled = new MockLogEnabled(); - MockLogger logger = new MockLogger("base"); - logEnabled.enableLogging(logger); - try { - logEnabled.setupLogger(childLogEnabled, (String) null); - } catch (IllegalStateException npe) { - return; - } - fail("Expected to fail setting up child logger with null name"); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java deleted file mode 100644 index ddc136f04..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -class MockLogEnabled extends AbstractLogEnabled {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java deleted file mode 100644 index a403046be..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -class MockLogger implements Logger { - private final String m_name; - - MockLogger(String name) { - m_name = name; - } - - public String getName() { - return m_name; - } - - public Logger getChildLogger(final String name) { - return new MockLogger(getName() + "." + name); - } - - public void debug(String message) {} - - public void debug(String message, Throwable throwable) {} - - public boolean isDebugEnabled() { - return false; - } - - public void info(String message) {} - - public void info(String message, Throwable throwable) {} - - public boolean isInfoEnabled() { - return false; - } - - public void warn(String message) {} - - public void warn(String message, Throwable throwable) {} - - public boolean isWarnEnabled() { - return false; - } - - public boolean isFatalErrorEnabled() { - return false; - } - - public void fatalError(String message) {} - - public void fatalError(String message, Throwable throwable) {} - - public void error(String message) {} - - public void error(String message, Throwable throwable) {} - - public boolean isErrorEnabled() { - return false; - } - - public int getThreshold() { - return 0; - } - - public void setThreshold(int threshold) {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java deleted file mode 100644 index 5b7c4b52b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.codehaus.plexus.logging; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @author Trygve Laugstøl - */ -public class MockLoggerManager implements LoggerManager { - public void setThreshold(int threshold) {} - - public void setThresholds(int threshold) {} - - public int getThreshold() { - return 0; - } - - public void setThreshold(String role, int threshold) {} - - public void setThreshold(String role, String roleHint, int threshold) {} - - public int getThreshold(String role) { - return 0; - } - - public int getThreshold(String role, String roleHint) { - return 0; - } - - public Logger getLoggerForComponent(String role) { - return new MockLogger(role.getClass().getName()); - } - - public Logger getLoggerForComponent(String role, String roleHint) { - return new MockLogger(role.getClass().getName() + ":" + roleHint); - } - - public void returnComponentLogger(String role) {} - - public void returnComponentLogger(String role, String hint) {} - - public int getActiveLoggerCount() { - return 0; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java deleted file mode 100644 index 86376c3f1..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.codehaus.plexus.logging.console; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.logging.AbstractLoggerManagerTest; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; - -/** - * Test for {@link org.codehaus.plexus.logging.console.ConsoleLoggerManager} and - * {@link org.codehaus.plexus.logging.console.ConsoleLogger}. - * - * @author Mark H. Wilkinson - * @version $Revision$ - */ -public final class ConsoleLoggerManagerTest extends AbstractLoggerManagerTest { - protected LoggerManager createLoggerManager() throws Exception { - return lookup(LoggerManager.class); - } - - public void testSetAllThresholds() throws Exception { - LoggerManager manager = createLoggerManager(); - manager.setThreshold(Logger.LEVEL_ERROR); - - Logger logger = manager.getLoggerForComponent("test"); - assertEquals(logger.getThreshold(), Logger.LEVEL_ERROR); - - manager.setThresholds(Logger.LEVEL_DEBUG); - assertEquals(logger.getThreshold(), Logger.LEVEL_DEBUG); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java deleted file mode 100644 index 74b87ddf4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.codehaus.plexus.logging.console; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import junit.framework.TestCase; -import org.codehaus.plexus.util.StringUtils; - -/** - * @author Jason van Zyl - * - */ -public class ConsoleLoggerTest extends TestCase { - public void testConsoleLogger() { - ConsoleLogger logger = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG, "test"); - - assertTrue(logger.isDebugEnabled()); - - assertTrue(logger.isInfoEnabled()); - - assertTrue(logger.isWarnEnabled()); - - assertTrue(logger.isErrorEnabled()); - - assertTrue(logger.isFatalErrorEnabled()); - - // Save the original print stream. - PrintStream original = System.out; - - Throwable t = new Throwable("throwable"); - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - - PrintStream consoleStream = new PrintStream(os); - - System.setOut(consoleStream); - - logger.debug("debug"); - - assertEquals("[DEBUG] debug", getMessage(consoleStream, os)); - - logger.debug("debug", t); - - assertEquals("[DEBUG] debug", getMessage(consoleStream, os)); - - os = new ByteArrayOutputStream(); - - consoleStream = new PrintStream(os); - - System.setOut(consoleStream); - - logger.info("info"); - - assertEquals("[INFO] info", getMessage(consoleStream, os)); - - logger.info("info", t); - - assertEquals("[INFO] info", getMessage(consoleStream, os)); - - os = new ByteArrayOutputStream(); - - consoleStream = new PrintStream(os); - - System.setOut(consoleStream); - - logger.warn("warn"); - - assertEquals("[WARNING] warn", getMessage(consoleStream, os)); - - logger.warn("warn", t); - - assertEquals("[WARNING] warn", getMessage(consoleStream, os)); - - os = new ByteArrayOutputStream(); - - consoleStream = new PrintStream(os); - - System.setOut(consoleStream); - - logger.error("error"); - - assertEquals("[ERROR] error", getMessage(consoleStream, os)); - - logger.error("error", t); - - assertEquals("[ERROR] error", getMessage(consoleStream, os)); - - os = new ByteArrayOutputStream(); - - consoleStream = new PrintStream(os); - - System.setOut(consoleStream); - - logger.fatalError("error"); - - assertEquals("[FATAL ERROR] error", getMessage(consoleStream, os)); - - logger.fatalError("error", t); - - assertEquals("[FATAL ERROR] error", getMessage(consoleStream, os)); - - // Set the original print stream. - System.setOut(original); - } - - private String getMessage(PrintStream consoleStream, ByteArrayOutputStream os) { - consoleStream.flush(); - - consoleStream.close(); - - return StringUtils.chopNewline(os.toString()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java deleted file mode 100644 index 3d858d0f9..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.codehaus.plexus.test; - -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; - -import static junit.framework.Assert.assertTrue; - -public class AbstractStartableComponent implements StartableComponent, Startable { - public int startOrder; - - public int stopOrder; - - public AbstractStartableComponent component1; - - public AbstractStartableComponent component2; - - public void start() throws StartingException { - startOrder = startGenerator.getAndIncrement(); - } - - public void stop() throws StoppingException { - stopOrder = stopGenerator.getAndIncrement(); - } - - public void assertStartOrderCorrect() { - if (component1 != null) { - assertTrue("This component started before injected component1", startOrder > component1.startOrder); - } - if (component2 != null) { - assertTrue("This component started before injected component2", startOrder > component2.startOrder); - } - - // assert children are correct - if (component1 != null) { - component1.assertStartOrderCorrect(); - } - if (component2 != null) { - component2.assertStartOrderCorrect(); - } - } - - public void assertStopOrderCorrect() { - if (component1 != null) { - assertTrue("This component stopped after injected component1", stopOrder < component1.stopOrder); - } - if (component2 != null) { - assertTrue("This component stopped after injected component2", stopOrder < component2.stopOrder); - } - - // assert children are correct - if (component1 != null) { - component1.assertStopOrderCorrect(); - } - if (component2 != null) { - component2.assertStopOrderCorrect(); - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java deleted file mode 100644 index 1c6c73817..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Action {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java deleted file mode 100644 index 3eed8190d..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class AddUserAction implements Action {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/CircularComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/CircularComponent.java deleted file mode 100644 index a831f7ba4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/CircularComponent.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.codehaus.plexus.test; - -public interface CircularComponent { - static String ROLE = CircularComponent.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java deleted file mode 100644 index 09583297d..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.test.map.Activity; - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Component { - static String ROLE = Component.class.getName(); - - String getHost(); - - int getPort(); - - Activity getActivity(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentA.java deleted file mode 100644 index 6ef1ba1bd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentA.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ComponentA { - static String ROLE = ComponentA.class.getName(); - - ComponentB getComponentB(); - - ComponentC getComponentC(); - - String getHost(); - - int getPort(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentB.java deleted file mode 100644 index b7aae6b82..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentB.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ComponentB { - static String ROLE = ComponentB.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentC.java deleted file mode 100644 index 9001e0ce4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentC.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ComponentC { - static String ROLE = ComponentC.class.getName(); - - ComponentD getComponentD(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentD.java deleted file mode 100644 index fc3f29cf5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentD.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ComponentD { - static String ROLE = ComponentD.class.getName(); - - String getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java deleted file mode 100644 index 2f48ee51c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -public interface ComponentManager { - - List getList(); - - Map getMap(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java deleted file mode 100644 index 304339835..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class ComponentWithRoleDefault {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java deleted file mode 100644 index 705f138a8..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class ConcreteThing implements Thing {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/CountInstancesComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/CountInstancesComponent.java deleted file mode 100644 index 7f2d4566e..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/CountInstancesComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * Component counts number of created instances of it. - * - * @author ptab at newitech.com Piotr Tabor - */ -public class CountInstancesComponent { - public static String ROLE = CountInstancesComponent.class.getName(); - - private static int instances = 0; - - public CountInstancesComponent() { - instances++; - } - - public static void reset() { - instances = 0; - } - - public static int getInstancesCount() { - return instances; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultCircularComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultCircularComponent.java deleted file mode 100644 index 35a59a57b..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultCircularComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.codehaus.plexus.test; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; - -public class DefaultCircularComponent implements CircularComponent, Startable { - private PlexusContainer container; - private String lookup; - private CircularComponent requirement; - - public void start() throws StartingException { - try { - if (lookup != null) { - container.lookup(CircularComponent.class, lookup); - } - } catch (Exception e) { - throw new StartingException("failed", e); - } - } - - public void stop() throws StoppingException {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponent.java deleted file mode 100644 index 80fb8d918..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.test.map.Activity; - -public class DefaultComponent implements Component { - private String host; - - private int port; - - private Activity activity; - - public Activity getActivity() { - return activity; - } - - public String getHost() { - return host; - } - - public int getPort() { - return port; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentA.java deleted file mode 100644 index 63d3ad612..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentA.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * @component.role org.codehaus.plexus.test.ComponentA - * @component.requirement org.codehaus.plexus.test.ComponentB - * @component.requirement org.codehaus.plexus.test.ComponentC - * @component.version 1.0 - */ -public class DefaultComponentA implements ComponentA { - private ComponentB componentB; - - private ComponentC componentC; - - /** @default localhost */ - private String host; - - /** @default 10000 */ - private int port; - - public ComponentB getComponentB() { - return componentB; - } - - public ComponentC getComponentC() { - return componentC; - } - - public String getHost() { - return host; - } - - public int getPort() { - return port; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentB.java deleted file mode 100644 index a10c4c5cf..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentB.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * 2.0 - */ -public class DefaultComponentB implements ComponentB {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentC.java deleted file mode 100644 index c8d65a4b0..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentC.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DefaultComponentC implements ComponentC { - private ComponentD componentD; - - public ComponentD getComponentD() { - return componentD; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentD.java deleted file mode 100644 index 30faeb0b4..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentD.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DefaultComponentD implements ComponentD { - private String name; - - public String getName() { - return name; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java deleted file mode 100644 index 17b5d5128..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -public class DefaultComponentManager implements ComponentManager { - - private List list; - - private Map map; - - public List getList() { - return list; - } - - public Map getMap() { - return map; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java deleted file mode 100644 index 6a963e85e..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DefaultComponentWithOptionalRequirement extends DefaultComponent { - - public Object optionalComponent; -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java deleted file mode 100644 index 4aae834ee..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultLoadOnStartService implements LoadOnStartService, Startable { - public static boolean isStarted = false; - - public void start() { - isStarted = true; - } - - public void stop() {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java deleted file mode 100644 index 0d9190207..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultLoadOnStartServiceWithRoleHint implements LoadOnStartService {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceB.java deleted file mode 100644 index 9d5b9951c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceB.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; - -/** - * A simple native plexus component. - */ -public class DefaultServiceB extends AbstractLogEnabled - implements ServiceB, Contextualizable, Initializable, Startable { - public boolean enableLogging; - public boolean contextualize; - public boolean initialize; - public boolean start; - public boolean stop; - - public void enableLogging(Logger logger) { - enableLogging = true; - } - - public void contextualize(Context context) throws ContextException { - contextualize = true; - } - - public void initialize() { - initialize = true; - } - - public void start() { - start = true; - } - - public void stop() { - stop = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceC.java deleted file mode 100644 index 3f55367bd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceC.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; - -public class DefaultServiceC implements ServiceC, Startable { - public boolean started = false; - public boolean stopped = false; - - public void start() { - started = true; - } - - public void stop() { - stopped = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceD.java deleted file mode 100644 index 9cb719259..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceD.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DefaultServiceD implements ServiceD {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceE.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceE.java deleted file mode 100644 index 1d46952cf..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceE.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; - -/** - * A simple native plexus component implementing the manual configuration phase. - */ -public class DefaultServiceE extends AbstractLogEnabled - implements ServiceE, Contextualizable, Initializable, Startable { - public boolean enableLogging; - public boolean configured; - public boolean contextualize; - public boolean initialize; - public boolean start; - public boolean stop; - public boolean serviced; - - public void enableLogging(Logger logger) { - enableLogging = true; - } - - public void contextualize(Context context) throws ContextException { - contextualize = true; - } - - public void initialize() { - initialize = true; - } - - public void start() { - start = true; - } - - public void stop() { - stop = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceH.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceH.java deleted file mode 100644 index 8c2015ffb..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceH.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.test.lifecycle.phase.Eeny; -import org.codehaus.plexus.test.lifecycle.phase.Meeny; -import org.codehaus.plexus.test.lifecycle.phase.Miny; -import org.codehaus.plexus.test.lifecycle.phase.Mo; - -/** This component implements the custom lifecycle defined by the phases - * - * Eeny - * Meeny - * Miny - * Mo - * - */ -public class DefaultServiceH extends AbstractLogEnabled implements ServiceH, Eeny, Meeny, Miny, Mo { - public boolean eeny; - public boolean meeny; - public boolean miny; - public boolean mo; - - // ---------------------------------------------------------------------- - // Lifecycle Management - // ---------------------------------------------------------------------- - - public void eeny() { - eeny = true; - } - - public void meeny() { - meeny = true; - } - - public void miny() { - miny = true; - } - - public void mo() { - mo = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentA.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentA.java deleted file mode 100644 index 988ca4b13..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentA.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.codehaus.plexus.test; - -public class DefaultStartableComponentA extends AbstractStartableComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentB.java deleted file mode 100644 index e34bf6851..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentB.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.codehaus.plexus.test; - -public class DefaultStartableComponentB extends AbstractStartableComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentC.java deleted file mode 100644 index 9645bbb56..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentC.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.codehaus.plexus.test; - -public class DefaultStartableComponentC extends AbstractStartableComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentD.java deleted file mode 100644 index 517bd8497..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentD.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.codehaus.plexus.test; - -public class DefaultStartableComponentD extends AbstractStartableComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentE.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentE.java deleted file mode 100644 index d7d15ab19..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultStartableComponentE.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.codehaus.plexus.test; - -public class DefaultStartableComponentE extends AbstractStartableComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java deleted file mode 100644 index 19a3ebe65..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class DefaultThingUser implements ThingUser { - - public Thing thing; -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java deleted file mode 100644 index bebf57bbb..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public class LiveComponent {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java deleted file mode 100644 index e7d9929fc..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface LoadOnStartService { - String ROLE = LoadOnStartService.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java deleted file mode 100644 index 219aa0db8..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface LoadOnStartServiceWithRoleHint { - String ROLE = LoadOnStartServiceWithRoleHint.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java deleted file mode 100644 index 43898dc4d..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java +++ /dev/null @@ -1,792 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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 java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicBoolean; - -import junit.framework.TestCase; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.discovery.DiscoveredComponent; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.lifecycle.BasicLifecycleHandler; -import org.codehaus.plexus.lifecycle.LifecycleHandler; -import org.codehaus.plexus.test.lifecycle.phase.EenyPhase; -import org.codehaus.plexus.test.lifecycle.phase.MeenyPhase; -import org.codehaus.plexus.test.lifecycle.phase.MinyPhase; -import org.codehaus.plexus.test.lifecycle.phase.MoPhase; -import org.codehaus.plexus.test.list.Pipeline; -import org.codehaus.plexus.test.list.Valve; -import org.codehaus.plexus.test.list.ValveFour; -import org.codehaus.plexus.test.list.ValveOne; -import org.codehaus.plexus.test.list.ValveThree; -import org.codehaus.plexus.test.list.ValveTwo; -import org.codehaus.plexus.test.map.Activity; -import org.codehaus.plexus.test.map.ActivityManager; - -public class PlexusContainerTest extends TestCase { - private String basedir; - - private ClassLoader classLoader; - - private String configuration; - - private DefaultPlexusContainer container; - - public PlexusContainerTest(String name) { - super(name); - } - - public void setUp() throws Exception { - basedir = System.getProperty("basedir"); - - classLoader = getClass().getClassLoader(); - - configuration = "/" + getClass().getName().replace('.', '/') + ".xml"; - - assertNotNull(classLoader); - - // ---------------------------------------------------------------------------- - // Context - // ---------------------------------------------------------------------------- - - Map context = new HashMap(); - - context.put("basedir", basedir); - - context.put("plexus.home", basedir + "/target/plexus-home"); - - LifecycleHandler arbitrary = new BasicLifecycleHandler("arbitrary"); - arbitrary.addBeginSegment(new EenyPhase()); - arbitrary.addBeginSegment(new MeenyPhase()); - arbitrary.addBeginSegment(new MinyPhase()); - arbitrary.addBeginSegment(new MoPhase()); - - ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration() - .setName("test") - .setContext(context) - .setContainerConfiguration(configuration) - .addLifecycleHandler(arbitrary); - - container = new DefaultPlexusContainer(containerConfiguration); - } - - public void tearDown() throws Exception { - container.dispose(); - - container = null; - } - - public void testDefaultPlexusContainerSetup() throws Exception { - assertEquals("bar", System.getProperty("foo")); - } - - // ---------------------------------------------------------------------- - // Test the native plexus lifecycle. Note that the configuration for - // this TestCase supplies its own lifecycle, so this test verifies that - // the native lifecycle is available after configuration merging. - // ---------------------------------------------------------------------- - - public void testNativeLifecyclePassage() throws Exception { - DefaultServiceB serviceB = (DefaultServiceB) container.lookup(ServiceB.class); - - // Make sure the component is alive. - assertNotNull(serviceB); - - // Make sure the component went through all the lifecycle phases - assertEquals(true, serviceB.enableLogging); - - assertEquals(true, serviceB.contextualize); - - assertEquals(true, serviceB.initialize); - - assertEquals(true, serviceB.start); - - assertEquals(false, serviceB.stop); - - container.release(serviceB); - - assertEquals(true, serviceB.stop); - } - - public void testConfigurableLifecyclePassage() throws Exception { - DefaultServiceE serviceE = (DefaultServiceE) container.lookup(ServiceE.class); - - // Make sure the component is alive. - assertNotNull(serviceE); - - // Make sure the component went through all the lifecycle phases - assertEquals(true, serviceE.enableLogging); - - assertEquals(true, serviceE.contextualize); - - assertEquals(true, serviceE.initialize); - - assertEquals(true, serviceE.start); - - assertEquals(false, serviceE.stop); - - container.release(serviceE); - - assertEquals(true, serviceE.stop); - } - - /* - * Check that we can get references to a single component with a role - * hint. - */ - public void testSingleComponentLookupWithRoleHint() throws Exception { - // Retrieve an instance of component c. - DefaultServiceC serviceC1 = (DefaultServiceC) container.lookup(ServiceC.class, "first-instance"); - - // Make sure the component is alive. - assertNotNull(serviceC1); - - assertTrue(serviceC1.started); - - assertFalse(serviceC1.stopped); - - // Retrieve a second reference to the same component. - DefaultServiceC serviceC2 = (DefaultServiceC) container.lookup(ServiceC.class, "first-instance"); - - // Make sure component is alive. - assertNotNull(serviceC2); - - assertTrue(serviceC2.started); - - assertFalse(serviceC2.stopped); - - // Let's make sure it gave us back the same component. - assertSame(serviceC1, serviceC2); - - container.release(serviceC1); - - // The component should still be alive. - assertTrue(serviceC2.started); - - assertTrue(serviceC2.stopped); - - container.release(serviceC2); - - // The component should now have been stopped. - assertTrue(serviceC2.started); - - assertTrue(serviceC2.stopped); - } - - /* - * Check that distinct components with the same implementation are managed correctly. - */ - public void testMultipleSingletonComponentInstances() throws Exception { - // Retrieve an instance of component c. - DefaultServiceC serviceC1 = (DefaultServiceC) container.lookup(ServiceC.class, "first-instance"); - - // Make sure the component is alive. - assertNotNull(serviceC1); - - assertTrue(serviceC1.started); - - assertFalse(serviceC1.stopped); - - // Retrieve an instance of component c, with a different role hint. - // This should give us a different component instance. - DefaultServiceC serviceC2 = (DefaultServiceC) container.lookup(ServiceC.class, "second-instance"); - - // Make sure component is alive. - assertNotNull(serviceC2); - - assertTrue(serviceC2.started); - - assertFalse(serviceC2.stopped); - - // The components should be distinct. - assertNotSame(serviceC1, serviceC2); - - container.release(serviceC1); - - // The first component should now have been stopped, the second - // one should still be alive. - assertTrue(serviceC1.started); - - assertTrue(serviceC1.stopped); - - assertTrue(serviceC2.started); - - assertFalse(serviceC2.stopped); - - container.release(serviceC2); - - // The second component should now have been stopped. - assertTrue(serviceC2.started); - - assertTrue(serviceC2.stopped); - } - - // ---------------------------------------------------------------------- - // Test using an arbitrary component lifecycle handler - // ---------------------------------------------------------------------- - - public void testArbitraryLifecyclePassageUsingFourArbitraryPhases() throws Exception { - // Retrieve an manager of component H. - DefaultServiceH serviceH = (DefaultServiceH) container.lookup(ServiceH.class); - - // Make sure the component is alive. - assertNotNull(serviceH); - - // Make sure the component went through all the lifecycle phases - assertEquals(true, serviceH.eeny); - - assertEquals(true, serviceH.meeny); - - assertEquals(true, serviceH.miny); - - assertEquals(true, serviceH.mo); - - container.release(serviceH); - } - - public void testLookupAll() throws Exception { - Map components = container.lookupMap(ServiceC.class); - - assertNotNull(components); - - assertEquals(2, components.size()); - - ServiceC component = components.get("first-instance"); - - assertNotNull(component); - - component = components.get("second-instance"); - - assertNotNull(component); - - container.releaseAll(components); - } - - public void testAutomatedComponentConfigurationUsingXStreamPoweredComponentConfigurator() throws Exception { - Component component = container.lookup(Component.class); - - assertNotNull(component); - - assertNotNull(component.getActivity()); - - assertEquals("localhost", component.getHost()); - - assertEquals(10000, component.getPort()); - } - - public void testAutomatedComponentComposition() throws Exception { - ComponentA componentA = container.lookup(ComponentA.class); - - assertNotNull(componentA); - - assertEquals("localhost", componentA.getHost()); - - assertEquals(10000, componentA.getPort()); - - ComponentB componentB = componentA.getComponentB(); - - assertNotNull(componentB); - - ComponentC componentC = componentA.getComponentC(); - - assertNotNull(componentC); - - ComponentD componentD = componentC.getComponentD(); - - assertNotNull(componentD); - - assertEquals("jason", componentD.getName()); - } - - public void testComponentCompositionWhereTargetFieldIsAMap() throws Exception { - ActivityManager am = container.lookup(ActivityManager.class); - - Activity one = am.getActivity("one"); - - assertNotNull(one); - - // repeated retrieval from map should not cause re-lookup even if instantiation strategy is per-lookup - assertSame(one, am.getActivity("one")); - - assertFalse(one.getState()); - - am.execute("one"); - - assertTrue(one.getState()); - - Activity two = am.getActivity("two"); - - assertNotNull(two); - - assertFalse(two.getState()); - - am.execute("two"); - - assertTrue(two.getState()); - } - - public void testComponentCompositionWhereTargetFieldIsAPartialMap() throws Exception { - ActivityManager am = container.lookup(ActivityManager.class, "slim"); - - assertEquals(1, am.getActivityCount()); - - Activity one = am.getActivity("one"); - - assertNotNull(one); - - assertFalse(one.getState()); - - am.execute("one"); - - assertTrue(one.getState()); - } - - public void testComponentCompositionWhereTargetFieldIsAList() throws Exception { - Pipeline pipeline = container.lookup(Pipeline.class); - - List valves = pipeline.getValves(); - - for (Object valve : valves) { - // repeated retrieval from list should not cause re-lookup even if instantiation strategy is per-lookup - assertSame(valve, valve); - } - - assertFalse(((Valve) valves.get(0)).getState()); - - assertFalse(((Valve) valves.get(1)).getState()); - - pipeline.execute(); - - assertTrue(((Valve) valves.get(0)).getState()); - - assertTrue(((Valve) valves.get(1)).getState()); - } - - public void testComponentCompositionWhereTargetFieldIsAPartialList() throws Exception { - Pipeline pipeline = container.lookup(Pipeline.class, "slim"); - - List valves = pipeline.getValves(); - - assertEquals(valves.size(), 1); - - assertFalse(((Valve) valves.get(0)).getState()); - - pipeline.execute(); - - assertTrue(((Valve) valves.get(0)).getState()); - } - - public void testComponentCompositionWhereTargetFieldAMapThatMustRetainTheOrderOfComponentsGivenASetOfRoleHints() - throws Exception { - Pipeline pipeline = container.lookup(Pipeline.class, "chubby"); - - Map valveMap = pipeline.getValveMap(); - - List valves = new ArrayList(valveMap.values()); - - assertEquals("Expecting three valves.", 4, valves.size()); - - assertTrue("Expecting valve one.", valves.get(0) instanceof ValveOne); - - assertTrue("Expecting valve two.", valves.get(1) instanceof ValveTwo); - - assertTrue("Expecting valve three.", valves.get(2) instanceof ValveThree); - - assertTrue("Expecting valve four.", valves.get(3) instanceof ValveFour); - } - - public void testLookupOfComponentThatShouldBeDiscovered() throws Exception { - DiscoveredComponent discoveredComponent = container.lookup(DiscoveredComponent.class); - - assertNotNull(discoveredComponent); - } - - public void testStartableComponentSnake() throws Exception { - StartableComponent ca = container.lookup(StartableComponent.class, "A-snake"); - - assertNotNull(ca); - - ca.assertStartOrderCorrect(); - - container.dispose(); - - ca.assertStopOrderCorrect(); - } - - public void testStartableComponentTree() throws Exception { - StartableComponent ca = container.lookup(StartableComponent.class, "A-tree"); - - assertNotNull(ca); - - ca.assertStartOrderCorrect(); - - container.dispose(); - - ca.assertStopOrderCorrect(); - } - - public void testLookupCircularity() throws Exception { - try { - container.lookup(CircularComponent.class, "A"); - fail("Expected ComponentLookupException due to circularity"); - } catch (ComponentLookupException e) { - // todo actually test nested exception is as expected when - } - } - - public void testAddComponent() throws Exception { - LiveComponent live = new LiveComponent(); - - container.addComponent(live, LiveComponent.class.getName()); - - LiveComponent c = container.lookup(LiveComponent.class); - - assertSame(live, c); - } - - public void testComponentOverride() throws Exception { - assertNotNull(container.lookup(Component.class)); - - Component live = new Component() { - public Activity getActivity() { - return null; - } - - public String getHost() { - return null; - } - - public int getPort() { - return 0; - } - }; - - container.addComponent(live, Component.class, null); - - assertSame(live, container.lookup(Component.class)); - } - - public void testUpdateOfActiveComponentCollectionUponChangeOfThreadContextClassLoader() throws Exception { - ComponentManager manager = container.lookup(ComponentManager.class); - - Map map = manager.getMap(); - assertNotNull(map); - assertEquals(0, map.size()); - - List list = manager.getList(); - assertNotNull(list); - assertEquals(0, list.size()); - - /* - * Below we're creating two realms which basically contain the same components, only their bytecode/version - * differs. When we switch the thread's context class loader, the active component collections in the component - * manager must accurately reflect the components from the current realm (and not from a previous realm). - */ - - ClassRealm realmA = container.createChildRealm("realm-a"); - realmA.addURL(new File("src/test/test-components/component-a-1.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmA); - - ClassRealm realmB = container.createChildRealm("realm-b"); - realmB.addURL(new File("src/test/test-components/component-a-2.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmB); - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - - try { - Thread.currentThread().setContextClassLoader(realmA); - - map = manager.getMap(); - assertNotNull(map); - assertEquals(1, map.size()); - assertSame(realmA, map.values().iterator().next().getClass().getClassLoader()); - - list = manager.getList(); - assertNotNull(list); - assertEquals(1, list.size()); - assertSame(realmA, list.iterator().next().getClass().getClassLoader()); - - Thread.currentThread().setContextClassLoader(realmB); - - map = manager.getMap(); - assertNotNull(map); - assertEquals(1, map.size()); - assertSame(realmB, map.values().iterator().next().getClass().getClassLoader()); - - list = manager.getList(); - assertNotNull(list); - assertEquals(1, list.size()); - assertSame(realmB, list.iterator().next().getClass().getClassLoader()); - } finally { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public void testUpdateOfActiveComponentCollectionUponChangeOfThreadContextClassLoaderFromParentToChildRealm() - throws Exception { - ComponentManager manager = container.lookup(ComponentManager.class); - - Map map = manager.getMap(); - assertNotNull(map); - assertEquals(0, map.size()); - - List list = manager.getList(); - assertNotNull(list); - assertEquals(0, list.size()); - - /* - * Below we're creating two realms which basically contain the same components, only their bytecode/version - * differs. The realms form a parent-child relationship where the child imports the component role from the - * parent. When we first load from the parent and then switch the thread's context class loader to the child, - * the active component collections in the component manager must accurately reflect the components from the - * current realm (and not from a previous realm). - */ - - ClassRealm realmA = container.createChildRealm("realm-a"); - realmA.addURL(new File("src/test/test-components/component-a-1.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmA); - - ClassRealm realmB = realmA.createChildRealm("realm-b"); - realmB.importFrom(realmA, "org.codehaus.plexus.components.A"); - realmB.importFromParent("nothing"); - realmB.addURL(new File("src/test/test-components/component-a-2.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmB); - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - - try { - Thread.currentThread().setContextClassLoader(realmA); - - map = manager.getMap(); - assertNotNull(map); - assertEquals(1, map.size()); - assertSame(realmA, map.values().iterator().next().getClass().getClassLoader()); - - list = manager.getList(); - assertNotNull(list); - assertEquals(1, list.size()); - assertSame(realmA, list.iterator().next().getClass().getClassLoader()); - - Thread.currentThread().setContextClassLoader(realmB); - - map = manager.getMap(); - assertNotNull(map); - assertEquals(1, map.size()); - assertSame(realmB, map.values().iterator().next().getClass().getClassLoader()); - - list = manager.getList(); - assertNotNull(list); - assertEquals(1, list.size()); - assertSame(realmB, list.iterator().next().getClass().getClassLoader()); - } finally { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public void testComponentLookupFromParentRealmOfImportedRealms() throws Exception { - ComponentManager manager = container.lookup(ComponentManager.class); - - Map map = manager.getMap(); - assertNotNull(map); - assertEquals(0, map.size()); - - List list = manager.getList(); - assertNotNull(list); - assertEquals(0, list.size()); - - URL componentUrl = new File("src/test/test-components/component-a-1.0-SNAPSHOT.jar") - .toURI() - .toURL(); - - ClassRealm realmP = container.createChildRealm("parent-of-imported-realm"); - realmP.addURL(componentUrl); - container.discoverComponents(realmP); - - ClassRealm realmI = realmP.createChildRealm("imported-realm"); - - ClassRealm realmL = container.createChildRealm("lookup-realm"); - realmL.importFrom(realmI, "org.something"); - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - - try { - Thread.currentThread().setContextClassLoader(realmL); - - map = manager.getMap(); - assertNotNull(map); - assertEquals(1, map.size()); - assertSame(realmP, map.values().iterator().next().getClass().getClassLoader()); - - list = manager.getList(); - assertNotNull(list); - assertEquals(1, list.size()); - assertSame(realmP, list.iterator().next().getClass().getClassLoader()); - } finally { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public void testOptionalComponentRequirement() throws Exception { - DefaultComponentWithOptionalRequirement ca = - (DefaultComponentWithOptionalRequirement) container.lookup(Component.class, "with-optional"); - - assertNotNull(ca); - - assertNotNull(ca.getActivity()); - - assertNull(ca.optionalComponent); - } - - public void testLookupOfComponentThatHasARequirementWithoutRoleHintAndTheOneAndOnlyImplHasNoDefaultHint() - throws Exception { - DefaultThingUser component = (DefaultThingUser) container.lookup(ThingUser.class); - - assertNotNull(component.thing); - } - - public void testSingleLookupWithAndWithoutRoleHint() throws Exception { - ComponentWithRoleDefault withRoleHint = container.lookup(ComponentWithRoleDefault.class, "default"); - - ComponentWithRoleDefault withoutRoleHint = container.lookup(ComponentWithRoleDefault.class); - - assertSame(withRoleHint, withoutRoleHint); - } - - public void testLookupUponChangeOfThreadContextClassLoaderFromParentToChildRealm() throws Exception { - /* - * Below we're creating two realms which basically contain the same components, only their bytecode/version - * differs. The realms form a parent-child relationship where the child imports the component role from the - * parent. When we first lookup from the parent and then switch the thread's context class loader to the child, - * the second lookup must accurately reflect the components from the current realm (and not from a previous - * realm). - */ - - ClassRealm realmA = container.createChildRealm("realm-a"); - realmA.addURL(new File("src/test/test-components/component-a-1.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmA); - - ClassRealm realmB = realmA.createChildRealm("realm-b"); - realmB.importFrom(realmA, "org.codehaus.plexus.components.A"); - realmB.importFromParent("nothing"); - realmB.addURL(new File("src/test/test-components/component-a-2.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realmB); - - Class role = realmA.loadClass("org.codehaus.plexus.components.A"); - - ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - - try { - Thread.currentThread().setContextClassLoader(realmA); - - Object comp1 = container.lookup(role, "default"); - - Thread.currentThread().setContextClassLoader(realmB); - - Object comp2 = container.lookup(role, "default"); - - assertNotNull(comp1); - assertNotNull(comp2); - assertNotSame(comp1, comp2); - assertSame(realmA, comp1.getClass().getClassLoader()); - assertSame(realmB, comp2.getClass().getClassLoader()); - } finally { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public void testSafeConcurrentAccessToActiveComponentCollection() throws Exception { - ComponentManager manager = container.lookup(ComponentManager.class); - - final Map map = manager.getMap(); - assertNotNull(map); - assertEquals(0, map.size()); - - final List list = manager.getList(); - assertNotNull(list); - assertEquals(0, list.size()); - - final AtomicBoolean go = new AtomicBoolean(false); - - final List exceptions = new CopyOnWriteArrayList(); - Thread[] threads = new Thread[64]; - final CountDownLatch latch = new CountDownLatch(threads.length); - for (int i = 0; i < threads.length; i++) { - threads[i] = new Thread() { - @Override - public void run() { - try { - ClassRealm realm = container.createChildRealm( - "realm-" + UUID.randomUUID().toString()); - realm.addURL(new File("src/test/test-components/component-a-1.0-SNAPSHOT.jar") - .toURI() - .toURL()); - container.discoverComponents(realm); - Thread.currentThread().setContextClassLoader(realm); - - while (!go.get()) { - // just wait - } - - for (int j = 0; j < 1000; j++) { - // this just must not die with some exception - for (Object value : map.values()) { - value.toString(); - } - for (Object value : list) { - value.toString(); - } - } - } catch (Exception e) { - e.printStackTrace(); - exceptions.add(e); - } finally { - latch.countDown(); - } - } - }; - threads[i].start(); - } - go.set(true); - latch.await(); - - assertTrue(exceptions.toString(), exceptions.isEmpty()); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceB.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceB.java deleted file mode 100644 index 848dd0ea3..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceB.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ServiceB { - static String ROLE = ServiceB.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceC.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceC.java deleted file mode 100644 index b9c4540da..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceC.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ServiceC { - static String ROLE = ServiceC.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceD.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceD.java deleted file mode 100644 index d705ba588..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceD.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ServiceD { - static String ROLE = ServiceD.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceE.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceE.java deleted file mode 100644 index a1f40a767..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceE.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ServiceE { - static String ROLE = ServiceE.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceH.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceH.java deleted file mode 100644 index 5be82241a..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceH.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ServiceH { - static String ROLE = ServiceH.class.getName(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java deleted file mode 100644 index 4ad0f9261..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.lifecycle.AbstractLifecycleHandler; - -/** - * - * - * @author Jason van Zyl - * - */ -public class SimpleLifecycleHandler extends AbstractLifecycleHandler { - public String getId() { - return "simple"; - } - - public void initialize() {} -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/StartableComponent.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/StartableComponent.java deleted file mode 100644 index ab1b52ddc..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/StartableComponent.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.codehaus.plexus.test; - -import java.util.concurrent.atomic.AtomicInteger; - -public interface StartableComponent { - static String ROLE = StartableComponent.class.getName(); - - AtomicInteger startGenerator = new AtomicInteger(1); - - AtomicInteger stopGenerator = new AtomicInteger(1); - - void assertStartOrderCorrect(); - - void assertStopOrderCorrect(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java deleted file mode 100644 index 99669f4d8..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface Thing {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java deleted file mode 100644 index 857131440..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.codehaus.plexus.test; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -public interface ThingUser {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java deleted file mode 100644 index cc3e87d70..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Eeny { - void eeny(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/EenyPhase.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/EenyPhase.java deleted file mode 100644 index 0ea4cdb8c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/EenyPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class EenyPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Eeny) { - ((Eeny) object).eeny(); - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java deleted file mode 100644 index 323ddc2d5..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Meeny { - void meeny(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MeenyPhase.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MeenyPhase.java deleted file mode 100644 index 2999ce218..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MeenyPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class MeenyPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Meeny) { - ((Meeny) object).meeny(); - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java deleted file mode 100644 index 4ee8f0870..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Miny { - void miny(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MinyPhase.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MinyPhase.java deleted file mode 100644 index 473946752..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MinyPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class MinyPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Miny) { - ((Miny) object).miny(); - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java deleted file mode 100644 index 15c6873a6..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Mo { - void mo(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MoPhase.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MoPhase.java deleted file mode 100644 index 14a9e2267..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MoPhase.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.codehaus.plexus.test.lifecycle.phase; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.lifecycle.phase.AbstractPhase; - -public class MoPhase extends AbstractPhase { - public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) { - if (object instanceof Mo) { - ((Mo) object).mo(); - } - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java deleted file mode 100644 index 1db108596..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public abstract class AbstractValve implements Valve { - private boolean state; - - public boolean getState() { - return state; - } - - public void execute() { - state = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java deleted file mode 100644 index d1072ab18..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultPipeline implements Pipeline { - private List valves; - - private Map valveMap; - - public void execute() { - for (Object valve : valves) { - ((Valve) valve).execute(); - } - } - - public List getValves() { - return valves; - } - - public Map getValveMap() { - return valveMap; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java deleted file mode 100644 index fd2133cbe..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.List; -import java.util.Map; - -/** - * @author Jason van Zyl - * - */ -public interface Pipeline { - static String ROLE = Pipeline.class.getName(); - - void execute(); - - List getValves(); - - Map getValveMap(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java deleted file mode 100644 index ba8b35991..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Valve { - static String ROLE = Valve.class.getName(); - - void execute(); - - boolean getState(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java deleted file mode 100644 index 668afa491..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ValveFour extends AbstractValve {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java deleted file mode 100644 index 9c0f8cc91..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ValveOne extends AbstractValve {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java deleted file mode 100644 index 960d4e618..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ValveThree extends AbstractValve {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java deleted file mode 100644 index 9fbf5c3af..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.list; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ValveTwo extends AbstractValve {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java deleted file mode 100644 index 17ecd172c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public abstract class AbstractActivity implements Activity { - private boolean state; - - public boolean getState() { - return state; - } - - public void execute() { - state = true; - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java deleted file mode 100644 index 4345b5ba2..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface Activity { - static String ROLE = Activity.class.getName(); - - void execute(); - - boolean getState(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java deleted file mode 100644 index 05cb9e07c..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public interface ActivityManager { - static String ROLE = ActivityManager.class.getName(); - - void execute(String id); - - Activity getActivity(String id); - - int getActivityCount(); -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java deleted file mode 100644 index da94af30e..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ActivityOne extends AbstractActivity {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java deleted file mode 100644 index 3628b8e09..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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. - */ - -/** - * - * - * @author Jason van Zyl - * - */ -public class ActivityTwo extends AbstractActivity {} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java deleted file mode 100644 index 6aaf4f8bb..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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 java.util.Map; - -/** - * - * - * @author Jason van Zyl - * - */ -public class DefaultActivityManager implements ActivityManager { - private Map activities; - - public void execute(String id) { - getActivity(id).execute(); - } - - public Activity getActivity(String id) { - return (Activity) activities.get(id); - } - - public int getActivityCount() { - return activities.size(); - } -} diff --git a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java b/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java deleted file mode 100644 index e2c461ecd..000000000 --- a/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codehaus.plexus.test.map; - -/* - * Copyright 2001-2006 Codehaus 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.codehaus.plexus.PlexusTestCase; - -/** - * @author Trygve Laugstøl - */ -public class NoComponentsMapTest extends PlexusTestCase { - public void testNoComponents() throws Exception { - ActivityManager manager; - - manager = lookup(ActivityManager.class); - - assertEquals(0, manager.getActivityCount()); - } -} diff --git a/plexus-container-default/src/test/resources/META-INF/plexus/components.xml b/plexus-container-default/src/test/resources/META-INF/plexus/components.xml deleted file mode 100644 index 4f91ea4da..000000000 --- a/plexus-container-default/src/test/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - org.codehaus.plexus.component.discovery.DiscoveredComponent - org.codehaus.plexus.component.discovery.DefaultDiscoveredComponent - - - org.codehaus.plexus.component.factory.ComponentFactory - testFactory2 - org.codehaus.plexus.component.factory.TestComponentFactory2 - - - - - plexus - monkey - 1.0 - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/META-INF/plexus/plexus.xml b/plexus-container-default/src/test/resources/META-INF/plexus/plexus.xml deleted file mode 100644 index 86d846d59..000000000 --- a/plexus-container-default/src/test/resources/META-INF/plexus/plexus.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - org.codehaus.plexus.component.factory.ComponentFactory - testFactory1 - org.codehaus.plexus.component.factory.TestComponentFactory1 - - - org.codehaus.plexus.test.CountInstancesComponent - org.codehaus.plexus.test.CountInstancesComponent - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/application/components.xml b/plexus-container-default/src/test/resources/application/components.xml deleted file mode 100644 index 7922158db..000000000 --- a/plexus-container-default/src/test/resources/application/components.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - server - - - - - - - - - two - - - - - - - - - three - - - - - - - - - - - - - four - - - - one - two - three - - - - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/application/configuration-mapping.xml b/plexus-container-default/src/test/resources/application/configuration-mapping.xml deleted file mode 100644 index f3d2b084d..000000000 --- a/plexus-container-default/src/test/resources/application/configuration-mapping.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - 8080 - localhost - - Santa Claus - santa@northpole.com - - - - email - Email - - - irc - Irc - - - - - - one - one - one - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/application/sentinel.xml b/plexus-container-default/src/test/resources/application/sentinel.xml deleted file mode 100644 index a21e4996d..000000000 --- a/plexus-container-default/src/test/resources/application/sentinel.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - 8080 - localhost - - Santa Claus - santa@northpole.com - - - - email - Email - - - irc - Irc - - - - - - one - one - one - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/inline-configuration.properties b/plexus-container-default/src/test/resources/inline-configuration.properties deleted file mode 100644 index 4f4b311bd..000000000 --- a/plexus-container-default/src/test/resources/inline-configuration.properties +++ /dev/null @@ -1,2 +0,0 @@ -first-name=andrew -last-name=williams \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/inline-configuration.xml b/plexus-container-default/src/test/resources/inline-configuration.xml deleted file mode 100644 index e622040b9..000000000 --- a/plexus-container-default/src/test/resources/inline-configuration.xml +++ /dev/null @@ -1,4 +0,0 @@ - - jason - van zyl - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/jar-repository/a.jar b/plexus-container-default/src/test/resources/jar-repository/a.jar deleted file mode 100644 index 60afd9060..000000000 Binary files a/plexus-container-default/src/test/resources/jar-repository/a.jar and /dev/null differ diff --git a/plexus-container-default/src/test/resources/jar-repository/b.jar b/plexus-container-default/src/test/resources/jar-repository/b.jar deleted file mode 100644 index 6b9353951..000000000 Binary files a/plexus-container-default/src/test/resources/jar-repository/b.jar and /dev/null differ diff --git a/plexus-container-default/src/test/resources/jar-repository/c.jar b/plexus-container-default/src/test/resources/jar-repository/c.jar deleted file mode 100644 index e54f08e7a..000000000 Binary files a/plexus-container-default/src/test/resources/jar-repository/c.jar and /dev/null differ diff --git a/plexus-container-default/src/test/resources/jar-repository/d.jar b/plexus-container-default/src/test/resources/jar-repository/d.jar deleted file mode 100644 index 31a5cabef..000000000 Binary files a/plexus-container-default/src/test/resources/jar-repository/d.jar and /dev/null differ diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/PlexusTestCaseTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/PlexusTestCaseTest.xml deleted file mode 100644 index 5ccfd9384..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/PlexusTestCaseTest.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.codehaus.plexus.test.LoadOnStartService - - - - - - org.codehaus.plexus.test.LoadOnStartService - org.codehaus.plexus.test.DefaultLoadOnStartService - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/autowire/AutowireCompositionTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/autowire/AutowireCompositionTest.xml deleted file mode 100644 index f449a1092..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/autowire/AutowireCompositionTest.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - org.codehaus.plexus.component.composition.autowire.One - org.codehaus.plexus.component.composition.autowire.DefaultOne - - - org.codehaus.plexus.component.composition.autowire.Two - org.codehaus.plexus.component.composition.autowire.DefaultTwo - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/components.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/components.xml deleted file mode 100644 index 81eb73245..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/components.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - org.codehaus.plexus.component.composition.ComponentA - org.codehaus.plexus.component.composition.DefaultComponentA - field - - - org.codehaus.plexus.component.composition.ComponentB - - - - localhost - 10000 - - - - org.codehaus.plexus.component.composition.ComponentB - org.codehaus.plexus.component.composition.DefaultComponentB - setter - - - org.codehaus.plexus.component.composition.ComponentC - - - - - org.codehaus.plexus.component.composition.ComponentC - org.codehaus.plexus.component.composition.DefaultComponentC - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/setter/SetterCompositionTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/setter/SetterCompositionTest.xml deleted file mode 100644 index 845550080..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/setter/SetterCompositionTest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - org.codehaus.plexus.component.composition.setter.Component - org.codehaus.plexus.component.composition.setter.ChildComponent - setter - - - org.codehaus.plexus.component.composition.ComponentA - - - org.codehaus.plexus.component.composition.ComponentB - - - - - org.codehaus.plexus.component.composition.ComponentA - org.codehaus.plexus.component.composition.DefaultComponentA - - - org.codehaus.plexus.component.composition.ComponentB - org.codehaus.plexus.component.composition.DefaultComponentB - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.xml deleted file mode 100644 index 9a43da407..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/factory/nonjava/NonJavaComponentFactoryTest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - org.codehaus.plexus.component.factory.ComponentFactory - nonjava - org.codehaus.plexus.component.factory.nonjava.NonJavaComponentFactory - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.xml deleted file mode 100644 index 5bcc96bbf..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - org.codehaus.plexus.component.manager.Component - org.codehaus.plexus.component.manager.DefaultComponent - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.xml deleted file mode 100644 index ad5b63349..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - org.codehaus.plexus.component.manager.SlowComponent - org.codehaus.plexus.component.manager.SlowComponent - - 300 - - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/components.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/components.xml deleted file mode 100644 index be273bddb..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/components.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.codehaus.plexus.test.ComponentA - one - org.codehaus.plexus.test.DefaultComponentA - - - org.codehaus.plexus.test.ComponentA - two - org.codehaus.plexus.test.DefaultComponentA - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/avalon.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/avalon.xml deleted file mode 100644 index 45617cbb9..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/avalon.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - - ${foo.home}/jars - ${my.home}/resources - - - user-conf-dir - - - logging-implementation - - INFO - - - - - org.codehaus.plexus.personality.avalon.AvalonComponentRepository - - - - - - frankie - - - - - - custom - - - custom - - - - - - - avalon - - - avalon - Avalon Lifecycle Handler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.codehaus.plexus.ServiceA - org.codehaus.plexus.DefaultServiceA - - - - - - - org.codehaus.plexus.ServiceB - org.codehaus.plexus.DefaultServiceB - - - - - - org.codehaus.plexus.ServiceC - first-instance - org.codehaus.plexus.DefaultServiceC - - - - - org.codehaus.plexus.ServiceC - second-instance - org.codehaus.plexus.DefaultServiceC - - - - - - org.codehaus.plexus.ServiceE - org.codehaus.plexus.DefaultServiceE - per-lookup - - - - - - org.codehaus.plexus.ServiceG - org.codehaus.plexus.DefaultServiceG - singleton - - - - - - - org.codehaus.plexus.ServiceH - org.codehaus.plexus.DefaultServiceH - arbitrary - - - - org.codehaus.plexus.LoadOnStartService - org.codehaus.plexus.DefaultLoadOnStartService - - - - - org.codehaus.plexus.LoadOnStartServiceWithRoleHint - role-hint - org.codehaus.plexus.DefaultLoadOnStartServiceWithRoleHint - - - - - org.codehaus.plexus.ConfigureService - org.codehaus.plexus.DefaultConfigureService - singleton - - - 1 - 2 - - - - - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.xml deleted file mode 100644 index 08d7257f7..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/ExtendingConfigurationSourceTest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - org.codehaus.plexus.configuration.source.ConfigurationSource - - dummy - - org.codehaus.plexus.configuration.source.ADummyConfigurationSource - - - - - org.codehaus.plexus.configuration.source.ConfigurationSource - - anotherDummy - - org.codehaus.plexus.configuration.source.AnotherDummyConfigurationSource - - - - org.codehaus.plexus.configuration.source.ConfigurationSource - dummy - - - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.xml deleted file mode 100644 index a785aa438..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/source/OverridingConfigurationSourceTest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - org.codehaus.plexus.configuration.source.ConfigurationSource - default - org.codehaus.plexus.configuration.source.ADummyConfigurationSource - - - \ No newline at end of file diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/embed/EmbedderTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/embed/EmbedderTest.xml deleted file mode 100644 index 34caf6b71..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/embed/EmbedderTest.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - ${basedir}/test-input - - - - - org.codehaus.plexus.embed.MockComponent - default - org.codehaus.plexus.embed.MockComponent - - - org.codehaus.plexus.embed.MockComponent - foo - org.codehaus.plexus.embed.MockComponent - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusOne.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusOne.xml deleted file mode 100644 index cb80be530..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusOne.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - org.codehaus.plexus.logging.console.ConsoleLoggerManager - - ERROR - - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - default - org.codehaus.plexus.hierarchy.TestServiceImpl - - three blind mice - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - hinted - org.codehaus.plexus.hierarchy.TestServiceImpl - - plexus one overriding hinted service - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - local - org.codehaus.plexus.hierarchy.TestServiceImpl - - plexus one local service - - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusTwo.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusTwo.xml deleted file mode 100644 index 96b0c117a..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusTwo.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - org.codehaus.plexus.logging.console.ConsoleLoggerManager - - ERROR - - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - default - org.codehaus.plexus.hierarchy.TestServiceImpl - - see how they run - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - local - org.codehaus.plexus.hierarchy.TestServiceImpl - - plexus two local service - - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.xml deleted file mode 100644 index 31a351915..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - org.codehaus.plexus.logging.console.ConsoleLoggerManager - - ERROR - - - - - - org.codehaus.plexus.PlexusContainerManager - default - org.codehaus.plexus.SimplePlexusContainerManager - - org/codehaus/plexus/hierarchy/ChildPlexusOne.xml - - - plexus-name - ChildPlexusOne - - - - - - - org.codehaus.plexus.PlexusContainerManager - two - org.codehaus.plexus.SimplePlexusContainerManager - - org/codehaus/plexus/hierarchy/ChildPlexusTwo.xml - - - plexus-name - ChildPlexusTwo - - - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - default - org.codehaus.plexus.hierarchy.TestServiceImpl - - cheesy default service - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - hinted - org.codehaus.plexus.hierarchy.TestServiceImpl - - hinted default service - - - - - org.codehaus.plexus.hierarchy.PlexusTestService - global - org.codehaus.plexus.hierarchy.TestServiceImpl - - globally visible service - - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/CustomLoggerManagerTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/CustomLoggerManagerTest.xml deleted file mode 100644 index 69cb2ac6a..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/CustomLoggerManagerTest.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.MockLoggerManager - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.xml deleted file mode 100644 index 9787f865f..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - per-lookup - - - fatal - - - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml deleted file mode 100644 index ba3252572..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml +++ /dev/null @@ -1,464 +0,0 @@ - - - - - ${basedir}/src/test-input/configurations-directory - - - - - - - - - - - - - - - - org.codehaus.plexus.test.ServiceB - org.codehaus.plexus.test.DefaultServiceB - - - - org.codehaus.plexus.test.ServiceC - first-instance - org.codehaus.plexus.test.DefaultServiceC - - - - org.codehaus.plexus.test.ServiceC - second-instance - org.codehaus.plexus.test.DefaultServiceC - - - - org.codehaus.plexus.test.ServiceD - org.codehaus.plexus.test.DefaultServiceD - - - - org.codehaus.plexus.test.ServiceE - org.codehaus.plexus.test.DefaultServiceE - plexus-configurable - - - - - - org.codehaus.plexus.test.ServiceH - - org.codehaus.plexus.test.DefaultServiceH - arbitrary - - - - org.codehaus.plexus.test.LoadOnStartService - org.codehaus.plexus.test.DefaultLoadOnStartService - - - - - org.codehaus.plexus.test.LoadOnStartServiceWithRoleHint - role-hint - org.codehaus.plexus.test.DefaultLoadOnStartServiceWithRoleHint - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - fatal - - - - - - - org.codehaus.plexus.test.Component - org.codehaus.plexus.test.DefaultComponent - - - org.codehaus.plexus.test.map.Activity - one - - - - localhost - 10000 - - - - org.codehaus.plexus.test.Component - org.codehaus.plexus.test.DefaultComponentWithOptionalRequirement - with-optional - - - org.codehaus.plexus.test.map.Activity - one - activity - - - org.codehaus.plexus.test.NonAvailableComponent - missing - optionalComponent - true - - - - - org.codehaus.plexus.test.ComponentA - org.codehaus.plexus.test.DefaultComponentA - - - org.codehaus.plexus.test.ComponentB - - - org.codehaus.plexus.test.ComponentC - - - - localhost - 10000 - - - - org.codehaus.plexus.test.ComponentB - org.codehaus.plexus.test.DefaultComponentB - - - org.codehaus.plexus.test.ComponentC - org.codehaus.plexus.test.DefaultComponentC - - - org.codehaus.plexus.test.ComponentD - - - - - org.codehaus.plexus.test.ComponentD - org.codehaus.plexus.test.DefaultComponentD - - jason - - - - - - org.codehaus.plexus.test.map.ActivityManager - org.codehaus.plexus.test.map.DefaultActivityManager - - - org.codehaus.plexus.test.map.Activity - activities - - - - - org.codehaus.plexus.test.map.ActivityManager - slim - org.codehaus.plexus.test.map.DefaultActivityManager - - - org.codehaus.plexus.test.map.Activity - activities - - one - - - - - - org.codehaus.plexus.test.map.Activity - one - org.codehaus.plexus.test.map.ActivityOne - per-lookup - - - org.codehaus.plexus.test.map.Activity - two - org.codehaus.plexus.test.map.ActivityTwo - - - - - org.codehaus.plexus.test.list.Pipeline - default - org.codehaus.plexus.test.list.DefaultPipeline - - - org.codehaus.plexus.test.list.Valve - valves - - - - - org.codehaus.plexus.test.list.Pipeline - slim - org.codehaus.plexus.test.list.DefaultPipeline - - - org.codehaus.plexus.test.list.Valve - valves - - one - - - - - - org.codehaus.plexus.test.list.Pipeline - chubby - org.codehaus.plexus.test.list.DefaultPipeline - - - org.codehaus.plexus.test.list.Valve - valveMap - - one - two - three - four - - - - - - - - org.codehaus.plexus.test.list.Valve - four - org.codehaus.plexus.test.list.ValveFour - - - org.codehaus.plexus.test.list.Valve - three - org.codehaus.plexus.test.list.ValveThree - - - org.codehaus.plexus.test.list.Valve - two - org.codehaus.plexus.test.list.ValveTwo - - - org.codehaus.plexus.test.list.Valve - one - org.codehaus.plexus.test.list.ValveOne - per-lookup - - - - org.codehaus.plexus.test.ComponentManager - org.codehaus.plexus.test.DefaultComponentManager - - - org.codehaus.plexus.components.A - list - - - org.codehaus.plexus.components.A - map - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - fatal - - - - - org.codehaus.plexus.test.Component - ComponentMissingRequirements - org.codehaus.plexus.test.DefaultComponent - - - NonExistingComponent - - - - - - - org.codehaus.plexus.test.StartableComponent - A-snake - org.codehaus.plexus.test.DefaultStartableComponentA - - - org.codehaus.plexus.test.StartableComponent - B-snake - component1 - - - - - - org.codehaus.plexus.test.StartableComponent - B-snake - org.codehaus.plexus.test.DefaultStartableComponentB - - - org.codehaus.plexus.test.StartableComponent - C-snake - component1 - - - - - - org.codehaus.plexus.test.StartableComponent - C-snake - org.codehaus.plexus.test.DefaultStartableComponentC - - - org.codehaus.plexus.test.StartableComponent - D-snake - component1 - - - - - - org.codehaus.plexus.test.StartableComponent - D-snake - org.codehaus.plexus.test.DefaultStartableComponentD - - - org.codehaus.plexus.test.StartableComponent - E-snake - component1 - - - - - - org.codehaus.plexus.test.StartableComponent - E-snake - org.codehaus.plexus.test.DefaultStartableComponentE - - - - - org.codehaus.plexus.test.StartableComponent - A-tree - org.codehaus.plexus.test.DefaultStartableComponentA - - - org.codehaus.plexus.test.StartableComponent - B-tree - component1 - - - org.codehaus.plexus.test.StartableComponent - C-tree - component2 - - - - - - org.codehaus.plexus.test.StartableComponent - B-tree - org.codehaus.plexus.test.DefaultStartableComponentB - - - org.codehaus.plexus.test.StartableComponent - D-tree - component1 - - - org.codehaus.plexus.test.StartableComponent - E-tree - component2 - - - - - - org.codehaus.plexus.test.StartableComponent - C-tree - org.codehaus.plexus.test.DefaultStartableComponentC - - - - org.codehaus.plexus.test.StartableComponent - D-tree - org.codehaus.plexus.test.DefaultStartableComponentD - - - - org.codehaus.plexus.test.StartableComponent - E-tree - org.codehaus.plexus.test.DefaultStartableComponentE - - - - - org.codehaus.plexus.test.CircularComponent - A - org.codehaus.plexus.test.DefaultCircularComponent - - - org.codehaus.plexus.test.CircularComponent - B - requirement - - - - - - org.codehaus.plexus.test.CircularComponent - B - org.codehaus.plexus.test.DefaultCircularComponent - - - org.codehaus.plexus.PlexusContainer - container - - - - A - - - - - org.codehaus.plexus.test.Thing - - concrete - org.codehaus.plexus.test.ConcreteThing - - - - org.codehaus.plexus.test.ThingUser - org.codehaus.plexus.test.DefaultThingUser - - - org.codehaus.plexus.test.Thing - - thing - - - - - - org.codehaus.plexus.test.ComponentWithRoleDefault - org.codehaus.plexus.test.ComponentWithRoleDefault - default - - - - diff --git a/plexus-container-default/src/test/resources/org/codehaus/plexus/test/map/NoComponentsMapTest.xml b/plexus-container-default/src/test/resources/org/codehaus/plexus/test/map/NoComponentsMapTest.xml deleted file mode 100644 index 4252753bd..000000000 --- a/plexus-container-default/src/test/resources/org/codehaus/plexus/test/map/NoComponentsMapTest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - org.codehaus.plexus.logging.console.ConsoleLoggerManager - - INFO - - - - - - org.codehaus.plexus.test.map.ActivityManager - org.codehaus.plexus.test.map.DefaultActivityManager - - - org.codehaus.plexus.test.map.Activity - activities - - - - - - - diff --git a/plexus-container-default/src/test/resources/test.txt b/plexus-container-default/src/test/resources/test.txt deleted file mode 100644 index 793aa682b..000000000 --- a/plexus-container-default/src/test/resources/test.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test \ No newline at end of file diff --git a/plexus-container-default/src/test/test-component-builds/component-a/pom.xml b/plexus-container-default/src/test/test-component-builds/component-a/pom.xml deleted file mode 100644 index 872b4819a..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-a/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - component-a - 1.0-SNAPSHOT - component-a - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.3 - - - - descriptor - - - - - - - diff --git a/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/A.java b/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/A.java deleted file mode 100644 index 0a18129f6..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/A.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.components; - -public interface A -{ - public void hello(); -} diff --git a/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/DefaultA.java b/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/DefaultA.java deleted file mode 100644 index 3b6f6a280..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-a/src/main/java/org/codehaus/plexus/components/DefaultA.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.components; - -/** - * @plexus.component - */ -public class DefaultA - implements A -{ - public void hello() - { - System.out.println( "Hello World!" ); - } -} diff --git a/plexus-container-default/src/test/test-component-builds/component-b/pom.xml b/plexus-container-default/src/test/test-component-builds/component-b/pom.xml deleted file mode 100644 index 60cadc1cb..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-b/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - component-b - 1.0-SNAPSHOT - component-b - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.3 - - - - descriptor - - - - - - - diff --git a/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/B.java b/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/B.java deleted file mode 100644 index ec834d866..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/B.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.components; - -public interface B -{ - public void hello(); -} diff --git a/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/DefaultB.java b/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/DefaultB.java deleted file mode 100644 index eb8bc1724..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-b/src/main/java/org/codehaus/plexus/components/DefaultB.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.components; - -/** - * @plexus.component - */ -public class DefaultB - implements B -{ - public void hello() - { - System.out.println( "Hello World!" ); - } -} diff --git a/plexus-container-default/src/test/test-component-builds/component-c/pom.xml b/plexus-container-default/src/test/test-component-builds/component-c/pom.xml deleted file mode 100644 index 6334944b1..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-c/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - component-c - 1.0-SNAPSHOT - component-c - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.3 - - - - descriptor - - - - - - - diff --git a/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/C.java b/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/C.java deleted file mode 100644 index c5f9f14b0..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/C.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.components; - -public interface C -{ - public void hello(); -} diff --git a/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/DefaultC.java b/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/DefaultC.java deleted file mode 100644 index 486fd01c4..000000000 --- a/plexus-container-default/src/test/test-component-builds/component-c/src/main/java/org/codehaus/plexus/components/DefaultC.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.codehaus.plexus.components; - -/** - * @plexus.component - */ -public class DefaultC - implements C -{ - public void hello() - { - System.out.println( "Hello World!" ); - } -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin0/pom.xml b/plexus-container-default/src/test/test-component-builds/plugin0/pom.xml deleted file mode 100644 index df96cd8f9..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin0/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - plugin0 - 1.0-SNAPSHOT - - - org.codehaus.plexus.components - component-a - 1.0-SNAPSHOT - - - org.codehaus.plexus.components - component-b - 1.0-SNAPSHOT - - - org.codehaus.plexus - plexus-archiver - 4.8.0 - - - org.codehaus.plexus - plexus-container-default - 1.0-beta-2-SNAPSHOT - - - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.3 - - - - descriptor - - - - - - - diff --git a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/AltPlugin0.java b/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/AltPlugin0.java deleted file mode 100644 index 58c5d2e27..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/AltPlugin0.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.plexus.plugins; - -import org.codehaus.plexus.components.A; -import org.codehaus.plexus.components.B; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.archiver.manager.ArchiverManager; - -/** - * @plexus.component role-hint="alt" - */ -public class AltPlugin0 - implements Plugin0, Contextualizable -{ - /** @plexus.requirement */ - private A a; - - /** @plexus.requirement */ - private B b; - - /** @plexus.requirement */ - private ArchiverManager archiverManager; - - public void hello() - { - System.out.println( "Hello World!" ); - } - - // ---------------------------------------------------------------------------- - // Lifecycle - // ---------------------------------------------------------------------------- - - public void contextualize( Context context ) - throws ContextException - { - PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - - try - { - archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE ); - } - catch ( ComponentLookupException e ) - { - throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e ); - } - } -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin0.java b/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin0.java deleted file mode 100644 index 56dbbe477..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin0.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.plexus.plugins; - -import org.codehaus.plexus.components.A; -import org.codehaus.plexus.components.B; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.archiver.manager.ArchiverManager; - -/** - * @plexus.component - */ -public class DefaultPlugin0 - implements Plugin0, Contextualizable -{ - /** @plexus.requirement */ - private A a; - - /** @plexus.requirement */ - private B b; - - /** @plexus.requirement */ - private ArchiverManager archiverManager; - - public void hello() - { - System.out.println( "Hello World!" ); - } - - // ---------------------------------------------------------------------------- - // Lifecycle - // ---------------------------------------------------------------------------- - - public void contextualize( Context context ) - throws ContextException - { - PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - - try - { - archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE ); - } - catch ( ComponentLookupException e ) - { - throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e ); - } - } -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/Plugin0.java b/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/Plugin0.java deleted file mode 100644 index 5f85c667d..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin0/src/main/java/org/codehaus/plexus/plugins/Plugin0.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.plugins; - -public interface Plugin0 -{ - public void hello(); -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin1/pom.xml b/plexus-container-default/src/test/test-component-builds/plugin1/pom.xml deleted file mode 100644 index e9b947e49..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin1/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - plugin1 - 1.0-SNAPSHOT - - - org.codehaus.plexus.components - component-a - 1.0-SNAPSHOT - - - org.codehaus.plexus.components - component-c - 1.0-SNAPSHOT - - - - - - org.codehaus.plexus - plexus-maven-plugin - 1.3.3 - - - - descriptor - - - - - - - diff --git a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/AltPlugin1.java b/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/AltPlugin1.java deleted file mode 100644 index 2b9714f99..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/AltPlugin1.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.plugins; - -import org.codehaus.plexus.components.A; -import org.codehaus.plexus.components.C; - -/** - * @plexus.component role-hint="alt" - */ -public class AltPlugin1 - implements Plugin1 -{ - /** @plexus.requirement */ - private A a; - - /** @plexus.requirement */ - private C c; - - public void hello() - { - System.out.println( "Hello World!" ); - } -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin1.java b/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin1.java deleted file mode 100644 index 1a93b8693..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/DefaultPlugin1.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.plexus.plugins; - -import org.codehaus.plexus.components.A; -import org.codehaus.plexus.components.C; - -/** - * @plexus.component - */ -public class DefaultPlugin1 - implements Plugin1 -{ - /** @plexus.requirement */ - private A a; - - /** @plexus.requirement */ - private C c; - - public void hello() - { - System.out.println( "Hello World!" ); - } -} diff --git a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/Plugin1.java b/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/Plugin1.java deleted file mode 100644 index c8063cb0a..000000000 --- a/plexus-container-default/src/test/test-component-builds/plugin1/src/main/java/org/codehaus/plexus/plugins/Plugin1.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.plexus.plugins; - -public interface Plugin1 -{ - public void hello(); -} diff --git a/plexus-container-default/src/test/test-component-builds/pom.xml b/plexus-container-default/src/test/test-component-builds/pom.xml deleted file mode 100644 index 0cb527882..000000000 --- a/plexus-container-default/src/test/test-component-builds/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - 4.0.0 - org.codehaus.plexus.components - component-parent - 1.0-SNAPSHOT - pom - - component-a - component-b - component-c - plugin0 - plugin1 - - diff --git a/plexus-container-default/src/test/test-components/component-a-1.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/component-a-1.0-SNAPSHOT.jar deleted file mode 100644 index b2eb74286..000000000 Binary files a/plexus-container-default/src/test/test-components/component-a-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/component-a-2.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/component-a-2.0-SNAPSHOT.jar deleted file mode 100644 index b2eb74286..000000000 Binary files a/plexus-container-default/src/test/test-components/component-a-2.0-SNAPSHOT.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/component-b-1.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/component-b-1.0-SNAPSHOT.jar deleted file mode 100644 index e588c9470..000000000 Binary files a/plexus-container-default/src/test/test-components/component-b-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/component-c-1.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/component-c-1.0-SNAPSHOT.jar deleted file mode 100644 index c2d1996b7..000000000 Binary files a/plexus-container-default/src/test/test-components/component-c-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/plexus-archiver-1.0-alpha-8.jar b/plexus-container-default/src/test/test-components/plexus-archiver-1.0-alpha-8.jar deleted file mode 100644 index 445287775..000000000 Binary files a/plexus-container-default/src/test/test-components/plexus-archiver-1.0-alpha-8.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/plugin0-1.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/plugin0-1.0-SNAPSHOT.jar deleted file mode 100644 index 6498abe93..000000000 Binary files a/plexus-container-default/src/test/test-components/plugin0-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/plexus-container-default/src/test/test-components/plugin1-1.0-SNAPSHOT.jar b/plexus-container-default/src/test/test-components/plugin1-1.0-SNAPSHOT.jar deleted file mode 100644 index 9b5c71408..000000000 Binary files a/plexus-container-default/src/test/test-components/plugin1-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index fb0fbd9d6..0d7b7fb0f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,6 @@ plexus-component-annotations plexus-component-metadata - plexus-container-default