plexus-container-default/0000755000175000017500000000000010631507720014465 5ustar paulpaulplexus-container-default/pom.xml0000644000175000017500000000755510574657773016042 0ustar paulpaul plexus-containers org.codehaus.plexus 1.0.3 4.0.0 plexus-container-default Default Plexus Container 1.0-alpha-9-stable-1 maven-surefire-plugin **/Test*.java **/Abstract*.java org.apache.maven.wagon wagon-webdav 1.0-beta-2 junit junit 3.8.1 compile org.codehaus.plexus plexus-utils 1.0.4 classworlds classworlds 1.1-alpha-2 codehaus.org Plexus Central Repository dav:https://dav.codehaus.org/repository/plexus codehaus.org Plexus Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/plexus codehaus.org dav:https://dav.codehaus.org/plexus plexus-container-default/src/0000755000175000017500000000000010631507717015262 5ustar paulpaulplexus-container-default/src/site/0000755000175000017500000000000010631507717016226 5ustar paulpaulplexus-container-default/src/site/apt/0000755000175000017500000000000010631507717017012 5ustar paulpaulplexus-container-default/src/site/apt/design/0000755000175000017500000000000010631507717020263 5ustar paulpaulplexus-container-default/src/site/apt/design/active-collections.apt0000644000175000017500000002523410227512010024545 0ustar paulpaul --- Plexus-Backed Active Collections Design --- John Casey --- 12-April-2005 --- Design Documentation: Plexus-Backed "Active" Collections of Components * Introduction Many plexus components use references to other components which are not as simple as a one-to-one mapping. In order to support such cases, plexus has a notion of Collection-oriented component injection, in which requirements of components can reference fields that are Collections (List, Set, Map). When the container attempts to wire satisfy these requirements, it sees that they are collection mappings, and gives the component the appropriate collection-view on the container's component repository. Behavior is summarized in the following way, accoring to the field-type for the injection target: [java.util.Map field type] Components of the specified role are assigned to this field in a mapping of role-hint -> component. [java.util.List field type] Components of the specified role are assigned to this field in a List containing all of the components matching that role. As far as I can tell, this list is non-deterministic from the configured component's point of view, since I think it's determined by either a call to Map.values(), or the order in which the components were discovered, or something similar. [java.util.Set field type] Components of the specified role are assigned to this field in a Set containing all of the components matching that role. Since Set's are unordered, the question of order within this collection is not as touchy as that of a java.util.List field type. While this arrangement is perfectly acceptable in the simplest situations, where a container is entirely configured from a single plexus.xml file and does not allow dynamic component introduction at runtime, it cannot adequately address some of the more advanced use cases of plexus (most notably, any of features introduced by an artifact-enabled container). It also cannot handle the case where "core" components are discovered and added as part of the components.xml-based discovery process. Such core components might include things like component-factories, or other components which are mapped into various handlers and handler-managers used directly by the container. The only solution to this non-refreshing issue is to introduce support for container-backed "active" collections for 1:N mappings within component structures. * Examples and Discussion As a concrete example, suppose we're using a DefaultPlexusContainer (not an artifact-enabled container; we don't have to get into that yet) and that we want to allow the user of our application to optionally add support for non-java component factories, like the marmalade factory. Since the core components discovered during container initialization are in the plexus.xml file - of which only one is currently allowed per container - only the component-factories in this resource will be discovered and added to the component-factory-manager in the default, bare-bones configuration. Now, suppose the user adds the marmalade component-factory artifact to the container classpath, and restarts. This type, like before, the component factory manager receives a mapping with one entry, to the java factory. This takes place before discovery based on the components.xml is initiated. Now, since the marmalade component factory cannot introduce a second plexus.xml (it is not allowed!), it configures itself via the components.xml, which is discovered, and the marmalade factory is added to the component repository. At this point, if anyone does a direct lookup of the component-factory role with a role-hint of "marmalade" they will indeed get a reference to the marmalade component factory. <>, since the component factory manager's mapping of languages to factories has already been initialized, it does NOT get an updated mapping of factories, and therefore has no knowledge of the marmalade factory. In what would seem an answer to this issue, I have recently submitted a proposal to add support for multiple plexus.xml files to the container initialization process. This would seem to solve the problem, since in this case the marmalade component factory could simply define a fragmentary plexus.xml file, and it would be discovered at initialization-time. However, consider a more involved example. This time, consider what happens when we use the artifact-enabled container to introduce a new component factory <>. The use case for this would be allowing the bare minimum configuration for an application like maven, while retaining the ability for a dynamically-added component to declare and load the component factory it needs to load itself on demand. If maven could use this, it could provide limitless language support for plugins, without bloating the core distribution at all. But there is a problem: even if we allow multiple plexus.xml files, the container has still been initialized by the time the first dynamic component addition can take place. This means that the container already has its static mapping of languages to component factories - again, with a single mapping for the java language. The most elegant solution to this is to add support for dynamically-updated, "active" 1:N mappings between collections. These collections would provide Collection-like support to components, but would delegate lookup calls to the container to retrieve the most up-to-date component collections. For instance, a ComponentFactoryManager which used an active map rather than a static one would support dynamic introduction of new component-factory instances seamlessly. * Implementation Details ** Supporting java.util.* Contracts The biggest advantage of supporting java.util.(Map|Set|List) contracts is that we can pass these component instances into sub-objects that have no concept of plexus, which can then use the collection generically. This is actually a powerful option, to enable embedding of non-plexus-aware apps and APIs (jetty, or hibernate, for example). Even if we opt to implement the java.util.* contracts, there is nothing stopping us from adding non-API methods for management, etc. It's possible that the plexus-aware APIs could deal with these collections as plexus-aware instances, and have access to additional APIs (perhaps implementing a plexus management interface or something). From my point of view, it is essential to implement the java.util.* contracts, if for no other reason than embeddability of other applications and APIs inside of plexus. In all likelihood, any usage of 1:N mapped components will use Collection-like API calls anyway, even if it is plexus-aware. So, we will probably have to implement these methods anyway, even if we decide to name them something different. ** Collected-Component Management Without doubt, any active collection should allow the release of the contained component references, in order to act as a good citizen inside the plexus environment. The question that remains is how best to implement this release behavior: * Explicit releaseAll():void and release(Object):void methods on the active collection. * Calls to Collection.clear():void and Collection.remove(Object):void could release any components referenced within. The first has the advantage of explicit knowledge about what the collection is doing...even if it also has the somewhat counter-intuitive side-effect that - since any component-owner that releases a component must relinquish it's own reference to that component - calls to release*() would result in the collection being clear()'ed. The second is more in-line with the intention of the java.util.Collection contract, but may not be adequately plexus-aware (may not allow sufficiently fine-grained control). My personal preference would be to integrate the release behavior with Collection.clear(), etc. until we have a use case that dictates finer-grained control. This approach has the advantages of elegance and simplicity, not to mention that aforementioned advantage of being usable by all sorts of APIs and applications - thus improving embeddability. ** Mutability When dealing with collections of plexus components, it absolutely essential to restrict mutability to the container itself. If other components can modify these mappings, the risk of misbehaving components losing references to critical components is dramatically increased. In addition, such modification violates the semantics of the container environment itself. The premise that the container alone has the ability to modify the runtime environment and associated collection of components in the system will only be compromised by components with access to mutable component collections. It is important to note that immutable collections are perfectly within the contracts of the java.util.* interfaces (see Collections.unmodifiable*() for Sun-sanctioned examples). The also drastically reduce the complexity of any "active" collection implementation, since you don't have to risk the dreaded ConcurrentModificationException and the like. ** iterator(), values(), keySet(), entrySet(), and Container Updates While a certain amount of the complexity surrounding these operations can be reduced by making the collection immutable from the component point of view, we still have to consider cases where the underlying container discovers new components. And while Iterators are usually considered short-lifecycle objects, there is nothing saying that they have to be. It's entirely permissable for a component or sub-object to hold onto an Iterator instance for long periods of time. Therefore, any Iterator derived from an active collection must deal with new component discovery, and the associated update. I mention Iterator's primarily, since they have a notion of ordered elements, and a current place within that order. Preserving this notion of current-index is the most complex issue surrounding externally-updated collection content, so it will inevitably be the largest section of this discussion. Iterator can have a SoftReference to the next() component, populated when/if the next() method is called. It will also have a boolean field that determines whether hasNext() was called since the last call to next(). If reference == null and hasNextCalled == true, no next. If next.get() == null, throw ConcurrentModificationException...? If hasNextCalled == false, then directly lookup the next component from the set of keys... plexus-container-default/src/site/apt/design/multiple-plexus-xmls.apt0000644000175000017500000001465510227016475025133 0ustar paulpaul --- Design Supporting Multiple plexus.xml Files --- John Casey --- 11-April-2005 --- Design Documentation: Supporting Multiple plexus.xml Files * Introduction and Motivation Currently, plexus is configured using one plexus.xml file, one user-space plexus.xml file, and zero or more components.xml files. The components.xml files are assumed to be embedded in META-INF/plexus within component artifacts that are included in the classpath. Unfortunately, because of the differences between plexus.xml and components.xml, so-called "core" components cannot be added or configured using components.xml (because the container is assumed to be completely ready to run before the component descriptors are processed). This means that the plexus.xml file has to be created outside of any component which in turn means that the plexus.xml author has to have quite a lot of information about each "core" component in order to write a core descriptor. Support for fragmentary plexus.xml files in component artifacts would promote reusability, and reduce the requirements for extensive dependency specification inside a container-driven application, particularly when that application has many optional add-ons that require optional core components to be added to the container. One good use-case for multiple plexus.xml files is maven-2. We want to support multiple languages for maven plugins, but cannot without adding their respective plexus-component-factory implementations. While this may not seem to be that big of a deal, the dependency chains dragged into the build by the inclusion of any one non-java plexus-component-factory can be quite significant. Bringing in plexus-marmalade-factory, for instance, dragged in 4 new artifacts (plexus-marmalade-factory, marmalade-core, maven-script-marmalade, marmalade-el-commons) to the maven-core build, where we had to configure the plexus marmalade factory in the plexus.xml...we didn't have the luxury of using different plexus.xml files depending on the desired language support. Adding a restricted incarnation of multiple plexus.xml support would allow users to determine which languages they want to use, and configure the appropriate factories by calling a maven-plugin, or by simply dropping the appropriate artifacts into the core directory. <> It might be perfectly safe to allow resolved component-artifacts to participate in core component configuration, as well. We need to explore these issues more fully in a design session, and come to some sort of consensus. The biggest advantage would be allowing maven plugins to simply load the component factory they needed to run, on-the-fly. For now, I will pursue discovery via plexus.xml even on resolved component artifacts. * Modification Points The following points in the code will have to be modified in order to accommodate this change: * [PlexusXmlComponentDiscoverer<(new)>] Scan for any resources named META-INF/plexus/plexus.xml. This discoverer will be used to component sets from the former core-config file, and will read multiple instances of this file in the classpath. This component will also have other public methods which are not part of the ComponentDiscoverer interface, and which will allow extraction of a PlexusConfiguration object that contains the member-component information for the container's configuration. In this way, we can reuse the code from this ComponentDiscoverer implementation which reads from plexus.xml files. It seems important to centralize all handler logic for this resource, in order to promote maintainability and reduce the lengths to which we must go if we change something in this file. * [DefaultPlexusContainer] Change the processing logic for plexus.xml resources to use the new PlexusXmlComponentDiscoverer, described above. In this usage, the implementation-specific public methods will be used to directly retrieve the PlexusConfiguration from those resources. This is part of the non-interface API for this component, as stated above. Once the PlexusConfiguration is retrieved from the PlexusXmlComponentDiscoverer instance, it will be merged in much the same way as is currently done, with the exception that each instance of the plexus.xml resource will be merged. * Implications for Container Initialization and Resolved Artifacts One implication of this type of discovery is that any resolved artifacts - that is, any artifact which is not on the original classpath of the container - will not be able to contribute to the member-components for the container itself. This should be obvious, because no component-artifact resolution can take place until the container itself is initialized. <> Is that really true? What about component descriptors in the original classpath that declare dependencies on artifacts that don't exist in the original classpath? Is there any reasonable way to initialize the artifact container with a set of artifact repositories, such that missing artifacts can be resolved, downloaded, and added to the classpath at initialization-time? Is this even a Good Thing(tm)?? If we were to support artifact resolution at initialization-time, we could say that only the artifacts either: [[a]] present on the original classpath, or [[b]] implied by artifacts on the original classpath would be used to discover container member-components (things like ComponentRepository, ComponentFactoryManager, etc.) and that subsequent calls to addComponent(..) or addArtifact(..) or whatever it's called would not be allowed to reconfigure the container's member-components. I think we could handle this, by changing the way we construct/initialize the ArtifactEnabledContainer, but it remains to be decided whether this non-conventional initialization parameter is permissable, and whether this approach is a good idea. It might be better to require that the core component set (that is, the components with which the container is initialized) be completely present on the original classpath, to avoid network induced errors during the initialization process... My personal tendency is to say that resolution of missing artifacts at initialization time is the only consistent way of using an ArtifactEnabledContainer. plexus-container-default/src/site/apt/implementation/0000755000175000017500000000000010631507717022037 5ustar paulpaulplexus-container-default/src/site/apt/implementation/active-components.apt0000644000175000017500000001612610227633245026206 0ustar paulpaul --- Implementation Details: Active Collections --- John Casey --- 14-April-2005 --- Implementation Details for Active Collections * Iterator [SetLogicActiveIterator] Iterator implementation which keeps a running list of the role-hints that it has iterated over, and a SoftReference to the next component to be iterated over when using hasNext()->next(). Fields: [lastRoleHintList:java.util.List] Using the equals(..) method on this list vs. a newly retrieved copy of the list of role-hints, determines whether we need to discard our current index in this list (used for traversal), and seek a new one from the new list instance and using the visitedRoleHints to skip repositioned components. <> This will be inefficient for large collections of role-hints (components bound to the same role with different hints), since List.equals(List) is O(n) I believe... [currentIndex:int] Used to quickly resume traversal of the list of role-hints in the event that that list hasn't changed since the last step in the iteration. If the lists (last-used vs. current) are not equal, this index is discarded, and a new "currentIndex" is sought based on the visitedRoleHints and the most current copy of the role-hint List. [nextComponent: java.lang.ref.SoftReference] Used to store the component reference resulting from searching for a "next" component, as in resulting from a call to hasNext():boolean. The following states are possible for this field: * If hasNext() is never called, the field will be null. * If hasNext() is called, and returns false, the field will be null. * If hasNext() returns true, and the component has not been unloaded from the container (and thus garbage-collected), this field will contain a reference to the next component to be returned as a result of the next() method call. * If hasNext() returns true, and the component has been unloaded from the container (and garbage-collected), this field will contain a SoftReference that references null. That is, SoftReference.get() will return null. [hasNextCalled: boolean] Used to flag when hasNext() is called, but next() has not yet been called. This is useful because it will determine the difference between hasNext() being called and not finding anything, and hasNext() not being called. In the former case, the next() method should NOT try to find a next-component. In the latter case, we don't know what's out there, so a call to next() should search for a next-component. The following states are possible for this field: * If hasNext() is not called, this field is false. * If hasNext() is called, and next() has not been called, this field is true. * When next() is called, this field is set to false again. That way, successive calls to next() will result in these calls searching for successive next-components. Methods: [findNextComponent():boolean] Used to find the next component in to visit from this Iterator instance. The return value signals whether this method was successful in populating the nextComponent field reference. Executes the following general algorithm: [[1]] Asks the container for a current list of role-hints corresponding to the role this Iterator was constructed with. [[2]] Using the list from [1], and the lastRoleHintsList field, determine whether the list has changed since the last step in the iteration. * If it has changed: [[a]] Reassign the lastRoleHintList field to the "current" value of the role-hint list. [[b]] Discard the currentIndex field value [[c]] Seek a new currentIndex value by calling seekCurrentPositionIn() and passing in the "current" list as the parameter. * If the result of this method call is false: [[a]] set nextComponent = null [[b]] return false [[3]] If the list has not changed, use currentIndex to retrieve the next role-hint used to lookup the next component in the iteration. * If the next role-hint is null, or the index >= role-hint list.size then: [[a]] set nextComponent = null [[b]] return false [[4]] Using the role-hint from [3], lookup the next component from the container. * If the component is null: [[a]] set nextComponent = null [[b]] return false * Otherwise: [[a]] set nextComponent = new SoftReference(component) This is to ensure that the Iterator instance doesn't hold onto the component inappropriately and block unloading, etc. [[c]] return true [seekCurrentPositionIn(List):boolean] Used to repopulate the currentIndex of this iterator in the traversal of the available role-hints for the container. This is only triggered in the event that a change to the list of associated role-hints is detected during iteration. The return value for this method is used to indicate whether the method succeeded in seeking a new value for currentIndex. If the return value is false, we are to assume that there are no unvisited components associated with the role with which this Iterator instance was constructed. Executes the following general algorithm: <> General algorithm notes: Iterate through the new list up to the currentIndex, and use Object equals() at each element to determine if the change is in the "past" relative to traversal progress. If so, replace currentIndex with that changed index (maybe with a notation to skip back to original current index after traversing values changed in the "past"?). If not, then we know that any changes have taken place ahead of our current position, so there is no need to reposition the current index. PROBLEM: If elements[0] changes and currentIndex == 5, then you will wind up re-traversing the other 4-5 elements you already visited because the resetting of the currentIndex will move them back out ahead of currentIndex. [[1]] <> I'm still trying to complete the update-detection algorithm...it needs work, to minimize the weird effects that take place with a container reorders the components assigned to a particular role. now.plexus-container-default/src/main/0000755000175000017500000000000010631507717016206 5ustar paulpaulplexus-container-default/src/main/resources/0000755000175000017500000000000010631507717020220 5ustar paulpaulplexus-container-default/src/main/resources/org/0000755000175000017500000000000010631507717021007 5ustar paulpaulplexus-container-default/src/main/resources/org/codehaus/0000755000175000017500000000000010631507717022602 5ustar paulpaulplexus-container-default/src/main/resources/org/codehaus/plexus/0000755000175000017500000000000010631507717024122 5ustar paulpaulplexus-container-default/src/main/resources/org/codehaus/plexus/plexus-bootstrap.xml0000644000175000017500000002416710274515050030201 0ustar paulpaul singleton per-lookup singleton singleton-keep-alive plexus plexus Plexus Lifecycle Handler basic plexus-configurable passive java field setter map-oriented noop org.codehaus.plexus.logging.LoggerManager org.codehaus.plexus.logging.console.ConsoleLoggerManager basic info org.codehaus.plexus.component.configurator.ComponentConfigurator basic org.codehaus.plexus.component.configurator.BasicComponentConfigurator passive org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup default org.codehaus.plexus.component.configurator.ComponentConfigurator map-oriented org.codehaus.plexus.component.configurator.MapOrientedComponentConfigurator passive org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup default org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup default org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup org.codehaus.plexus.component.configurator.converters.ConfigurationConverter converters plexus-container-default/src/main/java/0000755000175000017500000000000010631507706017125 5ustar paulpaulplexus-container-default/src/main/java/org/0000755000175000017500000000000010631507706017714 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/0000755000175000017500000000000010631507706021507 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/0000755000175000017500000000000010631507717023031 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java0000644000175000017500000014621010342751570030325 0ustar paulpaulpackage org.codehaus.plexus; /* * 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.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; import org.codehaus.classworlds.DuplicateRealmException; import org.codehaus.classworlds.NoSuchRealmException; import org.codehaus.plexus.component.composition.ComponentComposerManager; import org.codehaus.plexus.component.composition.CompositionException; import org.codehaus.plexus.component.composition.UndefinedComponentComposerException; import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; 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.DiscoveryListenerDescriptor; import org.codehaus.plexus.component.discovery.PlexusXmlComponentDiscoverer; import org.codehaus.plexus.component.factory.ComponentFactory; import org.codehaus.plexus.component.factory.ComponentFactoryManager; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.factory.UndefinedComponentFactoryException; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.component.manager.ComponentManagerManager; import org.codehaus.plexus.component.manager.UndefinedComponentManagerException; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRepository; 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.exception.ComponentRepositoryException; 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.PlexusConfigurationResourceException; import org.codehaus.plexus.configuration.processor.ConfigurationProcessingException; import org.codehaus.plexus.configuration.processor.ConfigurationProcessor; import org.codehaus.plexus.configuration.processor.ConfigurationResourceNotFoundException; import org.codehaus.plexus.configuration.processor.DirectoryConfigurationResourceHandler; import org.codehaus.plexus.configuration.processor.FileConfigurationResourceHandler; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; 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.lifecycle.LifecycleHandlerManager; import org.codehaus.plexus.lifecycle.UndefinedLifecycleHandlerException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.WeakHashMap; /** * @todo clarify configuration handling vis-a-vis user vs default values * @todo use classworlds whole hog, plexus' concern is applications. * @todo allow setting of a live configuraton so applications that embed plexus * can use whatever configuration mechanism they like. They just have to * adapt it into something plexus can understand. */ public class DefaultPlexusContainer extends AbstractLogEnabled implements PlexusContainer { private PlexusContainer parentContainer; private LoggerManager loggerManager; private DefaultContext context; protected PlexusConfiguration configuration; private Reader configurationReader; private ClassWorld classWorld; private ClassRealm coreRealm; private ClassRealm plexusRealm; private String name; private ComponentRepository componentRepository; private ComponentManagerManager componentManagerManager; private LifecycleHandlerManager lifecycleHandlerManager; private ComponentDiscovererManager componentDiscovererManager; private ComponentFactoryManager componentFactoryManager; private ComponentComposerManager componentComposerManager; private Map childContainers = new WeakHashMap(); public static final String BOOTSTRAP_CONFIGURATION = "org/codehaus/plexus/plexus-bootstrap.xml"; private boolean started = false; private boolean initialized = false; private final Date creationDate = new Date(); // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- public DefaultPlexusContainer() { context = new DefaultContext(); } // ---------------------------------------------------------------------- // Container Contract // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- // Timestamping Methods // ---------------------------------------------------------------------- public Date getCreationDate() { return creationDate; } // ---------------------------------------------------------------------- // Child container access // ---------------------------------------------------------------------- public boolean hasChildContainer( String name ) { return childContainers.get( name ) != null; } public void removeChildContainer( String name ) { childContainers.remove( name ); } public PlexusContainer getChildContainer( String name ) { return (PlexusContainer) childContainers.get( name ); } public PlexusContainer createChildContainer( String name, List classpathJars, Map context ) throws PlexusContainerException { return createChildContainer( name, classpathJars, context, Collections.EMPTY_LIST ); } public PlexusContainer createChildContainer( String name, List classpathJars, Map context, List discoveryListeners ) throws PlexusContainerException { if ( hasChildContainer( name ) ) { throw new DuplicateChildContainerException( getName(), name ); } DefaultPlexusContainer child = new DefaultPlexusContainer(); child.classWorld = classWorld; ClassRealm childRealm = null; String childRealmId = getName() + ".child-container[" + name + "]"; try { childRealm = classWorld.getRealm( childRealmId ); } catch ( NoSuchRealmException e ) { try { childRealm = classWorld.newRealm( childRealmId ); } catch ( DuplicateRealmException impossibleError ) { getLogger().error( "An impossible error has occurred. After getRealm() failed, newRealm() " + "produced duplication error on same id!", impossibleError ); } } childRealm.setParent( plexusRealm ); child.coreRealm = childRealm; child.plexusRealm = childRealm; child.setName( name ); child.setParentPlexusContainer( this ); // ---------------------------------------------------------------------- // Set all the child elements from the parent that were set // programmatically. // ---------------------------------------------------------------------- child.setLoggerManager( loggerManager ); for ( Iterator it = context.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); child.addContextValue( entry.getKey(), entry.getValue() ); } child.initialize(); for ( Iterator it = classpathJars.iterator(); it.hasNext(); ) { Object next = it.next(); File jar = (File) next; child.addJarResource( jar ); } for ( Iterator it = discoveryListeners.iterator(); it.hasNext(); ) { ComponentDiscoveryListener listener = (ComponentDiscoveryListener) it.next(); child.registerComponentDiscoveryListener( listener ); } child.start(); childContainers.put( name, child ); return child; } // ---------------------------------------------------------------------- // Component Lookup // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- // Try to lookup the component manager for the requested component. // // component manager exists: // -> return a component from the component manager. // // component manager doesn't exist; // -> lookup component descriptor for the requested component. // -> instantiate component manager for this component. // -> track the component manager for this component by the component class name. // -> return a component from the component manager. // ---------------------------------------------------------------------- public Object lookup( String componentKey ) throws ComponentLookupException { Object component = null; ComponentManager componentManager = componentManagerManager.findComponentManagerByComponentKey( componentKey ); // The first time we lookup a component a component manager will not exist so we ask the // component manager manager to create a component manager for us. if ( componentManager == null ) { ComponentDescriptor descriptor = componentRepository.getComponentDescriptor( componentKey ); if ( descriptor == null ) { if ( parentContainer != null ) { return parentContainer.lookup( componentKey ); } // don't need this AND an exception...we'll put it at the debug output level, rather than error... if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Nonexistent component: " + componentKey ); } String message = "Component descriptor cannot be found in the component repository: " + componentKey + "."; throw new ComponentLookupException( message ); } componentManager = createComponentManager( descriptor ); } try { component = componentManager.getComponent(); } catch ( ComponentInstantiationException e ) { throw new ComponentLookupException( "Unable to lookup component '" + componentKey + "', it could not be created", e ); } catch ( ComponentLifecycleException e ) { throw new ComponentLookupException( "Unable to lookup component '" + componentKey + "', it could not be started", e ); } componentManagerManager.associateComponentWithComponentManager( component, componentManager ); return component; } private ComponentManager createComponentManager( ComponentDescriptor descriptor ) throws ComponentLookupException { ComponentManager componentManager; try { componentManager = componentManagerManager.createComponentManager( descriptor, this ); } catch ( UndefinedComponentManagerException e ) { String message = "Cannot create component manager for " + descriptor.getComponentKey() + ", so we cannot provide a component instance."; throw new ComponentLookupException( message, e ); } catch ( UndefinedLifecycleHandlerException e ) { String message = "Cannot create component manager for " + descriptor.getComponentKey() + ", so we cannot provide a component instance."; throw new ComponentLookupException( message, e ); } return componentManager; } /** * @todo Change this to include components looked up from parents as well... */ public Map lookupMap( String role ) throws ComponentLookupException { Map components = new HashMap(); Map componentDescriptors = getComponentDescriptorMap( role ); if ( componentDescriptors != null ) { // Now we have a map of component descriptors keyed by role hint. for ( Iterator i = componentDescriptors.keySet().iterator(); i.hasNext(); ) { String roleHint = (String) i.next(); Object component = lookup( role, roleHint ); components.put( roleHint, component ); } } return components; } /** * @todo Change this to include components looked up from parents as well... */ public List lookupList( String role ) throws ComponentLookupException { List components = new ArrayList(); List componentDescriptors = getComponentDescriptorList( role ); if ( componentDescriptors != null ) { // Now we have a list of component descriptors. for ( Iterator i = componentDescriptors.iterator(); i.hasNext(); ) { ComponentDescriptor descriptor = (ComponentDescriptor) i.next(); String roleHint = descriptor.getRoleHint(); Object component; if ( roleHint != null ) { component = lookup( role, roleHint ); } else { component = lookup( role ); } components.add( component ); } } return components; } public Object lookup( String role, String roleHint ) throws ComponentLookupException { return lookup( role + roleHint ); } // ---------------------------------------------------------------------- // Component Descriptor Lookup // ---------------------------------------------------------------------- public ComponentDescriptor getComponentDescriptor( String componentKey ) { ComponentDescriptor result = componentRepository.getComponentDescriptor( componentKey ); if ( result == null && parentContainer != null ) { result = parentContainer.getComponentDescriptor( componentKey ); } return result; } public Map getComponentDescriptorMap( String role ) { Map result = null; if ( parentContainer != null ) { result = parentContainer.getComponentDescriptorMap( role ); } Map componentDescriptors = componentRepository.getComponentDescriptorMap( role ); if ( componentDescriptors != null ) { if ( result != null ) { result.putAll( componentDescriptors ); } else { result = componentDescriptors; } } return result; } public List getComponentDescriptorList( String role ) { List result = null; Map componentDescriptorsByHint = getComponentDescriptorMap( role ); if ( componentDescriptorsByHint != null ) { result = new ArrayList( componentDescriptorsByHint.values() ); } else { ComponentDescriptor unhintedDescriptor = getComponentDescriptor( role ); if ( unhintedDescriptor != null ) { result = Collections.singletonList( unhintedDescriptor ); } else { result = Collections.EMPTY_LIST; } } return result; } public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException { componentRepository.addComponentDescriptor( componentDescriptor ); } // ---------------------------------------------------------------------- // Component Release // ---------------------------------------------------------------------- public void release( Object component ) throws ComponentLifecycleException { if ( component == null ) { return; } ComponentManager componentManager = componentManagerManager.findComponentManagerByComponentInstance( component ); if ( componentManager == null ) { if ( parentContainer != null ) { parentContainer.release( component ); } else { getLogger().warn( "Component manager not found for returned component. Ignored. component=" + component ); } } else { componentManager.release( component ); if ( componentManager.getConnections() <= 0 ) { componentManagerManager.unassociateComponentWithComponentManager( component ); } } } public void releaseAll( Map components ) throws ComponentLifecycleException { for ( Iterator i = components.values().iterator(); i.hasNext(); ) { Object component = i.next(); release( component ); } } public void releaseAll( List components ) throws ComponentLifecycleException { for ( Iterator i = components.iterator(); i.hasNext(); ) { Object component = i.next(); release( component ); } } public boolean hasComponent( String componentKey ) { return componentRepository.hasComponent( componentKey ); } public boolean hasComponent( String role, String roleHint ) { return componentRepository.hasComponent( role, roleHint ); } public void suspend( Object component ) throws ComponentLifecycleException { if ( component == null ) { return; } ComponentManager componentManager = componentManagerManager.findComponentManagerByComponentInstance( component ); componentManager.suspend( component ); } public void resume( Object component ) throws ComponentLifecycleException { if ( component == null ) { return; } ComponentManager componentManager = componentManagerManager.findComponentManagerByComponentInstance( component ); componentManager.resume( component ); } // ---------------------------------------------------------------------- // Lifecylce Management // ---------------------------------------------------------------------- /** * @deprecated Use getContainerRealm() instead. */ public ClassRealm getComponentRealm( String id ) { return plexusRealm; } public boolean isInitialized() { return initialized; } public void initialize() throws PlexusContainerException { try { initializeClassWorlds(); initializeConfiguration(); initializeResources(); initializeCoreComponents(); initializeLoggerManager(); initializeContext(); initializeSystemProperties(); this.initialized = true; } catch ( DuplicateRealmException e ) { throw new PlexusContainerException( "Error initializing classworlds", e ); } catch ( ConfigurationProcessingException e ) { throw new PlexusContainerException( "Error processing configuration", e ); } catch ( ConfigurationResourceNotFoundException e ) { throw new PlexusContainerException( "Error processing configuration", e ); } catch ( ComponentConfigurationException e ) { throw new PlexusContainerException( "Error configuring components", e ); } catch ( PlexusConfigurationException e ) { throw new PlexusContainerException( "Error configuring components", e ); } catch ( ComponentRepositoryException e ) { throw new PlexusContainerException( "Error initializing components", e ); } catch ( ContextException e ) { throw new PlexusContainerException( "Error contextualizing components", e ); } } public void registerComponentDiscoveryListeners() throws ComponentLookupException { List listeners = componentDiscovererManager.getListenerDescriptors(); if ( listeners != null ) { for ( Iterator i = listeners.iterator(); i.hasNext(); ) { DiscoveryListenerDescriptor listenerDescriptor = (DiscoveryListenerDescriptor) i.next(); String role = listenerDescriptor.getRole(); ComponentDiscoveryListener l = (ComponentDiscoveryListener) lookup( role ); componentDiscovererManager.registerComponentDiscoveryListener( l ); } } } // We are assuming that any component which is designated as a component discovery // listener is listed in the plexus.xml file that will be discovered and processed // before the components.xml are discovered in JARs and processed. /** * TODO: Enhance the ComponentRepository so that it can take entire * ComponentSetDescriptors instead of just ComponentDescriptors. */ public List discoverComponents( ClassRealm classRealm ) throws PlexusConfigurationException, ComponentRepositoryException { List discoveredComponentDescriptors = new ArrayList(); for ( Iterator i = componentDiscovererManager.getComponentDiscoverers().iterator(); i.hasNext(); ) { ComponentDiscoverer componentDiscoverer = (ComponentDiscoverer) i.next(); List componentSetDescriptors = componentDiscoverer.findComponents( getContext(), classRealm ); for ( Iterator j = componentSetDescriptors.iterator(); j.hasNext(); ) { ComponentSetDescriptor componentSet = (ComponentSetDescriptor) j.next(); List componentDescriptors = componentSet.getComponents(); if ( componentDescriptors != null ) { for ( Iterator k = componentDescriptors.iterator(); k.hasNext(); ) { ComponentDescriptor componentDescriptor = (ComponentDescriptor) k.next(); componentDescriptor.setComponentSetDescriptor( componentSet ); // If the user has already defined a component descriptor for this particular // component then do not let the discovered component descriptor override // the user defined one. if ( getComponentDescriptor( componentDescriptor.getComponentKey() ) == null ) { addComponentDescriptor( componentDescriptor ); // We only want to add components that have not yet been // discovered in a parent realm. We don't quite have fine // grained control over this right now but this is for // dynamic additions which are only happening from maven // at the moment. And plugins have a parent realm and // a grand parent realm so if the component has been // discovered it's most likely in those realms. // I actually need to keep track of what realm a component // was discovered in so that i can accurately search the // parents. discoveredComponentDescriptors.add( componentDescriptor ); } } //discoveredComponentDescriptors.addAll( componentDescriptors ); } } } return discoveredComponentDescriptors; } // We need to be aware of dependencies between discovered components when the listed component // as the discovery listener itself depends on components that need to be discovered. public boolean isStarted() { return started; } public void start() throws PlexusContainerException { try { registerComponentDiscoveryListeners(); discoverComponents( plexusRealm ); loadComponentsOnStart(); this.started = true; } catch ( PlexusConfigurationException e ) { throw new PlexusContainerException( "Error starting container", e ); } catch ( ComponentLookupException e ) { throw new PlexusContainerException( "Error starting container", e ); } catch ( ComponentRepositoryException e ) { throw new PlexusContainerException( "Error starting container", e ); } configuration = null; } public void dispose() { disposeAllComponents(); if ( parentContainer != null ) { parentContainer.removeChildContainer( getName() ); parentContainer = null; } try { plexusRealm.setParent( null ); classWorld.disposeRealm( plexusRealm.getId() ); } catch ( NoSuchRealmException e ) { getLogger().debug( "Failed to dispose realm for exiting container: " + getName(), e ); } this.started = false; this.initialized = true; } protected void disposeAllComponents() { // copy the list so we don't get concurrent modification exceptions during disposal Collection collection = new ArrayList( componentManagerManager.getComponentManagers().values() ); for ( Iterator iter = collection.iterator(); iter.hasNext(); ) { try { ( (ComponentManager) iter.next() ).dispose(); } catch ( Exception e ) { getLogger().error( "Error while disposing component manager. Continuing with the rest", e ); } } componentManagerManager.getComponentManagers().clear(); } // ---------------------------------------------------------------------- // Pre-initialization - can only be called prior to initialization // ---------------------------------------------------------------------- public void setParentPlexusContainer( PlexusContainer parentContainer ) { this.parentContainer = parentContainer; } public void addContextValue( Object key, Object value ) { context.put( key, value ); } /** * @todo don't hold this reference - the reader will remain open forever * @see PlexusContainer#setConfigurationResource(Reader) */ public void setConfigurationResource( Reader configuration ) throws PlexusConfigurationResourceException { this.configurationReader = configuration; } // ---------------------------------------------------------------------- // Implementation // ---------------------------------------------------------------------- protected void loadComponentsOnStart() throws PlexusConfigurationException, ComponentLookupException { PlexusConfiguration[] loadOnStartComponents = configuration.getChild( "load-on-start" ).getChildren( "component" ); getLogger().debug( "Found " + loadOnStartComponents.length + " components to load on start" ); for ( int i = 0; i < loadOnStartComponents.length; i++ ) { String role = loadOnStartComponents[i].getChild( "role" ).getValue( null ); String roleHint = loadOnStartComponents[i].getChild( "role-hint" ).getValue(); if ( role == null ) { throw new PlexusConfigurationException( "Missing 'role' element from load-on-start." ); } if ( roleHint == null ) { getLogger().info( "Loading on start [role]: " + "[" + role + "]" ); lookup( role ); } else 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 ); } } } // ---------------------------------------------------------------------- // Misc Configuration // ---------------------------------------------------------------------- public String getName() { return name; } public void setName( String name ) { this.name = name; } public ClassWorld getClassWorld() { return classWorld; } public void setClassWorld( ClassWorld classWorld ) { this.classWorld = classWorld; } public ClassRealm getCoreRealm() { return coreRealm; } public void setCoreRealm( ClassRealm coreRealm ) { this.coreRealm = coreRealm; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void initializeClassWorlds() throws DuplicateRealmException { if ( classWorld == null ) { classWorld = new ClassWorld(); } // Create a name for our application if one doesn't exist. initializeName(); if ( coreRealm == null ) { try { coreRealm = classWorld.getRealm( "plexus.core" ); } catch ( NoSuchRealmException e ) { /* We are being loaded with someone who hasn't * given us any classworlds realms. In this case, * we want to use the classes already in the * ClassLoader for our realm. */ coreRealm = classWorld.newRealm( "plexus.core", Thread.currentThread().getContextClassLoader() ); } } // We are in a non-embedded situation if ( plexusRealm == null ) { try { plexusRealm = coreRealm.getWorld().getRealm( "plexus.core.maven" ); } catch ( NoSuchRealmException e ) { //plexusRealm = coreRealm.getWorld().newRealm( "plexus.core.maven" ); // If no app realm can be found then we will make the plexusRealm // the same as the app realm. plexusRealm = coreRealm; } //plexusRealm.importFrom( coreRealm.getId(), "" ); addContextValue( "common.classloader", plexusRealm.getClassLoader() ); Thread.currentThread().setContextClassLoader( plexusRealm.getClassLoader() ); } } public ClassRealm getContainerRealm() { return plexusRealm; } /** * Create a name for our application if one doesn't exist. */ protected void initializeName() { if ( name == null ) { int i = 0; while ( true ) { try { classWorld.getRealm( "plexus.app" + i ); i++; } catch ( NoSuchRealmException e ) { setName( "app" + i ); return; } } } } // ---------------------------------------------------------------------- // Context // ---------------------------------------------------------------------- public Context getContext() { return context; } private void initializeContext() { addContextValue( PlexusConstants.PLEXUS_KEY, this ); addContextValue( PlexusConstants.PLEXUS_CORE_REALM, plexusRealm ); } // ---------------------------------------------------------------------- // Configuration // ---------------------------------------------------------------------- protected void initializeConfiguration() throws ConfigurationProcessingException, ConfigurationResourceNotFoundException, PlexusConfigurationException { // System userConfiguration InputStream is = coreRealm.getResourceAsStream( BOOTSTRAP_CONFIGURATION ); if ( is == null ) { throw new IllegalStateException( "The internal default plexus-bootstrap.xml is missing. " + "This is highly irregular, your plexus JAR is " + "most likely corrupt." ); } PlexusConfiguration systemConfiguration = PlexusTools.buildConfiguration( BOOTSTRAP_CONFIGURATION, new InputStreamReader( is ) ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- // Some of this could probably be collapsed as having a plexus.xml in your // META-INF/plexus directory is probably a better solution then specifying // a configuration with an URL but I'm leaving the configuration by URL // as folks might be using it ... I made this change to accomodate Maven // but I think it's better to discover a configuration in a standard // place. configuration = systemConfiguration; PlexusXmlComponentDiscoverer discoverer = new PlexusXmlComponentDiscoverer(); PlexusConfiguration plexusConfiguration = discoverer.discoverConfiguration( getContext(), plexusRealm ); if ( plexusConfiguration != null ) { configuration = PlexusConfigurationMerger.merge( plexusConfiguration, configuration ); processConfigurationsDirectory(); } if ( configurationReader != null ) { // User userConfiguration PlexusConfiguration userConfiguration = PlexusTools.buildConfiguration( "", getInterpolationConfigurationReader( configurationReader ) ); // Merger of systemConfiguration and user userConfiguration configuration = PlexusConfigurationMerger.merge( userConfiguration, configuration ); processConfigurationsDirectory(); } // --------------------------------------------------------------------------- // Now that we have the configuration we will use the ConfigurationProcessor // to inline any external configuration instructions. // // At his point the variables in the configuration have already been // interpolated so we can send in an empty Map because the context // values are already there. // --------------------------------------------------------------------------- ConfigurationProcessor p = new ConfigurationProcessor(); p.addConfigurationResourceHandler( new FileConfigurationResourceHandler() ); p.addConfigurationResourceHandler( new DirectoryConfigurationResourceHandler() ); configuration = p.process( configuration, Collections.EMPTY_MAP ); } protected Reader getInterpolationConfigurationReader( Reader reader ) { InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, new ContextMapAdapter( context ) ); return interpolationFilterReader; } /** * Process any additional component configuration files that have been * specified. The specified directory is scanned recursively so configurations * can be within nested directories to help with component organization. */ private void processConfigurationsDirectory() throws PlexusConfigurationException { String s = configuration.getChild( "configurations-directory" ).getValue( null ); if ( s != null ) { PlexusConfiguration componentsConfiguration = configuration.getChild( "components" ); File configurationsDirectory = new File( s ); if ( configurationsDirectory.exists() && configurationsDirectory.isDirectory() ) { List componentConfigurationFiles = null; try { componentConfigurationFiles = FileUtils.getFiles( configurationsDirectory, "**/*.conf", "**/*.xml" ); } catch ( IOException e ) { throw new PlexusConfigurationException( "Unable to locate configuration files", e ); } for ( Iterator i = componentConfigurationFiles.iterator(); i.hasNext(); ) { File componentConfigurationFile = (File) i.next(); FileReader reader = null; try { reader = new FileReader( componentConfigurationFile ); PlexusConfiguration componentConfiguration = PlexusTools.buildConfiguration( componentConfigurationFile.getAbsolutePath(), getInterpolationConfigurationReader( reader ) ); componentsConfiguration.addChild( componentConfiguration.getChild( "components" ) ); } catch ( FileNotFoundException e ) { throw new PlexusConfigurationException( "File " + componentConfigurationFile + " disappeared before processing", e ); } finally { IOUtil.close( reader ); } } } } } private void initializeLoggerManager() throws PlexusContainerException { // ---------------------------------------------------------------------- // The logger manager may have been set programmatically so we need // to check. If it hasn't // ---------------------------------------------------------------------- if ( loggerManager == null ) { try { loggerManager = (LoggerManager) lookup( LoggerManager.ROLE ); } catch ( ComponentLookupException e ) { throw new PlexusContainerException( "Unable to locate logger manager", e ); } } enableLogging( loggerManager.getLoggerForComponent( PlexusContainer.class.getName() ) ); } private void initializeCoreComponents() throws ComponentConfigurationException, ComponentRepositoryException, ContextException { BasicComponentConfigurator configurator = new BasicComponentConfigurator(); PlexusConfiguration c = configuration.getChild( "component-repository" ); processCoreComponentConfiguration( "component-repository", configurator, c ); componentRepository.configure( configuration ); componentRepository.setClassRealm( plexusRealm ); componentRepository.initialize(); // Lifecycle handler manager c = configuration.getChild( "lifecycle-handler-manager" ); processCoreComponentConfiguration( "lifecycle-handler-manager", configurator, c ); lifecycleHandlerManager.initialize(); // Component manager manager c = configuration.getChild( "component-manager-manager" ); processCoreComponentConfiguration( "component-manager-manager", configurator, c ); componentManagerManager.setLifecycleHandlerManager( lifecycleHandlerManager ); // Component discoverer manager c = configuration.getChild( "component-discoverer-manager" ); processCoreComponentConfiguration( "component-discoverer-manager", configurator, c ); componentDiscovererManager.initialize(); // Component factory manager c = configuration.getChild( "component-factory-manager" ); processCoreComponentConfiguration( "component-factory-manager", configurator, c ); if ( componentFactoryManager instanceof Contextualizable ) { Context context = getContext(); context.put( PlexusConstants.PLEXUS_KEY, this ); ( (Contextualizable) componentFactoryManager ).contextualize( getContext() ); } // Component factory manager c = configuration.getChild( "component-composer-manager" ); processCoreComponentConfiguration( "component-composer-manager", configurator, c ); } private void processCoreComponentConfiguration( String role, BasicComponentConfigurator configurator, PlexusConfiguration c ) throws ComponentConfigurationException { String implementation = c.getAttribute( "implementation", null ); if ( implementation == null ) { String msg = "Core component: '" + role + "' + which is needed by plexus to function properly cannot " + "be instantiated. Implementation attribute was not specified in plexus.conf." + "This is highly irregular, your plexus JAR is most likely corrupt."; throw new ComponentConfigurationException( msg ); } ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setRole( role ); componentDescriptor.setImplementation( implementation ); PlexusConfiguration configuration = new XmlPlexusConfiguration( "configuration" ); configuration.addChild( c ); try { configurator.configureComponent( this, configuration, plexusRealm ); } catch ( ComponentConfigurationException e ) { // TODO: don't like rewrapping the same exception, but better than polluting this all through the config code String message = "Error configuring component: " + componentDescriptor.getHumanReadableKey(); throw new ComponentConfigurationException( message, e ); } } private void initializeSystemProperties() throws PlexusConfigurationException { PlexusConfiguration[] systemProperties = configuration.getChild( "system-properties" ).getChildren( "property" ); for ( int i = 0; i < systemProperties.length; ++i ) { String name = systemProperties[i].getAttribute( "name" ); String value = systemProperties[i].getAttribute( "value" ); if ( name == null ) { throw new PlexusConfigurationException( "Missing 'name' attribute in 'property' tag. " ); } if ( value == null ) { throw new PlexusConfigurationException( "Missing 'value' attribute in 'property' tag. " ); } System.getProperties().setProperty( name, value ); getLogger().info( "Setting system property: [ " + name + ", " + value + " ]" ); } } // ---------------------------------------------------------------------- // Resource Management // ---------------------------------------------------------------------- // TODO: Do not swallow exception public void initializeResources() throws PlexusConfigurationException { PlexusConfiguration[] resourceConfigs = configuration.getChild( "resources" ).getChildren(); for ( int i = 0; i < resourceConfigs.length; ++i ) { try { String name = resourceConfigs[i].getName(); if ( name.equals( "jar-repository" ) ) { addJarRepository( new File( resourceConfigs[i].getValue() ) ); } else if ( name.equals( "directory" ) ) { File directory = new File( resourceConfigs[i].getValue() ); if ( directory.exists() && directory.isDirectory() ) { plexusRealm.addConstituent( directory.toURL() ); } } else { getLogger().warn( "Unknown resource type: " + name ); } } catch ( MalformedURLException e ) { getLogger().error( "Error configuring resource: " + resourceConfigs[i].getName() + "=" + resourceConfigs[i].getValue(), e ); } } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public void addJarResource( File jar ) throws PlexusContainerException { try { plexusRealm.addConstituent( jar.toURL() ); if ( isStarted() ) { discoverComponents( plexusRealm ); } } catch ( MalformedURLException e ) { throw new PlexusContainerException( "Cannot add jar resource: " + jar + " (bad URL)", e ); } catch ( PlexusConfigurationException e ) { throw new PlexusContainerException( "Cannot add jar resource: " + jar + " (error discovering new components)", e ); } catch ( ComponentRepositoryException e ) { throw new PlexusContainerException( "Cannot add jar resource: " + jar + " (error discovering new components)", e ); } } public void addJarRepository( File repository ) { if ( repository.exists() && repository.isDirectory() ) { File[] jars = repository.listFiles(); for ( int j = 0; j < jars.length; j++ ) { if ( jars[j].getAbsolutePath().endsWith( ".jar" ) ) { try { addJarResource( jars[j] ); } catch ( PlexusContainerException e ) { getLogger().warn( "Unable to add JAR: " + jars[j], e ); } } } } else { getLogger().warn( "The specified JAR repository doesn't exist or is not a directory: '" + repository.getAbsolutePath() + "'." ); } } public Logger getLogger() { return super.getLogger(); } public Object createComponentInstance( ComponentDescriptor componentDescriptor ) throws ComponentInstantiationException, ComponentLifecycleException { String componentFactoryId = componentDescriptor.getComponentFactory(); ComponentFactory componentFactory = null; Object component = null; try { if ( componentFactoryId != null ) { componentFactory = componentFactoryManager.findComponentFactory( componentFactoryId ); } else { componentFactory = componentFactoryManager.getDefaultComponentFactory(); } component = componentFactory.newInstance( componentDescriptor, plexusRealm, this ); } catch ( UndefinedComponentFactoryException e ) { throw new ComponentInstantiationException( "Unable to create component as factory '" + componentFactoryId + "' could not be found", e ); } finally { // the java factory is a special case, without a component manager. // Don't bother releasing the java factory. if ( StringUtils.isNotEmpty( componentFactoryId ) && !"java".equals( componentFactoryId ) ) { release( componentFactory ); } } return component; } public void composeComponent( Object component, ComponentDescriptor componentDescriptor ) throws CompositionException, UndefinedComponentComposerException { componentComposerManager.assembleComponent( component, componentDescriptor, this ); } // ---------------------------------------------------------------------- // Discovery // ---------------------------------------------------------------------- public void registerComponentDiscoveryListener( ComponentDiscoveryListener listener ) { componentDiscovererManager.registerComponentDiscoveryListener( listener ); } public void removeComponentDiscoveryListener( ComponentDiscoveryListener listener ) { componentDiscovererManager.removeComponentDiscoveryListener( listener ); } // ---------------------------------------------------------------------- // Start of new programmatic API to fully control the container // ---------------------------------------------------------------------- public void setLoggerManager( LoggerManager loggerManager ) { this.loggerManager = loggerManager; } public LoggerManager getLoggerManager() { return loggerManager; } } plexus-container-default/src/main/java/org/codehaus/plexus/SimplePlexusContainerManager.java0000644000175000017500000001033610231133376031457 0ustar paulpaulpackage org.codehaus.plexus; /* * 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.configuration.PlexusConfigurationResourceException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; 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.InitializationException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Iterator; import java.util.Properties; /** * SimplePlexusContainerManager * * @author Mark Wilkinson * @version $Revision: 1750 $ */ public class SimplePlexusContainerManager implements PlexusContainerManager, Contextualizable, Initializable, Startable { /** * Parent PlexusContainer. That is, the * PlexusContainer that this component is in. */ private PlexusContainer parentPlexus; /** Our own PlexusContainer. */ private DefaultPlexusContainer myPlexus; private String plexusConfig; private Properties contextValues; public void contextualize( Context context ) throws ContextException { parentPlexus = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } public void initialize() throws InitializationException { myPlexus = new DefaultPlexusContainer(); myPlexus.setParentPlexusContainer( parentPlexus ); ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream stream = loader.getResourceAsStream( plexusConfig ); Reader r = new InputStreamReader( stream ); try { myPlexus.setConfigurationResource( r ); } catch ( PlexusConfigurationResourceException e ) { throw new InitializationException( "Unable to initialize container configuration", e ); } if ( contextValues != null ) { for ( Iterator i = contextValues.keySet().iterator(); i.hasNext(); ) { String name = (String) i.next(); myPlexus.addContextValue( name, contextValues.getProperty( name ) ); } } try { myPlexus.initialize(); } catch ( PlexusContainerException e ) { throw new InitializationException( "Error initializing container", e ); } } public void start() throws StartingException { try { myPlexus.start(); } catch ( PlexusContainerException e ) { throw new StartingException( "Error starting container", e ); } } public void stop() { myPlexus.dispose(); } public PlexusContainer[] getManagedContainers() { return new PlexusContainer[] { myPlexus }; } } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/0000755000175000017500000000000010631507706024766 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java0000644000175000017500000000766110231133376032516 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.lifecycle.phase.Phase; import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public abstract class AbstractLifecycleHandler implements LifecycleHandler { private String id = null; private String name = null; private List beginSegment; private List suspendSegment; private List resumeSegment; private List endSegment; public AbstractLifecycleHandler() { beginSegment = new ArrayList(); suspendSegment = new ArrayList(); resumeSegment = new ArrayList(); endSegment = new ArrayList(); } public String getId() { return id; } public String getName() { return name; } // ---------------------------------------------------------------------- // Begin Segment // ---------------------------------------------------------------------- public List getBeginSegment() { return beginSegment; } // ---------------------------------------------------------------------- // Suspend Segment // ---------------------------------------------------------------------- public List getSuspendSegment() { return suspendSegment; } // ---------------------------------------------------------------------- // Resume Segment // ---------------------------------------------------------------------- public List getResumeSegment() { return resumeSegment; } // ---------------------------------------------------------------------- // End Segment // ---------------------------------------------------------------------- public List getEndSegment() { return endSegment; } // ---------------------------------------------------------------------- // Lifecylce Management // ---------------------------------------------------------------------- /** * Start a component's lifecycle. */ public void start( Object component, ComponentManager manager ) throws PhaseExecutionException { if ( segmentIsEmpty( getBeginSegment() ) ) { return; } for ( Iterator i = getBeginSegment().iterator(); i.hasNext(); ) { Phase phase = (Phase) i.next(); phase.execute( component, manager ); } } public void suspend( Object component, ComponentManager manager ) throws PhaseExecutionException { if ( segmentIsEmpty( getSuspendSegment() ) ) { return; } for ( Iterator i = getSuspendSegment().iterator(); i.hasNext(); ) { Phase phase = (Phase) i.next(); phase.execute( component, manager ); } } public void resume( Object component, ComponentManager manager ) throws PhaseExecutionException { if ( segmentIsEmpty( getResumeSegment() ) ) { return; } for ( Iterator i = getResumeSegment().iterator(); i.hasNext(); ) { Phase phase = (Phase) i.next(); phase.execute( component, manager ); } } /** * End a component's lifecycle. */ public void end( Object component, ComponentManager manager ) throws PhaseExecutionException { if ( segmentIsEmpty( getEndSegment() ) ) { return; } for ( Iterator i = getEndSegment().iterator(); i.hasNext(); ) { Phase phase = (Phase) i.next(); phase.execute( component, manager ); } } private boolean segmentIsEmpty( List segment ) { if ( segment == null || segment.size() == 0 ) { return true; } return false; } } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandler.java0000644000175000017500000000125310231133376031021 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; public interface LifecycleHandler { String getId(); void start( Object component, ComponentManager manager ) throws PhaseExecutionException; void suspend( Object component, ComponentManager manager ) throws PhaseExecutionException; void resume( Object component, ComponentManager manager ) throws PhaseExecutionException; void end( Object component, ComponentManager manager ) throws PhaseExecutionException; void initialize(); } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java0000644000175000017500000000073610231133376032321 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; /** * * * @author Jason van Zyl * * @version $Id: LifecycleHandlerManager.java 1750 2005-04-19 07:45:02Z brett $ */ public interface LifecycleHandlerManager { void initialize(); LifecycleHandler getDefaultLifecycleHandler() throws UndefinedLifecycleHandlerException; LifecycleHandler getLifecycleHandler( String id ) throws UndefinedLifecycleHandlerException; } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.0000644000175000017500000000510310231133376032755 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; /* * 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.Iterator; import java.util.List; /** * @author Jason van Zyl * * @version $Id: DefaultLifecycleHandlerManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class DefaultLifecycleHandlerManager implements LifecycleHandlerManager { private List lifecycleHandlers = null; private String defaultLifecycleHandlerId = "plexus"; public void initialize() { for ( Iterator iterator = lifecycleHandlers.iterator(); iterator.hasNext(); ) { LifecycleHandler lifecycleHandler = (LifecycleHandler) iterator.next(); lifecycleHandler.initialize(); } } public LifecycleHandler getLifecycleHandler( String id ) throws UndefinedLifecycleHandlerException { LifecycleHandler lifecycleHandler = null; for ( Iterator iterator = lifecycleHandlers.iterator(); iterator.hasNext(); ) { lifecycleHandler = (LifecycleHandler) iterator.next(); if ( id.equals( lifecycleHandler.getId() ) ) { return lifecycleHandler; } } throw new UndefinedLifecycleHandlerException( "Specified lifecycle handler cannot be found: " + id ); } public LifecycleHandler getDefaultLifecycleHandler() throws UndefinedLifecycleHandlerException { return getLifecycleHandler( defaultLifecycleHandlerId ); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/UndefinedLifecycleHandlerException.javaplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/UndefinedLifecycleHandlerExcept0000644000175000017500000000033010161654653033077 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; public class UndefinedLifecycleHandlerException extends Exception { public UndefinedLifecycleHandlerException( String message ) { super( message ); } } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/BasicLifecycleHandler.java0000644000175000017500000000256210231133376031767 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; /* * 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 BasicLifecycleHandler extends AbstractLifecycleHandler { /** @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize */ public void initialize() { } } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/PassiveLifecycleHandler.java0000644000175000017500000000256410231133376032362 0ustar paulpaulpackage org.codehaus.plexus.lifecycle; /* * 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 PassiveLifecycleHandler extends AbstractLifecycleHandler { /** @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize */ public void initialize() { } } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/0000755000175000017500000000000010631507706026066 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/Phase.java0000644000175000017500000000055410231133376027767 0ustar paulpaulpackage org.codehaus.plexus.lifecycle.phase; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; public interface Phase { /** Execute the phase. */ public void execute( Object component, ComponentManager manager ) throws PhaseExecutionException; } plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/AbstractPhase.java0000644000175000017500000000062710231133376031454 0ustar paulpaulpackage org.codehaus.plexus.lifecycle.phase; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; public abstract class AbstractPhase implements Phase { /** Execute the phase. */ public abstract void execute( Object component, ComponentManager manager ) throws PhaseExecutionException; } plexus-container-default/src/main/java/org/codehaus/plexus/DuplicateChildContainerException.java0000644000175000017500000000231610263567340032275 0ustar paulpaulpackage org.codehaus.plexus; /* * 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 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; } } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java0000644000175000017500000001456010322665042027016 0ustar paulpaulpackage org.codehaus.plexus; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.component.composition.CompositionException; import org.codehaus.plexus.component.composition.UndefinedComponentComposerException; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; 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.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.PlexusConfigurationResourceException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.LoggerManager; import java.io.File; import java.io.Reader; import java.util.Date; import java.util.List; import java.util.Map; public interface PlexusContainer { String ROLE = PlexusContainer.class.getName(); // ---------------------------------------------------------------------- // Timestamp access // ---------------------------------------------------------------------- public Date getCreationDate(); // ---------------------------------------------------------------------- // Child container access // ---------------------------------------------------------------------- boolean hasChildContainer( String name ); void removeChildContainer( String name ); PlexusContainer getChildContainer( String name ); PlexusContainer createChildContainer( String name, List classpathJars, Map context ) throws PlexusContainerException; PlexusContainer createChildContainer( String name, List classpathJars, Map context, List discoveryListeners ) throws PlexusContainerException; // ---------------------------------------------------------------------- // 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 Descriptor Lookup // ---------------------------------------------------------------------- ComponentDescriptor getComponentDescriptor( String componentKey ); Map getComponentDescriptorMap( String role ); List getComponentDescriptorList( String role ); void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException; // ---------------------------------------------------------------------- // 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 ); // ---------------------------------------------------------------------- // Component replacement // ---------------------------------------------------------------------- void suspend( Object component ) throws ComponentLifecycleException; void resume( Object component ) throws ComponentLifecycleException; // ---------------------------------------------------------------------- // Lifecycle // ---------------------------------------------------------------------- void initialize() throws PlexusContainerException; boolean isInitialized(); void start() throws PlexusContainerException; boolean isStarted(); void dispose(); // ---------------------------------------------------------------------- // Context // ---------------------------------------------------------------------- Context getContext(); // ---------------------------------------------------------------------- // Container setup // ---------------------------------------------------------------------- void setParentPlexusContainer( PlexusContainer parentContainer ); void addContextValue( Object key, Object value ); void setConfigurationResource( Reader configuration ) throws PlexusConfigurationResourceException; Logger getLogger(); Object createComponentInstance( ComponentDescriptor componentDescriptor ) throws ComponentInstantiationException, ComponentLifecycleException; void composeComponent( Object component, ComponentDescriptor componentDescriptor ) throws CompositionException, UndefinedComponentComposerException; // ---------------------------------------------------------------------- // Discovery // ---------------------------------------------------------------------- void registerComponentDiscoveryListener( ComponentDiscoveryListener listener ); void removeComponentDiscoveryListener( ComponentDiscoveryListener listener ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- void addJarRepository( File repository ); void addJarResource( File resource ) throws PlexusContainerException; ClassRealm getContainerRealm(); /** @deprecated Use getContainerRealm() instead. */ ClassRealm getComponentRealm( String componentKey ); // ---------------------------------------------------------------------- // Start of new programmatic API to fully control the container // ---------------------------------------------------------------------- void setLoggerManager( LoggerManager loggerManager ); LoggerManager getLoggerManager(); } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java0000644000175000017500000000076710251162615030700 0ustar paulpaulpackage org.codehaus.plexus; /** * Container execution exception. * * @author Brett Porter * @version $Id: PlexusContainerException.java 2097 2005-06-07 00:08:45Z jdcasey $ */ public class PlexusContainerException extends Exception { public PlexusContainerException( String message, Throwable throwable ) { super( message, throwable ); } public PlexusContainerException( String message ) { super( message ); } } plexus-container-default/src/main/java/org/codehaus/plexus/component/0000755000175000017500000000000010631507712025026 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/0000755000175000017500000000000010631507712026475 5ustar paulpaul././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactor0000644000175000017500000000057010161654653033214 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /** * * * @author Jason van Zyl * * @version $Id: AbstractComponentFactory.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractComponentFactory implements ComponentFactory { protected String id; public String getId() { return id; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFacto0000644000175000017500000000116210161654653033166 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /** * * * @author Jason van Zyl * * @version $Id: UndefinedComponentFactoryException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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 ); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactory0000644000175000017500000000712110231133376033215 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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.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; import org.codehaus.plexus.util.StringUtils; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: DefaultComponentFactoryManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class DefaultComponentFactoryManager implements ComponentFactoryManager, Contextualizable { private String defaultComponentFactoryId = "java"; private ComponentFactory defaultComponentFactory = new JavaComponentFactory(); private PlexusContainer container; /** @deprecated Register factories as components with language as role-hint instead.*/ private List componentFactories; public ComponentFactory findComponentFactory( String id ) throws UndefinedComponentFactoryException { if(StringUtils.isEmpty(id) || defaultComponentFactoryId.equals(id)) { return defaultComponentFactory; } else { try { return (ComponentFactory) container.lookup(ComponentFactory.ROLE, id); } catch ( ComponentLookupException e ) { throw new UndefinedComponentFactoryException( "Specified component factory cannot be found: " + id, e ); } } // Commented out until we get active collections working; we'll do direct // lookups until then. // for ( Iterator iterator = componentFactories.iterator(); iterator.hasNext(); ) // { // componentFactory = (ComponentFactory) iterator.next(); // // if ( id.equals( componentFactory.getId() ) ) // { // return componentFactory; // } // } } public ComponentFactory getDefaultComponentFactory() throws UndefinedComponentFactoryException { return defaultComponentFactory; } public void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } } plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java0000644000175000017500000000145410161654653032643 0ustar paulpaulpackage org.codehaus.plexus.component.factory; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.PlexusContainer; import org.codehaus.classworlds.ClassRealm; /** A ServiceFactory is responsible for instantiating a component. * * @author Jason van Zyl * @author Michal Maczka * * @version $Id: ComponentFactory.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentFactory { /** Component role. */ static String ROLE = ComponentFactory.class.getName(); String getId(); Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container ) throws ComponentInstantiationException; } plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/0000755000175000017500000000000010631507712027416 5ustar paulpaul././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFacto0000644000175000017500000000614710251162615033067 0ustar paulpaulpackage org.codehaus.plexus.component.factory.java; import java.lang.reflect.Modifier; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.PlexusContainer; 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 * @version $Id: JavaComponentFactory.java 2097 2005-06-07 00:08:45Z jdcasey $ */ public class JavaComponentFactory extends AbstractComponentFactory { 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 instanciate implementation '" + implementation + "' because the class is a interface." ); } if ( Modifier.isAbstract( modifiers ) ) { throw new ComponentInstantiationException( "Cannot instanciate implementation '" + implementation + "' because the class is abstract." ); } Object instance = implementationClass.newInstance(); return instance; } catch ( InstantiationException e ) { 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. // ---------------------------------------------------------------------- componentClassRealm.display(); String msg = "Could not instanciate component: " + componentDescriptor.getHumanReadableKey(); return new ComponentInstantiationException( msg, e ); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationE0000644000175000017500000000114710161654653033244 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /** * * * @author Michal Maczka * * @version $Id: ComponentInstantiationException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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 ); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager0000644000175000017500000000071610161654653033216 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /** * * * @author Jason van Zyl * * @version $Id: ComponentFactoryManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentFactoryManager { ComponentFactory findComponentFactory( String id ) throws UndefinedComponentFactoryException; ComponentFactory getDefaultComponentFactory() throws UndefinedComponentFactoryException; } plexus-container-default/src/main/java/org/codehaus/plexus/component/MapOrientedComponent.java0000644000175000017500000000217510251162615031765 0ustar paulpaulpackage org.codehaus.plexus.component; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.repository.ComponentRequirement; import java.util.Map; /* * 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 MapOrientedComponent { void addComponentRequirement( ComponentRequirement requirementDescriptor, Object requirementValue ) throws ComponentConfigurationException; void setComponentConfiguration( Map componentConfiguration ) throws ComponentConfigurationException; } plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/0000755000175000017500000000000010631507707027251 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/0000755000175000017500000000000010631507707027660 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java0000644000175000017500000001672410236467234033037 0ustar paulpaulpackage org.codehaus.plexus.component.repository.io; /* * 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.repository.ComponentDependency; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; 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.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; import java.io.Reader; import java.io.StringReader; /** * @author Jason van Zyl * @version $Id: PlexusTools.java 1781 2005-05-05 19:06:04Z jdcasey $ * @todo these are all really tools for dealing with xml configurations so they * should be packaged as such. */ public class PlexusTools { public static PlexusConfiguration buildConfiguration( String resourceName, Reader configuration ) throws PlexusConfigurationException { try { return new XmlPlexusConfiguration( Xpp3DomBuilder.build( configuration ) ); } catch ( XmlPullParserException e ) { throw new PlexusConfigurationException( "Failed to parse configuration resource: \'" + resourceName + "\'\nError was: \'" + e.getLocalizedMessage() + "\'", 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 ) throws PlexusConfigurationException { return buildComponentDescriptor( buildConfiguration( configuration ) ); } public static ComponentDescriptor buildComponentDescriptor( PlexusConfiguration configuration ) throws PlexusConfigurationException { ComponentDescriptor cd = new ComponentDescriptor(); cd.setRole( configuration.getChild( "role" ).getValue() ); cd.setRoleHint( configuration.getChild( "role-hint" ).getValue() ); cd.setImplementation( configuration.getChild( "implementation" ).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 ( int i = 0; i < requirements.length; i++ ) { PlexusConfiguration requirement = requirements[i]; ComponentRequirement cr = new ComponentRequirement(); cr.setRole( requirement.getChild( "role" ).getValue() ); cr.setRoleHint( requirement.getChild( "role-hint" ).getValue() ); cr.setFieldName( requirement.getChild( "field-name" ).getValue() ); cd.addRequirement( cr ); } return cd; } public static ComponentSetDescriptor buildComponentSet( PlexusConfiguration c ) throws PlexusConfigurationException { ComponentSetDescriptor csd = new ComponentSetDescriptor(); // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- PlexusConfiguration[] components = c.getChild( "components" ).getChildren( "component" ); for ( int i = 0; i < components.length; i++ ) { PlexusConfiguration component = components[i]; csd.addComponentDescriptor( buildComponentDescriptor( component ) ); } // ---------------------------------------------------------------------- // Dependencies // ---------------------------------------------------------------------- PlexusConfiguration[] dependencies = c.getChild( "dependencies" ).getChildren( "dependency" ); for ( int i = 0; i < dependencies.length; i++ ) { PlexusConfiguration d = dependencies[i]; 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; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentProfileDescriptor.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentProfileDesc0000644000175000017500000000315310161654653033261 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /** * @author Jason van Zyl * * @version $Id: ComponentProfileDescriptor.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentProfileDescriptor { /** Component Factory Id. */ private String componentFactoryId; /** Lifecycle Handler Id. */ private String lifecycleHandlerId; /** Component Manager Id. */ private String componentManagerId; /** Component Composer Id. */ private String componentComposerId; // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- public String getComponentFactoryId() { return componentFactoryId; } public void setComponentFactoryId( String componentFactoryId ) { this.componentFactoryId = componentFactoryId; } public String getLifecycleHandlerId() { return lifecycleHandlerId; } public void setLifecycleHandlerId( String lifecycleHandlerId ) { this.lifecycleHandlerId = lifecycleHandlerId; } public String getComponentManagerId() { return componentManagerId; } public void setComponentManagerId( String componentManagerId ) { this.componentManagerId = componentManagerId; } public String getComponentComposerId() { return componentComposerId; } public void setComponentComposerId( String componentComposerId ) { this.componentComposerId = componentComposerId; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentProfile.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentProfile.jav0000644000175000017500000000360010161654653033236 0ustar paulpaulpackage org.codehaus.plexus.component.repository; import org.codehaus.plexus.component.composition.ComponentComposer; import org.codehaus.plexus.component.factory.ComponentFactory; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.lifecycle.LifecycleHandler; /** * @author Jason van Zyl * * @version $Id: ComponentProfile.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentProfile { /** Component Factory. */ private ComponentFactory componentFactory; /** Lifecycle Handler. */ private LifecycleHandler lifecycleHandler; /** Component Manager. */ private ComponentManager componentManager; /** Component Composer. */ private ComponentComposer componentComposer; // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- public ComponentFactory getComponentFactory() { return componentFactory; } public void setComponentFactory( ComponentFactory componentFactory ) { this.componentFactory = componentFactory; } public LifecycleHandler getLifecycleHandler() { return lifecycleHandler; } public void setLifecycleHandler( LifecycleHandler lifecycleHandler ) { this.lifecycleHandler = lifecycleHandler; } public ComponentManager getComponentManager() { return componentManager; } public void setComponentManager( ComponentManager componentManager ) { this.componentManager = componentManager; } public ComponentComposer getComponentComposer() { return componentComposer; } public void setComponentComposer( ComponentComposer componentComposer ) { this.componentComposer = componentComposer; } } plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/0000755000175000017500000000000010631507707031247 5ustar paulpaul././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentL0000644000175000017500000000114610161654653033253 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentLifecycleException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentLifecycleException extends Exception { public ComponentLifecycleException( String message ) { super( message ); } public ComponentLifecycleException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentR0000644000175000017500000000115210161654653033256 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentRepositoryException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentRepositoryException extends Exception { public ComponentRepositoryException( String message ) { super( message ); } public ComponentRepositoryException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentM0000644000175000017500000000126610161654653033257 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentManagerImplementationNotFoundException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentManagerImplementationNotFoundException extends Exception { public ComponentManagerImplementationNotFoundException( String message ) { super( message ); } public ComponentManagerImplementationNotFoundException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentI0000644000175000017500000000123210161654653033244 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentImplementationNotFoundException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentImplementationNotFoundException extends Exception { public ComponentImplementationNotFoundException( String message ) { super( message ); } public ComponentImplementationNotFoundException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentL0000644000175000017500000000113110161654653033245 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * The exception which is thrown by a component repository when * the requested component cannot be found. * * @author Jason van Zyl * * @version $Id: ComponentLookupException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentLookupException extends Exception { public ComponentLookupException( String message ) { super( message ); } public ComponentLookupException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentC0000644000175000017500000000116610161654653033244 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentConfigurationException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentConfigurationException extends Exception { public ComponentConfigurationException( String message ) { super( message ); } public ComponentConfigurationException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentD0000644000175000017500000000123610161654653033243 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentDescriptorUnmarshallingException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentDescriptorUnmarshallingException extends Exception { public ComponentDescriptorUnmarshallingException( String message ) { super( message ); } public ComponentDescriptorUnmarshallingException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentP0000644000175000017500000000113610161654653033256 0ustar paulpaulpackage org.codehaus.plexus.component.repository.exception; /** * Exception that is thrown when the class(es) required for a component * implementation are not available. * * @author Jason van Zyl * * @version $Id: ComponentProfileException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentProfileException extends Exception { public ComponentProfileException( String message ) { super( message ); } public ComponentProfileException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepo0000644000175000017500000002155010240016672033264 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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.classworlds.ClassRealm; import org.codehaus.plexus.component.composition.CompositionException; import org.codehaus.plexus.component.composition.CompositionResolver; import org.codehaus.plexus.component.repository.exception.ComponentImplementationNotFoundException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.component.repository.io.PlexusTools; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @todo We need to process component descriptors from a specified configuration file in addition * to component descriptors that are stored in the JAR along with the component. So we need to be * able to process a directory of components as we now can package any number of components * in a JAR which will all be described by a components.xml file in the top-level of the JAR. */ public class DefaultComponentRepository extends AbstractLogEnabled implements ComponentRepository { private static String COMPONENTS = "components"; private static String COMPONENT = "component"; private PlexusConfiguration configuration; private Map componentDescriptorMaps; private Map componentDescriptors; private CompositionResolver compositionResolver; private ClassRealm classRealm; public DefaultComponentRepository() { componentDescriptors = new HashMap(); componentDescriptorMaps = new HashMap(); } // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- protected PlexusConfiguration getConfiguration() { return configuration; } public boolean hasComponent( String role ) { return componentDescriptors.containsKey( role ); } public boolean hasComponent( String role, String roleHint ) { return componentDescriptors.containsKey( role + roleHint ); } public Map getComponentDescriptorMap( String role ) { return (Map) componentDescriptorMaps.get( role ); } public ComponentDescriptor getComponentDescriptor( String key ) { return (ComponentDescriptor) componentDescriptors.get( key ); } public void setClassRealm( ClassRealm classRealm ) { this.classRealm = classRealm; } // ---------------------------------------------------------------------- // Lifecylce Management // ---------------------------------------------------------------------- public void configure( PlexusConfiguration configuration ) { this.configuration = configuration; } public void initialize() throws ComponentRepositoryException { initializeComponentDescriptors(); } public void initializeComponentDescriptors() throws ComponentRepositoryException { initializeComponentDescriptorsFromUserConfiguration(); } private void initializeComponentDescriptorsFromUserConfiguration() throws ComponentRepositoryException { PlexusConfiguration[] componentConfigurations = configuration.getChild( COMPONENTS ).getChildren( COMPONENT ); for ( int i = 0; i < componentConfigurations.length; i++ ) { addComponentDescriptor( componentConfigurations[i] ); } } // ---------------------------------------------------------------------- // Component Descriptor processing. // ---------------------------------------------------------------------- public void addComponentDescriptor( PlexusConfiguration configuration ) throws ComponentRepositoryException { ComponentDescriptor componentDescriptor = null; try { componentDescriptor = PlexusTools.buildComponentDescriptor( configuration ); } catch ( PlexusConfigurationException e ) { throw new ComponentRepositoryException( "Cannot unmarshall component descriptor:", e ); } addComponentDescriptor( componentDescriptor ); } public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException { try { validateComponentDescriptor( componentDescriptor ); } catch ( ComponentImplementationNotFoundException e ) { throw new ComponentRepositoryException( "Component descriptor validation failed: ", e ); } String role = componentDescriptor.getRole(); String roleHint = componentDescriptor.getRoleHint(); if ( roleHint != null ) { if ( componentDescriptors.containsKey( role ) ) { ComponentDescriptor desc = (ComponentDescriptor) componentDescriptors.get( role ); if ( desc.getRoleHint() == null ) { String message = "Component descriptor " + componentDescriptor.getHumanReadableKey() + " has a hint, but there are other implementations that don't"; throw new ComponentRepositoryException( message ); } } Map map = (Map) componentDescriptorMaps.get( role ); if ( map == null ) { map = new HashMap(); componentDescriptorMaps.put( role, map ); } map.put( roleHint, componentDescriptor ); } else { if ( componentDescriptorMaps.containsKey( role ) ) { String message = "Component descriptor " + componentDescriptor.getHumanReadableKey() + " has no hint, but there are other implementations that do"; throw new ComponentRepositoryException( message ); } else if ( componentDescriptors.containsKey( role ) ) { if ( !componentDescriptors.get( role ).equals( componentDescriptor ) ) { String message = "Component role " + role + " is already in the repository and different to attempted addition of " + componentDescriptor.getHumanReadableKey(); throw new ComponentRepositoryException( message ); } } } try { compositionResolver.addComponentDescriptor( componentDescriptor ); } catch ( CompositionException e ) { throw new ComponentRepositoryException( e.getMessage(), e ); } componentDescriptors.put( componentDescriptor.getComponentKey(), componentDescriptor ); // We need to be able to lookup by role only (in non-collection situations), even when the // component has a roleHint. if ( !componentDescriptors.containsKey( role ) ) { componentDescriptors.put( role, componentDescriptor ); } } public void validateComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentImplementationNotFoundException { // Make sure the component implementation classes can be found. // Make sure ComponentManager implementation can be found. // Validate lifecycle. // Validate the component configuration. // Validate the component profile if one is used. } public List getComponentDependencies( ComponentDescriptor componentDescriptor ) { return compositionResolver.getRequirements( componentDescriptor.getComponentKey() ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.0000644000175000017500000000351210216646467033222 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: ComponentDependency.java 1569 2005-03-18 21:50:47Z jdcasey $ */ 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; /** * @return Returns the artifactId. */ public String getArtifactId() { return artifactId; } /** * @param artifactId The artifactId to set. */ public void setArtifactId(String artifactId) { this.artifactId = artifactId; } /** * @return Returns the groupId. */ public String getGroupId() { return groupId; } /** * @param groupId The groupId to set. */ public void setGroupId(String groupId) { this.groupId = groupId; } /** * @return Returns the type. */ public String getType() { return type; } /** * @param type The type to set. */ public void setType(String type) { this.type = type; } /** * @return Returns the version. */ public String getVersion() { return version; } /** * @param version The version to set. */ public void setVersion(String version) { this.version = version; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append( "groupId:artifactId:version:type = " + groupId + ":" + artifactId + ":" + version + ":" + type ); return sb.toString(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescript0000644000175000017500000000304510161654653033313 0ustar paulpaulpackage org.codehaus.plexus.component.repository; import java.util.List; import java.util.ArrayList; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: ComponentSetDescriptor.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentSetDescriptor { private List components; private List dependencies; private boolean isolatedRealm; private String id; public List getComponents() { return components; } public void addComponentDescriptor( ComponentDescriptor cd ) { if ( components == null ) { components = new ArrayList(); } components.add( cd ); } public void setComponents( List components ) { this.components = components; } public List getDependencies() { return dependencies; } public void addDependency( ComponentDependency cd ) { if ( dependencies == null ) { dependencies = new ArrayList(); } dependencies.add( cd ); } public void setDependencies( List dependencies ) { this.dependencies = dependencies; } public void setIsolatedRealm( boolean isolatedRealm ) { this.isolatedRealm = isolatedRealm; } public boolean isIsolatedRealm() { return isolatedRealm; } public String getId() { return id; } public void setId( String id ) { this.id = id; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.0000644000175000017500000000316410231133376033311 0ustar paulpaulpackage org.codehaus.plexus.component.repository; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentImplementationNotFoundException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.PlexusConfiguration; import java.util.List; import java.util.Map; /** * Like the avalon component manager. Central point to get the components from. * * TODO: Enhance the ComponentRepository so that it can take entire * ComponentSetDescriptors instead of just ComponentDescriptors. */ public interface ComponentRepository { void configure( PlexusConfiguration configuration ); void initialize() throws ComponentRepositoryException; boolean hasComponent( String role ); boolean hasComponent( String role, String id ); void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException; void addComponentDescriptor( PlexusConfiguration configuration ) throws ComponentRepositoryException; ComponentDescriptor getComponentDescriptor( String role ); Map getComponentDescriptorMap( String role ); List getComponentDependencies( ComponentDescriptor componentDescriptor ); // need to change this exception as not being able to find the class is but // only one validation problem. will do for now as i build up the tests. void validateComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentImplementationNotFoundException; void setClassRealm( ClassRealm classRealm ); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement0000644000175000017500000000526210317346130033354 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /** * @author Michal Maczka * * @version $Id: ComponentRequirement.java 2573 2005-09-30 23:38:00Z jdcasey $ * @todo Maybe hashCode and equals should use only 'role' */ public final class ComponentRequirement { private String role; private String roleHint; private String fieldName; private String fieldMappingType; public String getFieldName() { return fieldName; } public void setFieldName( final String fieldName ) { this.fieldName = fieldName; } public String getRole() { return role; } public void setRole( final String role ) { this.role = role; } public String getRoleHint() { return roleHint; } public void setRoleHint( final String roleHint ) { this.roleHint = roleHint; } public String getRequirementKey() { if ( getRoleHint() != null ) { return getRole() + getRoleHint(); } return getRole(); } public String toString() { return "ComponentRequirement{" + "role='" + role + "'" + ", roleHint='" + roleHint + "'" + ", fieldName='" + fieldName + "'" + "}"; } /** * */ public String getHumanReadableKey() { StringBuffer key = new StringBuffer(); key.append( "role: '"); key.append( getRole() ); key.append( "'" ); if ( getRoleHint() != null ) { key.append( ", role-hint: '" ); key.append( getRoleHint() ); key.append( "'. " ); } if ( getFieldName() != null ) { key.append( ", field name: '" ); key.append( getFieldName() ); key.append( "' " ); } String retValue = key.toString(); return retValue; } public String getFieldMappingType() { return fieldMappingType; } public void setFieldMappingType( String fieldType ) { this.fieldMappingType = fieldType; } 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(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.0000644000175000017500000001706510235733465033266 0ustar paulpaulpackage org.codehaus.plexus.component.repository; import org.codehaus.plexus.configuration.PlexusConfiguration; import java.util.ArrayList; import java.util.List; /** * Component instantiation description. * * @author Jason van Zyl * @author bob mcwhirter * @author Michal Maczka * @version $Id: ComponentDescriptor.java 1777 2005-05-03 17:39:01Z jdcasey $ */ public class ComponentDescriptor { private String alias = null; private String role = null; private String roleHint = null; private String implementation = null; private String version = null; private String componentType = null; private PlexusConfiguration configuration = null; private String instantiationStrategy = null; private String lifecycleHandler = null; private String componentProfile = null; private List requirements; private String componentFactory; private String componentComposer; private String componentConfigurator; private String description; // ---------------------------------------------------------------------- // 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 List dependencies; // ---------------------------------------------------------------------- private ComponentSetDescriptor componentSetDescriptor; // ---------------------------------------------------------------------- // Instance methods // ---------------------------------------------------------------------- public String getComponentKey() { if ( getRoleHint() != null ) { return getRole() + getRoleHint(); } return getRole(); } public String getHumanReadableKey() { StringBuffer key = new StringBuffer(); key.append("role: '" + role + "'" ); key.append( ", implementation: '" + implementation + "'" ); if ( roleHint != null ) { key.append( ", role hint: '" + roleHint + "'" ); } if ( alias != null ) { key.append( ", alias: '" + alias + "'" ); } return key.toString(); } public String getAlias() { return alias; } public void setAlias( String alias ) { this.alias = alias; } public String getRole() { return role; } public void setRole( String role ) { this.role = role; } public String getRoleHint() { return roleHint; } public void setRoleHint( String roleHint ) { this.roleHint = roleHint; } public String getImplementation() { return implementation; } public void setImplementation( String implementation ) { this.implementation = implementation; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public String getComponentType() { return componentType; } public void setComponentType( String componentType ) { this.componentType = componentType; } public String getInstantiationStrategy() { return instantiationStrategy; } public PlexusConfiguration getConfiguration() { return configuration; } public void setConfiguration( PlexusConfiguration configuration ) { this.configuration = configuration; } public boolean hasConfiguration() { return configuration != null; } public String getLifecycleHandler() { return lifecycleHandler; } public void setLifecycleHandler( String lifecycleHandler ) { this.lifecycleHandler = lifecycleHandler; } public String getComponentProfile() { return componentProfile; } public void setComponentProfile( String componentProfile ) { this.componentProfile = componentProfile; } public void addRequirement( final ComponentRequirement requirement ) { getRequirements().add( requirement ); } public List getRequirements() { if ( requirements == null ) { requirements = new ArrayList(); } return requirements; } public String getComponentFactory() { return componentFactory; } public void setComponentFactory( String componentFactory ) { this.componentFactory = componentFactory; } public String getComponentComposer() { return componentComposer; } public void setComponentComposer( String componentComposer ) { this.componentComposer = componentComposer; } public String getDescription() { return description; } public void setDescription( String description ) { this.description = description; } public void setInstantiationStrategy( String instantiationStrategy ) { this.instantiationStrategy = instantiationStrategy; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public boolean isIsolatedRealm() { return isolatedRealm; } public void setComponentSetDescriptor( ComponentSetDescriptor componentSetDescriptor ) { this.componentSetDescriptor = componentSetDescriptor; } public ComponentSetDescriptor getComponentSetDescriptor() { return componentSetDescriptor; } public void setIsolatedRealm( boolean isolatedRealm ) { this.isolatedRealm = isolatedRealm; } public List getDependencies() { return dependencies; } public String getComponentConfigurator() { return componentConfigurator; } public void setComponentConfigurator( String componentConfigurator ) { this.componentConfigurator = componentConfigurator; } // Component identity established here! public boolean equals(Object other) { if(!(other instanceof ComponentDescriptor)) { return false; } else { ComponentDescriptor otherDescriptor = (ComponentDescriptor) other; boolean isEqual = true; String role = getRole(); String otherRole = otherDescriptor.getRole(); isEqual = isEqual && ( role == otherRole || role.equals( otherRole ) ); String roleHint = getRoleHint(); String otherRoleHint = otherDescriptor.getRoleHint(); isEqual = isEqual && ( roleHint == otherRoleHint || roleHint.equals( otherRoleHint ) ); return isEqual; } } public String toString() { return this.getClass().getName() + " [role: \'" + getRole() + "\', hint: \'" + getRoleHint() + "\']"; } public int hashCode() { int result = getRole().hashCode() + 1; String hint = getRoleHint(); if( hint != null ) { result += hint.hashCode(); } return result; } } plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/0000755000175000017500000000000010631507713026441 5ustar paulpaul././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/DefaultComponentManagerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/DefaultComponentManager0000644000175000017500000001304410334422205033120 0ustar paulpaulpackage org.codehaus.plexus.component.manager; /* * 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.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.lifecycle.LifecycleHandler; import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; import org.codehaus.plexus.lifecycle.UndefinedLifecycleHandlerException; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * * * @author Jason van Zyl * * @version $Id: DefaultComponentManagerManager.java 2888 2005-11-09 16:32:05Z evenisse $ */ public class DefaultComponentManagerManager implements ComponentManagerManager { private Map activeComponentManagers = new HashMap(); private List componentManagers = null; private String defaultComponentManagerId = null; private LifecycleHandlerManager lifecycleHandlerManager; private Map componentManagersByComponentHashCode = Collections.synchronizedMap( new HashMap() ); public void setLifecycleHandlerManager( LifecycleHandlerManager lifecycleHandlerManager ) { this.lifecycleHandlerManager = lifecycleHandlerManager; } private ComponentManager copyComponentManager( String id ) throws UndefinedComponentManagerException { ComponentManager componentManager = null; for ( Iterator iterator = componentManagers.iterator(); iterator.hasNext(); ) { componentManager = (ComponentManager) iterator.next(); if ( id.equals( componentManager.getId() ) ) { return componentManager.copy(); } } throw new UndefinedComponentManagerException( "Specified component manager cannot be found: " + id ); } public ComponentManager createComponentManager( ComponentDescriptor descriptor, PlexusContainer container ) throws UndefinedComponentManagerException, UndefinedLifecycleHandlerException { String componentManagerId = descriptor.getInstantiationStrategy(); ComponentManager componentManager; if ( componentManagerId == null ) { componentManagerId = defaultComponentManagerId; } componentManager = copyComponentManager( componentManagerId ); componentManager.setup( container, findLifecycleHandler( descriptor ), descriptor ); componentManager.initialize(); activeComponentManagers.put( descriptor.getComponentKey(), componentManager ); return componentManager; } public ComponentManager findComponentManagerByComponentInstance( Object component ) { return (ComponentManager) componentManagersByComponentHashCode.get( new Integer( component.hashCode() ) ); } public ComponentManager findComponentManagerByComponentKey( String componentKey ) { ComponentManager componentManager = (ComponentManager) activeComponentManagers.get( componentKey ); return componentManager; } // ---------------------------------------------------------------------- // Lifecycle handler manager handling // ---------------------------------------------------------------------- private LifecycleHandler findLifecycleHandler( ComponentDescriptor descriptor ) throws UndefinedLifecycleHandlerException { String lifecycleHandlerId = descriptor.getLifecycleHandler(); LifecycleHandler lifecycleHandler; if ( lifecycleHandlerId == null ) { lifecycleHandler = lifecycleHandlerManager.getDefaultLifecycleHandler(); } else { lifecycleHandler = lifecycleHandlerManager.getLifecycleHandler( lifecycleHandlerId ); } return lifecycleHandler; } // ---------------------------------------------------------------------- // Component manager handling // ---------------------------------------------------------------------- public Map getComponentManagers() { return activeComponentManagers; } public void associateComponentWithComponentManager( Object component, ComponentManager componentManager ) { componentManagersByComponentHashCode.put( new Integer( component.hashCode() ), componentManager ); } public void unassociateComponentWithComponentManager( Object component ) { componentManagersByComponentHashCode.remove( new Integer( component.hashCode() ) ); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManag0000644000175000017500000000060310171462545033115 0ustar paulpaulpackage org.codehaus.plexus.component.manager; /** * @author Jason van Zyl * @version $Id: UndefinedComponentManagerException.java 1384 2005-01-13 12:11:17Z trygvis $ */ public class UndefinedComponentManagerException extends Exception { public UndefinedComponentManagerException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManag0000644000175000017500000000375710231133376033143 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; /* * 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. */ /** * Creates a new component manager for every lookup * * @author Jason van Zyl * * @version $Id: PerLookupComponentManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class PerLookupComponentManager extends AbstractComponentManager { public void dispose() { } public Object getComponent() throws ComponentInstantiationException, ComponentLifecycleException { Object component = createComponentInstance(); return component; } public void release( Object component ) throws ComponentLifecycleException { endComponentLifecycle( component ); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/AbstractComponentManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/AbstractComponentManage0000644000175000017500000000771610231133376033132 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.PlexusContainer; 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, Cloneable { private PlexusContainer container; private ComponentDescriptor componentDescriptor; private LifecycleHandler lifecycleHandler; private int connections; private String id = null; public ComponentManager copy() { try { ComponentManager componentManager = (ComponentManager) this.clone(); return componentManager; } catch ( CloneNotSupportedException e ) { } return null; } public ComponentDescriptor getComponentDescriptor() { return componentDescriptor; } public String getId() { return id; } 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 setup( PlexusContainer container, LifecycleHandler lifecycleHandler, ComponentDescriptor componentDescriptor ) { this.container = container; this.lifecycleHandler = lifecycleHandler; this.componentDescriptor = componentDescriptor; } public void initialize() { } protected Object createComponentInstance() throws ComponentInstantiationException, ComponentLifecycleException { Object component = container.createComponentInstance( componentDescriptor ); startComponentLifecycle( component ); return component; } protected void startComponentLifecycle( Object component ) throws ComponentLifecycleException { try { getLifecycleHandler().start( component, this ); } catch ( PhaseExecutionException e ) { throw new ComponentLifecycleException( "Error starting component", e ); } } public void suspend( Object component ) throws ComponentLifecycleException { try { getLifecycleHandler().suspend( component, this ); } catch ( PhaseExecutionException e ) { throw new ComponentLifecycleException( "Error suspending component", e ); } } public void resume( Object component ) throws ComponentLifecycleException { try { getLifecycleHandler().resume( component, this ); } catch ( PhaseExecutionException e ) { throw new ComponentLifecycleException( "Error suspending component", e ); } } protected void endComponentLifecycle( Object component ) throws ComponentLifecycleException { try { getLifecycleHandler().end( component, this ); } catch ( PhaseExecutionException e ) { throw new ComponentLifecycleException( "Error ending component lifecycle", e ); } } public PlexusContainer getContainer() { return container; } public Logger getLogger() { return container.getLogger(); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ClassicSingletonCompone0000644000175000017500000000624610231133376033155 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; /* * 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. */ /** * This ensures only a single manager of a a component exists. Once no * more connections for this component exists it is disposed. * * @author Jason van Zyl * @author Bert van Brakel * * @version $Id: ClassicSingletonComponentManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class ClassicSingletonComponentManager extends AbstractComponentManager { private Object lock = new Object(); private Object singleton; public void release( Object component ) throws ComponentLifecycleException { synchronized( lock ) { if ( singleton == component ) { decrementConnectionCount(); if ( !connected() ) { dispose(); } } else { getLogger().warn( "Component returned which is not the same manager. Ignored. component=" + component ); } } } public void dispose() throws ComponentLifecycleException { synchronized( lock ) { //wait for all the clients to return all the components //Do we do this in a seperate thread? or block the current thread?? //TODO if ( singleton != null ) { endComponentLifecycle( singleton ); singleton = null; } } } public Object getComponent() throws ComponentInstantiationException, ComponentLifecycleException { synchronized( lock ) { if ( singleton == null ) { singleton = createComponentInstance(); } incrementConnectionCount(); return singleton; } } } plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java0000644000175000017500000000310110231133376032530 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.PlexusContainer; 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; /** * 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 * * @version $Id: ComponentManager.java 1750 2005-04-19 07:45:02Z brett $ */ public interface ComponentManager { String ROLE = ComponentManager.class.getName(); ComponentManager copy(); String getId(); void setup( PlexusContainer container, LifecycleHandler lifecycleHandler, ComponentDescriptor componentDescriptor ); void initialize(); int getConnections(); LifecycleHandler getLifecycleHandler(); void dispose() throws ComponentLifecycleException; void release( Object component ) throws ComponentLifecycleException; void suspend( Object component ) throws ComponentLifecycleException; void resume( Object component ) throws ComponentLifecycleException; Object getComponent() throws ComponentInstantiationException, ComponentLifecycleException; ComponentDescriptor getComponentDescriptor(); PlexusContainer getContainer(); }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManagerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManagerManager0000644000175000017500000000263110334422205033106 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; import org.codehaus.plexus.lifecycle.UndefinedLifecycleHandlerException; import java.util.Map; /** * * * @author Jason van Zyl * * @version $Id: ComponentManagerManager.java 2888 2005-11-09 16:32:05Z evenisse $ */ public interface ComponentManagerManager { String ROLE = ComponentManagerManager.class.getName(); void setLifecycleHandlerManager( LifecycleHandlerManager lifecycleHandlerManager ); // ---------------------------------------------------------------------- // Component manager handling // ---------------------------------------------------------------------- ComponentManager findComponentManagerByComponentKey( String componentKey ); ComponentManager findComponentManagerByComponentInstance( Object component ); ComponentManager createComponentManager( ComponentDescriptor descriptor, PlexusContainer container ) throws UndefinedComponentManagerException, UndefinedLifecycleHandlerException; Map getComponentManagers(); void associateComponentWithComponentManager( Object component, ComponentManager componentManager ); void unassociateComponentWithComponentManager( Object component ); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/KeepAliveSingletonComponentManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/manager/KeepAliveSingletonCompo0000644000175000017500000000563510231133376033117 0ustar paulpaulpackage org.codehaus.plexus.component.manager; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; /* * 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. */ /** * This ensures a component is only used as a singleton, and is only shutdown when * the container shuts down. * * @author Bert van Brakel * * @version $Id: KeepAliveSingletonComponentManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class KeepAliveSingletonComponentManager extends AbstractComponentManager { private Object lock = new Object(); private Object singleton; public void release( Object component ) { synchronized( lock ) { if ( singleton == component ) { decrementConnectionCount(); } else { getLogger().warn( "Component returned which is not the same manager. Ignored. component=" + component ); } } } public void dispose() throws ComponentLifecycleException { synchronized( lock ) { //wait for all the clients to return all the components //Do we do this in a seperate thread? or block the current thread?? //TODO if ( singleton != null ) { endComponentLifecycle( singleton ); } } } public Object getComponent() throws ComponentInstantiationException, ComponentLifecycleException { synchronized( lock ) { if ( singleton == null ) { singleton = createComponentInstance(); } incrementConnectionCount(); return singleton; } } } plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/0000755000175000017500000000000010631507712027035 5ustar paulpaul././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractComponentDiscoverer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractComponentDisc0000644000175000017500000000702310323120450033177 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; import org.codehaus.classworlds.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 java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: AbstractComponentDiscoverer.java 2665 2005-10-12 05:37:44Z brett $ */ public abstract class AbstractComponentDiscoverer implements ComponentDiscoverer { private ComponentDiscovererManager manager; // ---------------------------------------------------------------------- // Abstract methods // ---------------------------------------------------------------------- protected abstract String getComponentDescriptorLocation(); protected abstract ComponentSetDescriptor createComponentDescriptors( Reader reader, String source ) throws PlexusConfigurationException; // ---------------------------------------------------------------------- // ComponentDiscoverer // ---------------------------------------------------------------------- public void setManager( ComponentDiscovererManager manager ) { this.manager = manager; } public List findComponents( Context context, ClassRealm classRealm ) throws PlexusConfigurationException { List componentSetDescriptors = new ArrayList(); Enumeration resources; try { resources = classRealm.findResources( getComponentDescriptorLocation() ); } catch ( IOException e ) { throw new PlexusConfigurationException( "Unable to retrieve resources for: " + getComponentDescriptorLocation() + " in class realm: " + classRealm.getId() ); } for ( Enumeration e = resources; e.hasMoreElements(); ) { URL url = (URL) e.nextElement(); InputStreamReader reader = null; try { URLConnection conn = url.openConnection(); conn.setUseCaches( false ); conn.connect(); reader = new InputStreamReader( conn.getInputStream() ); InterpolationFilterReader input = new InterpolationFilterReader( reader, new ContextMapAdapter( context ) ); ComponentSetDescriptor componentSetDescriptor = createComponentDescriptors( input, url.toString() ); componentSetDescriptors.add( componentSetDescriptor ); // Fire the event ComponentDiscoveryEvent event = new ComponentDiscoveryEvent( componentSetDescriptor ); manager.fireComponentDiscoveryEvent( event ); } catch ( IOException ex ) { throw new PlexusConfigurationException( "Error reading configuration " + url, ex ); } finally { IOUtil.close( reader ); } } return componentSetDescriptors; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoverer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoverer.j0000644000175000017500000000121710231133376033176 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.context.Context; import java.util.List; /** * @author Jason van Zyl * @version $Id: ComponentDiscoverer.java 1750 2005-04-19 07:45:02Z brett $ */ public interface ComponentDiscoverer { static String ROLE = ComponentDiscoverer.class.getName(); void setManager( ComponentDiscovererManager manager ); List findComponents( Context context, ClassRealm classRealm ) throws PlexusConfigurationException; } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscovererManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDisco0000644000175000017500000000575610231133376033223 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * 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.Iterator; import java.util.List; public class DefaultComponentDiscovererManager implements ComponentDiscovererManager { private List componentDiscoverers; private List componentDiscoveryListeners; private List listeners; public List getComponentDiscoverers() { return componentDiscoverers; } public void registerComponentDiscoveryListener( ComponentDiscoveryListener listener ) { if ( componentDiscoveryListeners == null ) { componentDiscoveryListeners = new ArrayList(); } componentDiscoveryListeners.add( listener ); } public void removeComponentDiscoveryListener( ComponentDiscoveryListener listener ) { if ( componentDiscoveryListeners != null ) { componentDiscoveryListeners.remove( listener ); } } public void fireComponentDiscoveryEvent( ComponentDiscoveryEvent event ) { if ( componentDiscoveryListeners != null ) { for ( Iterator i = componentDiscoveryListeners.iterator(); i.hasNext(); ) { ComponentDiscoveryListener listener = (ComponentDiscoveryListener) i.next(); listener.componentDiscovered( event ); } } } public List getListenerDescriptors() { return listeners; } // ---------------------------------------------------------------------- // Lifecylce Management // ---------------------------------------------------------------------- public void initialize() { for ( Iterator i = componentDiscoverers.iterator(); i.hasNext(); ) { ComponentDiscoverer componentDiscoverer = (ComponentDiscoverer) i.next(); componentDiscoverer.setManager( this ); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEve0000644000175000017500000000076010161654653033262 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; public class ComponentDiscoveryEvent { private ComponentSetDescriptor componentSetDescriptor; public ComponentDiscoveryEvent( ComponentSetDescriptor componentSetDescriptor ) { this.componentSetDescriptor = componentSetDescriptor; } public ComponentSetDescriptor getComponentSetDescriptor() { return componentSetDescriptor; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/PlexusXmlComponentDiscoverer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/PlexusXmlComponentDis0000644000175000017500000001362710236467234033262 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.classworlds.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; import org.codehaus.plexus.configuration.PlexusConfigurationMerger; 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 java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; import java.util.List; public class PlexusXmlComponentDiscoverer implements ComponentDiscoverer { private static final String PLEXUS_XML_RESOURCE = "META-INF/plexus/plexus.xml"; private ComponentDiscovererManager manager; public void setManager( ComponentDiscovererManager manager ) { this.manager = manager; } public List findComponents( Context context, ClassRealm classRealm ) throws PlexusConfigurationException { PlexusConfiguration configuration = discoverConfiguration( context, classRealm ); List componentSetDescriptors = new ArrayList(); ComponentSetDescriptor componentSetDescriptor = createComponentDescriptors( configuration, classRealm ); componentSetDescriptors.add( componentSetDescriptor ); // Fire the event ComponentDiscoveryEvent event = new ComponentDiscoveryEvent( componentSetDescriptor ); manager.fireComponentDiscoveryEvent( event ); return componentSetDescriptors; } public PlexusConfiguration discoverConfiguration( Context context, ClassRealm classRealm ) throws PlexusConfigurationException { PlexusConfiguration configuration = null; Enumeration resources = null; try { resources = classRealm.findResources( PLEXUS_XML_RESOURCE ); } catch ( IOException e ) { throw new PlexusConfigurationException( "Error retrieving configuration resources: " + PLEXUS_XML_RESOURCE + " from class realm: " + classRealm.getId(), e ); } for ( Enumeration e = resources; e.hasMoreElements(); ) { URL url = (URL) e.nextElement(); InputStreamReader reader = null; try { reader = new InputStreamReader( url.openStream() ); ContextMapAdapter contextAdapter = new ContextMapAdapter( context ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, contextAdapter ); PlexusConfiguration discoveredConfig = PlexusTools.buildConfiguration( url.toExternalForm(), interpolationFilterReader ); if ( configuration == null ) { configuration = discoveredConfig; } else { configuration = PlexusConfigurationMerger.merge( configuration, discoveredConfig ); } } catch ( IOException ex ) { throw new PlexusConfigurationException( "Error reading configuration from: " + url.toExternalForm(), ex ); } finally { IOUtil.close( reader ); } } return configuration; } private ComponentSetDescriptor createComponentDescriptors( PlexusConfiguration configuration, ClassRealm classRealm ) throws PlexusConfigurationException { ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor(); if ( configuration != null ) { List componentDescriptors = new ArrayList(); PlexusConfiguration[] componentConfigurations = configuration.getChild( "components" ).getChildren( "component" ); for ( int i = 0; i < componentConfigurations.length; i++ ) { PlexusConfiguration componentConfiguration = componentConfigurations[i]; ComponentDescriptor componentDescriptor = null; try { componentDescriptor = PlexusTools.buildComponentDescriptor( componentConfiguration ); } catch ( PlexusConfigurationException e ) { throw new PlexusConfigurationException( "Cannot build component descriptor from resource found in:\n" + Arrays.asList( classRealm.getConstituents() ), e ); } componentDescriptor.setComponentType( "plexus" ); componentDescriptors.add( componentDescriptor ); } componentSetDescriptor.setComponents( componentDescriptors ); // TODO: read and store the dependencies } return componentSetDescriptor; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscovererManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscovererMa0000644000175000017500000000071110231133376033222 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; import java.util.List; public interface ComponentDiscovererManager { List getComponentDiscoverers(); void registerComponentDiscoveryListener( ComponentDiscoveryListener listener); void removeComponentDiscoveryListener( ComponentDiscoveryListener listener ); void fireComponentDiscoveryEvent( ComponentDiscoveryEvent event ); void initialize(); List getListenerDescriptors(); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDiscoverer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DefaultComponentDisco0000644000175000017500000000652410236467234033225 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * 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.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; import java.io.Reader; import java.util.ArrayList; import java.util.List; /** * @author Jason van Zyl * @version $Id: DefaultComponentDiscoverer.java 1781 2005-05-05 19:06:04Z jdcasey $ */ public class DefaultComponentDiscoverer extends AbstractComponentDiscoverer { public String getComponentDescriptorLocation() { return "META-INF/plexus/components.xml"; } public ComponentSetDescriptor createComponentDescriptors( Reader componentDescriptorReader, String source ) throws PlexusConfigurationException { PlexusConfiguration componentDescriptorConfiguration = PlexusTools.buildConfiguration( source, componentDescriptorReader ); ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor(); List componentDescriptors = new ArrayList(); PlexusConfiguration[] componentConfigurations = componentDescriptorConfiguration.getChild( "components" ).getChildren( "component" ); for ( int i = 0; i < componentConfigurations.length; i++ ) { PlexusConfiguration componentConfiguration = componentConfigurations[i]; ComponentDescriptor componentDescriptor = null; try { componentDescriptor = PlexusTools.buildComponentDescriptor( componentConfiguration ); } catch ( PlexusConfigurationException e ) { throw new PlexusConfigurationException( "Cannot process component descriptor: " + source, e ); } componentDescriptor.setComponentType( "plexus" ); componentDescriptors.add( componentDescriptor ); } componentSetDescriptor.setComponents( componentDescriptors ); // TODO: read and store the dependencies return componentSetDescriptor; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryListener.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryLis0000644000175000017500000000024110161654653033264 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; public interface ComponentDiscoveryListener { void componentDiscovered( ComponentDiscoveryEvent event ); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDesc0000644000175000017500000000067110161654653033245 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /** * @author Jason van Zyl * * @version $Id: DiscoveryListenerDescriptor.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DiscoveryListenerDescriptor { private String role; private String roleHint; public String getRole() { return role; } public String getRoleHint() { return roleHint; } } plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/0000755000175000017500000000000010631507711027527 5ustar paulpaul././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/MapOrientedComponentConfigurator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/MapOrientedCompone0000644000175000017500000000410610321664044033202 0ustar paulpaulpackage org.codehaus.plexus.component.configurator; import org.codehaus.classworlds.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; import java.util.Map; /* * 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.getClassLoader(), expressionEvaluator, listener ); ( (MapOrientedComponent) component ).setComponentConfiguration( context ); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentC0000644000175000017500000000630410321670505033204 0ustar paulpaulpackage 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.classworlds.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 * @version $Id: AbstractComponentConfigurator.java 2636 2005-10-08 07:12:05Z brett $ */ public abstract class AbstractComponentConfigurator implements ComponentConfigurator { // TODO: configured as a component 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( Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener ) throws ComponentConfigurationException { // TODO: here so extended classes without the method continue to work. should be removed // this won't hit the method above going into a loop - instead, it will hit the overridden one configureComponent( component, configuration, expressionEvaluator, containerRealm ); } } plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/0000755000175000017500000000000010631507707031733 5ustar paulpaul././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/Express0000644000175000017500000000356410227650373033316 0ustar paulpaulpackage org.codehaus.plexus.component.configurator.expression; import java.io.File; /* * 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. */ /** * Evaluate an expression. * * @author Brett Porter * @version $Id: ExpressionEvaluator.java 1709 2005-04-15 05:28:27Z brett $ */ public interface ExpressionEvaluator { /** * Evaluate an expression. * * @param expression the expression * @return the value of the expression */ 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 ); } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/Express0000644000175000017500000000326710227643552033317 0ustar paulpaulpackage org.codehaus.plexus.component.configurator.expression; /* * 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. */ /** * Exception that occurs during the evaluation of an expression. * * @author Brett Porter * @version $Id: ExpressionEvaluationException.java 1708 2005-04-15 04:47:38Z brett $ */ public class ExpressionEvaluationException extends Exception { public ExpressionEvaluationException( String message ) { super( message ); } public ExpressionEvaluationException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/Default0000644000175000017500000000340710227650373033245 0ustar paulpaulpackage org.codehaus.plexus.component.configurator.expression; import java.io.File; /* * 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. */ /** * Evaluate an expression. * * @author Brett Porter * @version $Id: DefaultExpressionEvaluator.java 1709 2005-04-15 05:28:27Z brett $ */ 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; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigura0000644000175000017500000000311710317346130033251 0ustar paulpaulpackage org.codehaus.plexus.component.configurator; import org.codehaus.plexus.configuration.PlexusConfiguration; /** * * * @author Jason van Zyl * * @version $Id: ComponentConfigurationException.java 2573 2005-09-30 23:38:00Z jdcasey $ */ 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; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListe0000644000175000017500000000374710321664044033274 0ustar paulpaulpackage 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 * @version $Id: ConfigurationListener.java 2634 2005-10-08 06:33:08Z brett $ */ 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 ); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConf0000644000175000017500000000546010321664044033170 0ustar paulpaulpackage 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.classworlds.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 * @version $Id: BasicComponentConfigurator.java 2634 2005-10-08 06:33:08Z brett $ */ 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.getClassLoader(), configuration, expressionEvaluator, listener ); } } plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/0000755000175000017500000000000010631507711031721 5ustar paulpaul././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ConfigurationConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/Configu0000644000175000017500000000664710321664044033252 0ustar paulpaulpackage 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; import org.codehaus.plexus.logging.Logger; public interface ConfigurationConverter { boolean canConvert( Class type ); /** * @param converterLookup Repository of available converters * @param configuration * @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 * @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 * @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 * @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; } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/Compone0000644000175000017500000001713410321700551033243 0ustar paulpaul/* * Copyright (c) 2005 Your Corporation. All Rights Reserved. */ package org.codehaus.plexus.component.configurator.converters; 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; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * @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 { String exceptionInfo = object.getClass().getName() + "." + field.getName() + "; type: " + value.getClass().getName(); 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: " + exceptionInfo, e ); } catch ( IllegalArgumentException e ) { throw new ComponentConfigurationException( "Cannot assign value '" + value + "' to field: " + exceptionInfo, 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 cl, ExpressionEvaluator evaluator ) throws ComponentConfigurationException { Object value = null; // try setter converter + method first if ( setterTypeConverter != null ) { try { value = setterTypeConverter.fromConfiguration( lookup, config, setterParamType, object.getClass(), cl, 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(), cl, evaluator, listener ); if ( value != null ) { setValueUsingField( value ); } // FIXME: need this? else if ( savedEx != null ) { throw savedEx; } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special0000755000175000017500000000000010631507707033267 5ustar paulpaul././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special0000644000175000017500000000422510321664044033266 0ustar paulpaulpackage org.codehaus.plexus.component.configurator.converters.special; import org.codehaus.classworlds.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; import org.codehaus.plexus.logging.Logger; /** * 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 */ public ClassRealmConverter( ClassRealm classRealm ) { setClassRealm( classRealm ); } public void setClassRealm( ClassRealm classRealm ) { this.classRealm = classRealm; } public boolean canConvert( Class type ) { return 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 ) { return retValue; } return classRealm; } } plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/0000755000175000017500000000000010631507707033007 5ustar paulpaul././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UrlConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/U0000644000175000017500000000360710317644473033147 0ustar paulpaulpackage 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 java.net.MalformedURLException; import java.net.URL; /** * @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 ); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/F0000644000175000017500000000527610321664044033123 0ustar paulpaulpackage 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.lookup.ConverterLookup; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import java.io.File; /** * @author Brett Porter */ public class FileConverter extends AbstractBasicConverter { public boolean canConvert( Class type ) { return type.equals( File.class ); } public Object fromString( String str ) { 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; } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/C0000644000175000017500000000275010161654653033121 0ustar paulpaulpackage 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 new Character( str.charAt( 0 ) ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/BooleanConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/B0000644000175000017500000000277710161654653033131 0ustar paulpaulpackage 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; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/D0000644000175000017500000000425410161654653033123 0ustar paulpaulpackage 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 ( int i = 0; i < formats.length; i++ ) { try { return formats[i].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 ); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/LongConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/L0000644000175000017500000000272610161654653033135 0ustar paulpaulpackage 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 ); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FloatConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/F0000644000175000017500000000273210161654653033124 0ustar paulpaulpackage 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 ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/A0000644000175000017500000000560310321664044033110 0ustar paulpaulpackage 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; import org.codehaus.plexus.logging.Logger; import java.awt.event.ComponentListener; /** * @version $Id: AbstractBasicConverter.java 2634 2005-10-08 06:33:08Z brett $ */ public abstract class AbstractBasicConverter extends AbstractConfigurationConverter { protected abstract Object fromString( String str ) throws ComponentConfigurationException; 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 ) { retValue = fromString( (String) retValue ); } return retValue; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/Converter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/C0000644000175000017500000000312610161654653033117 0ustar paulpaulpackage 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 ); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/S0000644000175000017500000000265410161654653033144 0ustar paulpaulpackage 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; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/IntConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/I0000644000175000017500000000346610310425772033126 0ustar paulpaulpackage 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 ); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/StringBufferConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/S0000644000175000017500000000271310161654653033140 0ustar paulpaulpackage 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 ); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ShortConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/S0000644000175000017500000000273210161654653033141 0ustar paulpaulpackage 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 ); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/B0000644000175000017500000000275510161654653033125 0ustar paulpaulpackage 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 new Byte( (byte) Integer.parseInt( str ) ); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DoubleConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/D0000644000175000017500000000273610161654653033126 0ustar paulpaulpackage 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 ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000755000175000017500000000000010631507710033312 5ustar paulpaul././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000000734010574657263033337 0ustar paulpaulpackage 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 * @version $Id: PropertiesConverter.java 6054 2007-03-11 01:43:15Z jvanzyl $ */ 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 ( int i = 0; i < children.length; i++ ) { PlexusConfiguration child = children[i]; addEntry( retValue, element, child ); } } return retValue; } private void addEntry( Properties properties, String element, PlexusConfiguration property ) throws ComponentConfigurationException { String name; name = property.getChild( "name" ).getValue( null ); if ( name == null ) { String msg = "Converter: java.util.Properties. Trying to convert the configuration element: '" + element + "', missing child element 'name'."; throw new ComponentConfigurationException( msg ); } String value = property.getChild( "value" ).getValue( "" ); properties.put( name, value ); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000001311710321664044033317 0ustar paulpaulpackage 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.ComponentValueSetter; 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.logging.Logger; import org.codehaus.plexus.util.ReflectionUtils; import java.lang.reflect.Field; import java.util.Collection; import java.util.Dictionary; import java.util.Map; /** * @author Michal Maczka * @version $Id: ObjectWithFieldsConverter.java 2634 2005-10-08 06:33:08Z brett $ */ public class ObjectWithFieldsConverter extends AbstractConfigurationConverter { /** * @param type * @return * @todo I am not sure what should go into this method */ 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 ); 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 ); } } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000000504110321664044033314 0ustar paulpaulpackage 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; import org.codehaus.plexus.logging.Logger; /** * Converter for org.codehaus.plexus.configuration.PlexusConfiguration * * @author Michal Maczka * @version $Id: PlexusConfigurationConverter.java 2634 2005-10-08 06:33:08Z brett $ */ 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; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000000633410321664044033322 0ustar paulpaulpackage 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; import org.codehaus.plexus.logging.Logger; import java.util.Map; import java.util.Properties; import java.util.TreeMap; /** * Converter for java.util.Properties. * * @author Michal Maczka * @version $Id: MapConverter.java 2634 2005-10-08 06:33:08Z brett $ */ 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 ) { Map map = new TreeMap(); PlexusConfiguration[] children = configuration.getChildren(); for ( int i = 0; i < children.length; i++ ) { PlexusConfiguration child = children[i]; String name = child.getName(); map.put( name, fromExpression( child, expressionEvaluator ) ); } retValue = map; } else { retValue = fromExpression( configuration, expressionEvaluator ); } return retValue; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000001302210321664044033312 0ustar paulpaulpackage 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.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.logging.Logger; import org.codehaus.plexus.util.StringUtils; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @author Kenney Westerhof * @version $Id: ArrayConverter.java 2634 2005-10-08 06:33:08Z brett $ */ 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 c = configuration.getChild( i ); String configEntry = c.getName(); String name = fromXML( configEntry ); Class childType = getClassForImplementationHint( null, c, 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, c, childType, baseType, classLoader, expressionEvaluator, listener ); values.add( object ); } return values.toArray( (Object []) Array.newInstance( type.getComponentType(), 0 ) ); } protected Collection getDefaultCollection( Class collectionType ) { Collection retValue = null; if ( List.class.isAssignableFrom( collectionType ) ) { retValue = new ArrayList(); } else if ( Set.class.isAssignableFrom( collectionType ) ) { retValue = new HashSet(); } return retValue; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composi0000644000175000017500000001663610321664044033330 0ustar paulpaulpackage 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.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.logging.Logger; import org.codehaus.plexus.util.StringUtils; 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; /** * @author Michal Maczka * @version $Id: CollectionConverter.java 2634 2005-10-08 06:33:08Z brett $ */ 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 ( Set.class.isAssignableFrom( collectionType ) ) { retValue = new HashSet(); } return retValue; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/0000755000175000017500000000000010631507711033232 5ustar paulpaul././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/0000644000175000017500000001446310317644473033254 0ustar paulpaulpackage 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; 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.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.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; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; public class DefaultConverterLookup implements ConverterLookup { private List converters = new LinkedList(); private List customConverters = new LinkedList(); private Map converterMap = new HashMap(); public DefaultConverterLookup() { registerDefaultBasicConverters(); registerDefaultCompositeConverters(); } public void registerConverter( ConfigurationConverter converter ) { customConverters.add( converter ); } protected void registerDefaultConverter( ConfigurationConverter converter ) { converters.add( converter ); } public ConfigurationConverter lookupConverterForType( Class type ) throws ComponentConfigurationException { ConfigurationConverter retValue = null; if ( converterMap.containsKey( type ) ) { retValue = (ConfigurationConverter) converterMap.get( type ); } else { 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 ); } return retValue; } private ConfigurationConverter findConverterForType( List converters, Class type ) { for ( Iterator iterator = converters.iterator(); iterator.hasNext(); ) { ConfigurationConverter converter = (ConfigurationConverter) iterator.next(); if ( converter.canConvert( type ) ) { converterMap.put( type, converter ); 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 BigIntegerConverter() ); } 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() ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/0000644000175000017500000000321410223105111033215 0ustar paulpaulpackage 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: ConverterLookup.java 1632 2005-03-31 23:39:53Z trygvis $ */ public interface ConverterLookup{ void registerConverter( ConfigurationConverter converter ); ConfigurationConverter lookupConverterForType( Class type ) throws ComponentConfigurationException; } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/Abstrac0000644000175000017500000001716610321670505033234 0ustar paulpaulpackage 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.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.util.StringUtils; /** * @author Michal Maczka * @version $Id: AbstractConfigurationConverter.java 2636 2005-10-08 07:12:05Z brett $ */ 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 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 */ 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 = "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 ); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigura0000644000175000017500000000440510321664044033254 0ustar paulpaulpackage 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.classworlds.ClassRealm; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; /** * @author Jason van Zyl * @version $Id: ComponentConfigurator.java 2634 2005-10-08 06:33:08Z brett $ */ 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; } plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/0000755000175000017500000000000010631507712027371 5ustar paulpaul././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/ComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/ComponentComposer.j0000644000175000017500000000221010161654653033216 0ustar paulpaulpackage org.codehaus.plexus.component.composition; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import java.util.List; /** * @author Michal Maczka * @version $Revision: 1323 $ * @todo michal: I think that ideally component composer should somehow participate in parsing of * requiremnts section of configuration file * as this section tells how to do the composition */ public interface ComponentComposer { static String ROLE = ComponentComposer.class.getName(); String getId(); /** * @param component * @param componentDescriptor * @param container * * @return List of ComponentDescriptors which were used by ComponentComposer * @throws CompositionException * @throws UndefinedComponentComposerException * */ public List assembleComponent( Object component, ComponentDescriptor componentDescriptor, PlexusContainer container ) throws CompositionException, UndefinedComponentComposerException; } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultComponentCom0000644000175000017500000000760210231133376033224 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * @author Michal Maczka * @version $Id: DefaultComponentComposerManager.java 1750 2005-04-19 07:45:02Z brett $ */ public class DefaultComponentComposerManager implements ComponentComposerManager { private Map composerMap = new HashMap(); private List componentComposers; private String defaultComponentComposerId = "field"; public void assembleComponent( final Object component, final ComponentDescriptor componentDescriptor, final PlexusContainer container ) throws UndefinedComponentComposerException, CompositionException { if ( componentDescriptor.getRequirements().size() == 0 ) { //nothing to do return; } String componentComposerId = componentDescriptor.getComponentComposer(); if ( componentComposerId == null || componentComposerId.trim().length() == 0 ) { componentComposerId = defaultComponentComposerId ; } final ComponentComposer componentComposer = getComponentComposer( componentComposerId ); componentComposer.assembleComponent( component, componentDescriptor, container ); // @todo: michal: we need to build the graph of component dependencies // and detect cycles. Not sure exactly when and how it should happen //assembleComponents( descriptors, container ); } protected ComponentComposer getComponentComposer( final String id ) throws UndefinedComponentComposerException { ComponentComposer retValue = null; if ( composerMap.containsKey( id ) ) { retValue = ( ComponentComposer ) composerMap.get( id ); } else { retValue = findComponentComposer( id ); } if ( retValue == null ) { throw new UndefinedComponentComposerException( "Specified component composer cannot be found: " + id ); } return retValue; } private ComponentComposer findComponentComposer( final String id ) { ComponentComposer retValue = null; for ( Iterator iterator = componentComposers.iterator(); iterator.hasNext(); ) { final ComponentComposer componentComposer = ( ComponentComposer ) iterator.next(); if ( componentComposer.getId().equals( id ) ) { retValue = componentComposer; break; } } return retValue; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/AbstractComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/AbstractComponentCo0000644000175000017500000000072510161654653033235 0ustar paulpaulpackage org.codehaus.plexus.component.composition; import org.codehaus.plexus.logging.AbstractLogEnabled; /** * * * @author Jason van Zyl * * @version $Id: AbstractComponentComposer.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractComponentComposer extends AbstractLogEnabled implements ComponentComposer { private String id; public String getId() { return id; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/NoOpComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/NoOpComponentCompos0000644000175000017500000000363110161654653033243 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.repository.ComponentDescriptor; import org.codehaus.plexus.PlexusContainer; import java.util.List; import java.util.Collections; /** * No Op component composer. It's meant to be used with component * personalities which support constructor dependecy injection * * @author Michal Maczka * @version $Id: NoOpComponentComposer.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class NoOpComponentComposer extends AbstractComponentComposer { public String getId() { return null; } public List assembleComponent( Object component, ComponentDescriptor componentDescriptor, PlexusContainer container ) { return Collections.EMPTY_LIST; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/FieldComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/FieldComponentCompo0000644000175000017500000002547110251162615033226 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.ReflectionUtils; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; /** * @author Jason van Zyl * @author Michal Maczka * @version $Id: FieldComponentComposer.java 2097 2005-06-07 00:08:45Z jdcasey $ */ public class FieldComponentComposer extends AbstractComponentComposer { public List assembleComponent( Object component, ComponentDescriptor componentDescriptor, PlexusContainer container ) throws CompositionException { List retValue = new LinkedList(); List requirements = componentDescriptor.getRequirements(); for ( Iterator i = requirements.iterator(); i.hasNext(); ) { ComponentRequirement requirement = (ComponentRequirement) i.next(); Field field = findMatchingField( component, componentDescriptor, requirement, container ); // we want to use private fields. if ( !field.isAccessible() ) { field.setAccessible( true ); } // We have a field to which we should assigning component(s). // Cardinality is determined by field.getType() method // It can be array, map, collection or "ordinary" field List descriptors = assignRequirementToField( component, field, container, requirement ); retValue.addAll( descriptors ); } return retValue; } private List assignRequirementToField( Object component, Field field, PlexusContainer container, ComponentRequirement requirement ) throws CompositionException { try { List retValue; String role = requirement.getRole(); if ( field.getType().isArray() ) { List dependencies = container.lookupList( role ); Object[] array = (Object[]) Array.newInstance( field.getType(), dependencies.size() ); retValue = container.getComponentDescriptorList( role ); field.set( component, dependencies.toArray( array ) ); } else if ( Map.class.isAssignableFrom( field.getType() ) ) { Map dependencies = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); field.set( component, dependencies ); } else if ( List.class.isAssignableFrom( field.getType() ) ) { List dependencies = container.lookupList( role ); retValue = container.getComponentDescriptorList( role ); field.set( component, dependencies ); } else if ( Set.class.isAssignableFrom( field.getType() ) ) { Map dependencies = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); field.set( component, dependencies.entrySet() ); } else //"ordinary" field { String key = requirement.getRequirementKey(); Object dependency = container.lookup( key ); ComponentDescriptor componentDescriptor = container.getComponentDescriptor( key ); retValue = new ArrayList( 1 ); retValue.add( componentDescriptor ); field.set( component, dependency ); } return retValue; } catch ( IllegalArgumentException e ) { throw new CompositionException( "Composition failed for the field " + field.getName() + " " + "in object of type " + component.getClass().getName(), e ); } catch ( IllegalAccessException e ) { throw new CompositionException( "Composition failed for the field " + field.getName() + " " + "in object of type " + component.getClass().getName(), e ); } catch ( ComponentLookupException e ) { throw new CompositionException( "Composition failed of field " + field.getName() + " " + "in object of type " + component.getClass().getName() + " because the requirement " + requirement + " was missing", e ); } } protected Field findMatchingField( Object component, ComponentDescriptor componentDescriptor, ComponentRequirement requirement, PlexusContainer container ) throws CompositionException { String fieldName = requirement.getFieldName(); Field field = null; if ( fieldName != null ) { field = getFieldByName( component, fieldName, componentDescriptor ); } else { Class fieldClass = null; try { if ( container != null ) { fieldClass = container.getContainerRealm().loadClass( requirement.getRole() ); } else { fieldClass = Thread.currentThread().getContextClassLoader().loadClass( requirement.getRole() ); } } catch ( ClassNotFoundException e ) { StringBuffer msg = new StringBuffer( "Component Composition failed for component: " ); msg.append( componentDescriptor.getHumanReadableKey() ); msg.append( ": Requirement class: '" ); msg.append( requirement.getRole() ); msg.append( "' not found." ); throw new CompositionException( msg.toString(), e ); } field = getFieldByType( component, fieldClass, componentDescriptor ); } return field; } protected Field getFieldByName( Object component, String fieldName, ComponentDescriptor componentDescriptor ) throws CompositionException { Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( fieldName, component.getClass() ); if ( field == null ) { StringBuffer msg = new StringBuffer( "Component Composition failed. No field of name: '" ); msg.append( fieldName ); msg.append( "' exists in component: " ); msg.append( componentDescriptor.getHumanReadableKey() ); throw new CompositionException( msg.toString() ); } return field; } protected Field getFieldByTypeIncludingSuperclasses( Class componentClass, Class type, ComponentDescriptor componentDescriptor ) throws CompositionException { List fields = getFieldsByTypeIncludingSuperclasses( componentClass, type, componentDescriptor ); if ( fields.size() == 0 ) { return null; } if ( fields.size() == 1 ) { return (Field) fields.get( 0 ); } throw new CompositionException( "There are several fields of type '" + type + "', " + "use 'field-name' to select the correct field." ); } protected List getFieldsByTypeIncludingSuperclasses( Class componentClass, Class type, ComponentDescriptor componentDescriptor ) throws CompositionException { Class arrayType = Array.newInstance( type, 0 ).getClass(); Field[] fields = componentClass.getDeclaredFields(); List foundFields = new ArrayList(); for ( int i = 0; i < fields.length; i++ ) { Class fieldType = fields[i].getType(); if ( fieldType.isAssignableFrom( type ) || fieldType.isAssignableFrom( arrayType ) ) { foundFields.add( fields[i] ); } } if ( componentClass.getSuperclass() != Object.class ) { List superFields = getFieldsByTypeIncludingSuperclasses( componentClass.getSuperclass(), type, componentDescriptor ); foundFields.addAll( superFields ); } return foundFields; } protected Field getFieldByType( Object component, Class type, ComponentDescriptor componentDescriptor ) throws CompositionException { Field field = getFieldByTypeIncludingSuperclasses( component.getClass(), type, componentDescriptor ); if ( field == null ) { StringBuffer msg = new StringBuffer( "Component composition failed. No field of type: '" ); msg.append( type ); msg.append( "' exists in class '" ); msg.append( component.getClass().getName() ); msg.append( "'." ); if ( componentDescriptor != null ) { msg.append( " Component: " ); msg.append( componentDescriptor.getHumanReadableKey() ); } throw new CompositionException( msg.toString() ); } return field; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionExceptio0000644000175000017500000000161010161654653033323 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /** * * * @author Jason van Zyl * @author Michal Maczka * * @version $Id: CompositionException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class CompositionException extends Exception { /** * Construct a new CompositionException instance. * * @param message The detail message for this exception. */ public CompositionException( String s ) { super( s ); } /** * Construct a new CompositionException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public CompositionException( final String message, final Throwable throwable ) { super( message, throwable ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/SetterComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/SetterComponentComp0000644000175000017500000002610410161654653033274 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.beans.Statement; import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * @author Michal Maczka * @version $Id: SetterComponentComposer.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class SetterComponentComposer extends AbstractComponentComposer { public List assembleComponent( final Object component, final ComponentDescriptor descriptor, final PlexusContainer container ) throws CompositionException, UndefinedComponentComposerException { final List requirements = descriptor.getRequirements(); BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo( component.getClass() ); } catch ( IntrospectionException e ) { reportErrorFailedToIntrospect( descriptor ); } final List retValue = new LinkedList(); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for ( final Iterator i = requirements.iterator(); i.hasNext(); ) { final ComponentRequirement requirement = ( ComponentRequirement ) i.next(); final PropertyDescriptor propertyDescriptor = findMatchingPropertyDescriptor( requirement, propertyDescriptors ); if ( propertyDescriptor != null ) { final List descriptors = setProperty( component, descriptor, requirement, propertyDescriptor, container ); retValue.addAll( descriptors ); } else { reportErrorNoSuchProperty( descriptor, requirement ); } } return retValue; } private List setProperty( final Object component, final ComponentDescriptor descriptor, final ComponentRequirement requirement, final PropertyDescriptor propertyDescriptor, final PlexusContainer container ) throws CompositionException { List retValue = null; final Method writeMethod = propertyDescriptor.getWriteMethod(); final String role = requirement.getRole(); final Object[] params = new Object[ 1 ]; final Class propertyType = propertyDescriptor.getPropertyType(); try { if ( propertyType.isArray() ) { final Map dependencies = container.lookupMap( role ); final Object[] array = ( Object[] ) Array.newInstance( propertyType, dependencies.size() ); retValue = container.getComponentDescriptorList( role ); params[ 0 ] = dependencies.entrySet().toArray( array ); } else if ( Map.class.isAssignableFrom( propertyType ) ) { final Map dependencies = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); params[ 0 ] = dependencies; } else if ( List.class.isAssignableFrom( propertyType ) ) { // final Map dependencies = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); params[ 0 ] = container.lookupList( role ); } else if ( Set.class.isAssignableFrom( propertyType ) ) { final Map dependencies = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); params[ 0 ] = dependencies.entrySet(); } else //"ordinary" field { final String key = requirement.getRequirementKey(); final Object dependency = container.lookup( key ); final ComponentDescriptor componentDescriptor = container.getComponentDescriptor( key ); retValue = new ArrayList( 1 ); retValue.add( componentDescriptor ); params[ 0 ] = dependency; } } catch ( ComponentLookupException e ) { reportErrorCannotLookupRequiredComponent( descriptor, requirement, e ); } final Statement statement = new Statement( component, writeMethod.getName(), params ); try { statement.execute(); } catch ( Exception e ) { reportErrorCannotAssignRequiredComponent( descriptor, requirement, e ); } return retValue; } /** * @param requirement * @return */ protected PropertyDescriptor findMatchingPropertyDescriptor( final ComponentRequirement requirement, final PropertyDescriptor[] propertyDescriptors ) { PropertyDescriptor retValue = null; final String property = requirement.getFieldName(); if ( property != null ) { retValue = getPropertyDescriptorByName( property, propertyDescriptors ); } else { final String role = requirement.getRole(); retValue = getPropertyDescriptorByType( role, propertyDescriptors ); } return retValue; } /** * @param name * @return */ protected PropertyDescriptor getPropertyDescriptorByName( final String name, final PropertyDescriptor[] propertyDescriptors ) { PropertyDescriptor retValue = null; for ( int i = 0; i < propertyDescriptors.length; i++ ) { final PropertyDescriptor propertyDescriptor = propertyDescriptors[ i ]; if ( name.equals( propertyDescriptor.getName() ) ) { retValue = propertyDescriptor; break; } } return retValue; } protected PropertyDescriptor getPropertyDescriptorByType( final String type, final PropertyDescriptor[] propertyDescriptors ) { PropertyDescriptor retValue = null; for ( int i = 0; i < propertyDescriptors.length; i++ ) { final PropertyDescriptor propertyDescriptor = propertyDescriptors[ i ]; if ( propertyDescriptor.getPropertyType().toString().indexOf( type ) > 0 ) { retValue = propertyDescriptor; break; } } return retValue; } private void reportErrorNoSuchProperty( final ComponentDescriptor descriptor, final ComponentRequirement requirement ) throws CompositionException { final String causeDescriprion = "Failed to assign requirment using Java Bean introspection mechanism." + " No matching property was found in bean class"; final String msg = getErrorMessage( descriptor, requirement, causeDescriprion ); throw new CompositionException( msg ); } private void reportErrorCannotAssignRequiredComponent( final ComponentDescriptor descriptor, final ComponentRequirement requirement, final Exception e ) throws CompositionException { final String causeDescriprion = "Failed to assign requirment using Java Bean introspection mechanism. "; final String msg = getErrorMessage( descriptor, requirement, causeDescriprion ); throw new CompositionException( msg ); } private void reportErrorCannotLookupRequiredComponent( final ComponentDescriptor descriptor, final ComponentRequirement requirement, final Throwable cause ) throws CompositionException { final String causeDescriprion = "Failed to lookup required component."; final String msg = getErrorMessage( descriptor, requirement, causeDescriprion ); throw new CompositionException( msg, cause ); } /** * @param descriptor */ private void reportErrorFailedToIntrospect( final ComponentDescriptor descriptor ) throws CompositionException { final String msg = getErrorMessage( descriptor, null, null ); throw new CompositionException( msg ); } private String getErrorMessage( final ComponentDescriptor descriptor, final ComponentRequirement requirement, final String causeDescription ) { final StringBuffer msg = new StringBuffer( "Component composition failed." ); msg.append( " Failed to resolve requirement for component of role: '" ); msg.append( descriptor.getRole() ); msg.append( "'" ); if ( descriptor.getRoleHint() != null ) { msg.append( " and role-hint: '" ); msg.append( descriptor.getRoleHint() ); msg.append( "'. " ); } if ( requirement != null ) { msg.append( "Failing requirement: " + requirement.getHumanReadableKey() ); } if ( causeDescription != null ) { msg.append( causeDescription ); } return msg.toString(); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentC0000644000175000017500000000117610161654653033215 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /** * * * @author Michal Maczka * * @version $Id: UndefinedComponentComposerException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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 ); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionR0000644000175000017500000000572010227405046033250 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.dag.DAG; import java.util.Iterator; import java.util.List; /** * @author Michal Maczka * @version $Id: DefaultCompositionResolver.java 1700 2005-04-14 06:13:58Z brett $ */ public class DefaultCompositionResolver implements CompositionResolver { private DAG dag = new DAG(); public void addComponentDescriptor( final ComponentDescriptor componentDescriptor ) throws CompositionException { final String componentKey = componentDescriptor.getComponentKey(); final List requirements = componentDescriptor.getRequirements(); for ( final Iterator iterator = requirements.iterator(); iterator.hasNext(); ) { final ComponentRequirement requirement = (ComponentRequirement) iterator.next(); try { dag.addEdge( componentKey, requirement.getRole() ); } catch ( CycleDetectedException e ) { throw new CompositionException( "Cyclic requirement detected", e ); } } } /** * @see org.codehaus.plexus.component.composition.CompositionResolver#getRequirements(java.lang.String) */ public List getRequirements( final String componentKey ) { return dag.getChildLabels( componentKey ); } /** * @see org.codehaus.plexus.component.composition.CompositionResolver#findRequirements(java.lang.String) */ public List findRequirements( final String componentKey ) { return dag.getParentLabels( componentKey ); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/MapOrientedComponentComposer.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/MapOrientedComponen0000644000175000017500000001231610251162615033222 0ustar paulpaulpackage org.codehaus.plexus.component.composition; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.MapOrientedComponent; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.StringUtils; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; /* * 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 MapOrientedComponentComposer extends AbstractComponentComposer { private static final String SINGLE_MAPPING_TYPE = "single"; private static final String MAP_MAPPING_TYPE = "map"; private static final String SET_MAPPING_TYPE = "set"; private static final String DEFAULT_MAPPING_TYPE = SINGLE_MAPPING_TYPE; public List assembleComponent( Object component, ComponentDescriptor componentDescriptor, PlexusContainer container ) throws CompositionException { if ( !( component instanceof MapOrientedComponent ) ) { throw new CompositionException( "Cannot compose component: " + component.getClass().getName() + "; it does not implement " + MapOrientedComponent.class.getName() ); } List retValue = new LinkedList(); List requirements = componentDescriptor.getRequirements(); for ( Iterator i = requirements.iterator(); i.hasNext(); ) { ComponentRequirement requirement = (ComponentRequirement) i.next(); List descriptors = addRequirement( (MapOrientedComponent) component, container, requirement ); retValue.addAll( descriptors ); } return retValue; } private List addRequirement( MapOrientedComponent component, PlexusContainer container, ComponentRequirement requirement ) throws CompositionException { try { List retValue; String role = requirement.getRole(); String hint = requirement.getRoleHint(); String mappingType = requirement.getFieldMappingType(); Object value = null; // if the hint is not empty, we don't care about mapping type...it's a single-value, not a collection. if ( StringUtils.isNotEmpty( hint ) ) { String key = requirement.getRequirementKey(); value = container.lookup( key ); ComponentDescriptor componentDescriptor = container.getComponentDescriptor( key ); retValue = Collections.singletonList( componentDescriptor ); } else if ( SINGLE_MAPPING_TYPE.equals( mappingType ) ) { String key = requirement.getRequirementKey(); value = container.lookup( key ); ComponentDescriptor componentDescriptor = container.getComponentDescriptor( key ); retValue = Collections.singletonList( componentDescriptor ); } else if ( MAP_MAPPING_TYPE.equals( mappingType ) ) { value = container.lookupMap( role ); retValue = container.getComponentDescriptorList( role ); } else if ( SET_MAPPING_TYPE.equals( mappingType ) ) { value = new HashSet( container.lookupList( role ) ); retValue = container.getComponentDescriptorList( role ); } else { String key = requirement.getRequirementKey(); value = container.lookup( key ); ComponentDescriptor componentDescriptor = container.getComponentDescriptor( key ); retValue = Collections.singletonList( componentDescriptor ); } component.addComponentRequirement( requirement, value ); return retValue; } catch ( ComponentLookupException e ) { throw new CompositionException( "Composition failed in object of type " + component.getClass().getName() + " because the requirement " + requirement + " was missing", e ); } catch ( ComponentConfigurationException e ) { throw new CompositionException( "Composition failed in object of type " + component.getClass().getName() + " because the requirement " + requirement + " cannot be set on the component.", e ); } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver0000644000175000017500000000240210161654653033344 0ustar paulpaulpackage org.codehaus.plexus.component.composition; import org.codehaus.plexus.component.repository.ComponentDescriptor; import java.util.List; /** * * * @author Jason van Zyl * @author Michal Maczka * * @version $Id: CompositionResolver.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface CompositionResolver { /** * * @param componentDescriptor * @throws CompositionException when cycle is detected */ void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws CompositionException; /** * Returns the list of names of components which are required * by the component of given componentKey. * * @param componentKey The name of the component * @return The list of components which are required by given component */ List getRequirements( String componentKey ); /** * Returns the list of names of components which are using the component. * of given componentKey * * @param componentKey The name of the component * @return The list of components which are requiring given component */ List findRequirements( String componentKey ); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/ComponentComposerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/component/composition/ComponentComposerMa0000644000175000017500000000117110231133376033241 0ustar paulpaulpackage org.codehaus.plexus.component.composition; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; /** * @author Michal Maczka * @version $Id: ComponentComposerManager.java 1750 2005-04-19 07:45:02Z brett $ */ public interface ComponentComposerManager { String ROLE = ComponentComposerManager.class.getName(); void assembleComponent( Object component, final ComponentDescriptor componentDescriptor, final PlexusContainer container ) throws CompositionException, UndefinedComponentComposerException; } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusConstants.java0000644000175000017500000000052210161654653027050 0ustar paulpaulpackage org.codehaus.plexus; public abstract class PlexusConstants { /** Key used to retrieve the plexus container from the context. */ public static final String PLEXUS_KEY = "plexus"; /** Key used to retrieve the core classworlds realm from the context.*/ public static final String PLEXUS_CORE_REALM = "coreRealm"; } plexus-container-default/src/main/java/org/codehaus/plexus/embed/0000755000175000017500000000000010631507717024105 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/embed/Embedder.java0000644000175000017500000001543210317361503026454 0ustar paulpaulpackage org.codehaus.plexus.embed; /* * 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.classworlds.ClassWorld; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfigurationResourceException; import org.codehaus.plexus.util.PropertyUtils; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.util.Iterator; import java.util.Properties; import java.util.Set; public class Embedder implements PlexusEmbedder { private Reader configurationReader; /** Context properties */ private Properties properties; private final DefaultPlexusContainer container; private boolean embedderStarted = false; private boolean embedderStopped = false; public Embedder() { container = new DefaultPlexusContainer(); } public synchronized PlexusContainer getContainer() { if ( !embedderStarted ) { throw new IllegalStateException( "Embedder must be started" ); } return container; } public Object lookup( String role ) throws ComponentLookupException { return getContainer().lookup( role ); } public Object lookup( String role, String id ) throws ComponentLookupException { return getContainer().lookup( role, id ); } public boolean hasComponent( String role ) { return getContainer().hasComponent( role ); } public boolean hasComponent( String role, String id ) { return getContainer().hasComponent( role, id ); } public void release( Object service ) throws ComponentLifecycleException { getContainer().release( service ); } //public synchronized void setClassLoader( ClassLoader classLoader ) //{ // container.setClassLoader( classLoader ); //} public synchronized void setClassWorld( ClassWorld classWorld ) { container.setClassWorld( classWorld ); } public synchronized void setConfiguration( URL configuration ) throws IOException { if ( embedderStarted || embedderStopped ) { throw new IllegalStateException( "Embedder has already been started" ); } this.configurationReader = new InputStreamReader(configuration.openStream()); } public synchronized void setConfiguration( Reader configuration ) throws IOException { if ( embedderStarted || embedderStopped ) { throw new IllegalStateException( "Embedder has already been started" ); } this.configurationReader = configuration; } public synchronized void addContextValue( Object key, Object value ) { if ( embedderStarted || embedderStopped ) { throw new IllegalStateException( "Embedder has already been started" ); } container.addContextValue( key, value ); } public synchronized void setProperties( Properties properties ) { this.properties = properties; } public synchronized void setProperties( File file ) { properties = PropertyUtils.loadProperties( file ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public void setLoggerManager( LoggerManager loggerManager ) { container.setLoggerManager( loggerManager ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected synchronized void initializeContext() { Set keys = properties.keySet(); for ( Iterator iter = keys.iterator(); iter.hasNext(); ) { String key = ( String ) iter.next(); String value = properties.getProperty( key ); container.addContextValue( key, value ); } } public synchronized void start( ClassWorld classWorld ) throws PlexusContainerException { container.setClassWorld( classWorld ); start(); } public synchronized void start() throws PlexusContainerException { if ( embedderStarted ) { throw new IllegalStateException( "Embedder already started" ); } if ( embedderStopped ) { throw new IllegalStateException( "Embedder cannot be restarted" ); } if ( configurationReader != null ) { try { container.setConfigurationResource( configurationReader ); } catch ( PlexusConfigurationResourceException e ) { throw new PlexusContainerException( "Error loading from configuration reader", e ); } } if ( properties != null) { initializeContext(); } container.initialize(); embedderStarted = true; container.start(); } public synchronized void stop() { if ( embedderStopped ) { throw new IllegalStateException( "Embedder already stopped" ); } if ( !embedderStarted ) { throw new IllegalStateException( "Embedder not started" ); } container.dispose(); embedderStarted = false; embedderStopped = true; } } plexus-container-default/src/main/java/org/codehaus/plexus/embed/PlexusEmbedder.java0000644000175000017500000000346410317361503027657 0ustar paulpaul/* Created on Oct 7, 2004 */ package org.codehaus.plexus.embed; import org.codehaus.classworlds.ClassWorld; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfigurationResourceException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.net.URL; import java.util.Properties; /** * @author jdcasey */ public interface PlexusEmbedder { PlexusContainer getContainer(); Object lookup( String role ) throws ComponentLookupException; Object lookup( String role, String id ) throws ComponentLookupException; boolean hasComponent( String role ); boolean hasComponent( String role, String id ); void release( Object service ) throws ComponentLifecycleException; void setClassWorld( ClassWorld classWorld ); void setConfiguration( URL configuration ) throws IOException; void setConfiguration( Reader configuration ) throws IOException; void addContextValue( Object key, Object value ); void setProperties( Properties properties ); void setProperties( File file ); void start( ClassWorld classWorld ) throws PlexusContainerException, PlexusConfigurationResourceException; void start() throws PlexusContainerException, PlexusConfigurationResourceException; void stop(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- void setLoggerManager( LoggerManager loggerManager ); } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerManager.java0000644000175000017500000000136510161654653030317 0ustar paulpaul/* * $Id: PlexusContainerManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ package org.codehaus.plexus; /** * PlexusContainerManager defines the interface for Plexus * components that can create and manage Plexus containers. An * implementation of this interface will configure and create Plexus * containers according to some policy that the component defines; * for example, a container factory might create a Plexus container for * each JAR file that exists in a given directory. * * @author Mark Wilkinson * @version $Revision: 1323 $ */ public interface PlexusContainerManager { String ROLE = PlexusContainerManager.class.getName(); PlexusContainer[] getManagedContainers(); } plexus-container-default/src/main/java/org/codehaus/plexus/context/0000755000175000017500000000000010631507706024513 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java0000644000175000017500000000720510161654653030667 0ustar paulpaul/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.codehaus.plexus.context; /** * 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 context value. * * @author Avalon Development Team * @version CVS $Revision: 1323 $ $Date: 2004-12-20 23:00:59 +0000 (Mon, 20 Dec 2004) $ */ public class ContextException extends Exception { /** * 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 ); } } plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextMapAdapter.java0000644000175000017500000000120110161654653030735 0ustar paulpaulpackage org.codehaus.plexus.context; 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; } } } plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java0000644000175000017500000001461710161654653030322 0ustar paulpaulpackage org.codehaus.plexus.context; /* * 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.Serializable; import java.util.Hashtable; import java.util.Map; /** * 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 context will not search in the parent context for the value. * * @author Avalon Development Team * @version $Id: DefaultContext.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultContext implements Context { /** */ private static Hidden HIDDEN_MAKER = new Hidden(); /** Context data. */ private Map contextData; /** Parent Context. */ private Context parent; /** Is the context read only. */ private boolean readOnly; /** * Create a Context with specified data and parent. * * @param contextData the context data * @param parent the parent Context (may be null) */ public DefaultContext( Map contextData, Context parent ) { this.parent = parent; this.contextData = contextData; } /** * Create a empty Context with specified data. * * @param contextData the context data */ public DefaultContext( Map contextData ) { this( contextData, null ); } /** * Create a Context with specified parent. * * @param parent the parent Context (may be null) */ public DefaultContext( Context parent ) { this( new Hashtable(), parent ); } /** * Create a empty Context with no parent. */ public DefaultContext() { this( (Context) null ); } /** * Returns true if the map or the parent map contains the key. * * @param key The key to search for. * @return Returns true if the key was found. */ public boolean contains( Object key ) { Object data = contextData.get( key ); if ( null != data ) { if ( data instanceof Hidden ) { return false; } return true; } // If data was null, check the parent if ( null == parent ) { return false; } return parent.contains( 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 * @throws ContextException If the key doesn't exist. */ public Object get( Object key ) throws ContextException { Object data = contextData.get( key ); if ( data != null ) { if ( data instanceof Hidden ) { // Always fail throw new ContextException( "Unable to locate " + key ); } return data; } // If data was null, check the parent if ( parent == null ) { // There was no parent, and no data throw new ContextException( "Unable to resolve context key: " + key ); } return parent.get( key ); } /** * Helper method for adding items to Context. * * @param key the items key * @param value the item * @throws java.lang.IllegalStateException if context is read only */ public void put( Object key, Object value ) throws IllegalStateException { checkWriteable(); if ( null == value ) { contextData.remove( key ); } else { contextData.put( key, value ); } } /** * Hides the item in the context. * * After remove(key) has been called, a get(key) * will always fail, even if the parent context * has such a mapping. * * @param key the items key * @throws java.lang.IllegalStateException if context is read only */ public void hide( Object key ) throws IllegalStateException { checkWriteable(); contextData.put( key, HIDDEN_MAKER ); } /** * Utility method to retrieve context data. * * @return the context data */ protected Map getContextData() { return contextData; } /** * Get parent context if any. * * @return the parent Context (may be null) */ protected Context getParent() { return parent; } /** * Make the context read-only. * Any attempt to write to the context via put() * will result in an IllegalStateException. */ public void makeReadOnly() { readOnly = true; } /** * Utility method to check if context is writeable and if not throw exception. * * @throws java.lang.IllegalStateException if context is read only */ protected void checkWriteable() throws IllegalStateException { if ( readOnly ) { throw new IllegalStateException( "Context is read only and can not be modified" ); } } /** * This class is only used as a marker in the map to indicate a hidden value. */ private static class Hidden implements Serializable { } } plexus-container-default/src/main/java/org/codehaus/plexus/context/Context.java0000644000175000017500000000710310161654653027005 0ustar paulpaul/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.codehaus.plexus.context; public interface Context { Object get( Object key ) throws ContextException; boolean contains( Object key ); /** * Adds the item to the context. * * @param key the key of the item * @param value the item * @throws java.lang.IllegalStateException if context is read only */ public void put( Object key, Object value )throws IllegalStateException; /** * Hides the item in the context. * After remove(key) has been called, a get(key) * will always fail, even if the parent context * has such a mapping. * * @param key the items key * @throws java.lang.IllegalStateException if context is read only */ void hide( Object key ) throws IllegalStateException; /** * Make the context read-only. * Any attempt to write to the context via put() * will result in an IllegalStateException. */ void makeReadOnly(); } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerHost.java0000644000175000017500000001513310231133376027650 0ustar paulpaulpackage org.codehaus.plexus; /* * 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.classworlds.ClassWorld; import org.codehaus.plexus.configuration.PlexusConfigurationResourceException; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; /** * A ContainerHost. * * @author Jason van Zyl * @author bob mcwhirter * * @version $Id: PlexusContainerHost.java 1750 2005-04-19 07:45:02Z brett $ */ public class PlexusContainerHost implements Runnable { private DefaultPlexusContainer container; private boolean shouldStop; private boolean isStopped; private Object shutdownSignal; // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Constuctor. */ public PlexusContainerHost() { shutdownSignal = new Object(); } // ---------------------------------------------------------------------- // Implementation // ---------------------------------------------------------------------- public PlexusContainer start( ClassWorld classWorld, String configurationResource ) throws FileNotFoundException, PlexusConfigurationResourceException, PlexusContainerException { container = getPlexusContainer(); container.setClassWorld( classWorld ); container.setConfigurationResource( new FileReader( configurationResource ) ); customizeContainer( container ); // Move this to the logging subsystem. And there might be a logging directory // so we need better analsys as the container might be embedded. File plexusLogs = new File( System.getProperty( "plexus.home" ) + "/logs" ); if ( plexusLogs.exists() == false ) { plexusLogs.mkdirs(); } container.initialize(); container.start(); Thread thread = new Thread( this ); thread.setDaemon( false ); Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() { public void run() { try { shutdown(); } catch ( Exception e ) { // do nothing. } } } ) ); thread.start(); return container; } // ---------------------------------------------------------------------- // Methods for customizing the container // ---------------------------------------------------------------------- protected DefaultPlexusContainer getPlexusContainer() { return new DefaultPlexusContainer(); } protected void customizeContainer( PlexusContainer container ) { container.addContextValue( "plexus.home", System.getProperty( "plexus.home" ) ); container.addContextValue( "plexus.work", System.getProperty( "plexus.home" ) + "/work" ); container.addContextValue( "plexus.logs", System.getProperty( "plexus.home" ) + "/logs" ); } /** * Asynchronous hosting component loop. */ public void run() { synchronized ( this ) { while ( !shouldStop ) { try { wait(); } catch ( InterruptedException e ) { //ignore } } } synchronized ( this ) { isStopped = true; notifyAll(); } } // ---------------------------------------------------------------------- // Container control // ---------------------------------------------------------------------- /** * Shutdown this container. */ public void shutdown() { synchronized ( this ) { shouldStop = true; container.dispose(); notifyAll(); } synchronized ( this ) { while ( !isStopped() ) { try { wait(); } catch ( InterruptedException e ) { //ignore } } synchronized( shutdownSignal ) { shutdownSignal.notifyAll(); } } } public void waitForContainerShutdown() { while ( !isStopped() ) { try { synchronized( shutdownSignal ) { shutdownSignal.wait(); } } catch ( InterruptedException e ) { // ignored } } } public boolean isStopped() { return isStopped; } /** * Main entry-point. * * @param args Command-line arguments. */ public static void main( String[] args, ClassWorld classWorld ) { if ( args.length != 1 ) { System.err.println( "usage: plexus " ); System.exit( 1 ); } try { PlexusContainerHost host = new PlexusContainerHost(); host.start( classWorld, args[0] ); host.waitForContainerShutdown(); } catch ( Exception e ) { e.printStackTrace(); System.exit( 2 ); } } } plexus-container-default/src/main/java/org/codehaus/plexus/personality/0000755000175000017500000000000010631507716025401 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/0000755000175000017500000000000010631507717026722 5ustar paulpaul././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/PlexusLifecycleHandler.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/PlexusLifecycleHandler0000644000175000017500000000056610231133376033242 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus; import org.codehaus.plexus.lifecycle.AbstractLifecycleHandler; public class PlexusLifecycleHandler extends AbstractLifecycleHandler { public static String COMPONENT_CONFIGURATOR = "component.configurator"; public PlexusLifecycleHandler() { super(); } public void initialize() { } } plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/0000755000175000017500000000000010631507716030660 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/0000755000175000017500000000000010631507717031761 5ustar paulpaul././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspendable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspen0000644000175000017500000000021210161654653033154 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; public interface Suspendable { void suspend(); void resume(); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Configurable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Config0000644000175000017500000000065710161654653033121 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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; } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Starti0000644000175000017500000000100010231133376033131 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * Error occuring while starting a component. * * @author Brett Porter * @version $Id: StartingException.java 1750 2005-04-19 07:45:02Z brett $ */ public class StartingException extends Exception { public StartingException( String message ) { super( message ); } public StartingException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Serviceable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Servic0000644000175000017500000000043010161654653033134 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * Indicates that a class wants a hold on a ServiceLocator. * * @author Dan Diephouse */ public interface Serviceable { void service( ServiceLocator locator ); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StopPhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StopPh0000644000175000017500000000123210246131767033117 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) throws PhaseExecutionException { if ( object instanceof Startable ) { try { ( (Startable) object ).stop(); } catch ( StoppingException e ) { throw new PhaseExecutionException( "Error stopping component", e ); } } } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ResumePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Resume0000644000175000017500000000066110231133376033137 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) { if ( object instanceof Suspendable ) { ( (Suspendable) object ).resume(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initia0000644000175000017500000000127010231133376033111 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) throws PhaseExecutionException { if ( object instanceof Initializable ) { try { ( (Initializable) object ).initialize(); } catch ( InitializationException e ) { throw new PhaseExecutionException( "Error initialising component", e ); } } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/AutoConfigurePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/AutoCo0000644000175000017500000000403610251162615033071 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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.lifecycle.phase.AbstractPhase; import org.codehaus.plexus.util.StringUtils; /** * @todo (michal) should this phase be called only for components which * does not implement Configurable interface? */ public class AutoConfigurePhase extends AbstractPhase { public static final String DEFAULT_CONFIGURATOR_ID = "basic"; public void execute( Object object, ComponentManager manager ) throws PhaseExecutionException { try { ComponentDescriptor descriptor = manager.getComponentDescriptor(); String configuratorId = descriptor.getComponentConfigurator(); if(StringUtils.isEmpty(configuratorId)) { configuratorId = DEFAULT_CONFIGURATOR_ID; } ComponentConfigurator componentConfigurator = (ComponentConfigurator) manager.getContainer().lookup( ComponentConfigurator.ROLE, configuratorId ); if ( manager.getComponentDescriptor().hasConfiguration() ) { componentConfigurator.configureComponent( object, manager.getComponentDescriptor().getConfiguration(), manager.getContainer().getContainerRealm() ); } } 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 ); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ConfigurablePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Config0000644000175000017500000000150110231133376033076 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) 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 ); } } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Stoppi0000644000175000017500000000110610246131767033160 0ustar paulpaul/* * Copyright (c) 2005 Your Corporation. All Rights Reserved. */ package org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * Error occuring while starting a component. * * @author Brett Porter * @version $Id: StoppingException.java 2019 2005-05-28 18:09:59Z jvanzyl $ */ public class StoppingException extends Exception { public StoppingException( String message ) { super( message ); } public StoppingException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/CompositionPhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Compos0000644000175000017500000000271110231133376033135 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.composition.CompositionException; import org.codehaus.plexus.component.composition.UndefinedComponentComposerException; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; /** * @todo this little example works but is indicative of of some decoupling that * needs to happen wrt the lifecycle handlers. We should be able to specify by * configuration which entities for a lifecycle handler are required. */ public class CompositionPhase extends AbstractPhase { public void execute( Object object, ComponentManager manager ) throws PhaseExecutionException { // We only need to assemble a component if it specifies requirements. PlexusContainer container = manager.getContainer(); ComponentDescriptor descriptor = manager.getComponentDescriptor(); try { container.composeComponent( object, descriptor ); } catch ( CompositionException e ) { throw new PhaseExecutionException( "Error composing component", e ); } catch ( UndefinedComponentComposerException e ) { throw new PhaseExecutionException( "Error composing component", e ); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/SuspendPhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Suspen0000644000175000017500000000066310231133376033156 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) { if ( object instanceof Suspendable ) { ( (Suspendable) object ).suspend(); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initia0000644000175000017500000000047610231133376033120 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * * * @author Jason van Zyl * * @version $Id: Initializable.java 1750 2005-04-19 07:45:02Z brett $ */ public interface Initializable { public void initialize() throws InitializationException; } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PlexusContainerLocator.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Plexus0000644000175000017500000000505510231133376033161 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.List; import java.util.Map; /** * A ServiceLocator for PlexusContainer. * * @author Dan Diephouse */ public class PlexusContainerLocator implements ServiceLocator { private PlexusContainer container; public PlexusContainerLocator( PlexusContainer container ) { this.container = container; } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#lookup(java.lang.String) */ public Object lookup(String componentKey) throws ComponentLookupException { return container.lookup(componentKey); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#lookup(java.lang.String, java.lang.String) */ public Object lookup(String role, String roleHint) throws ComponentLookupException { return container.lookup(role, roleHint); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#lookupMap(java.lang.String) */ public Map lookupMap(String role) throws ComponentLookupException { return container.lookupMap(role); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#lookupList(java.lang.String) */ public List lookupList(String role) throws ComponentLookupException { return container.lookupList(role); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#release(java.lang.Object) */ public void release(Object component) throws ComponentLifecycleException { container.release(component); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#releaseAll(java.util.Map) */ public void releaseAll(Map components) throws ComponentLifecycleException { container.releaseAll(components); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#releaseAll(java.util.List) */ public void releaseAll(List components) throws ComponentLifecycleException { container.releaseAll(components); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#hasComponent(java.lang.String) */ public boolean hasComponent(String componentKey) { return container.hasComponent(componentKey); } /** * @see org.codehaus.xfire.lifecycle.ServiceLocator#hasComponent(java.lang.String, java.lang.String) */ public boolean hasComponent(String role, String roleHint) { return container.hasComponent(role, roleHint); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contex0000644000175000017500000000065210231133376033137 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; /** * @author Jason van Zyl * @version $Id: Contextualizable.java 1750 2005-04-19 07:45:02Z brett $ */ public interface Contextualizable { public void contextualize( Context context ) throws ContextException; } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceLocator.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Servic0000644000175000017500000000322710231133376033133 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.List; import java.util.Map; /** * 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 ); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Startable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Starta0000644000175000017500000000030610246131767033141 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; public interface Startable { void start() throws StartingException; void stop() throws StoppingException; } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/DisposePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Dispos0000644000175000017500000000066110231133376033140 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) { if ( object instanceof Disposable ) { ( (Disposable) object ).dispose(); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Dispos0000644000175000017500000000042010161654653033141 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * * * @author Jason van Zyl * * @version $Id: Disposable.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Disposable { public void dispose(); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDis0000644000175000017500000000257610231133376033067 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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.lifecycle.phase.AbstractPhase; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.LoggerManager; /** * @author Trygve Laugstøl * @version $Id: LogDisablePhase.java 1750 2005-04-19 07:45:02Z brett $ */ public class LogDisablePhase extends AbstractPhase { public void execute( Object object, ComponentManager componentManager ) throws PhaseExecutionException { LoggerManager loggerManager; ComponentDescriptor descriptor; if ( object instanceof LogEnabled ) { try { loggerManager = (LoggerManager) componentManager.getContainer().lookup( LoggerManager.ROLE ); } catch ( ComponentLookupException e ) { throw new PhaseExecutionException( "Unable to locate logger manager", e ); } descriptor = componentManager.getComponentDescriptor(); loggerManager.returnComponentLogger( descriptor.getRole(), descriptor.getRoleHint() ); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ContextualizePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contex0000644000175000017500000000156010231133376033136 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) throws PhaseExecutionException { if ( object instanceof Contextualizable ) { Context context = manager.getContainer().getContext(); try { ( (Contextualizable) object ).contextualize( context ); } catch ( ContextException e ) { throw new PhaseExecutionException( "Unable to contextualize component", e ); } } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/ServiceablePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Servic0000644000175000017500000000111310231133376033123 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; import org.codehaus.plexus.PlexusContainer; 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 ) { if ( object instanceof Serviceable ) { PlexusContainer container = manager.getContainer(); ( (Serviceable) object ).service( new PlexusContainerLocator(container) ); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseE0000644000175000017500000000073310231133376033044 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * Describes an error that has occurred during the execution of a phase. * * @author Brett Porter * @version $Id: PhaseExecutionException.java 1750 2005-04-19 07:45:02Z brett $ */ public class PhaseExecutionException extends Exception { public PhaseExecutionException( String message, Throwable throwable ) { super( message, throwable ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartPhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartP0000644000175000017500000000123410231133376033111 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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 ) throws PhaseExecutionException { if ( object instanceof Startable ) { try { ( (Startable) object ).start(); } catch ( StartingException e ) { throw new PhaseExecutionException( "Error starting component", e ); } } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEna0000644000175000017500000000220010317361503033033 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; 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.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 ) throws PhaseExecutionException { LoggerManager loggerManager; ComponentDescriptor descriptor; Logger logger; if ( object instanceof LogEnabled ) { loggerManager = componentManager.getContainer().getLoggerManager(); descriptor = componentManager.getComponentDescriptor(); logger = loggerManager.getLoggerForComponent( descriptor.getRole(), descriptor.getRoleHint() ); ( (LogEnabled) object ).enableLogging( logger ); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initia0000644000175000017500000000104310231133376033107 0ustar paulpaulpackage org.codehaus.plexus.personality.plexus.lifecycle.phase; /** * Indicates a problem occurred when initialising a component. * * @author Brett Porter * @version $Id: InitializationException.java 1750 2005-04-19 07:45:02Z brett $ */ public class InitializationException extends Exception { public InitializationException( String message ) { super( message ); } public InitializationException( String message, Throwable cause ) { super( message, cause ); } } plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java0000644000175000017500000001605410227643552026615 0ustar paulpaulpackage org.codehaus.plexus; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.context.Context; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; /** * @author Jason van Zyl * @author Trygve Laugstøl * @author Michal Maczka * @version $Id: PlexusTestCase.java 1708 2005-04-15 04:47:38Z brett $ */ public abstract class PlexusTestCase extends TestCase { protected PlexusContainer container; /** * @deprecated Use getBasedir(); instead of accessing this variable directly. * * When removing this variable rename basedirPath to basedir. Trygve. */ protected String basedir; private static String basedirPath; public PlexusTestCase() { } /** * @deprecated Use the no arg contstructor. */ public PlexusTestCase( String testName ) { super( testName ); } protected void setUp() throws Exception { InputStream configuration = null; try { configuration = getCustomConfiguration(); if ( configuration == null ) { configuration = getConfiguration(); } } catch ( Exception e ) { System.out.println( "Error with configuration:" ); System.out.println( "configuration = " + configuration ); fail( e.getMessage() ); } basedir = getBasedir(); container = createContainerInstance(); container.addContextValue( "basedir", getBasedir() ); // this method was deprecated customizeContext(); customizeContext( getContext() ); boolean hasPlexusHome = getContext().contains( "plexus.home" ); if ( !hasPlexusHome ) { File f = getTestFile( "target/plexus-home" ); if ( !f.isDirectory() ) { f.mkdir(); } getContext().put( "plexus.home", f.getAbsolutePath() ); } if ( configuration != null ) { container.setConfigurationResource( new InputStreamReader( configuration ) ); } container.initialize(); container.start(); } protected PlexusContainer createContainerInstance() { return new DefaultPlexusContainer(); } private Context getContext() { return container.getContext(); } //!!! this should probably take a context as a parameter so that the // user is not forced to do getContainer().addContextValue(..) // this would require a change to PlexusContainer in order to get // hold of the context ... // @deprecated use void customizeContext( Context context ) protected void customizeContext() throws Exception { } protected void customizeContext( Context context ) throws Exception { } protected InputStream getCustomConfiguration() throws Exception { return null; } protected void tearDown() throws Exception { container.dispose(); container = null; } protected PlexusContainer getContainer() { return container; } protected InputStream getConfiguration() throws Exception { return getConfiguration( null ); } protected InputStream getConfiguration( String subname ) throws Exception { String className = getClass().getName(); String base = className.substring( className.lastIndexOf( "." ) + 1 ); String config = null; if ( subname == null || subname.equals( "" ) ) { config = base + ".xml"; } else { config = base + "-" + subname + ".xml"; } InputStream configStream = getResourceAsStream( config ); return configStream; } protected InputStream getResourceAsStream( String resource ) { return getClass().getResourceAsStream( resource ); } protected ClassLoader getClassLoader() { return getClass().getClassLoader(); } // ---------------------------------------------------------------------- // Container access // ---------------------------------------------------------------------- protected Object lookup( String componentKey ) throws Exception { return getContainer().lookup( componentKey ); } protected Object lookup( String role, String id ) throws Exception { return getContainer().lookup( role, id ); } 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 ( basedirPath != null ) { return basedirPath; } basedirPath = System.getProperty( "basedir" ); if ( basedirPath == null ) { basedirPath = new File( "" ).getAbsolutePath(); } return basedirPath; } } plexus-container-default/src/main/java/org/codehaus/plexus/configuration/0000755000175000017500000000000010631507715025676 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfiguration.java0000644000175000017500000001003010161654653032545 0ustar paulpaulpackage org.codehaus.plexus.configuration; /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ public interface PlexusConfiguration { // ---------------------------------------------------------------------- // Name handling // ---------------------------------------------------------------------- String getName(); // ---------------------------------------------------------------------- // Value handling // ---------------------------------------------------------------------- String getValue() throws PlexusConfigurationException; String getValue( String defaultValue ); // ---------------------------------------------------------------------- // Attribute handling // ---------------------------------------------------------------------- String[] getAttributeNames(); String getAttribute( String paramName ) throws PlexusConfigurationException; String getAttribute( String name, String defaultValue ); // ---------------------------------------------------------------------- // Child handling // ---------------------------------------------------------------------- PlexusConfiguration getChild( String child ); PlexusConfiguration getChild( int i ); PlexusConfiguration getChild( String child, boolean createChild ); PlexusConfiguration[] getChildren(); PlexusConfiguration[] getChildren( String name ); void addChild( PlexusConfiguration configuration ); int getChildCount(); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationException.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationExceptio0000644000175000017500000000565410161654653033346 0ustar paulpaul/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.codehaus.plexus.configuration; public class PlexusConfigurationException extends Exception { public PlexusConfigurationException( String message ) { this( message, null ); } public PlexusConfigurationException( String message, Throwable throwable ) { super( message, throwable ); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationResourceException.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationResource0000644000175000017500000000034010161654653033340 0ustar paulpaulpackage org.codehaus.plexus.configuration; public class PlexusConfigurationResourceException extends Exception { public PlexusConfigurationResourceException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.j0000644000175000017500000003053610231133376033224 0ustar paulpaulpackage org.codehaus.plexus.configuration; /* * 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.configuration.xml.XmlPlexusConfiguration; /** * @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 ignore // -----------------------------------+----------------------------------------------------------------- // lifecycle-handler-manager | user wins, but system lifecycles show through // -----------------------------------+----------------------------------------------------------------- // components | user // -----------------------------------+----------------------------------------------------------------- public static PlexusConfiguration merge( PlexusConfiguration user, PlexusConfiguration system ) { XmlPlexusConfiguration 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 ( int i = 0; i < configurationsDirectories.length; i++ ) { mergedConfiguration.addChild( configurationsDirectories[i] ); } } // ---------------------------------------------------------------------- // Logging // ---------------------------------------------------------------------- PlexusConfiguration logging = user.getChild( "logging" ); if ( logging.getChildCount() != 0 ) { mergedConfiguration.addChild( logging ); } else { mergedConfiguration.addChild( system.getChild( "logging" ) ); } // ---------------------------------------------------------------------- // 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 // ---------------------------------------------------------------------- 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(); XmlPlexusConfiguration dest = (XmlPlexusConfiguration) destination.getChild( "resources" ); for ( int i = 0; i < handlers.length; i++ ) { dest.addChild( handlers[i] ); } } private static void copyComponentDiscoverers( PlexusConfiguration source, PlexusConfiguration destination ) { PlexusConfiguration handlers[] = source.getChild( "component-discoverers" ).getChildren( "component-discoverer" ); XmlPlexusConfiguration dest = (XmlPlexusConfiguration) destination.getChild( "component-discoverers" ); for ( int i = 0; i < handlers.length; i++ ) { dest.addChild( handlers[i] ); } } private static void copyComponentFactories( PlexusConfiguration source, PlexusConfiguration destination ) { PlexusConfiguration handlers[] = source.getChild( "component-factories" ).getChildren( "component-factory" ); XmlPlexusConfiguration dest = (XmlPlexusConfiguration) destination.getChild( "component-factories" ); for ( int i = 0; i < handlers.length; i++ ) { dest.addChild( handlers[i] ); } } private static void copyComponentComposers( PlexusConfiguration source, PlexusConfiguration destination ) { PlexusConfiguration composers[] = source.getChild( "component-composers" ).getChildren( "component-composer" ); XmlPlexusConfiguration dest = (XmlPlexusConfiguration) destination.getChild( "component-composers" ); for ( int i = 0; i < composers.length; i++ ) { dest.addChild( composers[i] ); } } private static void copyLifecycles( PlexusConfiguration source, PlexusConfiguration destination ) { PlexusConfiguration handlers[] = source.getChild( "lifecycle-handlers" ).getChildren( "lifecycle-handler" ); XmlPlexusConfiguration dest = (XmlPlexusConfiguration) destination.getChild( "lifecycle-handlers" ); for ( int i = 0; i < handlers.length; i++ ) { dest.addChild( handlers[i] ); } } private static void copyComponents( PlexusConfiguration source, PlexusConfiguration destination ) { PlexusConfiguration components[] = source.getChildren( "component" ); for ( int i = 0; i < components.length; i++ ) { destination.addChild( components[i] ); } } } plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/0000755000175000017500000000000010631507714026475 5ustar paulpaul././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.0000644000175000017500000002012410231114556033160 0ustar paulpaulpackage org.codehaus.plexus.configuration.xml; /* * 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.configuration.PlexusConfiguration; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * @version $Id: XmlPlexusConfiguration.java 1747 2005-04-19 05:38:54Z brett $ */ public class XmlPlexusConfiguration implements PlexusConfiguration { private Xpp3Dom dom; public XmlPlexusConfiguration( String name ) { this.dom = new Xpp3Dom( name ); } public XmlPlexusConfiguration( Xpp3Dom dom ) { this.dom = dom; } public Xpp3Dom getXpp3Dom() { return dom; } // ---------------------------------------------------------------------- // Name handling // ---------------------------------------------------------------------- public String getName() { return dom.getName(); } // ---------------------------------------------------------------------- // Value handling // ---------------------------------------------------------------------- public String getValue() { return dom.getValue(); } public String getValue( String defaultValue ) { String value = dom.getValue(); if ( value == null ) { value = defaultValue; } return value; } public void setValue( String value ) { dom.setValue( value ); } // ---------------------------------------------------------------------- // Attribute handling // ---------------------------------------------------------------------- public void setAttribute( String name, String value ) { dom.setAttribute( name, value ); } public String getAttribute( String name, String defaultValue ) { String attribute = getAttribute( name ); if ( attribute == null ) { attribute = defaultValue; } return attribute; } public String getAttribute( String name ) { return dom.getAttribute( name ); } public String[] getAttributeNames() { return dom.getAttributeNames(); } // ---------------------------------------------------------------------- // Child handling // ---------------------------------------------------------------------- // The behaviour of getChild* that we adopted from avalon is that if the child // does not exist then we create the child. public PlexusConfiguration getChild( String name ) { return getChild( name, true ); } public PlexusConfiguration getChild( int i ) { return new XmlPlexusConfiguration( dom.getChild( i ) ); } public PlexusConfiguration getChild( String name, boolean createChild ) { Xpp3Dom child = dom.getChild( name ); if ( child == null ) { if ( createChild ) { child = new Xpp3Dom( name ); dom.addChild( child ); } else { return null; } } return new XmlPlexusConfiguration( child ); } public PlexusConfiguration[] getChildren() { Xpp3Dom[] doms = dom.getChildren(); PlexusConfiguration[] children = new XmlPlexusConfiguration[doms.length]; for ( int i = 0; i < children.length; i++ ) { children[i] = new XmlPlexusConfiguration( doms[i] ); } return children; } public PlexusConfiguration[] getChildren( String name ) { Xpp3Dom[] doms = dom.getChildren( name ); PlexusConfiguration[] children = new XmlPlexusConfiguration[doms.length]; for ( int i = 0; i < children.length; i++ ) { children[i] = new XmlPlexusConfiguration( doms[i] ); } return children; } public void addChild( PlexusConfiguration configuration ) { dom.addChild( ( (XmlPlexusConfiguration) configuration ).getXpp3Dom() ); } public void addAllChildren( PlexusConfiguration other ) { PlexusConfiguration[] children = other.getChildren(); for ( int i = 0; i < children.length; i++ ) { addChild( children[i] ); } } public int getChildCount() { return dom.getChildCount(); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public String toString() { StringBuffer sb = new StringBuffer(); int depth = 0; display( this, sb, depth ); return sb.toString(); } private void display( PlexusConfiguration c, StringBuffer sb, int depth ) { sb.append( indent( depth ) ). append( '<' ). append( c.getName() ). append( '>' ). append( '\n' ); int count = c.getChildCount(); for ( int i = 0; i < count; i++ ) { PlexusConfiguration child = c.getChild( i ); int childCount = child.getChildCount(); depth++; if ( childCount > 0 ) { display( child, sb, depth ); } else { String value = child.getValue( null ); if ( value != null ) { sb.append( indent( depth ) ). append( '<' ). append( child.getName() ); attributes( child, sb ); sb.append( '>' ). append( child.getValue( null ) ). append( '<' ). append( '/' ). append( child.getName() ). append( '>' ). append( '\n' ); } else { sb.append( indent( depth ) ). append( '<' ). append( child.getName() ); attributes( child, sb ); sb.append( '/' ). append( '>' ). append( "\n" ); } } depth--; } sb.append( indent( depth ) ). append( '<' ). append( '/' ). append( c.getName() ). append( '>' ). append( '\n' ); } private void attributes( PlexusConfiguration c, StringBuffer sb ) { String[] names = c.getAttributeNames(); for ( int i = 0; i < names.length; i++ ) { sb.append( ' ' ). append( names[i] ). append( '=' ). append( '"' ). append( c.getAttribute( names[i], null ) ). append( '"' ); } } private String indent( int depth ) { StringBuffer sb = new StringBuffer(); for ( int i = 0; i < depth; i++ ) { sb.append( ' ' ); } return sb.toString(); } } plexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/0000755000175000017500000000000010631507714027714 5ustar paulpaul././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/FileConfigurationResourceHandler.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/FileConfiguration0000644000175000017500000000546410236467234033262 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; import org.codehaus.plexus.component.repository.io.PlexusTools; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.util.IOUtil; import java.io.File; import java.io.FileReader; import java.io.FileNotFoundException; import java.util.Map; /* * 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 * @version $Id: FileConfigurationResourceHandler.java 1781 2005-05-05 19:06:04Z jdcasey $ */ public class FileConfigurationResourceHandler extends AbstractConfigurationResourceHandler { public String getId() { return "file-configuration-resource"; } public PlexusConfiguration[] handleRequest( Map parameters ) throws ConfigurationResourceNotFoundException, ConfigurationProcessingException { File f = new File( getSource( parameters ) ); if ( !f.exists() ) { throw new ConfigurationResourceNotFoundException( "The specified resource " + f + " cannot be found." ); } FileReader configurationReader = null; try { configurationReader = new FileReader( f ); return new PlexusConfiguration[]{ PlexusTools.buildConfiguration( f.getAbsolutePath(), configurationReader ) }; } catch ( PlexusConfigurationException e ) { throw new ConfigurationProcessingException( e ); } catch ( FileNotFoundException e ) { throw new ConfigurationProcessingException( e ); } finally { IOUtil.close( configurationReader ); } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationResourceNotFoundException.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationReso0000644000175000017500000000336710161654653033313 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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 * @version $Id: ConfigurationResourceNotFoundException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ConfigurationResourceNotFoundException extends Exception { public ConfigurationResourceNotFoundException( String message ) { super( message ); } public ConfigurationResourceNotFoundException( Throwable cause ) { super( cause ); } public ConfigurationResourceNotFoundException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationProcessor.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationProc0000644000175000017500000001462010227643552033277 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.util.StringUtils; import java.util.HashMap; import java.util.Map; /** * Take a normal PlexusConfiguration and look for directives within it * that allow the inlining of external configuration sources. * * @todo could this be amalgamated with the expression handling in the component configurator? It cannot be used here, * as it requires actual objects to be returned, which cannot be stored back into a configuration object. * * @author Jason van Zyl * @version $Id: ConfigurationProcessor.java 1708 2005-04-15 04:47:38Z brett $ */ public class ConfigurationProcessor { protected Map handlers; public ConfigurationProcessor() { handlers = new HashMap(); } public void addConfigurationResourceHandler( ConfigurationResourceHandler handler ) { handlers.put( handler.getId(), handler ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public PlexusConfiguration process( PlexusConfiguration configuration, Map variables ) throws ConfigurationResourceNotFoundException, ConfigurationProcessingException { XmlPlexusConfiguration processed = new XmlPlexusConfiguration( "configuration" ); walk( configuration, processed, variables ); return processed; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected void walk( PlexusConfiguration source, PlexusConfiguration processed, Map variables ) throws ConfigurationResourceNotFoundException, ConfigurationProcessingException { PlexusConfiguration[] children = source.getChildren(); for ( int i = 0; i < children.length; i++ ) { PlexusConfiguration child = children[i]; int count = child.getChildCount(); if ( count > 0 ) { // ---------------------------------------------------------------------- // If we have a child with children itself then we must make a configuration // with the name of the child, add that child to the processed configuration // and walk the child. // // // // // bar // // // // // ---------------------------------------------------------------------- XmlPlexusConfiguration processedChild = new XmlPlexusConfiguration( child.getName() ); copyAttributes( child, processedChild ); processed.addChild( processedChild ); walk( child, processedChild, variables ); } else { String elementName = child.getName(); // ---------------------------------------------------------------------- // Check to see if this element name matches the id of any of our // source resource handlers. // ---------------------------------------------------------------------- if ( handlers.containsKey( elementName ) ) { ConfigurationResourceHandler handler = (ConfigurationResourceHandler) handlers.get( elementName ); PlexusConfiguration[] configurations = handler.handleRequest( createHandlerParameters( child, variables ) ); for ( int j = 0; j < configurations.length; j++ ) { processed.addChild( configurations[j] ); } } else { processed.addChild( child ); } } } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected Map createHandlerParameters( PlexusConfiguration c, Map variables ) { Map parameters = new HashMap(); String[] parameterNames = c.getAttributeNames(); for ( int i = 0; i < parameterNames.length; i++ ) { String key = parameterNames[i]; String value = StringUtils.interpolate( c.getAttribute( key, null ), variables ); parameters.put( key, value ); } return parameters; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void copyAttributes( PlexusConfiguration source, XmlPlexusConfiguration target ) { String[] names = source.getAttributeNames(); for ( int i = 0; i < names.length; i++ ) { target.setAttribute( names[i], source.getAttribute( names[i], null ) ); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/DirectoryConfigurationResourceHandler.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/DirectoryConfigur0000644000175000017500000001030710236467234033304 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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.repository.io.PlexusTools; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.List; import java.util.Map; /** * @author Jason van Zyl * @version $Id: DirectoryConfigurationResourceHandler.java 1781 2005-05-05 19:06:04Z jdcasey $ */ public class DirectoryConfigurationResourceHandler extends AbstractConfigurationResourceHandler { public String getId() { return "directory-configuration-resource"; } public PlexusConfiguration[] handleRequest( Map parameters ) throws ConfigurationResourceNotFoundException, ConfigurationProcessingException { File f = new File( getSource( parameters ) ); if ( !f.exists() ) { throw new ConfigurationResourceNotFoundException( "The specified resource " + f + " cannot be found." ); } if ( !f.isDirectory() ) { throw new ConfigurationResourceNotFoundException( "The specified resource " + f + " is not a directory." ); } // ---------------------------------------------------------------------- // Parameters // // source == basedir // includes // excludes // ---------------------------------------------------------------------- String includes = (String) parameters.get( "includes" ); if ( includes == null ) { includes = "**/*.xml"; } String excludes = (String) parameters.get( "excludes" ); try { List files = FileUtils.getFiles( f, includes, excludes ); // ---------------------------------------------------------------------- // For each file we find we want to read it in and turn it into a // PlexusConfiguration and insert it into the source configuration. // ---------------------------------------------------------------------- PlexusConfiguration[] configurations = new PlexusConfiguration[files.size()]; for ( int i = 0; i < configurations.length; i++ ) { File configurationFile = (File) files.get( i ); PlexusConfiguration configuration = PlexusTools.buildConfiguration( configurationFile.getAbsolutePath(), new FileReader( configurationFile ) ); configurations[i] = configuration; } return configurations; } catch ( FileNotFoundException e ) { throw new ConfigurationProcessingException( e ); } catch ( IOException e ) { throw new ConfigurationProcessingException( e ); } catch ( PlexusConfigurationException e ) { throw new ConfigurationProcessingException( e ); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationResourceHandler.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationReso0000644000175000017500000000364210161654653033307 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; import java.util.Map; import org.codehaus.plexus.configuration.PlexusConfiguration; /* * 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 * @version $Id: ConfigurationResourceHandler.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ConfigurationResourceHandler { /** * Attribute used to identify the external configuration source. * *
     *
     * 
     *   
     * 
     *
     * 
*/ static final String SOURCE = "source"; String getId(); PlexusConfiguration[] handleRequest( Map parameters ) throws ConfigurationResourceNotFoundException, ConfigurationProcessingException; } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationProcessingException.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/ConfigurationProc0000644000175000017500000000333110161654653033275 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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 * @version $Id: ConfigurationProcessingException.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ConfigurationProcessingException extends Exception { public ConfigurationProcessingException( String message ) { super( message ); } public ConfigurationProcessingException( Throwable cause ) { super( cause ); } public ConfigurationProcessingException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/AbstractConfigurationResourceHandler.javaplexus-container-default/src/main/java/org/codehaus/plexus/configuration/processor/AbstractConfigura0000644000175000017500000000357310161654653033253 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; import java.util.Map; /* * 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 * @version $Id: AbstractConfigurationResourceHandler.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractConfigurationResourceHandler implements ConfigurationResourceHandler { protected String getSource( Map parameters ) throws ConfigurationProcessingException { String source = (String) parameters.get( ConfigurationResourceHandler.SOURCE ); if ( source == null ) { throw new ConfigurationProcessingException( "The 'source' attribute for a configuration resource handler cannot be null." ); } return source; } } plexus-container-default/src/main/java/org/codehaus/plexus/logging/0000755000175000017500000000000010631507706024455 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java0000644000175000017500000000542310161654653027322 0ustar paulpaul/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.codehaus.plexus.logging; /** * @version $Id: LogEnabled.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface LogEnabled { void enableLogging( Logger logger ); } plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java0000644000175000017500000000246610161654653031530 0ustar paulpaulpackage org.codehaus.plexus.logging; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: AbstractLoggerManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } } plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java0000644000175000017500000000443310231120071030205 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * LICENSE */ /** * @author Trygve Laugstøl * @version $Id: AbstractLogger.java 1748 2005-04-19 06:07:53Z brett $ */ 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; } } plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java0000644000175000017500000000240610161654653030036 0ustar paulpaulpackage org.codehaus.plexus.logging; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: LoggerManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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(); // 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(); } plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java0000644000175000017500000000732410231133376030625 0ustar paulpaulpackage org.codehaus.plexus.logging; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import java.util.HashMap; import java.util.Map; /** * Base class for all LoggerManagers which use cache of Loggers. * * @author Michal Maczka * @version $Id: BaseLoggerManager.java 1750 2005-04-19 07:45:02Z brett $ */ 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(); 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; } /** * 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; } } plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/0000755000175000017500000000000010631507706026117 5ustar paulpaulplexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java0000644000175000017500000000454310161654653031534 0ustar paulpaulpackage org.codehaus.plexus.logging.console; 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 * @version $Id: ConsoleLogger.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.javaplexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java0000644000175000017500000001336010161654653033024 0ustar paulpaulpackage org.codehaus.plexus.logging.console; import java.util.HashMap; 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: *

 * 
 *   org.codehaus.plexus.logging.ConsoleLoggerManager
 *   
 *     DEBUG
 *   
 * 
 * 
* * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: ConsoleLoggerManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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. */ 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; } /** * @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 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 = new ConsoleLogger( 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(); 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 ); } } plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java0000644000175000017500000001025410161654653026543 0ustar paulpaul/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.codehaus.plexus.logging; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: Logger.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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(); /** * This one probably shouldn't be deprecated after all. One useful use case is when * you have a server that creates a lot of threads and would like to create a child * logger pr thread. */ Logger getChildLogger( String name ); int getThreshold(); String getName(); } plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java0000644000175000017500000000231010242106764030771 0ustar paulpaulpackage org.codehaus.plexus.logging; import org.codehaus.plexus.logging.console.ConsoleLogger; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: AbstractLogEnabled.java 1806 2005-05-16 12:11:32Z evenisse $ */ 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 ); } } } plexus-container-default/src/test/0000755000175000017500000000000010631507705016236 5ustar paulpaulplexus-container-default/src/test/resources/0000755000175000017500000000000010631507706020251 5ustar paulpaulplexus-container-default/src/test/resources/configurations-directory/0000755000175000017500000000000010631507706025305 5ustar paulpaulplexus-container-default/src/test/resources/configurations-directory/additional-configuration.xml0000644000175000017500000000045510161654653033012 0ustar paulpaul org.codehaus.plexus.ServiceF org.codehaus.plexus.DefaultServiceF ${plexus.home} plexus-container-default/src/test/resources/META-INF/0000755000175000017500000000000010631507705021410 5ustar paulpaulplexus-container-default/src/test/resources/META-INF/maven/0000755000175000017500000000000010631507705022516 5ustar paulpaulplexus-container-default/src/test/resources/META-INF/maven/plugin.xml0000644000175000017500000000054110161654653024541 0ustar paulpaul org.codehaus.plexus.test.discovery.MockMavenPlugin mocky antlr #maven.build.dest #project.build.resources plexus-container-default/src/test/resources/META-INF/plexus/0000755000175000017500000000000010631507705022730 5ustar paulpaulplexus-container-default/src/test/resources/META-INF/plexus/components.xml0000644000175000017500000000127610227633245025645 0ustar paulpaul 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 plexus-container-default/src/test/resources/META-INF/plexus/plexus.xml0000644000175000017500000000045110227633245024772 0ustar paulpaul org.codehaus.plexus.component.factory.ComponentFactory testFactory1 org.codehaus.plexus.component.factory.TestComponentFactory1 plexus-container-default/src/test/resources/jar-repository/0000755000175000017500000000000010631507706023242 5ustar paulpaulplexus-container-default/src/test/resources/jar-repository/c.jar0000644000175000017500000000132210161654653024162 0ustar paulpaulPK @‚;/ META-INF/PK=‚;/META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àårÌCq,HLÎHUŠ%MõŒx¹œ‹RKRSt*ALô ã Œt“ Ì4‚Kó|3“‹ò‹+‹KRs‹<ó’õ4y¹x¹PK—Ñ|2_kPK =‚;/c/PK=‚;/ c/C.class-ŽÍÁP…ÏЪT¼íBØ›&V b[7\©6©Ö{YI,<€‡s1“ÌÌ9óe2¯÷ã ÀG×AmÁš«L• B}0ÜŒ0ßK‚©L®ªs,‹­ˆSvzQžˆt' ¥õß4Ê£ºÌ( ÂÁÙäU‘È¥Ò;+ôOâ*\0ù:„®v‚Td‡`ŸdR¢£ƒ8åj±5`Žî 5Ø\îÀ„Á)<¹?MÞè­/é~PKli‹½ìPK @‚;/ íAMETA-INF/PK=‚;/—Ñ|2_k¤'META-INF/MANIFEST.MFPK =‚;/íAÈc/PK=‚;/li‹½ì ¤èc/C.classPKàÜplexus-container-default/src/test/resources/jar-repository/b.jar0000644000175000017500000000146410161654653024170 0ustar paulpaulPK @‚;/ META-INF/PK=‚;/META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àårÌCq,HLÎHUŠ%MõŒx¹œ‹RKRSt*ALô ã Œt“ Ì4‚Kó|3“‹ò‹+‹KRs‹<ó’õ4y¹x¹PK—Ñ|2_kPK =‚;/b/PK=‚;/ b/B.classQ»NÃ0=·ÍBÒBw¤ÂP¨)C+1E0•ÉI£ÔUšHN ßÅ„ÄÀðQˆk© x¸Ïsν¶?¿Þ? Ð ÐD×DZ‚7R…ªoÍþùŒàLÊyJ8ŒT‘Þ­Wqªdœs¥•‰ÌgR+“ÿz¡*‚Åbrº’ª „ý§h)Ÿ¥Èe‘‰i­U‘…Q©3‘°øB®+‘䲪^JÏ+11ñ£‰C»ÔkvÿÐ ["áì_šLš–k¤·Ê¬ìF·._š'´·“îãešÔ8EƒÉœÈ@Ùzœ]²'öîÅèÕ¶}¶{àŠ×Øá¨µa—;`»g+F`h9øMö,xd‰½Mû8°Óù'ж3,¾ó PKd4©ÆPK @‚;/ íAMETA-INF/PK=‚;/—Ñ|2_k¤'META-INF/MANIFEST.MFPK =‚;/íAÈb/PK=‚;/d4©Æ ¤èb/B.classPKà>plexus-container-default/src/test/resources/jar-repository/d.jar0000644000175000017500000000131610161654653024166 0ustar paulpaulPK @‚;/ META-INF/PK=‚;/META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àårÌCq,HLÎHUŠ%MõŒx¹œ‹RKRSt*ALô ã Œt“ Ì4‚Kó|3“‹ò‹+‹KRs‹<ó’õ4y¹x¹PK—Ñ|2_kPK =‚;/d/PK=‚;/ d/D.class-Ž=‚@…ß ?Š(ÄØ©ÄZc£±"ZhèÜè„Ñ{Y™XxeЙäeß›o6óþ<_|x6ZèYè[p æ\åªZZ£qDЗÅAÜPårs=Dz܋8ãd‰È"QªÚÿC½:© ÁÁjF°wŵLäZÕ3så§â&è0øw&^™ÈÁ6NeRa¯©‹¸e5ÙŒÉt燋ÕlÂ)Ú¬Î@v³Þm(ç PKDó¹èPK @‚;/ íAMETA-INF/PK=‚;/—Ñ|2_k¤'META-INF/MANIFEST.MFPK =‚;/íAÈd/PK=‚;/Dó¹è ¤èd/D.classPKàØplexus-container-default/src/test/resources/jar-repository/a.jar0000644000175000017500000000173610161654653024171 0ustar paulpaulPK @‚;/ META-INF/PK=‚;/META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àårÌCq,HLÎHUŠ%MõŒx¹œ‹RKRSt*ALô ã Œt“ Ì4‚Kó|3“‹ò‹+‹KRs‹<ó’õ4y¹x¹PK—Ñ|2_kPK =‚;/a/PK=‚;/ a/A.classmQËJ1=éc¦3޶¶¶¾u5u1ƒ uQŠàjP¡Ò«´†š2I§‚Ÿ¥ ~€%ÞL Uh÷pONιI¾>¿x8´a`ÍBÖml`ÓÄ–‰mã\Æ2½`È»­Cá2y å@Æâzõ…ºãý˜j xØãJê~FÒG9f(Üï´©¸Œî}0âÏÜy<ô»©’ñ°™s5$ymÁ6ƒÝM&j ®¤66:ž–80Q2±ã`{$éxÜÓnËľƒ4inÊf¨Ìoú#1HÿQÝ—q*"Ò ¥êÓx™ø·”Ò‚G4AmÍ`>é.¤{ÕÝE×BEz]½r`z`ªu>!#,}€½fÛ6U##±DÕ™ — -¬ <;|–™÷†\5ÿŽÂÜÀ&N(çô‰… V é§2eíPKäÊæFýPKùPþ. a.propertiesKT((Ê/H-*ÉL-æPKü½÷˜ PK @‚;/ íAMETA-INF/PK=‚;/—Ñ|2_k¤'META-INF/MANIFEST.MFPK =‚;/íAÈa/PK=‚;/äÊæFý ¤èa/A.classPKùPþ.ü½÷˜ ¤ea.propertiesPK®plexus-container-default/src/test/resources/inline-configuration.xml0000644000175000017500000000012410161654653025115 0ustar paulpaul jason van zyl plexus-container-default/src/test/resources/org/0000755000175000017500000000000010631507705021037 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/0000755000175000017500000000000010631507705022632 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/0000755000175000017500000000000010631507705024152 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/PlexusTestCaseTest.xml0000644000175000017500000000056210167024450030446 0ustar paulpaul org.codehaus.plexus.test.LoadOnStartService org.codehaus.plexus.test.LoadOnStartService org.codehaus.plexus.test.DefaultLoadOnStartService plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/0000755000175000017500000000000010631507705026130 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.xml0000644000175000017500000000434310317361503032630 0ustar paulpaul 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 plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusTwo.xml0000644000175000017500000000157510317361503031573 0ustar paulpaul 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 plexus-container-default/src/test/resources/org/codehaus/plexus/hierarchy/ChildPlexusOne.xml0000644000175000017500000000232010317361503031530 0ustar paulpaul 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 plexus-container-default/src/test/resources/org/codehaus/plexus/component/0000755000175000017500000000000010631507705026154 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/0000755000175000017500000000000010631507705027566 5ustar paulpaul././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.xmlplexus-container-default/src/test/resources/org/codehaus/plexus/component/manager/ClassicSingletonCo0000644000175000017500000000051710161654653033245 0ustar paulpaul org.codehaus.plexus.component.manager.SlowComponent org.codehaus.plexus.component.manager.SlowComponent 300 plexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/0000755000175000017500000000000010631507705030517 5ustar paulpaul././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/components.xmlplexus-container-default/src/test/resources/org/codehaus/plexus/component/composition/components.xml0000644000175000017500000000423610161654653033436 0ustar paulpaul 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 plexus-container-default/src/test/resources/org/codehaus/plexus/embed/0000755000175000017500000000000010631507705025226 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/embed/EmbedderTest.xml0000644000175000017500000000103410240016672030307 0ustar paulpaul ${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 plexus-container-default/src/test/resources/org/codehaus/plexus/test/0000755000175000017500000000000010631507705025131 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/test/map/0000755000175000017500000000000010631507705025706 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/test/map/NoComponentsMapTest.xml0000644000175000017500000000200610161654653032351 0ustar paulpaul 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 plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml0000644000175000017500000002062310167027127031640 0ustar paulpaul ${basedir}/src/test-input/configurations-directory arbitrary Arbitrary Lifecycle Handler org.codehaus.plexus.test.discovery.PluginManager org.codehaus.plexus.test.discovery.MockMavenPluginManager 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 poolable 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.test.logging.LoggerManager org.codehaus.plexus.test.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.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.Activity one org.codehaus.plexus.test.map.ActivityOne org.codehaus.plexus.test.map.Activity two org.codehaus.plexus.test.map.ActivityTwo org.codehaus.plexus.test.list.Pipeline org.codehaus.plexus.test.list.DefaultPipeline org.codehaus.plexus.test.list.Valve valves org.codehaus.plexus.test.list.Valve one org.codehaus.plexus.test.list.ValveOne org.codehaus.plexus.test.list.Valve two org.codehaus.plexus.test.list.ValveTwo org.codehaus.plexus.logging.LoggerManager org.codehaus.plexus.logging.console.ConsoleLoggerManager basic fatal org.codehaus.plexus.test.ComponentMissingRequirements org.codehaus.plexus.test.DefaultComponent NonExistingComponent plexus-container-default/src/test/resources/org/codehaus/plexus/configuration/0000755000175000017500000000000010631507705027021 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/configuration/avalon.xml0000644000175000017500000001310410161654653031025 0ustar paulpaul ${foo.home}/jars ${my.home}/resources user-conf-dir logging-implementation INFO org.codehaus.plexus.personality.avalon.AvalonComponentRepository 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-keep-alive 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-keep-alive 1 2 plexus-container-default/src/test/resources/org/codehaus/plexus/logging/0000755000175000017500000000000010631507705025600 5ustar paulpaulplexus-container-default/src/test/resources/org/codehaus/plexus/logging/CustomLoggerManagerTest.xml0000644000175000017500000000035110161654653033071 0ustar paulpaul org.codehaus.plexus.logging.LoggerManager org.codehaus.plexus.logging.MockLoggerManager plexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/0000755000175000017500000000000010631507705027242 5ustar paulpaul././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.xmlplexus-container-default/src/test/resources/org/codehaus/plexus/logging/console/ConsoleLoggerManager0000644000175000017500000000111010161654653033216 0ustar paulpaul org.codehaus.plexus.logging.LoggerManager org.codehaus.plexus.logging.console.ConsoleLoggerManager basic per-lookup fatal plexus-container-default/src/test/resources/inline-configurations/0000755000175000017500000000000010631507705024556 5ustar paulpaulplexus-container-default/src/test/resources/inline-configurations/inline-configuration.xml0000644000175000017500000000012410161654653031423 0ustar paulpaul jason van zyl plexus-container-default/src/test/resources/test.txt0000644000175000017500000000001610161654653021770 0ustar paulpaulThis is a testplexus-container-default/src/test/java/0000755000175000017500000000000010631507673017163 5ustar paulpaulplexus-container-default/src/test/java/org/0000755000175000017500000000000010631507673017752 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/0000755000175000017500000000000010631507673021545 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/0000755000175000017500000000000010631507705023061 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java0000644000175000017500000001003210161654653031313 0ustar paulpaulpackage org.codehaus.plexus; /* * 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 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 * * @version $Id: DyanamicComponentKungFuTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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. 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. * * 3. Let the component perform its role * * 4. Suspend the component * a) 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? * * 5. Reconfigure the component * * 6. Resume the component * * 7. Let the component perform its role * * 8. Release the component */ 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. */ public void testComponentReplacementDuringContainerOperation() throws Exception { } } plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/0000755000175000017500000000000010631507705025037 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusHierarchyTest.java0000644000175000017500000002650010317361503031657 0ustar paulpaulpackage org.codehaus.plexus.hierarchy; /* * 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.PlexusContainer; import org.codehaus.plexus.PlexusContainerManager; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * Test for {@link org.codehaus.plexus.SimplePlexusContainerManager}, * and the hierarchical behaviour of * {@link org.codehaus.plexus.DefaultPlexusContainer}. * * @author Mark Wilkinson */ public class PlexusHierarchyTest extends PlexusTestCase { private PlexusContainer rootPlexus; private PlexusContainer childPlexus; private PlexusContainer childPlexus2; private PlexusTestService testService; protected void setUp() throws Exception { super.setUp(); PlexusContainerManager manager; manager = (PlexusContainerManager) lookup( PlexusContainerManager.ROLE ); rootPlexus = getContainer(); childPlexus = manager.getManagedContainers()[0]; manager = (PlexusContainerManager) lookup( PlexusContainerManager.ROLE, "two" ); childPlexus2 = manager.getManagedContainers()[0]; } protected void customizeContext() throws Exception { getContainer().addContextValue( "plexus-name", "root" ); } public void testPlexus() throws Exception { assertTrue( childPlexus.hasComponent( PlexusTestService.ROLE ) ); testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE ); assertEquals( "ChildPlexusOne", testService.getPlexusName() ); assertEquals( "three blind mice", testService.getKnownValue() ); } public void testPlexusWithId() throws Exception { assertTrue( childPlexus2.hasComponent( PlexusTestService.ROLE ) ); testService = (PlexusTestService) childPlexus2.lookup( PlexusTestService.ROLE ); assertEquals( "ChildPlexusTwo", testService.getPlexusName() ); assertEquals( "see how they run", testService.getKnownValue() ); } /* * Test that components can find components in other containers, if they * know how to navigate the tree of containers. This technique should be * considered a hack as it ties a component to a certain container * configuration. */ public void testSiblingPlexusResolution() throws Exception { assertTrue( childPlexus.hasComponent( PlexusTestService.ROLE ) ); testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE ); assertEquals( "see how they run", testService.getSiblingKnownValue( "two" ) ); assertTrue( childPlexus2.hasComponent( PlexusTestService.ROLE ) ); testService = (PlexusTestService) childPlexus2.lookup( PlexusTestService.ROLE ); assertEquals( "three blind mice", testService.getSiblingKnownValue( null ) ); } public void testLookups() throws Exception { // Child plexus should override the component with no role-hint testService = (PlexusTestService) lookup( PlexusTestService.ROLE ); assertEquals( "cheesy default service", testService.getKnownValue() ); release( testService ); testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE ); assertEquals( "three blind mice", testService.getKnownValue() ); childPlexus.release( testService ); // Child plexus one should override the hinted component testService = (PlexusTestService) lookup( PlexusTestService.ROLE, "hinted" ); assertEquals( "hinted default service", testService.getKnownValue() ); release( testService ); testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE, "hinted" ); assertEquals( "plexus one overriding hinted service", testService.getKnownValue() ); childPlexus.release( testService ); // Child plexus two should inherit the hinted component testService = (PlexusTestService) lookup( PlexusTestService.ROLE, "hinted" ); assertEquals( "hinted default service", testService.getKnownValue() ); release( testService ); testService = (PlexusTestService) childPlexus2.lookup( PlexusTestService.ROLE, "hinted" ); assertEquals( "hinted default service", testService.getKnownValue() ); childPlexus2.release( testService ); // Child plexus should provide access to global component from // parent plexus. testService = (PlexusTestService) lookup( PlexusTestService.ROLE, "global" ); assertEquals( "globally visible service", testService.getKnownValue() ); release( testService ); testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE, "global" ); assertEquals( "globally visible service", testService.getKnownValue() ); childPlexus.release( testService ); // Child plexus should provide access to components local to the // container. try { testService = (PlexusTestService) lookup( PlexusTestService.ROLE, "local" ); fail( "found child component through parent container" ); } catch ( ComponentLookupException e ) { assertTrue( true ); } testService = (PlexusTestService) childPlexus.lookup( PlexusTestService.ROLE, "local" ); assertEquals( "plexus one local service", testService.getKnownValue() ); childPlexus.release( testService ); } public void testLookupMap() throws Exception { // Root plexus should give us a map containing its components. Map componentMap = rootPlexus.lookupMap( PlexusTestService.ROLE ); assertEquals( 3, componentMap.size() ); testService = (PlexusTestService) componentMap.get( "global" ); assertEquals( "globally visible service", testService.getKnownValue() ); testService = (PlexusTestService) componentMap.get( "hinted" ); assertEquals( "hinted default service", testService.getKnownValue() ); assertFalse( componentMap.containsKey( "local" ) ); rootPlexus.releaseAll( componentMap ); // Child plexus one should give us a map containing its components // and those from its parent. componentMap = childPlexus.lookupMap( PlexusTestService.ROLE ); assertEquals( 4, componentMap.size() ); testService = (PlexusTestService) componentMap.get( "global" ); assertEquals( "globally visible service", testService.getKnownValue() ); testService = (PlexusTestService) componentMap.get( "hinted" ); assertEquals( "plexus one overriding hinted service", testService.getKnownValue() ); testService = (PlexusTestService) componentMap.get( "local" ); assertEquals( "plexus one local service", testService.getKnownValue() ); childPlexus.releaseAll( componentMap ); // Child plexus two should give us a map containing its components // and those from its parent. componentMap = childPlexus2.lookupMap( PlexusTestService.ROLE ); assertEquals( 4, componentMap.size() ); testService = (PlexusTestService) componentMap.get( "global" ); assertEquals( "globally visible service", testService.getKnownValue() ); testService = (PlexusTestService) componentMap.get( "hinted" ); assertEquals( "hinted default service", testService.getKnownValue() ); testService = (PlexusTestService) componentMap.get( "local" ); assertEquals( "plexus two local service", testService.getKnownValue() ); childPlexus2.releaseAll( componentMap ); } public void testLookupList() throws Exception { // Root plexus should give us a list containing its components. List componentList = rootPlexus.lookupList( PlexusTestService.ROLE ); assertEquals( 3, componentList.size() ); String[] strings = new String[] { "cheesy default service", "hinted default service", "globally visible service", }; Set expectedValues = new HashSet( Arrays.asList( strings ) ); for ( Iterator i = componentList.iterator(); i.hasNext(); ) { testService = (PlexusTestService) i.next(); expectedValues.remove( testService.getKnownValue() ); } assertEquals( 0, expectedValues.size() ); rootPlexus.releaseAll( componentList ); // Child plexus one should give us a list containing its components // and those from its parent. componentList = childPlexus.lookupList( PlexusTestService.ROLE ); assertEquals( 4, componentList.size() ); strings = new String[] { "globally visible service", "three blind mice", "plexus one overriding hinted service", "plexus one local service", }; expectedValues = new HashSet( Arrays.asList( strings ) ); for ( Iterator i = componentList.iterator(); i.hasNext(); ) { testService = (PlexusTestService) i.next(); expectedValues.remove( testService.getKnownValue() ); } assertEquals( 0, expectedValues.size() ); childPlexus.releaseAll( componentList ); // Child plexus two should give us a map containing its components // and those from its parent. componentList = childPlexus2.lookupList( PlexusTestService.ROLE ); assertEquals( 4, componentList.size() ); strings = new String[] { "hinted default service", "globally visible service", "see how they run", "plexus two local service", }; expectedValues = new HashSet( Arrays.asList( strings ) ); for ( Iterator i = componentList.iterator(); i.hasNext(); ) { testService = (PlexusTestService) i.next(); expectedValues.remove( testService.getKnownValue() ); } assertEquals( 0, expectedValues.size() ); childPlexus2.releaseAll( componentList ); } } plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/PlexusTestService.java0000644000175000017500000000424010317361503031336 0ustar paulpaulpackage org.codehaus.plexus.hierarchy; /* * 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.repository.exception.ComponentLookupException; /** * Simple Avalon interface. * * @author Mark Wilkinson */ public interface PlexusTestService { /** Component role. */ String ROLE = PlexusTestService.class.getName(); String getPlexusName(); String getKnownValue(); /** * Get the known value contained in the TestService implementation * provided by the plexus with the given id. * * @param id Id of the Plexus instance to look-up. * @return Result of getKnownValue on the TestService in that * plexus. * @throws org.codehaus.plexus.component.repository.exception.ComponentLookupException If a plexus with the given id could not * be found. This exception would normally be thrown by the * service method, but it is delayed until this point * for the test case. */ String getSiblingKnownValue( String id ) throws ComponentLookupException; } plexus-container-default/src/test/java/org/codehaus/plexus/hierarchy/TestServiceImpl.java0000644000175000017500000000563410317361503030767 0ustar paulpaulpackage org.codehaus.plexus.hierarchy; /* * 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.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerManager; 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; /** * Simple implementation of the {@link PlexusTestService} Component interface. * * @author Mark Wilkinson */ public class TestServiceImpl implements PlexusTestService, Contextualizable { private PlexusContainer parentPlexus; private String plexusName; private String knownValue; public void contextualize( Context context ) throws ContextException { parentPlexus = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); plexusName = (String) context.get( "plexus-name" ); } public String getPlexusName() { return plexusName; } public String getKnownValue() { return knownValue; } public String getSiblingKnownValue( String id ) throws ComponentLookupException { PlexusContainerManager manager; if ( id != null ) { manager = (PlexusContainerManager) parentPlexus.lookup( PlexusContainerManager.ROLE, id ); } else { manager = (PlexusContainerManager) parentPlexus.lookup( PlexusContainerManager.ROLE ); } PlexusContainer siblingContainer = manager.getManagedContainers()[0]; PlexusTestService service = (PlexusTestService) siblingContainer.lookup( PlexusTestService.ROLE ); return service.getKnownValue(); } } plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java0000644000175000017500000000741510231114556027501 0ustar paulpaulpackage org.codehaus.plexus; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.discovery.DiscoveredComponent; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.test.DefaultLoadOnStartService; import java.io.File; import java.io.InputStream; /** * @author Jason van Zyl * * @version $Id: PlexusTestCaseTest.java 1747 2005-04-19 05:38:54Z brett $ */ 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( "foo", "bar" ); fail( "Expected ComponentLookupException." ); } catch ( ComponentLookupException ex ) { assertTrue( true ); } // This component is discovered from src/test/META-INF/plexus/components.xml Object component = tc.lookup( "org.codehaus.plexus.component.discovery.DiscoveredComponent" ); assertNotNull( component ); assertTrue( component instanceof DiscoveredComponent ); assertNotNull( tc.getClassLoader() ); tc.tearDown(); } public void testLoadOnStartComponents() throws Exception { final InputStream is = this.getClass().getClassLoader().getResourceAsStream( "org/codehaus/plexus/PlexusTestCaseTest.xml" ); assertNotNull( "Missing configuration", is ); PlexusTestCase tc = new PlexusTestCase() { protected InputStream getConfiguration() throws Exception { return is; } }; tc.setUp(); // 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() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/0000755000175000017500000000000010631507702025060 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/0000755000175000017500000000000010631507702026527 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java0000644000175000017500000000253210214446344032263 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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 * @version $Id: ComponentImplB.java 1524 2005-03-12 01:59:00Z jvanzyl $ */ public class ComponentImplB { } plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java0000644000175000017500000000256210161654653032272 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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 * * @version $Id: ComponentImplA.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentImplA implements Component { } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory2.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory2.j0000644000175000017500000000227110227633245033123 0ustar paulpaulpackage org.codehaus.plexus.component.factory; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; /* * 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 TestComponentFactory2 implements ComponentFactory { public String getId() { return "testFactory2"; } public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container ) throws ComponentInstantiationException { return new TestFactoryResultComponent(getId()); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java0000644000175000017500000000254310216646467032300 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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 * @version $Id: ComponentImplC.java 1569 2005-03-18 21:50:47Z jdcasey $ */ public abstract class ComponentImplC { } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestFactoryResultComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestFactoryResultCompon0000644000175000017500000000164310227633245033303 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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 TestFactoryResultComponent { private final String factoryId; public TestFactoryResultComponent( String factoryId ) { this.factoryId = factoryId; } public String getFactoryId() { return factoryId; } } plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/0000755000175000017500000000000010631507701027447 5ustar paulpaul././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFacto0000644000175000017500000001061410231114556033113 0ustar paulpaulpackage org.codehaus.plexus.component.factory.java; /* * 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 junit.framework.TestCase; import org.codehaus.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; import org.codehaus.plexus.embed.Embedder; /** * @author Jason van Zyl * @author Michal Maczka * @version $Id: JavaComponentFactoryTest.java 1747 2005-04-19 05:38:54Z brett $ */ 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() ); Embedder embedder = new Embedder(); embedder.start( classWorld ); Object component = factory.newInstance( componentDescriptor, classWorld.getRealm( "core" ), embedder.getContainer() ); 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() ); Embedder embedder = new Embedder(); embedder.start( classWorld ); factory.newInstance( componentDescriptor, classWorld.getRealm( "core" ), embedder.getContainer() ); } 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() ); Embedder embedder = new Embedder(); embedder.start( classWorld ); // container. try { factory.newInstance( componentDescriptor, classWorld.getRealm( "core" ), embedder.getContainer() ); fail( "Expected ComponentInstantiationException when instanciating a abstract class." ); } catch( ComponentInstantiationException ex ) { assertTrue( true ); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory1.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/TestComponentFactory1.j0000644000175000017500000000227110227633245033122 0ustar paulpaulpackage org.codehaus.plexus.component.factory; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; /* * 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 TestComponentFactory1 implements ComponentFactory { public String getId() { return "testFactory1"; } public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container ) throws ComponentInstantiationException { return new TestFactoryResultComponent(getId()); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java0000644000175000017500000000251410161654653031344 0ustar paulpaulpackage org.codehaus.plexus.component.factory; /* * 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 * @version $Id: Component.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Component { } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/DiscoveredComponentFactoryTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/factory/DiscoveredComponentFact0000644000175000017500000000440110227633245033224 0ustar paulpaulpackage org.codehaus.plexus.component.factory; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.ComponentDescriptor; /* * 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 DiscoveredComponentFactoryTest extends PlexusTestCase { public void testShouldFindComponentFactoriesDefinedInBothPlexusXmlAndComponentsXml() throws Exception { assertNotNull( "Cannot find test component factory from plexus.xml test resource.", lookup( ComponentFactory.ROLE, "testFactory1" ) ); assertNotNull( "Cannot find test component factory from components.xml test resource.", lookup( ComponentFactory.ROLE, "testFactory2" ) ); } public void testShouldInstantiateComponentUsingFactoryDiscoveredInPlexusXml() throws Exception { lookupTestComponent( "testFactory1" ); } 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() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/0000755000175000017500000000000010631507676027311 5ustar paulpaul././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirement0000644000175000017500000000341210161654653033413 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; /** * @author Michal Maczka * @version $Id: ComponentRequirementTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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() ); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepo0000644000175000017500000000314510161654653033330 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; /** * * * @author Jason van Zyl * * @version $Id: DefaultComponentRepositoryTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultComponentRepositoryTest extends TestCase { private static String configuration = "" + ""; public void testDefaultComponentRepository() { } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.jav0000644000175000017500000000750010161654653033267 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.repository.io.PlexusTools; import java.util.Iterator; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: ComponentSetTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentSetTest extends TestCase { public void testSimpleComponentResolution() throws Exception { String xml = "" + " " + " " + " c1" + " role-hint" + " component-profile" + " " + " " + " c2" + " " + " " + " c3" + " " + " " + " " + " " + " " + " " + " plexus" + " wedgy" + " 1.0" + " " + " " + ""; ComponentSetDescriptor cs = PlexusTools.buildComponentSet( PlexusTools.buildConfiguration( xml ) ); ComponentDescriptor c1 = (ComponentDescriptor) 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 ( Iterator iterator = requirements.iterator(); iterator.hasNext(); ) { ComponentRequirement requirement = (ComponentRequirement) iterator.next(); if ( requirement.getRole().equals( "c2" ) ) { containsC2 = true; } else if ( requirement.getRole().equals( "c3" ) ) { containsC3 = true; } } assertTrue( containsC2 ); assertTrue( containsC3 ); ComponentDependency d1 = (ComponentDependency) cs.getDependencies().get( 0 ); assertEquals( "plexus", d1.getGroupId() ); assertEquals( "wedgy", d1.getArtifactId() ); assertEquals( "1.0", d1.getVersion() ); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentProfileTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentProfileTest0000644000175000017500000000523110161654653033354 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.factory.ComponentFactory; import org.codehaus.plexus.component.factory.java.JavaComponentFactory; import org.codehaus.plexus.component.manager.ClassicSingletonComponentManager; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.lifecycle.AbstractLifecycleHandler; import org.codehaus.plexus.lifecycle.LifecycleHandler; /** * * * @author Jason van Zyl * * @version $Id: ComponentProfileTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentProfileTest extends TestCase { public void testComponentProfile() { ComponentProfile profile = new ComponentProfile(); ComponentFactory componentFactory = new JavaComponentFactory(); LifecycleHandler lifecycleHandler = new MockLifecycleHandler(); ComponentManager componentManager = new ClassicSingletonComponentManager(); profile.setComponentFactory( componentFactory ); assertEquals( componentFactory, profile.getComponentFactory() ); profile.setLifecycleHandler( lifecycleHandler ); assertEquals( lifecycleHandler, profile.getLifecycleHandler() ); profile.setComponentManager( componentManager ); assertEquals( componentManager, profile.getComponentManager() ); } class MockLifecycleHandler extends AbstractLifecycleHandler { public void initialize() { } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorT0000644000175000017500000000665110235733465033366 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.repository.io.PlexusTools; import java.util.Iterator; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: ComponentDescriptorTest.java 1777 2005-05-03 17:39:01Z jdcasey $ */ public class ComponentDescriptorTest extends TestCase { public void testSimpleComponentResolution() throws Exception { String cc1 = "" + " c1" + " role-hint" + " component-profile" + " " + " " + " c2" + " " + " " + " c3" + " " + " " + ""; ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor( cc1 ); 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 ( Iterator iterator = requirements.iterator(); iterator.hasNext(); ) { ComponentRequirement requirement = ( ComponentRequirement ) iterator.next(); 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)); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentProfileDescriptorTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentProfileDesc0000644000175000017500000000351510161654653033316 0ustar paulpaulpackage org.codehaus.plexus.component.repository; /* * 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 junit.framework.TestCase; /** */ public class ComponentProfileDescriptorTest extends TestCase { public ComponentProfileDescriptorTest( String name ) { super( name ); } public void testComponentProfileDescriptor() throws Exception { ComponentProfileDescriptor d = new ComponentProfileDescriptor(); d.setComponentFactoryId( "cfid" ); assertEquals( "cfid", d.getComponentFactoryId() ); d.setLifecycleHandlerId( "lfhid" ); assertEquals( "lfhid", d.getLifecycleHandlerId() ); d.setComponentManagerId( "cmid" ); assertEquals( "cmid", d.getComponentManagerId() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/TestMapOrientedComponent.java0000644000175000017500000000256310235454302032660 0ustar paulpaulpackage org.codehaus.plexus.component; import org.codehaus.plexus.component.repository.ComponentRequirement; import java.util.Map; import java.util.TreeMap; /* * 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 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; } } plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/0000755000175000017500000000000010631507702026472 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java0000644000175000017500000000360010231133376032141 0ustar paulpaulpackage org.codehaus.plexus.component.manager; /* * 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.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 * @version $Id: SlowComponent.java 1750 2005-04-19 07:45:02Z brett $ */ 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() { } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonCompone0000644000175000017500000000653610227643552033221 0ustar paulpaulpackage org.codehaus.plexus.component.manager; /* * 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.PlexusContainer; import org.codehaus.plexus.PlexusTestCase; class ComponentLookupThread extends Thread { final PlexusContainer container; private SlowComponent component; public ComponentLookupThread( PlexusContainer container ) { this.container = container; } public void run() { try { SlowComponent tmpComponent = (SlowComponent) container.lookup( SlowComponent.ROLE ); synchronized ( this ) { this.component = tmpComponent; } } catch ( Exception e ) { e.printStackTrace(); } } public SlowComponent getComponent() { synchronized ( this ) { return component; } } } /** * @author Ben Walding * @version $Id: ClassicSingletonComponentManagerTest.java 1708 2005-04-15 04:47:38Z brett $ */ public class ClassicSingletonComponentManagerTest extends PlexusTestCase { public void testThreads1() throws Exception { test( 1 ); } /** * Tests that multiple concurrent threads don't acquire different components. * @todo [BP] I've seen this fail at random */ public void testThreads10() throws Exception { test( 10 ); } public void test( int count ) throws Exception { ComponentLookupThread components[] = new ComponentLookupThread[ count ]; //Start them for ( int i = 0; i < count; i++ ) { components[ i ] = new ComponentLookupThread( getContainer() ); components[ i ].start(); } //Wait for them to finish for ( int i = 0; i < count; i++ ) { while ( components[ i ].getComponent() == null ) { Thread.sleep( 100 ); } } //Get master component SlowComponent masterComponent = (SlowComponent) lookup( SlowComponent.ROLE ); //Verify them for ( int i = 0; i < count; i++ ) { assertSame( "components[" + i + "].getComponent()", masterComponent, components[ i ].getComponent() ); } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/MapOrientedComponentProcessingTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/MapOrientedComponentProcessingT0000644000175000017500000000522410235454302033256 0ustar paulpaulpackage org.codehaus.plexus.component; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.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.embed.Embedder; import org.codehaus.plexus.logging.LoggerManager; import java.util.Map; import junit.framework.TestCase; public class MapOrientedComponentProcessingTest extends TestCase { public void testShouldFindAndInitializeMapOrientedComponent() throws Exception { ComponentDescriptor descriptor = new ComponentDescriptor(); 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 ); XmlPlexusConfiguration param = new XmlPlexusConfiguration( "testParameter" ); param.setValue( "testValue" ); PlexusConfiguration configuration = new XmlPlexusConfiguration( "configuration" ); configuration.addChild( param ); descriptor.setConfiguration( configuration ); Embedder embedder = new Embedder(); embedder.start(); embedder.getContainer().addComponentDescriptor( descriptor ); TestMapOrientedComponent component = (TestMapOrientedComponent) embedder.lookup( TestMapOrientedComponent.ROLE ); Map context = component.getContext(); assertTrue( "requirement (LogManager) missing from context.", ( context.get( "testRequirement" ) instanceof LoggerManager ) ); assertEquals( "parameter missing from context.", "testValue", context.get( "testParameter" ) ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/0000755000175000017500000000000010631507701027066 5ustar paulpaul././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.j0000644000175000017500000000264510161654653033231 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * 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 * * @version $Id: DiscoveredComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface DiscoveredComponent { String ROLE = DiscoveredComponent.class.getName(); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComp0000644000175000017500000000263310161654653033237 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * 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 * * @version $Id: DefaultDiscoveredComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultDiscoveredComponent implements DiscoveredComponent { } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTe0000644000175000017500000000602410161654653033303 0ustar paulpaulpackage org.codehaus.plexus.component.discovery; /* * 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.util.List; import junit.framework.TestCase; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.context.DefaultContext; /** * @author Jason van Zyl * * @version $Id: ComponentDiscovererTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentDiscovererTest extends TestCase { public void testDefaultComponentDiscoverer() throws Exception { ComponentDiscoverer componentDiscoverer = new DefaultComponentDiscoverer(); componentDiscoverer.setManager( new DefaultComponentDiscovererManager() ); ClassWorld classWorld = new ClassWorld(); ClassRealm core = classWorld.newRealm( "core" ); File testClasses = new File( System.getProperty( "basedir" ), "target/test-classes" ); core.addConstituent( testClasses.toURL() ); List componentSetDescriptors = componentDiscoverer.findComponents( new DefaultContext(), core ); System.out.println( componentSetDescriptors.get( 0 ) ); assertEquals( 1, componentSetDescriptors.size() ); assertEquals( ComponentSetDescriptor.class.getName(), componentSetDescriptors.get( 0 ).getClass().getName() ); ComponentSetDescriptor componentSet = (ComponentSetDescriptor) componentSetDescriptors.get( 0 ); List components = componentSet.getComponents(); ComponentDescriptor cd = (ComponentDescriptor) components.get( 0 ); assertEquals( "org.codehaus.plexus.component.discovery.DiscoveredComponent", cd.getRole() ); assertEquals( "org.codehaus.plexus.component.discovery.DefaultDiscoveredComponent", cd.getImplementation() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/0000755000175000017500000000000010631507677027575 5ustar paulpaul././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.jav0000644000175000017500000000275210274515050033237 0ustar paulpaulpackage 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 * * @version $Id: ImportantThing.java 2381 2005-08-04 22:43:52Z kenney $ */ public class ImportantThing extends AbstractThing implements ThingInterface { private String name; public String getName() { return name; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractThing.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractThing.java0000644000175000017500000000232310274515050033160 0ustar paulpaulpackage 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 { } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.0000644000175000017500000000273110161654653033222 0ustar paulpaulpackage 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 * * @version $Id: AbstractComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class AbstractComponent implements Component { private String name; public String getName() { return name; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSette0000644000175000017500000000735010310421603033302 0ustar paulpaulpackage 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.configuration.PlexusConfiguration; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: ConfigurableComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableCompon0000644000175000017500000000430610161654653033272 0ustar paulpaulpackage 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.configuration.PlexusConfiguration; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: ConfigurableComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ConfigurableComponent { private int intValue; private float floatValue; private long longValue; private double doubleValue; private String stringValue; private List importantThings; private PlexusConfiguration configuration; public int getIntValue() { return intValue; } public float getFloatValue() { return floatValue; } public long getLongValue() { return longValue; } public double getDoubleValue() { return doubleValue; } public String getStringValue() { return stringValue; } public List getImportantThings() { return importantThings; } public PlexusConfiguration getConfiguration() { return configuration; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPrope0000644000175000017500000000303510161654653033320 0ustar paulpaulpackage 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 * * @version $Id: ComponentWithPropertiesField.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentWithPropertiesField { private Properties someProperties; public Properties getSomeProperties() { return someProperties; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapFi0000644000175000017500000000273010276726550033233 0ustar paulpaulpackage 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 * * @version $Id: ComponentWithMapField.java 2400 2005-08-11 19:56:24Z kenney $ */ public class ComponentWithMapField { private Map map; public Map getMap() { return map; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompo0000644000175000017500000000275310274515050033306 0ustar paulpaulpackage 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 * * @version $Id: ComponentWithCompositeFields.java 2381 2005-08-04 22:43:52Z kenney $ */ public class ComponentWithCompositeFields { private ThingInterface thing; public ThingInterface getThing() { return thing; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithColle0000644000175000017500000000346210317644473033277 0ustar paulpaulpackage 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.Vector; /** * @author Michal Maczka * @version $Id: ComponentWithCollectionFields.java 2575 2005-10-02 02:43:07Z brett $ */ public class ComponentWithCollectionFields { private Vector vector; private HashSet set; private List list; private List stringList; public Vector getVector() { return vector; } public HashSet getSet() { return set; } public List getList() { return list; } public List getStringList() { return stringList; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArray0000644000175000017500000000434510317644473033320 0ustar paulpaulpackage 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 * @version $Id: ComponentWithArrayFields.java 2575 2005-10-02 02:43:07Z brett $ */ 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; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentC0000644000175000017500000004303010317644473033246 0ustar paulpaulpackage 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 junit.framework.Assert; import junit.framework.TestCase; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; 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; import java.io.File; import java.io.StringReader; 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; /** * @author Michal Maczka * @version $Id: AbstractComponentConfiguratorTest.java 2575 2005-10-02 02:43:07Z brett $ */ public abstract class AbstractComponentConfiguratorTest extends TestCase { public AbstractComponentConfiguratorTest( String s ) { super( s ); } protected abstract ComponentConfigurator getComponentConfigurator(); public void testComponentConfigurator() throws Exception { String xml = "" + " 0" + " 1" + " 2" + " 3" + " foo" + " " + " jason" + " tess" + " " + " " + " jason" + " " + ""; PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); ConfigurableComponent component = new ConfigurableComponent(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); assertEquals( "check integer value", 0, component.getIntValue() ); assertEquals( "check float value", 1.0f, component.getFloatValue(), 0.001f ); assertEquals( "check long value", 2L, component.getLongValue() ); Assert.assertEquals( "check double value", 3.0, component.getDoubleValue(), 0.001 ); assertEquals( "foo", component.getStringValue() ); 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(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, 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 ); Assert.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(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); assertEquals( "jason", component.getName() ); assertEquals( "bollywood", component.getAddress() ); } public void testComponentConfigurationWhereFieldsAreCollections() throws Exception { String xml = "" + " " + " " + " life" + " " + " " + " " + " " + " life" + " " + " " + " " + " " + " life" + " " + " " + " " + " abc" + " def" + " " + // TODO: implement List etc.. // "" + // " 12" + // " 34" + // "" + ""; PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); ComponentWithCollectionFields component = new ComponentWithCollectionFields(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); Vector vector = component.getVector(); assertEquals( "life", ( (ImportantThing) vector.get( 0 ) ).getName() ); assertEquals( 1, vector.size() ); Set set = component.getSet(); 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() ); } 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(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, 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( new Integer( 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(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); assertNotNull( component.getThing() ); assertEquals( "I am not abstract!", component.getThing().getName() ); } public void testInvalidComponentConfiguration() throws Exception { String xml = "theName"; try { PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); fail( "Should have caused an error because of the invalid XML." ); } catch ( PlexusConfigurationException e ) { // should catch this... System.out.println( "Error Message:\n\n" + e.getLocalizedMessage() + "\n\n" ); System.err.println( "Error with stacktrace:\n\n" ); e.printStackTrace(); System.err.println( "\n\n" ); } 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(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); Properties properties = component.getSomeProperties(); assertNotNull( properties ); assertEquals( "michal", properties.get( "firstname" ) ); assertEquals( "maczka", properties.get( "lastname" ) ); } public void testComponentConfigurationWithMapField() throws Exception { String xml = "" + " " + " Kenney" + " Westerhof" + " " + ""; PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); ComponentWithMapField component = new ComponentWithMapField(); ComponentConfigurator cc = getComponentConfigurator(); ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "role" ); descriptor.setImplementation( component.getClass().getName() ); ClassWorld classWorld = new ClassWorld(); ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); cc.configureComponent( component, configuration, realm ); Map map = component.getMap(); assertNotNull( map ); assertEquals( "Kenney", map.get( "firstName" ) ); assertEquals( "Westerhof", map.get( "lastName" ) ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java0000644000175000017500000000253510161654653032402 0ustar paulpaulpackage 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 * * @version $Id: Component.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Component { } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.j0000644000175000017500000000274510161654653033222 0ustar paulpaulpackage 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 * * @version $Id: DefaultComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultComponent extends AbstractComponent { private String address; public String getAddress() { return address; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/BasicComponentConfiguratorTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/BasicComponentConf0000644000175000017500000000273110231114556033217 0ustar paulpaulpackage 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 { public BasicComponentConfiguratorTest( String s ) { super( s ); } protected ComponentConfigurator getComponentConfigurator() { return new BasicComponentConfigurator(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ThingInterface.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ThingInterface.jav0000644000175000017500000000234510274515050033160 0ustar paulpaulpackage 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(); } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/0000755000175000017500000000000010631507700027421 5ustar paulpaul././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptionTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptio0000644000175000017500000000313210161654653033357 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 junit.framework.TestCase; /** * * * @author Jason van Zyl * * @version $Id: CompositionExceptionTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class CompositionExceptionTest extends TestCase { public void testException() { CompositionException e = new CompositionException( "bad doggy!" ); assertEquals( "bad doggy!", e.getMessage() ); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComposition0000644000175000017500000001634210161654653033351 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.io.PlexusTools; import java.util.List; /** * * * @author Jason van Zyl * * @version $Id: AbstractCompositionResolverTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractCompositionResolverTest extends TestCase { /** * * @return */ protected abstract CompositionResolver getCompositionResolver(); // ------------------------------------------------------------------------ // // +-------+ +-------+ // | c1 | --------> | c2 | // +-------+ +-------+ // | // | // V // +-------+ // | c3 | // +-------+ // // ------------------------------------------------------------------------ public void testSimpleComponentResolution() throws Exception { String cc1 = "" + " c1" + " " + " " + " c2" + " " + " " + " c3" + " " + " " + ""; String cc2 = "" + " c2" + ""; String cc3 = "" + " c3" + ""; CompositionResolver compositionResolver = getCompositionResolver(); ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor( cc1 ); ComponentDescriptor c2 = PlexusTools.buildComponentDescriptor( cc2 ); ComponentDescriptor c3 = PlexusTools.buildComponentDescriptor( cc3 ); compositionResolver.addComponentDescriptor( c1 ); compositionResolver.addComponentDescriptor( c2 ); compositionResolver.addComponentDescriptor( c3 ); List dependencies = compositionResolver.getRequirements( c1.getComponentKey() ); assertEquals( 2, dependencies.size() ); assertTrue( dependencies.contains( c2.getRole() ) ); assertTrue( dependencies.contains( c3.getRole() ) ); assertEquals( 2, dependencies.size() ); } // ------------------------------------------------------------------------ // // +-------+ +-------+ // | c1 | --------> | c2 | // +-------+ +-------+ // | // | // V // +-------+ +-------+ // | c3 | --------> | c4 | // +-------+ +-------+ // | // | // V // +-------+ // | c5 | // +-------+ // // ------------------------------------------------------------------------ public void testComplexComponentResolution() throws Exception { String cc1 = "" + " c1" + " " + " " + " c2" + " " + " " + " c3" + " " + " " + ""; String cc2 = "" + " c2" + ""; String cc3 = "" + " c3" + " " + " " + " c4" + " " + " " + " c5" + " " + " " + ""; String cc4 = "" + " c4" + ""; String cc5 = "" + " c5" + ""; CompositionResolver compositionResolver = getCompositionResolver(); ComponentDescriptor c1 = PlexusTools.buildComponentDescriptor( cc1 ); ComponentDescriptor c2 = PlexusTools.buildComponentDescriptor( cc2 ); ComponentDescriptor c3 = PlexusTools.buildComponentDescriptor( cc3 ); ComponentDescriptor c4 = PlexusTools.buildComponentDescriptor( cc4 ); ComponentDescriptor c5 = PlexusTools.buildComponentDescriptor( cc5 ); compositionResolver.addComponentDescriptor( c1 ); compositionResolver.addComponentDescriptor( c2 ); compositionResolver.addComponentDescriptor( c3 ); compositionResolver.addComponentDescriptor( c4 ); compositionResolver.addComponentDescriptor( c5 ); List dependencies = compositionResolver.getRequirements( c1.getComponentKey() ); 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" ) ); */ } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerUsingSuperclassesTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentCom0000644000175000017500000000437210161654653033270 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 junit.framework.TestCase; import java.lang.reflect.Field; /** * @author Jason van Zyl * @version $Id: DefaultComponentComposerUsingSuperclassesTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultComponentComposerUsingSuperclassesTest extends TestCase { public void testGetFieldByTypeWhereFieldResidesInTheSuperclass() throws Exception { FieldComponentComposer composer = new FieldComponentComposer(); DefaultComponent component = new DefaultComponent(); Field fieldA = composer.getFieldByType( component, ComponentA.class, null ); assertEquals( ComponentA.class, fieldA.getType() ); } public void testGetFieldByNameWhereFieldResidesInTheSuperclass() throws Exception { FieldComponentComposer composer = new FieldComponentComposer(); DefaultComponent component = new DefaultComponent(); Field fieldA = composer.getFieldByName( component, "componentA", null ); assertEquals( "componentA", fieldA.getName() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java0000644000175000017500000000260410161654653032342 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: ComponentB.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentB { ComponentC getComponentC(); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.j0000644000175000017500000000276210161654653033241 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: AbstractComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class AbstractComponent implements Component { private ComponentA componentA; public ComponentA getComponentA() { return componentA; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/FieldComponentComposerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/FieldComponentCompo0000644000175000017500000001777010161654653033274 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.Field; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import junit.framework.TestCase; /** * @author Jason van Zyl * @version $Id: FieldComponentComposerTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class FieldComponentComposerTest extends TestCase { public void testGetFieldByName() throws Exception { ComponentF componentF = new ComponentF(); final FieldComponentComposer composer = new FieldComponentComposer(); Field fieldA = composer.getFieldByName( componentF, "componentA", null ); assertEquals( ComponentA.class, fieldA.getType() ); Field fieldB = composer.getFieldByName( componentF, "componentB", null ); assertEquals( ComponentB.class, fieldB.getType() ); // we have arrays of C components Field fieldC = composer.getFieldByName( componentF, "componentC", null ); assertTrue( fieldC.getType().isArray() ); ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setRole( "myRole" ); componentDescriptor.setRoleHint( "myRoleHint" ); try { composer.getFieldByName( componentF, "dummy", componentDescriptor ); fail( "Exception was expected" ); } catch ( CompositionException e ) { assertTrue( e.getMessage().indexOf( "myRole" ) > 0 ); assertTrue( e.getMessage().indexOf( "myRoleHint" ) > 0 ); } } public void testGetFieldByType() throws Exception { ComponentF componentF = new ComponentF(); final FieldComponentComposer composer = new FieldComponentComposer(); Field fieldA = composer.getFieldByType( componentF, ComponentA.class, null ); assertEquals( ComponentA.class, fieldA.getType() ); assertFalse( fieldA.getType().isArray() ); Field fieldB = composer.getFieldByType( componentF, ComponentB.class, null ); assertEquals( ComponentB.class, fieldB.getType() ); assertFalse( fieldB.getType().isArray() ); Field fieldC = composer.getFieldByType( componentF, ComponentC.class, null ); assertTrue( fieldC.getType().isArray() ); ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setRole( "myRole" ); componentDescriptor.setRoleHint( "myRoleHint" ); try { composer.getFieldByType( componentF, ComponentF.class, componentDescriptor ); fail( "Exception was expected" ); } catch ( CompositionException e ) { assertTrue( e.getMessage().indexOf( "myRole" ) > 0 ); assertTrue( e.getMessage().indexOf( "myRoleHint" ) > 0 ); } } public void testFindMatchingField() throws Exception { ComponentF componentF = new ComponentF(); ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setRole( ComponentF.class.getName() ); componentDescriptor.setRoleHint( "myRoleHint" ); ComponentRequirement requirementA = new ComponentRequirement(); requirementA.setRole( ComponentA.class.getName() ); componentDescriptor.addRequirement( requirementA ); ComponentRequirement requirementD = new ComponentRequirement(); requirementD.setRole( ComponentD.class.getName() ); requirementD.setFieldName( "componentD" ); componentDescriptor.addRequirement( requirementD ); final FieldComponentComposer composer = new FieldComponentComposer(); composer.findMatchingField( componentF, componentDescriptor, requirementA, null ); composer.findMatchingField( componentF, componentDescriptor, requirementD, null ); } public void testCompositionOfComponentsWithSeveralFieldsOfTheSameType() throws Exception { // ---------------------------------------------------------------------- // Set up // ---------------------------------------------------------------------- // Add a single requirement ComponentRequirement requirementOne = new ComponentRequirement(); requirementOne.setRole( ComponentE.class.getName() ); // The descriptor ComponentDescriptor descriptor = new ComponentDescriptor(); descriptor.setRole( "1" ); descriptor.setImplementation( ComponentWithSeveralFieldsOfTheSameType.class.getName() ); descriptor.addRequirement( requirementOne ); // ---------------------------------------------------------------------- // Assert that this fails as there is one requirement and // two fields that will match the requirement // ---------------------------------------------------------------------- FieldComponentComposer composer = new FieldComponentComposer(); ComponentWithSeveralFieldsOfTheSameType component = new ComponentWithSeveralFieldsOfTheSameType(); try { composer.findMatchingField( component, descriptor, requirementOne, null ); fail( "Expected CompositionException" ); } catch( CompositionException ex ) { assertTrue( ex.getMessage().startsWith( "There are several fields of type" ) ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- // Make a second requirement without a field name ComponentRequirement requirementTwo = new ComponentRequirement(); requirementTwo.setRole( ComponentE.class.getName() ); descriptor.addRequirement( requirementTwo ); try { composer.findMatchingField( component, descriptor, requirementOne, null ); fail( "Expected CompositionException" ); } catch ( CompositionException ex ) { assertTrue( ex.getMessage().startsWith( "There are several fields of type" ) ); } // ---------------------------------------------------------------------- // Set the field names // ---------------------------------------------------------------------- requirementOne.setFieldName( "one" ); requirementTwo.setFieldName( "two" ); Field one = composer.findMatchingField( component, descriptor, requirementOne, null ); Field two = composer.findMatchingField( component, descriptor, requirementTwo, null ); assertEquals( one.getName(), "one" ); assertEquals( one.getDeclaringClass(), component.getClass() ); assertEquals( two.getName(), "two" ); assertEquals( two.getDeclaringClass(), component.getClass() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java0000644000175000017500000000253510161654653032350 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: ComponentE.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentE { } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSevera0000644000175000017500000000311510161654653033320 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 Trygve Laugstøl * @version $Id: ComponentWithSeveralFieldsOfTheSameType.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ComponentWithSeveralFieldsOfTheSameType { private ComponentE one; private ComponentE two; public ComponentE getOne() { return one; } public ComponentE getTwo() { return two; } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java0000644000175000017500000000253510161654653032346 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: ComponentC.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentC { } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/SetterComponentComposerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/SetterComponentComp0000644000175000017500000000741510231114556033322 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 junit.framework.TestCase; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; /** * @author Jason van Zyl * @version $Id: SetterComponentComposerTest.java 1747 2005-04-19 05:38:54Z brett $ */ public class SetterComponentComposerTest extends TestCase { public void testGetPropertyByName() throws IntrospectionException { ComponentF componentF = new ComponentF(); BeanInfo beanInfo = Introspector.getBeanInfo( componentF.getClass() ); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); final SetterComponentComposer composer = new SetterComponentComposer(); final PropertyDescriptor propertyA = composer.getPropertyDescriptorByName( "componentA", propertyDescriptors ); assertEquals( ComponentA.class, propertyA.getPropertyType() ); final PropertyDescriptor propertyB = composer.getPropertyDescriptorByName( "componentB", propertyDescriptors ); assertEquals( ComponentB.class, propertyB.getPropertyType() ); final PropertyDescriptor propertyC = composer.getPropertyDescriptorByName( "componentC", propertyDescriptors ); assertTrue( propertyC.getPropertyType().isArray() ); } public void testGetPropertyByType() throws IntrospectionException { final SetterComponentComposer composer = new SetterComponentComposer(); final ComponentF componentF = new ComponentF(); BeanInfo beanInfo = Introspector.getBeanInfo( componentF.getClass() ); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); final PropertyDescriptor propertyA = composer.getPropertyDescriptorByType( ComponentA.class.getName(), propertyDescriptors ); assertNotNull( propertyA ); assertEquals( ComponentA.class, propertyA.getPropertyType() ); final PropertyDescriptor propertyB = composer.getPropertyDescriptorByType( ComponentB.class.getName(), propertyDescriptors ); assertEquals( ComponentB.class, propertyB.getPropertyType() ); final PropertyDescriptor propertyC = composer.getPropertyDescriptorByType( ComponentC.class.getName(), propertyDescriptors ); assertTrue( propertyC.getPropertyType().isArray() ); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentCom0000644000175000017500000000427410231114556033260 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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.PlexusTestCase; import java.io.InputStream; /** * @author Michal Maczka * @version $Id: DefaultComponentComposerManagerTest.java 1747 2005-04-19 05:38:54Z brett $ */ public class DefaultComponentComposerManagerTest extends PlexusTestCase { protected InputStream getCustomConfiguration() throws Exception { System.out.println( "Reading custom configuration" ); final InputStream retValue = getResourceAsStream( "/org/codehaus/plexus/component/composition/components.xml" ); assertNotNull( retValue ); return retValue; } public void testComposition() throws Exception { final ComponentA componentA = (ComponentA) lookup( ComponentA.ROLE ); assertNotNull( componentA ); final ComponentB componentB = componentA.getComponentB(); assertNotNull( componentB ); final ComponentC componentC = componentB.getComponentC(); assertNotNull( componentC ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.j0000644000175000017500000000315610161654653033161 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: DefaultComponentA.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.j0000644000175000017500000000260110161654653033155 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: DefaultComponentC.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultComponentC implements ComponentC { } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java0000644000175000017500000000253410161654653032242 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: Component.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Component { } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.ja0000644000175000017500000000260210231114556033203 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: DefaultComponent.java 1747 2005-04-19 05:38:54Z brett $ */ public class DefaultComponent extends AbstractComponent { } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionR0000644000175000017500000000304510161654653033310 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: DefaultCompositionResolverTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultCompositionResolverTest extends AbstractCompositionResolverTest { protected CompositionResolver getCompositionResolver() { return new DefaultCompositionResolver(); } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java0000644000175000017500000000464610161654653032356 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 java.util.Map; /** * @author Michal Maczka * @version $Id: ComponentF.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java0000644000175000017500000000253510161654653032347 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: ComponentD.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentD { } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.javaplexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.j0000644000175000017500000000323110161654653033154 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: DefaultComponentB.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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; } } plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java0000644000175000017500000000265410161654653032346 0ustar paulpaulpackage org.codehaus.plexus.component.composition; /* * 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 * * @version $Id: ComponentA.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ComponentA { String ROLE = ComponentA.class.getName(); ComponentB getComponentB(); } plexus-container-default/src/test/java/org/codehaus/plexus/embed/0000755000175000017500000000000010631507705024135 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/embed/MockComponent.java0000644000175000017500000000337010161654653027562 0ustar paulpaulpackage org.codehaus.plexus.embed; /* * 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.context.Context; import org.codehaus.plexus.context.ContextException; /** * @author Ben Walding * @version $Id: MockComponent.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class MockComponent { public static final String ROLE = MockComponent.class.getName(); public String toString() { return "I AM MOCKCOMPONENT"; } private String foo; public String getFoo() { return foo; } public void contextualize( Context context ) throws ContextException { foo = (String) context.get( "foo" ); } } plexus-container-default/src/test/java/org/codehaus/plexus/embed/EmbedderTest.java0000644000175000017500000000446510231114556027352 0ustar paulpaulpackage org.codehaus.plexus.embed; /* * 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 junit.framework.TestCase; import java.util.Properties; /** * @author Ben Walding * @author Jason van Zyl * @version $Id: EmbedderTest.java 1747 2005-04-19 05:38:54Z brett $ */ public class EmbedderTest extends TestCase { public void testConfigurationByURL() throws Exception { PlexusEmbedder embed = new Embedder(); embed.setConfiguration( getClass().getResource( "EmbedderTest.xml" ) ); embed.addContextValue( "foo", "bar" ); Properties contextProperties = new Properties(); contextProperties.setProperty( "property1", "value1" ); contextProperties.setProperty( "property2", "value2" ); embed.start(); try { embed.setConfiguration( getClass().getResource( "EmbedderTest.xml" ) ); fail(); } catch ( IllegalStateException e ) { assertTrue( true ); } Object o = embed.lookup( MockComponent.ROLE ); assertEquals( "I AM MOCKCOMPONENT", o.toString() ); assertNotNull( getClass().getResource( "/test.txt" ) ); embed.stop(); } } plexus-container-default/src/test/java/org/codehaus/plexus/test/0000755000175000017500000000000010631507676024047 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java0000644000175000017500000000250510161654653026125 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 * * @version $Id: Action.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Action { } plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java0000644000175000017500000003264510251162615030673 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.DefaultPlexusContainer; //import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.discovery.DiscoveredComponent; import org.codehaus.plexus.test.list.Pipeline; import org.codehaus.plexus.test.list.Valve; import org.codehaus.plexus.test.map.Activity; import org.codehaus.plexus.test.map.ActivityManager; //import org.codehaus.plexus.util.AbstractTestThread; //import org.codehaus.plexus.util.TestThreadManager; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.util.Map; public class PlexusContainerTest extends TestCase { private String basedir; private InputStream configurationStream; private ClassLoader classLoader; private DefaultPlexusContainer container; public PlexusContainerTest( String name ) { super( name ); } public void setUp() throws Exception { basedir = System.getProperty( "basedir" ); classLoader = getClass().getClassLoader(); configurationStream = PlexusContainerTest.class.getResourceAsStream( "PlexusContainerTest.xml" ); assertNotNull( configurationStream ); assertNotNull( classLoader ); container = new DefaultPlexusContainer(); container.addContextValue( "basedir", basedir ); container.addContextValue( "plexus.home", basedir + "/target/plexus-home" ); container.setConfigurationResource( new InputStreamReader( configurationStream ) ); container.initialize(); container.start(); } 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.ROLE ); // 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.ROLE ); // 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 ); assertEquals( true, serviceE.serviced ); assertEquals( true, serviceE.configured ); 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.ROLE, "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.ROLE, "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 ); assertFalse( 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.ROLE, "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.ROLE, "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.ROLE ); // 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.ROLE ); assertNotNull( components ); assertEquals( 2, components.size() ); ServiceC component = (ServiceC) components.get( "first-instance" ); assertNotNull( component ); component = (ServiceC) components.get( "second-instance" ); assertNotNull( component ); container.releaseAll( components ); } // class SingletonComponentTestThread // extends AbstractTestThread // { // private Object expectedComponent; // // private Object returnedComponent; // // private PlexusContainer container; // // private String role; // // public SingletonComponentTestThread( PlexusContainer container, String role, Object expectedComponent ) // { // super(); // // this.expectedComponent = expectedComponent; // // this.container = container; // // this.role = role; // } // // /** // * @param registry // */ // public SingletonComponentTestThread( TestThreadManager registry, PlexusContainer container, String role, // Object expectedComponent ) // { // super( registry ); // // this.expectedComponent = expectedComponent; // // this.container = container; // // this.role = role; // } // // /* (non-Javadoc) // * @see org.codehaus.plexus.util.AbstractRegisteredThread#doRun() // */ // public void doRun() // throws Throwable // { // try // { // returnedComponent = container.lookup( role ); // // if ( returnedComponent == null ) // { // setErrorMsg( "Null component returned" ); // } // else if ( returnedComponent == expectedComponent ) // { // setPassed( true ); // } // else // { // setErrorMsg( // "Returned component was a different manager. Expected=" + expectedComponent + ", got=" + // returnedComponent ); // } // } // finally // { // container.release( returnedComponent ); // } // } // } public void testAutomatedComponentConfigurationUsingXStreamPoweredComponentConfigurator() throws Exception { Component component = (Component) container.lookup( Component.ROLE ); assertNotNull( component ); assertNotNull( component.getActivity() ); assertEquals( "localhost", component.getHost() ); assertEquals( 10000, component.getPort() ); } public void testAutomatedComponentComposition() throws Exception { ComponentA componentA = (ComponentA) container.lookup( ComponentA.ROLE ); 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 = (ActivityManager) container.lookup( ActivityManager.ROLE ); Activity one = am.getActivity( "one" ); assertNotNull( 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 testComponentCompositionWhereTargetFieldIsAList() throws Exception { Pipeline pipeline = (Pipeline) container.lookup( Pipeline.ROLE ); List valves = pipeline.getValves(); 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 testLookupOfInternallyDefinedComponentConfigurator() throws Exception { container.lookup( ComponentConfigurator.ROLE ); } public void testLookupOfComponentThatShouldBeDiscovered() throws Exception { DiscoveredComponent discoveredComponent = (DiscoveredComponent) container.lookup( DiscoveredComponent.ROLE ); assertNotNull( discoveredComponent ); } } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/0000755000175000017500000000000010631507676024624 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java0000644000175000017500000000322110161654653031401 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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.PlexusTestCase; /** * @author Trygve Laugstøl * @version $Id: NoComponentsMapTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class NoComponentsMapTest extends PlexusTestCase { public void testNoComponents() throws Exception { ActivityManager manager; manager = (ActivityManager) lookup( ActivityManager.ROLE ); assertEquals( 0, manager.getActivityCount() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java0000644000175000017500000000302310161654653030741 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 * * @version $Id: AbstractActivity.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractActivity implements Activity { private boolean state; public boolean getState() { return state; } public void execute() { state = true; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java0000644000175000017500000000255410161654653027727 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 * * @version $Id: ActivityOne.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ActivityOne extends AbstractActivity { } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java0000644000175000017500000000277610161654653030566 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 * * @version $Id: ActivityManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface ActivityManager { static String ROLE = ActivityManager.class.getName(); void execute( String id ); Activity getActivity( String id ); int getActivityCount(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java0000644000175000017500000000265610161654653027270 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 * * @version $Id: Activity.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Activity { static String ROLE = Activity.class.getName(); void execute(); boolean getState(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java0000644000175000017500000000255410161654653027757 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 * * @version $Id: ActivityTwo.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ActivityTwo extends AbstractActivity { } plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java0000644000175000017500000000330610161654653032061 0ustar paulpaulpackage org.codehaus.plexus.test.map; /* * 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 Jason van Zyl * * @version $Id: DefaultActivityManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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(); } } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceC.java0000644000175000017500000000274710161654653027730 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.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; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.javaplexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHin0000644000175000017500000000264110161654653033126 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 * * @version $Id: DefaultLoadOnStartServiceWithRoleHint.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultLoadOnStartServiceWithRoleHint implements LoadOnStartService { } plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java0000644000175000017500000000266610161654653032734 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 * * @version $Id: LoadOnStartServiceWithRoleHint.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface LoadOnStartServiceWithRoleHint { String ROLE = LoadOnStartServiceWithRoleHint.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java0000644000175000017500000000275410231133376031255 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.lifecycle.AbstractLifecycleHandler; /** * * * @author Jason van Zyl * * @version $Id: SimpleLifecycleHandler.java 1750 2005-04-19 07:45:02Z brett $ */ public class SimpleLifecycleHandler extends AbstractLifecycleHandler { public void initialize() { } } plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceE.java0000644000175000017500000000235110161654653026414 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ServiceE { static String ROLE = ServiceE.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentB.java0000644000175000017500000000235510161654653026757 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ComponentB { static String ROLE = ComponentB.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceD.java0000644000175000017500000000235110161654653026413 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ServiceD { static String ROLE = ServiceD.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentD.java0000644000175000017500000000245410161654653030266 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 DefaultComponentD implements ComponentD { private String name; public String getName() { return name; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/0000755000175000017500000000000010631507674026004 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/0000755000175000017500000000000010631507675027105 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java0000644000175000017500000000254110161654653030663 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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 * * @version $Id: Miny.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Miny { void miny(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java0000644000175000017500000000254110161654653030647 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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 * * @version $Id: Eeny.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Eeny { void eeny(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MeenyPhase.java0000644000175000017500000000301210231133376031767 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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.manager.ComponentManager; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; public class MeenyPhase extends AbstractPhase { public void execute( Object object, ComponentManager manager ) { if ( object instanceof Meeny ) { ( (Meeny) object ).meeny(); } } } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java0000644000175000017500000000254410161654653031027 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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 * * @version $Id: Meeny.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Meeny { void meeny(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java0000644000175000017500000000253310161654653030323 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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 * * @version $Id: Mo.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Mo { void mo(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/EenyPhase.java0000644000175000017500000000300610231133376031615 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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.manager.ComponentManager; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; public class EenyPhase extends AbstractPhase { public void execute( Object object, ComponentManager manager ) { if ( object instanceof Eeny ) { ( (Eeny) object ).eeny(); } } } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MinyPhase.java0000644000175000017500000000300610231133376031631 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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.manager.ComponentManager; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; public class MinyPhase extends AbstractPhase { public void execute( Object object, ComponentManager manager ) { if ( object instanceof Miny ) { ( (Miny) object ).miny(); } } } plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/MoPhase.java0000644000175000017500000000277610231133376031305 0ustar paulpaulpackage org.codehaus.plexus.test.lifecycle.phase; /* * 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.manager.ComponentManager; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; public class MoPhase extends AbstractPhase { public void execute( Object object, ComponentManager manager ) { if ( object instanceof Mo ) { ( (Mo) object ).mo(); } } } plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java0000644000175000017500000000262210161654653030423 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 * * @version $Id: LoadOnStartService.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface LoadOnStartService { String ROLE = LoadOnStartService.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceD.java0000644000175000017500000000232210161654653027716 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 DefaultServiceD implements ServiceD { } plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceC.java0000644000175000017500000000235110161654653026412 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ServiceC { static String ROLE = ServiceC.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentC.java0000644000175000017500000000241610161654653026756 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ComponentC { static String ROLE = ComponentC.class.getName(); ComponentD getComponentD(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/0000755000175000017500000000000010631507676025022 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java0000644000175000017500000000267610161654653027441 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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; /** * @author Jason van Zyl * * @version $Id: Pipeline.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Pipeline { static String ROLE = Pipeline.class.getName(); void execute(); List getValves(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java0000644000175000017500000000323610161654653030737 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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 java.util.Iterator; /** * * * @author Jason van Zyl * * @version $Id: DefaultPipeline.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DefaultPipeline implements Pipeline { private List valves; public void execute() { for ( Iterator i = valves.iterator(); i.hasNext(); ) { ((Valve) i.next()).execute(); } } public List getValves() { return valves; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java0000644000175000017500000000254410161654653027435 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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 * * @version $Id: ValveTwo.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ValveTwo extends AbstractValve { } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java0000644000175000017500000000301310161654653030417 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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 * * @version $Id: AbstractValve.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public abstract class AbstractValve implements Valve { private boolean state; public boolean getState() { return state; } public void execute() { state = true; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java0000644000175000017500000000254410161654653027405 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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 * * @version $Id: ValveOne.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ValveOne extends AbstractValve { } plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java0000644000175000017500000000264610161654653026746 0ustar paulpaulpackage org.codehaus.plexus.test.list; /* * 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 * * @version $Id: Valve.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Valve { static String ROLE = Valve.class.getName(); void execute(); boolean getState(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentA.java0000644000175000017500000000355710161654653030270 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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. */ /** * @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; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceH.java0000644000175000017500000000421210161654653027722 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.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; import org.codehaus.plexus.logging.AbstractLogEnabled; /** 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; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentC.java0000644000175000017500000000250610161654653030263 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 DefaultComponentC implements ComponentC { private ComponentD componentD; public ComponentD getComponentD() { return componentD; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceE.java0000644000175000017500000000570610231133376027720 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; 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.Configurable; 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.ServiceLocator; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable; 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, Configurable, Serviceable { 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; } public void configure(PlexusConfiguration configuration) throws PlexusConfigurationException { configured = true; } public void service(ServiceLocator locator) { serviced = true; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java0000644000175000017500000000276610161654653026663 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.test.map.Activity; /** * * * @author Jason van Zyl * * @version $Id: Component.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public interface Component { static String ROLE = Component.class.getName(); String getHost(); int getPort(); Activity getActivity(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponent.java0000644000175000017500000000302310161654653030153 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.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; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java0000644000175000017500000000254510161654653027401 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 * * @version $Id: AddUserAction.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class AddUserAction implements Action { } plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceH.java0000644000175000017500000000235110161654653026417 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ServiceH { static String ROLE = ServiceH.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentD.java0000644000175000017500000000240410161654653026754 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ComponentD { static String ROLE = ComponentD.class.getName(); String getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java0000644000175000017500000000315310231133376031720 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.personality.plexus.lifecycle.phase.Startable; /** * * * @author Jason van Zyl * * @version $Id: DefaultLoadOnStartService.java 1750 2005-04-19 07:45:02Z brett $ */ public class DefaultLoadOnStartService implements LoadOnStartService, Startable { public static boolean isStarted = false; public void start() { isStarted = true; } public void stop() { } } plexus-container-default/src/test/java/org/codehaus/plexus/test/ServiceB.java0000644000175000017500000000235110161654653026411 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ServiceB { static String ROLE = ServiceB.class.getName(); } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentB.java0000644000175000017500000000236710161654653030267 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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. */ /** * @component.version 2.0 */ public class DefaultComponentB implements ComponentB { } plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultServiceB.java0000644000175000017500000000443010231133376027706 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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.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; } } plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentA.java0000644000175000017500000000253210161654653026753 0ustar paulpaulpackage org.codehaus.plexus.test; /* * 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 ComponentA { static String ROLE = ComponentA.class.getName(); ComponentB getComponentB(); ComponentC getComponentC(); String getHost(); int getPort(); } plexus-container-default/src/test/java/org/codehaus/plexus/context/0000755000175000017500000000000010631507702024542 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/context/DefaultContextTest.java0000644000175000017500000000777010231114556031206 0ustar paulpaulpackage org.codehaus.plexus.context; /* * 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 junit.framework.AssertionFailedError; import junit.framework.TestCase; import java.util.HashMap; import java.util.Map; /** * 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 context. 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 { DefaultContext parent = new DefaultContext(); parent.put( "test", "test" ); parent.makeReadOnly(); DefaultContext child = new DefaultContext( parent ); assertNotNull( child.getParent() ); child.put( "check", "check" ); Context context = child; assertTrue( "check".equals( context.get( "check" ) ) ); assertTrue( "test".equals( context.get( "test" ) ) ); child.hide( "test" ); try { context.get( "test" ); fail( "The item \"test\" was hidden in the child context, but could still be retrieved via get()." ); } catch ( ContextException ce ) { assertTrue( true ); } child.makeReadOnly(); try { child.hide( "test" ); fail( "hide() did not throw an exception, even though the context is supposed to be read-only." ); } catch ( IllegalStateException ise ) { assertTrue( true ); } } } plexus-container-default/src/test/java/org/codehaus/plexus/context/ContextMapAdapterTest.java0000644000175000017500000000545410161654653031646 0ustar paulpaulpackage org.codehaus.plexus.context; /* * 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 junit.framework.TestCase; import java.io.StringReader; import java.io.StringWriter; import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.IOUtil; /** * 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 ); } } plexus-container-default/src/test/java/org/codehaus/plexus/configuration/0000755000175000017500000000000010631507704025727 5ustar paulpaul././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationMergerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationMergerTest.jav0000644000175000017500000001251010274515050033235 0ustar paulpaulpackage org.codehaus.plexus.configuration; /* * 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.InputStream; import java.io.InputStreamReader; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.component.repository.io.PlexusTools; import junit.framework.TestCase; /** * * * @author Jason van Zyl * * @version $Id: ConfigurationMergerTest.java 2381 2005-08-04 22:43:52Z kenney $ */ public class ConfigurationMergerTest extends TestCase { private PlexusConfiguration user; private PlexusConfiguration system; public ConfigurationMergerTest( String s ) { super( s ); } public void setUp() throws Exception { InputStream userStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( "org/codehaus/plexus/configuration/avalon.xml" ); assertNotNull( userStream ); user = PlexusTools.buildConfiguration( "", new InputStreamReader( userStream ) ); InputStream systemStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( DefaultPlexusContainer.BOOTSTRAP_CONFIGURATION ); assertNotNull( systemStream ); system = PlexusTools.buildConfiguration( "", new InputStreamReader( systemStream ) ); } public void testSimpleConfigurationCascading() throws Exception { PlexusConfiguration cc = PlexusConfigurationMerger.merge( user, system ); assertEquals( "user-conf-dir", cc.getChildren( "configurations-directory" )[0].getValue() ); assertEquals( "org.codehaus.plexus.personality.avalon.AvalonComponentRepository", cc.getChild( "component-repository" ).getChild( "implementation" ).getValue() ); assertEquals( "logging-implementation", cc.getChild( "logging" ).getChild( "implementation" ).getValue() ); PlexusConfiguration lhm = cc.getChild( "lifecycle-handler-manager" ); assertEquals( "avalon", lhm.getChild( "default-lifecycle-handler-id" ).getValue() ); PlexusConfiguration lh = lhm.getChild( "lifecycle-handlers" ).getChildren( "lifecycle-handler" )[0]; assertEquals( "avalon", lh.getChild( "id" ).getValue() ); PlexusConfiguration[] bs = lh.getChild( "begin-segment" ).getChildren( "phase" ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.LogEnablePhase", bs[0].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.ContextualizePhase", bs[1].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.ServicePhase", bs[2].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.ComposePhase", bs[3].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.ConfigurePhase", bs[4].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.InitializePhase", bs[5].getAttribute( "implementation" ) ); assertEquals( "org.codehaus.plexus.personality.avalon.lifecycle.phase.StartPhase", bs[6].getAttribute( "implementation" ) ); PlexusConfiguration componentMM = cc.getChild( "component-manager-manager" ); assertEquals( "singleton", componentMM.getChild( "default-component-manager-id" ).getValue() ); PlexusConfiguration[] components = cc.getChild( "components" ).getChildren( "component" ); // There are now three internal components defined which come before the user components // are processed. assertEquals( "org.codehaus.plexus.ServiceA", components[4].getChild( "role" ).getValue() ); // Test the merging of the elements. PlexusConfiguration[] resources = cc.getChild( "resources" ).getChildren(); assertEquals( 2, resources.length ); assertEquals( "jar-resource", resources[0].getName() ); assertEquals( "${foo.home}/jars", resources[0].getValue() ); assertEquals( "my-resource", resources[1].getName() ); assertEquals( "${my.home}/resources", resources[1].getValue() ); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.jav0000644000175000017500000000566410236467234033257 0ustar paulpaulpackage org.codehaus.plexus.configuration; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.component.repository.io.PlexusTools; import java.io.StringReader; /** * @author Jason van Zyl * @version $Id: ConfigurationTestHelper.java 1781 2005-05-05 19:06:04Z jdcasey $ */ 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 // 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 ) ); } } plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/0000755000175000017500000000000010631507703026526 5ustar paulpaul././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationT0000644000175000017500000000600410223217763033267 0ustar paulpaulpackage org.codehaus.plexus.configuration.xml; /* * 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.configuration.ConfigurationTestHelper; import org.codehaus.plexus.configuration.PlexusConfiguration; import junit.framework.TestCase; /** * @author Ran Tene * @version $Id: XmlPlexusConfigurationTest.java 1637 2005-04-01 10:18:27Z trygvis $ */ 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 { XmlPlexusConfiguration 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() ); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExcept0000644000175000017500000000320610161654653033347 0ustar paulpaulpackage org.codehaus.plexus.configuration; /* * 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 junit.framework.TestCase; /** * * * @author Jason van Zyl * * @version $Id: ConfigurationResourceExceptionTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ConfigurationResourceExceptionTest extends TestCase { public void testException() { PlexusConfigurationResourceException e = new PlexusConfigurationResourceException( "bad doggy!" ); assertEquals( "bad doggy!", e.getMessage() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/0000755000175000017500000000000010631507703027745 5ustar paulpaul././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/FileConfigurationResourceHandlerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/FileConfiguration0000644000175000017500000000432310231114556033275 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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 junit.framework.TestCase; import org.codehaus.plexus.configuration.PlexusConfiguration; import java.io.File; import java.util.HashMap; import java.util.Map; /** * @author Jason van Zyl * @version $Id: FileConfigurationResourceHandlerTest.java 1747 2005-04-19 05:38:54Z brett $ */ public class FileConfigurationResourceHandlerTest extends TestCase { public void testFileConfigurationResourceHandler() throws Exception { String basedir = System.getProperty( "basedir" ); FileConfigurationResourceHandler h = new FileConfigurationResourceHandler(); Map parameters = new HashMap(); parameters.put( "source", new File( basedir, "src/test/resources/inline-configuration.xml" ).getPath() ); PlexusConfiguration[] processed = h.handleRequest( parameters ); PlexusConfiguration p = processed[0]; assertEquals( "jason", p.getChild( "first-name" ).getValue() ); assertEquals( "van zyl", p.getChild( "last-name" ).getValue() ); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/DirectoryConfigurationResourceHandlerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/DirectoryConfigur0000644000175000017500000000433610161654653033344 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; /* * 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 junit.framework.TestCase; import java.util.Map; import java.util.HashMap; import java.io.File; import org.codehaus.plexus.configuration.PlexusConfiguration; /** * @author Jason van Zyl * @version $Id: DirectoryConfigurationResourceHandlerTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class DirectoryConfigurationResourceHandlerTest extends TestCase { public void testFileConfigurationResourceHandler() throws Exception { String basedir = System.getProperty( "basedir" ); ConfigurationResourceHandler h = new DirectoryConfigurationResourceHandler(); Map parameters = new HashMap(); parameters.put( "source", new File( basedir, "src/test/resources/inline-configurations" ).getPath() ); PlexusConfiguration[] processed = h.handleRequest( parameters ); PlexusConfiguration p = processed[0]; assertEquals( "jason", p.getChild( "first-name" ).getValue() ); assertEquals( "van zyl", p.getChild( "last-name" ).getValue() ); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/SimpleConfigurationResourceHandler.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/SimpleConfigurati0000644000175000017500000000420010161654653033315 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import java.util.Map; /* * 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 * @version $Id: SimpleConfigurationResourceHandler.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class SimpleConfigurationResourceHandler implements ConfigurationResourceHandler { public String getId() { return "simple-configuration-resource"; } public PlexusConfiguration[] handleRequest( Map parameters ) throws ConfigurationProcessingException { XmlPlexusConfiguration a = new XmlPlexusConfiguration( "name" ); a.setValue( (String) parameters.get( ConfigurationResourceHandler.SOURCE ) ); XmlPlexusConfiguration b = new XmlPlexusConfiguration( "occupation" ); b.setValue( (String) parameters.get( "occupation" ) ); return new PlexusConfiguration[]{ a, b }; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/ConfigurationProcessorTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/configuration/processor/ConfigurationProc0000644000175000017500000001273110161654653033334 0ustar paulpaulpackage org.codehaus.plexus.configuration.processor; import junit.framework.TestCase; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import java.util.Map; import java.util.HashMap; /* * 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 * @version $Id: ConfigurationProcessorTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class ConfigurationProcessorTest extends TestCase { private Map variables; protected void setUp() { variables = new HashMap(); variables.put( "basedir", System.getProperty( "basedir" ) ); variables.put( "occupation", "slacker" ); } public void testConfigurationProcessorWhereThereAreNoDirectivesForExternalConfigurations() throws Exception { ConfigurationProcessor p = new ConfigurationProcessor(); XmlPlexusConfiguration source = new XmlPlexusConfiguration( "configuration" ); // ---------------------------------------------------------------------- XmlPlexusConfiguration a = new XmlPlexusConfiguration( "a" ); a.setValue( "a" ); source.addChild( a ); // ---------------------------------------------------------------------- XmlPlexusConfiguration b = new XmlPlexusConfiguration( "b" ); b.setValue( "b" ); source.addChild( b ); // ---------------------------------------------------------------------- XmlPlexusConfiguration c = new XmlPlexusConfiguration( "c" ); c.setValue( "c" ); source.addChild( c ); // ---------------------------------------------------------------------- // Just a check to make the source is of the form we need before testing // ---------------------------------------------------------------------- assertEquals( "a", source.getChild( "a" ).getValue() ); assertEquals( "b", source.getChild( "b" ).getValue() ); assertEquals( "c", source.getChild( "c" ).getValue() ); // ---------------------------------------------------------------------- PlexusConfiguration processed = p.process( source, variables ); assertEquals( "a", processed.getChild( "a" ).getValue() ); assertEquals( "b", processed.getChild( "b" ).getValue() ); assertEquals( "c", processed.getChild( "c" ).getValue() ); } public void testConfigurationProcessorWithASimpleConfigurationResource() throws Exception { ConfigurationProcessor p = new ConfigurationProcessor(); ConfigurationResourceHandler handler = new SimpleConfigurationResourceHandler(); p.addConfigurationResourceHandler( handler ); // ---------------------------------------------------------------------- // Create the following: // // // // // // ---------------------------------------------------------------------- XmlPlexusConfiguration source = new XmlPlexusConfiguration( "configuration" ); XmlPlexusConfiguration resource = new XmlPlexusConfiguration( handler.getId() ); String sourceValue = "local"; resource.setAttribute( "source", sourceValue ); resource.setAttribute( "occupation", "${occupation}" ); source.addChild( resource ); // ---------------------------------------------------------------------- // So we will now process the configuration and we should end up with // the following: // // // local // // // The SimpleConfigurationResourceHandler just creates a "name" element // where the value is that of the source attribute. // ---------------------------------------------------------------------- PlexusConfiguration processed = p.process( source, variables ); assertEquals( sourceValue, processed.getChild( "name" ).getValue() ); // ---------------------------------------------------------------------- // Check that the interpolated value came through // ---------------------------------------------------------------------- assertEquals( "slacker", processed.getChild( "occupation" ).getValue() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/0000755000175000017500000000000010631507702024504 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java0000644000175000017500000000525710161654653027417 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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 Peter Donald * @version $Revision: 1323 $ $Date: 2004-12-20 23:00:59 +0000 (Mon, 20 Dec 2004) $ */ 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; } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java0000644000175000017500000000720110161654653030211 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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 junit.framework.TestCase; /** * * @author Peter Donald * @version $Revision: 1323 $ $Date: 2004-12-20 23:00:59 +0000 (Mon, 20 Dec 2004) $ */ 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" ); } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java0000644000175000017500000001717110161654653032422 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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.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: 1323 $ */ 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. */ 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() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java0000644000175000017500000000330310161654653032121 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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.PlexusTestCase; /** * @author Trygve Laugstøl * @version $Id: CustomLoggerManagerTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class CustomLoggerManagerTest extends PlexusTestCase { public void testBasic() throws Exception { LoggerManager manager = (LoggerManager)lookup( LoggerManager.class.getName() ); assertNotNull( manager ); assertEquals( MockLoggerManager.class.getName(), manager.getClass().getName() ); } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/0000755000175000017500000000000010631507702026146 5ustar paulpaulplexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java0000644000175000017500000001011210161654653032414 0ustar paulpaulpackage org.codehaus.plexus.logging.console; /* * 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 junit.framework.TestCase; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import org.codehaus.plexus.util.StringUtils; /** * @author Jason van Zyl * * @version $Id: ConsoleLoggerTest.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ 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() ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.javaplexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.0000644000175000017500000000331110161654653033050 0ustar paulpaulpackage org.codehaus.plexus.logging.console; /* * 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.logging.AbstractLoggerManagerTest; 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: 1323 $ */ public final class ConsoleLoggerManagerTest extends AbstractLoggerManagerTest { protected LoggerManager createLoggerManager() throws Exception { return (LoggerManager)lookup(LoggerManager.ROLE); } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java0000644000175000017500000000442610161654653030707 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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 Trygve Laugstøl * @version $Id: MockLoggerManager.java 1323 2004-12-20 23:00:59Z jvanzyl $ */ public class MockLoggerManager implements LoggerManager { public void setThreshold(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; } } plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java0000644000175000017500000000257110161654653030170 0ustar paulpaulpackage org.codehaus.plexus.logging; /* * 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 Peter Donald * @version $Revision: 1323 $ $Date: 2004-12-20 23:00:59 +0000 (Mon, 20 Dec 2004) $ */ class MockLogEnabled extends AbstractLogEnabled { } plexus-container-default/integration-tests/0000755000175000017500000000000010631507672020156 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/0000755000175000017500000000000010631507673023426 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/pom.xml0000644000175000017500000000136010230754255024736 0ustar paulpaul 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 plexus-container-default/integration-tests/multi-plexus.xml/src/0000755000175000017500000000000010631507672024214 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/0000755000175000017500000000000010631507672025140 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/resources/0000755000175000017500000000000010631507673027153 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/resources/META-INF/0000755000175000017500000000000010631507673030313 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/resources/META-INF/plexus/0000755000175000017500000000000010631507673031633 5ustar paulpaul././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/main/resources/META-INF/plexus/plexus.xmlplexus-container-default/integration-tests/multi-plexus.xml/src/main/resources/META-INF/plexus/plexu0000644000175000017500000000035610230754255032712 0ustar paulpaul org.codehaus.plexus.test.it.multiplx.Component org.codehaus.plexus.test.it.multiplx.ComponentImpl plexus-container-default/integration-tests/multi-plexus.xml/src/main/java/0000755000175000017500000000000010631507672026061 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/0000755000175000017500000000000010631507672026650 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/0000755000175000017500000000000010631507672030443 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/0000755000175000017500000000000010631507672031763 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/0000755000175000017500000000000010631507672032742 5ustar paulpaul././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/plexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/i0000755000175000017500000000000010631507672033113 5ustar paulpaul././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/plexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/i0000755000175000017500000000000010631507672033113 5ustar paulpaul././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/Component.javaplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/i0000644000175000017500000000146310230754255033115 0ustar paulpaulpackage 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); } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/it/multiplx/ComponentImpl.javaplexus-container-default/integration-tests/multi-plexus.xml/src/main/java/org/codehaus/plexus/test/i0000644000175000017500000000146610230754255033120 0ustar paulpaulpackage 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; } } plexus-container-default/integration-tests/multi-plexus.xml/src/test/0000755000175000017500000000000010631507672025173 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/0000755000175000017500000000000010631507672026114 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/0000755000175000017500000000000010631507672026703 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/0000755000175000017500000000000010631507672030476 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/0000755000175000017500000000000010631507672032016 5ustar paulpaulplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/0000755000175000017500000000000010631507672032775 5ustar paulpaul././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/plexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/i0000755000175000017500000000000010631507672033146 5ustar paulpaul././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/multiplx/plexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/i0000755000175000017500000000000010631507672033146 5ustar paulpaul././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/it/multiplx/ComponentLookupTest.javaplexus-container-default/integration-tests/multi-plexus.xml/src/test/java/org/codehaus/plexus/test/i0000644000175000017500000000213410230754255033144 0ustar paulpaulpackage 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); } } plexus-container-default/test-fodder/0000755000175000017500000000000010631507671016712 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/0000755000175000017500000000000010631507672024003 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/pom.xml0000644000175000017500000000027310230754255025316 0ustar paulpaul 4.0.0 plexus plexus-testFodder-componentWithPlexusXml 1.0-SNAPSHOT plexus-container-default/test-fodder/component-with-plexus.xml/src/0000755000175000017500000000000010631507671024571 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/0000755000175000017500000000000010631507671025515 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/resources/0000755000175000017500000000000010631507671027527 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/0000755000175000017500000000000010631507671030667 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/0000755000175000017500000000000010631507671032207 5ustar paulpaul././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/plexus.xmlplexus-container-default/test-fodder/component-with-plexus.xml/src/main/resources/META-INF/plexus/pl0000644000175000017500000000037410230754255032546 0ustar paulpaul org.codehaus.plexus.test.fodder.withplx.TestComponent org.codehaus.plexus.test.fodder.withplx.TestComponentImpl plexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/0000755000175000017500000000000010631507671026436 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/0000755000175000017500000000000010631507671027225 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/0000755000175000017500000000000010631507671031020 5ustar paulpaulplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/0000755000175000017500000000000010631507671032340 5ustar paulpaul././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/plexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/tes0000755000175000017500000000000010631507671033054 5ustar paulpaul././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/plexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/tes0000755000175000017500000000000010631507671033054 5ustar paulpaul././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/plexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/tes0000755000175000017500000000000010631507671033054 5ustar paulpaul././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponentImpl.javaplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/tes0000644000175000017500000000150410230754255033053 0ustar paulpaulpackage 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; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/test/fodder/withplx/TestComponent.javaplexus-container-default/test-fodder/component-with-plexus.xml/src/main/java/org/codehaus/plexus/tes0000644000175000017500000000136610230754255033061 0ustar paulpaulpackage 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); }