plexus-cdc-1.0-alpha-14/0000755000175000017500000000000011117672311014664 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/0000755000175000017500000000000011117672310015452 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/0000755000175000017500000000000011117672310016431 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/0000755000175000017500000000000011117672310017352 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/0000755000175000017500000000000011117672310020141 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/0000755000175000017500000000000011117672310021734 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/0000755000175000017500000000000011117672310023254 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/cdc/0000755000175000017500000000000011117672310024005 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/cdc/merge/0000755000175000017500000000000011117672310025104 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/cdc/merge/ComponentsXmlMergerTest.java0000644000175000017500000003046710700073353032570 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, 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 org.codehaus.plexus.cdc.merge.support.AbstractMergeableElement; import org.codehaus.plexus.cdc.merge.support.AbstractMergeableElementList; import org.codehaus.plexus.cdc.merge.support.ComponentElement; import org.codehaus.plexus.cdc.merge.support.ComponentsElement; import org.codehaus.plexus.cdc.merge.support.RequirementsElement; import org.codehaus.plexus.util.FileUtils; import org.jdom.Document; import org.jdom.Element; import org.jdom.input.SAXBuilder; import java.io.File; import java.util.List; /** * Tests for {@link ComponentsXmlMerger}. * * @author Rahul Thakur * @version $Id: ComponentsXmlMergerTest.java 6923 2007-10-01 04:26:19Z user57 $ */ public class ComponentsXmlMergerTest extends PlexusTestCase { public void testBasic() throws Exception { ComponentsXmlMerger merger = (ComponentsXmlMerger) lookup( Merger.ROLE, "componentsXml" ); assertNotNull( merger ); } public void testComponentsXmlFileMerge() throws Exception { File dominantXml = getTestFile( "src/test/resources/org/codehaus/plexus/cdc/merge/dominant.xml" ); File recessiveXml = getTestFile( "src/test/resources/org/codehaus/plexus/cdc/merge/recessive.xml" ); Document dDoc = new SAXBuilder().build( dominantXml ); Document rDoc = new SAXBuilder().build( recessiveXml ); // ComponentsXmlMerger merger = new ComponentsXmlMerger (dDoc); Merger merger = (Merger) lookup( Merger.ROLE, "componentsXml" ); assertNotNull( merger ); merger.merge( dDoc, rDoc ); File merged_xml = getTestFile( "target/merged.xml" ); if ( merged_xml.exists() ) { FileUtils.forceDelete( merged_xml ); } merger.writeMergedDocument( dDoc, merged_xml ); assertTrue( merged_xml.exists() ); // read merged xml and verify it was merged as expected Document mDoc = new SAXBuilder().build( merged_xml ); Element mRootElt = mDoc.getRootElement(); assertTrue( mRootElt.getName().equals( "component-set" ) ); assertEquals( 1, mRootElt.getChildren( "components" ).size() ); List componentEltList = mRootElt.getChild( "components" ).getChildren( "component" ); assertEquals( 2, componentEltList.size() ); Element cElt = (Element) componentEltList.get( 0 ); assertEquals( "org.codehaus.plexus.cdc.component.IComponent", cElt.getChildTextTrim( "role" ) ); assertEquals( "org.codehaus.plexus.cdc.component.DominantComponent", cElt.getChildTextTrim( "implementation" ) ); assertEquals( "Should only have 1 description element.", 1, cElt.getChildren( "description" ).size() ); assertEquals( "Description for Dominant component", cElt.getChildTextTrim( "description" ) ); assertEquals( "Should only have 1 configuration element.", 1, cElt.getChildren( "configuration" ).size() ); // assert Merged configuration properties Element configurationElt = cElt.getChild( "configuration" ); assertNotNull( configurationElt ); assertEquals( 1, configurationElt.getChildren( "prop1" ).size() ); assertEquals( "Dominant Property1 value", configurationElt.getChildTextTrim( "prop1" ) ); assertEquals( 1, configurationElt.getChildren( "prop2" ).size() ); assertEquals( 0, configurationElt.getChildren( "prop3" ).size() ); // now for the second component cElt = (Element) componentEltList.get( 1 ); assertEquals( "org.codehaus.plexus.cdc.component.INonConflictingComponent", cElt.getChildTextTrim( "role" ) ); assertEquals( "org.codehaus.plexus.cdc.component.RecessiveComponent", cElt.getChildTextTrim( "implementation" ) ); assertEquals( 1, mRootElt.getChildren( "lifecycle-handler-manager" ).size() ); assertEquals( "org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager", mRootElt .getChild( "lifecycle-handler-manager" ).getAttributeValue( "implementation" ) ); } public void testInvalidMergeableElements() throws Exception { // dominant Component Element AbstractMergeableElement dCE = new ComponentElement( new Element( "component" ) ); Element roleElt = new Element( "role" ); roleElt.setText( "org.codehaus.plexus.ISampleRole" ); dCE.addContent( roleElt ); AbstractMergeableElementList reqElt = new RequirementsElement( new Element( "requirement" ) ); // attempt and invalid merge try { dCE.merge( reqElt ); fail( "Expected MergeException!" ); } catch ( MergeException e ) { // do nothing. } } /** * Tests if <component> elements from two sets are being merged properly. * * @throws Exception if there was an unexpected error. */ public void testComponentsMerge() throws Exception { // dominant Components Element AbstractMergeableElement dParent = new ComponentsElement( new Element( "components" ) ); Element dCE = new Element( "component" ); dParent.addContent( dCE ); Element roleElt = new Element( "role" ); roleElt.setText( "org.codehaus.plexus.ISampleRole" ); dCE.addContent( roleElt ); Element roleHintElt = new Element( "role-hint" ); roleHintElt.setText( "sample-role-hint" ); dCE.addContent( roleHintElt ); Element implElt = new Element( "implementation" ); implElt.setText( "org.codehaus.plexus.DominantImplementation" ); dCE.addContent( implElt ); Element requirementsElt = new Element( "requirements" ); Element reqElt = new Element( "requirement" ); Element reqRoleElt = new Element( "role" ); reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); reqElt.addContent( reqRoleElt ); requirementsElt.addContent( reqElt ); dCE.addContent( requirementsElt ); // recessive Component Element AbstractMergeableElement rParent = new ComponentsElement( new Element( "components" ) ); Element rCE = new Element( "component" ); rParent.addContent( rCE ); roleElt = new Element( "role" ); roleElt.setText( "org.codehaus.plexus.ISampleRole" ); rCE.addContent( roleElt ); roleHintElt = new Element( "role-hint" ); roleHintElt.setText( "sample-role-hint" ); rCE.addContent( roleHintElt ); implElt = new Element( "implementation" ); implElt.setText( "org.codehaus.plexus.RecessiveImplementation" ); rCE.addContent( implElt ); Element lifecycleHandlerElt = new Element( "lifecycle-handler" ); rCE.addContent( lifecycleHandlerElt ); lifecycleHandlerElt.setText( "plexus-configurable" ); requirementsElt = new Element( "requirements" ); reqElt = new Element( "requirement" ); reqRoleElt = new Element( "role" ); reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); reqElt.addContent( reqRoleElt ); requirementsElt.addContent( reqElt ); Element reqRoleHintElt = new Element( "role-hint" ); reqRoleHintElt.setText( "recessive-required-role-hint" ); reqElt.addContent( reqRoleHintElt ); rCE.addContent( requirementsElt ); // attempt to merge dParent.merge( rParent ); assertEquals( 1, dParent.getChildren( "component" ).size() ); assertEquals( "org.codehaus.plexus.DominantImplementation", dParent.getChild( "component" ) .getChildText( "implementation" ) ); assertEquals( 1, dParent.getChild( "component" ).getChild( "requirements" ).getChildren( "requirement" ).size() ); } /** * This is deprecated as we dont' want to drill to merging * nested elements within a component.

* Keeping this around for testing MergeStrategy implmentation. * * @throws Exception */ public void testDeepComponentsMerge() throws Exception { // FIXME: Review this after MergeStrategies are in place. if ( true ) { return; } // dominant Component Element AbstractMergeableElement dCE = new ComponentElement( new Element( "component" ) ); Element roleElt = new Element( "role" ); roleElt.setText( "org.codehaus.plexus.ISampleRole" ); dCE.addContent( roleElt ); Element roleHintElt; // roleHintElt = new Element ("role-hint"); // roleHintElt.setText ("sample-hint"); // dCE.addContent (roleHintElt); Element implElt = new Element( "implementation" ); implElt.setText( "org.codehaus.plexus.DominantImplementation" ); dCE.addContent( implElt ); Element requirementsElt = new Element( "requirements" ); Element reqElt = new Element( "requirement" ); Element reqRoleElt = new Element( "role" ); reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); reqElt.addContent( reqRoleElt ); requirementsElt.addContent( reqElt ); dCE.addContent( requirementsElt ); // recessive Component Element AbstractMergeableElement rCE = new ComponentElement( new Element( "component" ) ); roleElt = new Element( "role" ); roleElt.setText( "org.codehaus.plexus.ISampleRole" ); rCE.addContent( roleElt ); roleHintElt = new Element( "role-hint" ); roleHintElt.setText( "recessive-hint" ); rCE.addContent( roleHintElt ); implElt = new Element( "implementation" ); implElt.setText( "org.codehaus.plexus.RecessiveImplementation" ); rCE.addContent( implElt ); Element lifecycleHandlerElt = new Element( "lifecycle-handler" ); rCE.addContent( lifecycleHandlerElt ); lifecycleHandlerElt.setText( "plexus-configurable" ); requirementsElt = new Element( "requirements" ); reqElt = new Element( "requirement" ); reqRoleElt = new Element( "role" ); reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); reqElt.addContent( reqRoleElt ); requirementsElt.addContent( reqElt ); Element reqRoleHintElt = new Element( "role-hint" ); reqRoleHintElt.setText( "recessive-required-role-hint" ); reqElt.addContent( reqRoleHintElt ); rCE.addContent( requirementsElt ); // attempt to merge dCE.merge( rCE ); // verify the merge assertTrue( null != dCE.getChild( "role" ) ); assertEquals( "org.codehaus.plexus.ISampleRole", dCE.getChildText( "role" ) ); assertTrue( null != dCE.getChild( "role-hint" ) ); assertEquals( "recessive-hint", dCE.getChildText( "role-hint" ) ); assertTrue( null != dCE.getChild( "lifecycle-handler" ) ); assertEquals( "plexus-configurable", dCE.getChildText( "lifecycle-handler" ) ); assertTrue( null != dCE.getChild( "requirements" ) ); assertEquals( 1, dCE.getChild( "requirements" ).getChildren( "requirement" ).size() ); assertEquals( "recessive-required-role-hint", ( (Element) dCE.getChild( "requirements" ) .getChildren( "requirement" ).get( 0 ) ).getChildText( "role-hint" ) ); } } plexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/cdc/gleaner/0000755000175000017500000000000011117672310025422 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/test/java/org/codehaus/plexus/cdc/gleaner/QDoxComponentGleanerTest.java0000644000175000017500000001051210715477763033202 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; import java.io.IOException; import java.net.URL; import java.util.List; import com.thoughtworks.qdox.JavaDocBuilder; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaSource; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.component.repository.cdc.ComponentRequirement; import org.codehaus.plexus.configuration.PlexusConfiguration; /** * Tests for the {@link QDoxComponentGleaner} class. * * @version $Rev: 7051 $ $Date: 2007-11-11 05:07:15 +0100 (So, 11. Nov 2007) $ */ public class QDoxComponentGleanerTest extends PlexusTestCase { private QDoxComponentGleaner gleaner; private JavaDocBuilder builder; // @Override protected void setUp() throws Exception { super.setUp(); gleaner = new QDoxComponentGleaner(); builder = new JavaDocBuilder(); } // @Override protected void tearDown() throws Exception { gleaner = null; builder = null; super.tearDown(); } private JavaSource addSource(final String name) throws IOException { URL url = getClass().getResource(name); assertNotNull(url); return builder.addSource(url); } private JavaClass loadJavaClass(final String name) throws IOException { JavaSource source = addSource(name); assertNotNull(source); JavaClass[] classes = source.getClasses(); assertNotNull(classes); assertEquals(1, classes.length); assertNotNull(classes[0]); return classes[0]; } private ComponentDescriptor glean(final String name, final String[] supporting) throws Exception { if (supporting != null) { for (int i=0; i org.codehaus.plexus.cdc.component.IComponent org.codehaus.plexus.cdc.component.RecessiveComponent Description for conflicting recessive component Recessive Property1 value Property3 value org.codehaus.plexus.cdc.component.IComponentA recessiveField org.codehaus.plexus.cdc.component.INonConflictingComponent org.codehaus.plexus.cdc.component.RecessiveComponent Description for non-conflicting recessive component Non conflicting Property1 value Non conflicting Property2 value org.codehaus.plexus.cdc.component.IComponentA webapp webapp Webapp plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/merge/dominant.xml0000644000175000017500000000123110700073353030524 0ustar twernertwerner org.codehaus.plexus.cdc.component.IComponent org.codehaus.plexus.cdc.component.DominantComponent Description for Dominant component Dominant Property1 value Dominant Property2 value org.codehaus.plexus.cdc.component.IComponentA plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/0000755000175000017500000000000011117672310026513 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/AbstractWithAnnoClass.javaplexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/AbstractWithAnnoClass.jav0000644000175000017500000000151110700073353033413 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @plexus.component role="foo" * * @version $Id: AbstractWithAnnoClass.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class AbstractWithAnnoClass { }plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/NoAnnotationsClass.java0000644000175000017500000000143010700073353033133 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @version $Id: NoAnnotationsClass.java 6923 2007-10-01 04:26:19Z user57 $ */ public class NoAnnotationsClass { } plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/ChildComponent.java0000644000175000017500000000153510700073353032267 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @plexus.component role="org.codehaus.plexus.cdc.gleaner.ChildComponent" * * @version $Id: ChildComponent.java 6923 2007-10-01 04:26:19Z user57 $ */ public class ChildComponent { }plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/MyComponent.java0000644000175000017500000000202510700073353031624 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @plexus.component role="org.codehaus.plexus.cdc.gleaner.MyComponent" role-hint="foo" * * @version $Rev: 6923 $ $Date: 2007-10-01 06:26:19 +0200 (Mo, 01. Okt 2007) $ */ public class MyComponent { /** * @plexus.requirement */ private ChildComponent child; /** * @plexus.configuration default-value="bar" */ private String foo; }plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/AbstractClass.java0000644000175000017500000000142610700073353032111 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @version $Id: AbstractClass.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class AbstractClass { }plexus-cdc-1.0-alpha-14/src/test/resources/org/codehaus/plexus/cdc/gleaner/NoAnnotationsIntf.java0000644000175000017500000000143110700073353032767 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; /** * ??? * * @version $Id: NoAnnotationsIntf.java 6923 2007-10-01 04:26:19Z user57 $ */ public interface NoAnnotationsIntf { }plexus-cdc-1.0-alpha-14/src/main/0000755000175000017500000000000011117672311016377 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/0000755000175000017500000000000011117672310017317 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/0000755000175000017500000000000011117672310020106 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/0000755000175000017500000000000011117672310021701 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/0000755000175000017500000000000011117672310023221 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/0000755000175000017500000000000011117672310025223 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/0000755000175000017500000000000011117672310027442 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/0000755000175000017500000000000011117672310030173 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/README.txt0000644000175000017500000000032410777725005031703 0ustar twernertwernerThis package contains some classes copied from the container before it started using the "default" role hints. This can be removed once all supported maven versions are using a container newer than 1.0-alpha-19.././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentRequirementList.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentRequirem0000644000175000017500000000165110700073353033574 0ustar twernertwernerpackage org.codehaus.plexus.component.repository.cdc; import java.util.Iterator; import java.util.List; /** * Created by IntelliJ IDEA. * * @author Andrew Williams * @version $Id: ComponentRequirementList.java 6923 2007-10-01 04:26:19Z user57 $ * @since 1.0 */ public final class ComponentRequirementList extends ComponentRequirement { private List roleHints; public List getRoleHints() { return roleHints; } public void setRoleHints(List roleHints) { this.roleHints = roleHints; } public String getRoleHint() { StringBuffer ret = new StringBuffer(); Iterator iter = getRoleHints().iterator(); while (iter.hasNext()) { String hint = (String) iter.next(); ret.append(hint); if (iter.hasNext()) { ret.append(","); } } return ret.toString(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentDescriptor.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentDescript0000644000175000017500000001761010777725005033576 0ustar twernertwernerpackage org.codehaus.plexus.component.repository.cdc; import java.util.ArrayList; import java.util.List; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; /** * 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; private boolean abstractComponent; // ---------------------------------------------------------------------- // 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; } public void setAbstractComponent( boolean abstractComponent ) { this.abstractComponent = abstractComponent; } public boolean isAbstractComponent() { return abstractComponent; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentRequirement.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentRequirem0000644000175000017500000000526010777725005033610 0ustar twernertwernerpackage org.codehaus.plexus.component.repository.cdc; /** * @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 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(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentSetDescriptor.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/component/repository/cdc/ComponentSetDescr0000644000175000017500000000315710777725005033536 0ustar twernertwernerpackage org.codehaus.plexus.component.repository.cdc; import java.util.ArrayList; import java.util.List; import org.codehaus.plexus.component.repository.ComponentDependency; /** * @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; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/0000755000175000017500000000000011117672311023753 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/0000755000175000017500000000000011117672311025052 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/0000755000175000017500000000000011117672311026566 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ComponentSetElement.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ComponentSetElement.java0000644000175000017500000000335510455207755033401 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.jdom.Element; /** * @author Rahul Thakur * @version $Id: ComponentSetElement.java 3522 2006-07-12 15:06:21Z brett $ */ public class ComponentSetElement extends AbstractMergeableElement { public ComponentSetElement( Element element ) { super( element ); } public DescriptorTag[] getAllowedTags() { return new DescriptorTag[]{ComponentsElement.TAG}; } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof ComponentSetElement; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ComponentsElement.java0000644000175000017500000000535710700073353033100 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.ArrayList; import java.util.List; import org.jdom.Element; /** * @author Rahul Thakur * @version $Id: ComponentsElement.java 6923 2007-10-01 04:26:19Z user57 $ */ public class ComponentsElement extends AbstractMergeableElementList { static final DescriptorTag TAG = new DescriptorTag( "components", true, ComponentsElement.class ); private List conflictVerificationkeys = new ArrayList(); public ComponentsElement( Element element ) { super( element ); conflictVerificationkeys.add( ComponentElement.ROLE.getTagName() ); conflictVerificationkeys.add( ComponentElement.ROLE_HINT.getTagName() ); } public DescriptorTag[] getAllowedTags() { return new DescriptorTag[]{ComponentElement.TAG}; } protected boolean isExpectedElementType( Mergeable me ) { return ( me instanceof ComponentsElement ); } protected List getElementNamesForConflictChecks( List defaultList ) { // Allow to return custom keys for conflict checks/resolution. return this.conflictVerificationkeys; } protected String getTagNameForRecurringMergeable() { return ComponentElement.TAG.getTagName(); } protected List getElementNamesForConflictResolution( List defaultList ) { // TODO: how is this different from getElementNamesForConflictChecks? List l = new ArrayList(); l.add( ComponentElement.ROLE.getTagName() ); l.add( ComponentElement.ROLE_HINT.getTagName() ); return l; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/Mergeable.java0000644000175000017500000000541110455207755031327 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.cdc.merge.MergeException; import org.codehaus.plexus.cdc.merge.MergeStrategy; import org.jdom.Element; /** * Interface that marks an implementing entity as mergeable.

* Not all the elements/tags are expected to implement this interface.
* It should be implemented by elements/tags that need to have a certain control on how elements of the same type are merged with them. * * @author Rahul Thakur * @version $Id: Mergeable.java 3522 2006-07-12 15:06:21Z brett $ */ public interface Mergeable { /** * Merges an element of same type. * * @param me Another entity that is mergeable. * @throws MergeException if there was an error merging the mergeables. */ void merge( Mergeable me ) throws MergeException; /** * Applies the passed in {@link MergeStrategy} to merge two {@link Mergeable} instance.

* * @param me Recessive {@link Mergeable} instance. * @param strategy {@link MergeStrategy} to apply for merging. * @throws MergeException if there was an error while merging. */ void merge( Mergeable me, MergeStrategy strategy ) throws MergeException; /** * Returns the wrapped up JDom {@link Element} instance that was used to create this Mergeable. * * @return the wrapped up JDom {@link Element} instance. */ Element getElement(); /** * Returns an array of tags/elements that are allowed under the current * element. * * @return the allowedTags */ DescriptorTag[] getAllowedTags(); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableElement.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableElement0000644000175000017500000001623310700073353033375 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.codehaus.plexus.cdc.merge.MergeException; import org.codehaus.plexus.cdc.merge.MergeStrategy; import org.jdom.Content; import org.jdom.Element; /** * @author Rahul Thakur * @version $Id: AbstractMergeableElement.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class AbstractMergeableElement extends AbstractMergeableSupport { public AbstractMergeableElement( Element element ) { super( element ); } /** * Detects if there was a conflict, that is the specified element was * present in both dominant and recessive element-sets. *

* This delegates to * {@link #isRecessiveElementInConflict(AbstractMergeableElement,List)}. * * @param re Recessive element. * @param eltName Element name to test for. * @return true if there was a conflict of element. * @deprecated use {@link #isRecessiveElementInConflict(AbstractMergeableElement,List)} instead. */ protected boolean isRecessiveElementInConflict( AbstractMergeableElement re, String eltName ) { // return (null != getChild (eltName) && null != re.getChild (eltName)); List l = new ArrayList(); l.add( eltName ); return isRecessiveElementInConflict( re, l ); } /** * Detects if there was a conflict, that is the specified element was * present in both dominant and recessive element-sets. *

* Use this to determine conflicts when the Dominant and Recessive element * sets are keyed with Composite keys.
* For instance: <component> is keyed on * <role> and <role-hint>. * * @param re * @param eltNameList List of elements that will be checked for values in both dominant and recessive sets. * @return */ protected boolean isRecessiveElementInConflict( AbstractMergeableElement re, List eltNameList ) { // give opportunity to subclasses to provide any custom Composite keys // for conflict checks. eltNameList = getElementNamesForConflictResolution( eltNameList ); if ( null == eltNameList || eltNameList.size() == 0 ) { return false; } // assuming the elements will conflict. for ( Iterator it = eltNameList.iterator(); it.hasNext(); ) { String eltName = (String) it.next(); String dEltValue = getChildTextTrim( eltName ); String rEltValue = re.getChildTextTrim( eltName ); if ( null == dEltValue || null == rEltValue || !dEltValue.equals( rEltValue ) ) { return false; } } return true; } /** * Determines if the Element to be merged is to be sourced from Recessive * Element set. * * @param re Recessive element. * @param eltName Element name to test for. * @return */ protected boolean mergeableElementComesFromRecessive( AbstractMergeableElement re, String eltName ) { return null == getChildText( eltName ) && null != re.getChildText( eltName ); } /** * Simply delegate to * * @see Mergeable#merge(Mergeable,org.codehaus.plexus.cdc.merge.MergeStrategy) */ public void merge( Mergeable me, MergeStrategy strategy ) throws MergeException { // TODO set up a unit test for this! strategy.apply( this, me ); } public void merge( Mergeable me ) throws MergeException { if ( !isExpectedElementType( me ) ) { // if (getLogger().isErrorEnabled) // getLogger().error ("Cannot Merge dissimilar elements. (Expected : '" + getClass ().getName () + "', found '" + me.getClass ().getName () + "')"); throw new MergeException( "Cannot Merge dissimilar elements. " + "(Expected : '" + getClass().getName() + "', found '" + me.getClass().getName() + "')" ); } // recessive Component Element. AbstractMergeableElement rce = (AbstractMergeableElement) me; Set allowedTags = new HashSet(); for ( int i = 0; i < getAllowedTags().length; i++ ) { String tagName = getAllowedTags()[i].getTagName(); allowedTags.add( tagName ); List defaultConflictChecklist = new ArrayList(); defaultConflictChecklist.add( tagName ); if ( !isRecessiveElementInConflict( rce, defaultConflictChecklist ) && mergeableElementComesFromRecessive( rce, tagName ) ) { this.addContent( (Element) rce.getChild( tagName ).clone() ); // else dominant wins in anycase! } else if ( getAllowedTags()[i].isMergeable() && isRecessiveElementInConflict( rce, defaultConflictChecklist ) ) { // this allows for merging multiple/list of elements. try { getAllowedTags()[i].createMergeable( this.getChild( tagName ) ) .merge( getAllowedTags()[i].createMergeable( rce.getChild( tagName ) ), getDefaultMergeStrategy() ); } catch ( Exception e ) { // TODO log to error throw new MergeException( "Unable to create Mergeable instance for tag " + "'" + getAllowedTags()[i] + "'.", e ); } } } for ( Iterator i = me.getElement().getChildren().iterator(); i.hasNext(); ) { Element child = (Element) i.next(); if ( !allowedTags.contains( child.getName() ) ) { // not yet merged, copy over element.addContent( (Content) child.clone() ); } } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ConfigurationElement.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ConfigurationElement.jav0000644000175000017500000000343310455207755033426 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.jdom.Element; /** * TODO Implement merge for this. * * @author Rahul Thakur * @version $Id: ConfigurationElement.java 3522 2006-07-12 15:06:21Z brett $ */ public class ConfigurationElement extends AbstractMergeableElement { public ConfigurationElement( Element element ) { super( element ); } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof ConfigurationElement; } public DescriptorTag[] getAllowedTags() { // TODO Implement! return new DescriptorTag[0]; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableElementList.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableElement0000644000175000017500000002063110700073353033372 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.codehaus.plexus.cdc.merge.MergeException; import org.jdom.Element; /** * Base class that allows for handling merging two element lists. *

* TODO Refactor and make this extend {@link AbstractMergeableElement} which is what * this actually is, but with added bits for merging child element lists. * * @author Rahul Thakur * @version $Id: AbstractMergeableElementList.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class AbstractMergeableElementList extends AbstractMergeableElement { public AbstractMergeableElementList( Element element ) { super( element ); } /** * Parses <component> elements and builds a map keyed basd on the list of composite keys specified. * * @param tagName Name of the tag that appears multiple times * @param compositeKeyList List of element/tag names to be used as composite keys to register recurring * {@link Mergeable} instances. * @return Map of {@link Mergeable} instances keyed on the composite key obtained from * {@link #getElementNamesForConflictResolution(java.util.List)} * @throws Exception if there was an error parsing and registering {@link Mergeable} instances */ protected Map parseRecurringMergeables( String tagName, List compositeKeyList, Mergeable parentElement ) throws Exception { Map mergeables = new LinkedHashMap(); List list = this.getChildren( tagName ); for ( Iterator it = list.iterator(); it.hasNext(); ) { Element ce = (Element) it.next(); // use the composite key specified by the passed in list String compositeKey = ""; for ( Iterator itr = compositeKeyList.iterator(); itr.hasNext(); ) { String key = (String) itr.next(); if ( null != ce.getChildText( key ) ) { compositeKey = compositeKey + ce.getChildText( key ); } } // create a Mergeable instance and store it in the map. DescriptorTag tag = lookupTagInstanceByName( tagName, parentElement.getAllowedTags() ); Mergeable mergeable = tag.createMergeable( ce ); // register the Mergeable instance based on composite key mergeables.put( compositeKey, mergeable ); } return mergeables; } /** * Looks up and returns an {@link DescriptorTag} instance for the * specified tag name. * * @param name key to look up the {@link DescriptorTag} instance on. * @return {@link DescriptorTag} instance whose name matches the name specified. * Returns null if no match is found. */ private DescriptorTag lookupTagInstanceByName( String name, DescriptorTag[] values ) { DescriptorTag value = null; for ( int i = 0; i < values.length && value == null; i++ ) { if ( values[i].getTagName().equals( name ) ) { value = values[i]; } } // not found! return value; } public void merge( Mergeable me ) throws MergeException { try { Map dRequirementsMap = parseRecurringMergeables( getTagNameForRecurringMergeable(), getElementNamesForConflictResolution( new ArrayList() ), me ); Map rRequirementsMap = ( (AbstractMergeableElementList) me ) .parseRecurringMergeables( getTagNameForRecurringMergeable(), getElementNamesForConflictResolution( new ArrayList() ), me ); merge( getElement(), dRequirementsMap, rRequirementsMap ); } catch ( Exception e ) { // TODO: log to error // TODO: better error message throw new MergeException( "Unable to merge Mergeable lists for element '" + getName() + "'.", e ); } } /** * Identifies the conflicting elements in the dominant and recessive * {@link Map} instance and merges as required. * * @param parent {@link Element} that is parent for the children in the dominant Map instance. Merged content is * added to this element. * @param dMap Dominant Map keyed by the composite key obtained from * {@link #getElementNamesForConflictResolution(List)} * @param rMap Recessive Map keyed by the composite key obtained from * {@link #getElementNamesForConflictResolution(List)} * @throws Exception if there was an error merging both the maps. */ protected void merge( Element parent, Map dMap, Map rMap ) throws Exception { Set dKeySet = dMap.keySet(); Set rKeySet = rMap.keySet(); // check if there are any entities to merge if ( !isMergeRequired( dKeySet, rKeySet ) ) { return; } // iterate over components and process them for ( Iterator it = dKeySet.iterator(); it.hasNext(); ) { String dKey = (String) it.next(); if ( rMap.containsKey( dKey ) ) { // conflict ! merge this component Mergeable dMeregeable = (Mergeable) dMap.get( dKey ); Mergeable rMergeable = (Mergeable) rMap.get( dKey ); dMeregeable.merge( rMergeable ); // and remove from the recessive list to mark it as merged. rMap.remove( dKey ); } } // check if any unmerged components are left in the recessive map. if ( rMap.keySet().size() > 0 ) { // add them to results for ( Iterator it = rKeySet.iterator(); it.hasNext(); ) { String rKey = (String) it.next(); // add to parent parent.addContent( (Element) ( (Mergeable) rMap.get( rKey ) ).getElement().clone() ); } } } /** * Determines if a merge operation is required for the two sets (dominant and recessive) specified. * * @param dKeySet the dominant set of elements. * @param rKeySet the recessive set of elements. * @return true if a merge operation was required. */ private boolean isMergeRequired( Set dKeySet, Set rKeySet ) { return ( dKeySet.size() > 0 || rKeySet.size() > 0 ); } /** * Allows the sub classes to provided a tag name that they expect to recurr * within them. *

* For instance:
*

* * @return tag name of the {@link Mergeable} element that occurs multiple times. */ protected abstract String getTagNameForRecurringMergeable(); protected abstract List getElementNamesForConflictResolution( List defaultList ); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableSupport.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/AbstractMergeableSupport0000644000175000017500000003742510700073353033466 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.Collection; import java.util.Iterator; import java.util.List; import org.codehaus.plexus.cdc.merge.MergeException; import org.codehaus.plexus.cdc.merge.MergeStrategy; import org.jdom.Attribute; import org.jdom.Content; import org.jdom.Document; import org.jdom.Element; import org.jdom.Namespace; import org.jdom.Parent; import org.jdom.filter.Filter; /** * @author Rahul Thakur * @version $Id: AbstractMergeableSupport.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class AbstractMergeableSupport implements Mergeable { /** * Wrapped JDOM element. */ protected Element element; /** * The default merging strategy used. */ private static final MergeStrategy DEFAULT_MERGE_STRATEGY = MergeStrategies.DEEP; public AbstractMergeableSupport( Element element ) { this.element = element; } public abstract void merge( Mergeable me ) throws MergeException; /** * Determines if the passed in {@link Mergeable} was of same type as this * class. * * @param me {@link Mergeable} instance to test. * @return true if the passed in Mergeable can be merged with * the current Mergeable. */ protected abstract boolean isExpectedElementType( Mergeable me ); // ---------------------------------------------------------------------- // Methods delegated on wrapped JDOM element. // ---------------------------------------------------------------------- public Element addContent( Collection collection ) { return element.addContent( collection ); } public Element addContent( Content child ) { return element.addContent( child ); } public Element addContent( int index, Collection c ) { return element.addContent( index, c ); } public Element addContent( int index, Content child ) { return element.addContent( index, child ); } public Element addContent( String str ) { return element.addContent( str ); } public void addNamespaceDeclaration( Namespace additional ) { element.addNamespaceDeclaration( additional ); } public Object clone() { return element.clone(); } public List cloneContent() { return element.cloneContent(); } public Content detach() { return element.detach(); } public boolean equals( Object obj ) { return element.equals( obj ); } public List getAdditionalNamespaces() { return element.getAdditionalNamespaces(); } public Attribute getAttribute( String name, Namespace ns ) { return element.getAttribute( name, ns ); } public Attribute getAttribute( String name ) { return element.getAttribute( name ); } public List getAttributes() { return element.getAttributes(); } /** * @see org.jdom.Element#getAttributeValue(java.lang.String,org.jdom.Namespace,java.lang.String) */ public String getAttributeValue( String name, Namespace ns, String def ) { return element.getAttributeValue( name, ns, def ); } /** * @see org.jdom.Element#getAttributeValue(java.lang.String,org.jdom.Namespace) */ public String getAttributeValue( String name, Namespace ns ) { return element.getAttributeValue( name, ns ); } /** * @see org.jdom.Element#getAttributeValue(java.lang.String,java.lang.String) */ public String getAttributeValue( String name, String def ) { return element.getAttributeValue( name, def ); } /** * @see org.jdom.Element#getAttributeValue(java.lang.String) */ public String getAttributeValue( String name ) { return element.getAttributeValue( name ); } /** * @return * @see org.jdom.Element#getChild(java.lang.String,org.jdom.Namespace) */ public Element getChild( String name, Namespace ns ) { return element.getChild( name, ns ); } /** * @see org.jdom.Element#getChild(java.lang.String) */ public Element getChild( String name ) { return element.getChild( name ); } /** * @see org.jdom.Element#getChildren() */ public List getChildren() { return element.getChildren(); } /** * @see org.jdom.Element#getChildren(java.lang.String,org.jdom.Namespace) */ public List getChildren( String name, Namespace ns ) { return element.getChildren( name, ns ); } /** * @see org.jdom.Element#getChildren(java.lang.String) */ public List getChildren( String name ) { return element.getChildren( name ); } /** * @see org.jdom.Element#getChildText(java.lang.String,org.jdom.Namespace) */ public String getChildText( String name, Namespace ns ) { return element.getChildText( name, ns ); } /** * @see org.jdom.Element#getChildText(java.lang.String) */ public String getChildText( String name ) { return element.getChildText( name ); } /** * @see org.jdom.Element#getChildTextNormalize(java.lang.String,org.jdom.Namespace) */ public String getChildTextNormalize( String name, Namespace ns ) { return element.getChildTextNormalize( name, ns ); } /** * @see org.jdom.Element#getChildTextNormalize(java.lang.String) */ public String getChildTextNormalize( String name ) { return element.getChildTextNormalize( name ); } /** * @see org.jdom.Element#getChildTextTrim(java.lang.String,org.jdom.Namespace) */ public String getChildTextTrim( String name, Namespace ns ) { return element.getChildTextTrim( name, ns ); } /** * @see org.jdom.Element#getChildTextTrim(java.lang.String) */ public String getChildTextTrim( String name ) { return element.getChildTextTrim( name ); } /** * @see org.jdom.Element#getContent() */ public List getContent() { return element.getContent(); } /** * @see org.jdom.Element#getContent(org.jdom.filter.Filter) */ public List getContent( Filter filter ) { return element.getContent( filter ); } /** * @see org.jdom.Element#getContent(int) */ public Content getContent( int index ) { return element.getContent( index ); } /** * @return * @see org.jdom.Element#getContentSize() */ public int getContentSize() { return element.getContentSize(); } /** * @see org.jdom.Element#getDescendants() */ public Iterator getDescendants() { return element.getDescendants(); } /** * @see org.jdom.Element#getDescendants(org.jdom.filter.Filter) */ public Iterator getDescendants( Filter filter ) { return element.getDescendants( filter ); } /** * @see org.jdom.Content#getDocument() */ public Document getDocument() { return element.getDocument(); } /** * @see org.jdom.Element#getName() */ public String getName() { return element.getName(); } /** * @see org.jdom.Element#getNamespace() */ public Namespace getNamespace() { return element.getNamespace(); } /** * @see org.jdom.Element#getNamespace(java.lang.String) */ public Namespace getNamespace( String prefix ) { return element.getNamespace( prefix ); } /** * @see org.jdom.Element#getNamespacePrefix() */ public String getNamespacePrefix() { return element.getNamespacePrefix(); } /** * @see org.jdom.Element#getNamespaceURI() */ public String getNamespaceURI() { return element.getNamespaceURI(); } /** * @see org.jdom.Content#getParent() */ public Parent getParent() { return element.getParent(); } /** * @see org.jdom.Content#getParentElement() */ public Element getParentElement() { return element.getParentElement(); } /** * @see org.jdom.Element#getQualifiedName() */ public String getQualifiedName() { return element.getQualifiedName(); } /** * @see org.jdom.Element#getText() */ public String getText() { return element.getText(); } /** * @see org.jdom.Element#getTextNormalize() */ public String getTextNormalize() { return element.getTextNormalize(); } /** * @see org.jdom.Element#getTextTrim() */ public String getTextTrim() { return element.getTextTrim(); } /** * @see org.jdom.Element#getValue() */ public String getValue() { return element.getValue(); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return element.hashCode(); } /** * @see org.jdom.Element#indexOf(org.jdom.Content) */ public int indexOf( Content child ) { return element.indexOf( child ); } /** * @see org.jdom.Element#isAncestor(org.jdom.Element) */ public boolean isAncestor( Element element ) { return element.isAncestor( element ); } /** * @see org.jdom.Element#isRootElement() */ public boolean isRootElement() { return element.isRootElement(); } /** * @see org.jdom.Element#removeAttribute(org.jdom.Attribute) */ public boolean removeAttribute( Attribute attribute ) { return element.removeAttribute( attribute ); } /** * @see org.jdom.Element#removeAttribute(java.lang.String,org.jdom.Namespace) */ public boolean removeAttribute( String name, Namespace ns ) { return element.removeAttribute( name, ns ); } /** * @see org.jdom.Element#removeAttribute(java.lang.String) */ public boolean removeAttribute( String name ) { return element.removeAttribute( name ); } /** * @see org.jdom.Element#removeChild(java.lang.String,org.jdom.Namespace) */ public boolean removeChild( String name, Namespace ns ) { return element.removeChild( name, ns ); } /** * @see org.jdom.Element#removeChild(java.lang.String) */ public boolean removeChild( String name ) { return element.removeChild( name ); } /** * @see org.jdom.Element#removeChildren(java.lang.String,org.jdom.Namespace) */ public boolean removeChildren( String name, Namespace ns ) { return element.removeChildren( name, ns ); } /** * @see org.jdom.Element#removeChildren(java.lang.String) */ public boolean removeChildren( String name ) { return element.removeChildren( name ); } /** * @see org.jdom.Element#removeContent() */ public List removeContent() { return element.removeContent(); } /** * @see org.jdom.Element#removeContent(org.jdom.Content) */ public boolean removeContent( Content child ) { return element.removeContent( child ); } /** * @see org.jdom.Element#removeContent(org.jdom.filter.Filter) */ public List removeContent( Filter filter ) { return element.removeContent( filter ); } /** * @see org.jdom.Element#removeContent(int) */ public Content removeContent( int index ) { return element.removeContent( index ); } /** * @see org.jdom.Element#removeNamespaceDeclaration(org.jdom.Namespace) */ public void removeNamespaceDeclaration( Namespace additionalNamespace ) { element.removeNamespaceDeclaration( additionalNamespace ); } /** * @see org.jdom.Element#setAttribute(org.jdom.Attribute) */ public Element setAttribute( Attribute attribute ) { return element.setAttribute( attribute ); } /** * @see org.jdom.Element#setAttribute(java.lang.String,java.lang.String,org.jdom.Namespace) */ public Element setAttribute( String name, String value, Namespace ns ) { return element.setAttribute( name, value, ns ); } /** * @see org.jdom.Element#setAttribute(java.lang.String,java.lang.String) */ public Element setAttribute( String name, String value ) { return element.setAttribute( name, value ); } /** * @see org.jdom.Element#setAttributes(java.util.List) */ public Element setAttributes( List newAttributes ) { return element.setAttributes( newAttributes ); } /** * @see org.jdom.Element#setContent(java.util.Collection) */ public Element setContent( Collection newContent ) { return element.setContent( newContent ); } /** * @see org.jdom.Element#setContent(org.jdom.Content) */ public Element setContent( Content child ) { return element.setContent( child ); } /** * @see org.jdom.Element#setContent(int,java.util.Collection) */ public Parent setContent( int index, Collection collection ) { return element.setContent( index, collection ); } /** * @see org.jdom.Element#setContent(int,org.jdom.Content) */ public Element setContent( int index, Content child ) { return element.setContent( index, child ); } /** * @see org.jdom.Element#setName(java.lang.String) */ public Element setName( String name ) { return element.setName( name ); } /** * @see org.jdom.Element#setNamespace(org.jdom.Namespace) */ public Element setNamespace( Namespace namespace ) { return element.setNamespace( namespace ); } /** * @see org.jdom.Element#setText(java.lang.String) */ public Element setText( String text ) { return element.setText( text ); } /** * @see org.jdom.Element#toString() */ public String toString() { return element.toString(); } /** * Returns the wrapped up JDom {@link Element} instance. */ public Element getElement() { return this.element; } /** * Sub classes should override if they wish to provide a different * combination of composite keys for determining conflicts. */ protected List getElementNamesForConflictResolution( List defaultList ) { return defaultList; } /** * Returns the default {@link MergeStrategy} instance. */ protected MergeStrategy getDefaultMergeStrategy() { return DEFAULT_MERGE_STRATEGY; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/DescriptorTag.java0000644000175000017500000001177210700073353032211 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * ======================================================================== * * Copyright 2003 The Apache Software Foundation. Code from this file * was originally imported from the Jakarta Cactus project. * * Copyright 2004-2006 Vincent Massol. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ======================================================================== */ import java.lang.reflect.Constructor; import org.jdom.Element; /** * Represents the various top-level tags in a deployment descriptor as a typesafe enumeration. * * @version $Id: DescriptorTag.java 6923 2007-10-01 04:26:19Z user57 $ */ public class DescriptorTag { /** * The tag name. */ private String tagName; /** * Whether multiple occurrences of the tag in the descriptor are allowed. */ private boolean multipleAllowed; /** * Class that wraps this tag and provides for merging same tags. */ private Class mergeableClass; /** * Constructor. * * @param tagName The tag name of the element */ public DescriptorTag( String tagName ) { this( tagName, false, null ); } /** * Constructor. * * @param tagName The tag name of the element * @param isMultipleAllowed Whether the element may occur multiple times in the descriptor * @deprecated Use {@link #DescriptorTag(String,boolean,Class)} instead */ public DescriptorTag( String tagName, boolean isMultipleAllowed ) { this( tagName, isMultipleAllowed, null ); } /** * Constructor. * * @param tagName The tag name of the element * @param isMultipleAllowed Whether the element may occur multiple times in the descriptor * @param mergeableClass Concrete implementation of {@link Mergeable} that is bound this tag. */ public DescriptorTag( String tagName, boolean isMultipleAllowed, Class mergeableClass ) { this.tagName = tagName; this.multipleAllowed = isMultipleAllowed; this.mergeableClass = mergeableClass; } public boolean equals( Object other ) { boolean eq = false; if ( other instanceof DescriptorTag ) { DescriptorTag tag = (DescriptorTag) other; if ( tag.getTagName().equals( this.tagName ) ) { eq = true; } } return eq; } public int hashCode() { return this.getTagName().hashCode(); } public String getTagName() { return this.tagName; } /** * Returns whether the tag may occur multiple times in the descriptor. * * @return Whether multiple occurrences are allowed */ public boolean isMultipleAllowed() { return this.multipleAllowed; } /** * Determines if a particular Tag is mergeable or not. *

* Basically means if we have a {@link Mergeable} class registered for a tag instance. * * @return true if this tag is mergeable. */ public boolean isMergeable() { return null != this.mergeableClass; } public String toString() { return getTagName(); } /** * Creates an {@link Mergeable} instance from the registered class for this * tag instance. * * @return instance of {@link Mergeable}. * @throws Exception if there was an error creating an instance. */ public Mergeable createMergeable( Element element ) throws Exception { Constructor cons = this.mergeableClass.getConstructor( new Class[] { Element.class } ); // XXX Is there a better way to determine this? if ( this.mergeableClass.getSuperclass().equals( AbstractMergeableElementList.class ) ) { return (AbstractMergeableElementList) cons.newInstance( new Object[] { element } ); } else if ( this.mergeableClass.getSuperclass().equals( AbstractMergeableElement.class ) ) { return (AbstractMergeableElement) cons.newInstance( new Object[] { element } ); } else { // TODO set up Logger // if (getLogger ().isErrorEnabled ()) // getLogger.error ( "Could not create Mergeable instance for specified class '" + this.mergeableClass + "'" ); throw new Exception( "Could not create Mergeable instance for specified class " + "'" + this.mergeableClass + "'" ); } } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/MergeStrategies.java0000644000175000017500000000617410700073353032531 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.Collections; import java.util.List; import org.codehaus.plexus.cdc.merge.MergeException; import org.codehaus.plexus.cdc.merge.MergeStrategy; /** * Collection of available Merge Strategies.

* TODO: Revisit and factor {@link Mergeable#merge(Mergeable)} to use a {@link MergeStrategy}. * * @author Rahul Thakur * @version $Id: MergeStrategies.java 6923 2007-10-01 04:26:19Z user57 $ */ public class MergeStrategies { /** * {@link MergeStrategy} implementation wherein the elements are merged * down to the deepest available {@link Mergeable} instance in the DOM tree. */ public static final MergeStrategy DEEP = new MergeStrategy() { public void apply( Mergeable dElt, Mergeable rElt ) throws MergeException { dElt.merge( rElt ); } }; /** * {@link MergeStrategy} implementation wherein only the element on * which the merge operation is called is 'merged'. The merge does not * traverse the DOM tree any further. */ public static final MergeStrategy SHALLOW = new MergeStrategy() { /** * @throws MergeException * @see org.codehaus.plexus.cdc.merge.MergeStrategy#apply(Mergeable,Mergeable) */ public void apply( Mergeable dElt, Mergeable rElt ) throws MergeException { AbstractMergeableElement dame = (AbstractMergeableElement) dElt; AbstractMergeableElement rame = (AbstractMergeableElement) rElt; // check if the dominant was in conflict with recessive. List elementNames = dame.getElementNamesForConflictResolution( Collections.EMPTY_LIST ); if ( !dame.isRecessiveElementInConflict( rame, elementNames ) ) { // no conflict, simply add recessive to dominant's parent dame.getElement().addContent( rame.getElement() ); } } }; } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/RequirementElement.java0000644000175000017500000000405510455207755033261 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.cdc.merge.MergeException; import org.jdom.Element; /** * @author Rahul Thakur * @version $Id: RequirementElement.java 3522 2006-07-12 15:06:21Z brett $ */ public class RequirementElement extends AbstractMergeableElement { static final DescriptorTag TAG = new DescriptorTag( "requirement", true, RequirementElement.class ); public RequirementElement( Element element ) { super( element ); } public DescriptorTag[] getAllowedTags() { return new DescriptorTag[]{ComponentElement.ROLE, ComponentElement.ROLE_HINT, ComponentElement.FIELD_NAME}; } public void merge( Mergeable me ) throws MergeException { super.merge( me ); } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof RequirementElement; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/ComponentElement.java0000644000175000017500000000532710533627076032725 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.jdom.Element; /** * @author Rahul Thakur * @version $Id: ComponentElement.java 4918 2006-11-30 19:17:18Z rahul $ */ public class ComponentElement extends AbstractMergeableElement { /** * Allowed elements/tags that we can expect under this element. */ private final DescriptorTag[] allowedTags = { ROLE, ROLE_HINT, IMPLEMENTATION, FIELD_NAME, LIFECYCLE_HANDLER, DESCRIPTION, CONFIGURATION, RequirementsElement.TAG }; static final DescriptorTag TAG = new DescriptorTag( "component", true, ComponentElement.class ); static final DescriptorTag ROLE = new DescriptorTag( "role" ); static final DescriptorTag ROLE_HINT = new DescriptorTag( "role-hint" ); private static final DescriptorTag DESCRIPTION = new DescriptorTag( "description" ); private static final DescriptorTag CONFIGURATION = new DescriptorTag( "configuration" ); static final DescriptorTag FIELD_NAME = new DescriptorTag( "field-name" ); private static final DescriptorTag IMPLEMENTATION = new DescriptorTag( "implementation" ); private static final DescriptorTag LIFECYCLE_HANDLER = new DescriptorTag( "lifecycle-handler", false, null ); public ComponentElement( Element element ) { super( element ); } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof ComponentElement; } public DescriptorTag[] getAllowedTags() { return allowedTags; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/RequirementsElement.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/RequirementsElement.java0000644000175000017500000000475110700073353033433 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.ArrayList; import java.util.List; import org.jdom.Element; /** * @author Rahul Thakur * @version $Id: RequirementsElement.java 6923 2007-10-01 04:26:19Z user57 $ */ public class RequirementsElement extends AbstractMergeableElementList { public static final DescriptorTag TAG = new DescriptorTag( "requirements", true, RequirementsElement.class ); public RequirementsElement( Element element ) { super( element ); } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof RequirementsElement; } public DescriptorTag[] getAllowedTags() { return new DescriptorTag[]{RequirementElement.TAG}; } protected List getElementNamesForConflictResolution( List defaultList ) { // we return the keys that we know we want to lookup to identify and // resolve conflicts. List l = new ArrayList(); l.add( ComponentElement.ROLE.getTagName() ); // TODO: add this back, but a test will fail (based on a role with no hint, which shouldn't be legal) // l.add( ComponentElement.ROLE_HINT.getTagName() ); return l; } protected String getTagNameForRecurringMergeable() { return RequirementElement.TAG.getTagName(); } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/PlexusXmlTag.java0000644000175000017500000000471410455207755032046 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /** * All allowable tags in components.xml and their bindings to * {@link org.codehaus.plexus.cdc.merge.support.Mergeable} counterparts (if required). *

* This implementation may change.
* TODO Might be an idea factor and set up the list of allowed tags here itself. * * @author Rahul Thakur * @version $Id: PlexusXmlTag.java 3522 2006-07-12 15:06:21Z brett $ */ public class PlexusXmlTag extends DescriptorTag { public static final PlexusXmlTag COMPONENT_SET = new PlexusXmlTag( "component-set", false, ComponentSetElement.class ); public static final PlexusXmlTag COMPONENTS = new PlexusXmlTag( "components", true, ComponentsElement.class ); public static final PlexusXmlTag COMPONENT = new PlexusXmlTag( "component", true, ComponentElement.class ); public static final PlexusXmlTag ROLE = new PlexusXmlTag( "role" ); public static final PlexusXmlTag ROLE_HINT = new PlexusXmlTag( "role-hint" ); public static final PlexusXmlTag FIELD_NAME = new PlexusXmlTag( "field-name" ); public static final PlexusXmlTag IMPLEMENTATION = new PlexusXmlTag( "implementation" ); public static final PlexusXmlTag LIFECYCLE_HANDLER = new PlexusXmlTag( "lifecycle-handler", false, null ); public static final PlexusXmlTag REQUIREMENTS = new PlexusXmlTag( "requirements", true, RequirementsElement.class ); public static final PlexusXmlTag CONFIGURATION = new PlexusXmlTag( "configuration", true, ConfigurationElement.class ); public static final PlexusXmlTag REQUIREMENT = new PlexusXmlTag( "requirement", true, RequirementElement.class ); /** * @param tagName * @param isMultipleAllowed * @param mergeableClass Class that wraps this tag (as JDom element) and provides for merging same tags. */ private PlexusXmlTag( String tagName, boolean isMultipleAllowed, Class mergeableClass ) { super( tagName, isMultipleAllowed, mergeableClass ); } /** * By default we don't allow multiples of same tag names. * * @param tagName */ private PlexusXmlTag( String tagName ) { super( tagName, false, null ); } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/support/PlexusRootElement.java0000644000175000017500000000341410455207755033103 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge.support; /* * The MIT License * * Copyright (c) 2006, 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.jdom.Element; /** * @author Rahul Thakur * @version $Id: PlexusRootElement.java 3522 2006-07-12 15:06:21Z brett $ */ public class PlexusRootElement extends AbstractMergeableElement { public PlexusRootElement( Element element ) { super( element ); } public DescriptorTag[] getAllowedTags() { // TODO: add the managers, etc return new DescriptorTag[]{ComponentsElement.TAG}; } protected boolean isExpectedElementType( Mergeable me ) { return me instanceof PlexusRootElement; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/Merger.java0000644000175000017500000000433310700073353027137 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.io.File; import java.io.IOException; import org.jdom.Document; /** * @author Rahul Thakur * @version $Id: Merger.java 6923 2007-10-01 04:26:19Z user57 $ */ public interface Merger { String ROLE = Merger.class.getName(); /** * Merge with the recessive document. * * @param dDocument the dominant document. * @param rDocument the recessive document. * @return the merged {@link Document} instance. * * @throws MergeException if there was an error in merge. */ Document merge( Document dDocument, Document rDocument ) throws MergeException; /** * Allows writing out a merged JDom Document to the specified file. * * @param mergedDocument the merged {@link Document} instance. * @param file File to write the merged contents to. * @throws IOException if there was an error while writing merged contents to the specified file. */ void writeMergedDocument( Document mergedDocument, File file ) throws IOException; } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/PlexusXmlMerger.java0000644000175000017500000000446010640450741031025 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, 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.cdc.merge.support.PlexusRootElement; import org.jdom.Document; /** * Plexus XML merger. This is a superset of the components xml merger so can be used in its place if necessary. * * @author Rahul Thakur * @version $Id: PlexusXmlMerger.java 6564 2007-06-27 12:02:41Z kenney $ */ public class PlexusXmlMerger extends AbstractMerger { /** * @see org.codehaus.plexus.cdc.merge.Merger#merge(org.jdom.Document, org.jdom.Document) */ public Document merge( Document dDocument, Document rDocument ) throws MergeException { // TODO: Ideally we don't want to manipulate the original // dominant document but use its copy for merge. //Document mDoc = (Document) dDocument.clone(); // doesn't merge properly Document mDoc = dDocument; PlexusRootElement dCSE = new PlexusRootElement( mDoc.getRootElement() ); PlexusRootElement rCSE = new PlexusRootElement( rDocument.getRootElement() ); dCSE.merge( rCSE ); // the contents are merged into the dominant document DOM. return mDoc; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/MergeStrategy.java0000644000175000017500000000334510447070020030476 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, 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.cdc.merge.support.Mergeable; /** * @author Rahul Thakur * @version $Id: MergeStrategy.java 3422 2006-06-23 22:49:52Z trygvis $ */ public interface MergeStrategy { /** * Merges a dominant {@link Mergeable} instance with a recessive one. * * @param dElt Dominant {@link Mergeable} instance. * @param rElt Recessive {@link Mergeable} instance. * @throws MergeException TODO */ void apply( Mergeable dElt, Mergeable rElt ) throws MergeException; } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/ComponentsXmlMerger.java0000644000175000017500000000423710640450741031674 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, 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.cdc.merge.support.ComponentSetElement; import org.jdom.Document; /** * @author Rahul Thakur * @version $Id: ComponentsXmlMerger.java 6564 2007-06-27 12:02:41Z kenney $ */ public class ComponentsXmlMerger extends AbstractMerger { /** * @see Merger#merge(Document, Document) */ public Document merge( Document dDocument, Document rDocument ) throws MergeException { // TODO: Ideally we don't want to manipulate the original // dominant document but use its copy for merge. //Document mDoc = (Document) dDocument.clone(); // doesn't merge properly Document mDoc = dDocument; ComponentSetElement dCSE = new ComponentSetElement( mDoc.getRootElement() ); ComponentSetElement rCSE = new ComponentSetElement( rDocument.getRootElement() ); dCSE.merge( rCSE ); // the contents are merged into the dominant document DOM. return mDoc; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/AbstractMerger.java0000644000175000017500000000413310700073353030621 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.io.File; import java.io.FileWriter; import java.io.IOException; import org.codehaus.plexus.util.IOUtil; import org.jdom.Document; import org.jdom.output.XMLOutputter; /** * Base class for common mergers. * * @author Brett Porter */ public abstract class AbstractMerger implements Merger { /** * @see org.codehaus.plexus.cdc.merge.Merger#writeMergedDocument(org.jdom.Document, java.io.File) */ public void writeMergedDocument( Document mergedDocument, File file ) throws IOException { if ( !file.getParentFile().exists() ) { file.getParentFile().mkdirs(); } XMLOutputter out = new XMLOutputter(); FileWriter fw = null; try { fw = new FileWriter( file ); out.output( mergedDocument, fw ); } finally { IOUtil.close( fw ); } } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/merge/MergeException.java0000644000175000017500000000305210447070020030625 0ustar twernertwernerpackage org.codehaus.plexus.cdc.merge; /* * The MIT License * * Copyright (c) 2006, 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 Rahul Thakur * @version $Id: MergeException.java 3422 2006-06-23 22:49:52Z trygvis $ */ public class MergeException extends Exception { public MergeException( String message, Throwable cause ) { super( message, cause ); } public MergeException( String message ) { super( message ); } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/0000755000175000017500000000000011117672311025370 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/ComponentGleanerException.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/ComponentGleanerException.java0000644000175000017500000000326210700073353033353 0ustar twernertwernerpackage org.codehaus.plexus.cdc.gleaner; /* * 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: ComponentGleanerException.java 6923 2007-10-01 04:26:19Z user57 $ */ public class ComponentGleanerException extends Exception { public ComponentGleanerException( String message ) { super( message ); } public ComponentGleanerException( String message, Throwable cause ) { super( message, cause ); } public ComponentGleanerException( Throwable cause ) { super( cause ); } }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/SourceComponentGleaner.java0000644000175000017500000000237010700073353032654 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaClassCache; import org.codehaus.plexus.cdc.gleaner.ComponentGleanerException; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; /** * Interface for component gleaners which glean off of source code. * * @version $Id: SourceComponentGleaner.java 6923 2007-10-01 04:26:19Z user57 $ */ public interface SourceComponentGleaner { String ROLE = SourceComponentGleaner.class.getName(); ComponentDescriptor glean(JavaClassCache classCache, JavaClass javaClass) throws ComponentGleanerException; }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/ClassComponentGleaner.java0000644000175000017500000000216610700073353032464 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; import org.codehaus.plexus.cdc.gleaner.ComponentGleanerException; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; /** * Interface for component gleaners which glean off of compiled classes.. * * @version $Id: ClassComponentGleaner.java 6923 2007-10-01 04:26:19Z user57 $ */ public interface ClassComponentGleaner { String ROLE = ClassComponentGleaner.class.getName(); ComponentDescriptor glean(Class type) throws ComponentGleanerException; }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/QDoxComponentGleaner.java0000644000175000017500000004660010715477763032316 0ustar twernertwernerpackage org.codehaus.plexus.cdc.gleaner; /* * 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.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import com.thoughtworks.qdox.model.DocletTag; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaClassCache; import com.thoughtworks.qdox.model.JavaField; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.component.repository.cdc.ComponentRequirement; import org.codehaus.plexus.component.repository.cdc.ComponentRequirementList; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.LogEnabled; 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.Disposable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Suspendable; import org.codehaus.plexus.util.StringUtils; /** * A source component gleaner which uses QDox to discover Javadoc annotations. * * @author Trygve Laugstøl * @version $Id: QDoxComponentGleaner.java 7051 2007-11-11 04:07:15Z jvanzyl $ */ public class QDoxComponentGleaner extends ComponentGleanerSupport implements SourceComponentGleaner { public static final String PLEXUS_COMPONENT_TAG = "plexus.component"; public static final String PLEXUS_REQUIREMENT_TAG = "plexus.requirement"; public static final String PLEXUS_CONFIGURATION_TAG = "plexus.configuration"; public static final String PLEXUS_VERSION_PARAMETER = "version"; public static final String PLEXUS_ROLE_PARAMETER = "role"; public static final String PLEXUS_ROLE_HINT_PARAMETER = "role-hint"; public static final String PLEXUS_ROLE_HINT_LIST_PARAMETER = "role-hints"; public static final String PLEXUS_ALIAS_PARAMETER = "alias"; public static final String PLEXUS_DEFAULT_VALUE_PARAMETER = "default-value"; public static final String PLEXUS_LIFECYCLE_HANDLER_PARAMETER = "lifecycle-handler"; public static final String PLEXUS_INSTANTIATION_STARTEGY_PARAMETER = "instantiation-strategy"; // XXX This is a duplicate of the constant in PlexusConstants, as we do not want to be tied to a // particular container API public static final String PLEXUS_DEFAULT_HINT = "default"; // ---------------------------------------------------------------------- // ComponentGleaner Implementation // ---------------------------------------------------------------------- public ComponentDescriptor glean( JavaClassCache classCache, JavaClass javaClass ) throws ComponentGleanerException { DocletTag tag = javaClass.getTagByName( PLEXUS_COMPONENT_TAG ); if ( tag == null ) { return null; } Map parameters = tag.getNamedParameterMap(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- String fqn = javaClass.getFullyQualifiedName(); log.debug( "Creating descriptor for component: {}", fqn ); ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setImplementation( fqn ); // ---------------------------------------------------------------------- // Role // ---------------------------------------------------------------------- String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER ); if ( role == null ) { role = findRole( javaClass ); if ( role == null ) { log.warn( "Could not figure out a role for the component '" + fqn + "'. " + "Please specify a role with a parameter '" + PLEXUS_ROLE_PARAMETER + "' " + "on the @" + PLEXUS_COMPONENT_TAG + " tag." ); return null; } } componentDescriptor.setRole( role ); // ---------------------------------------------------------------------- // Role hint // ---------------------------------------------------------------------- String roleHint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER ); if ( roleHint != null ) { // getLogger().debug( " Role hint: " + roleHint ); } componentDescriptor.setRoleHint( roleHint ); // ---------------------------------------------------------------------- // Version // ---------------------------------------------------------------------- String version = getParameter( parameters, PLEXUS_VERSION_PARAMETER ); componentDescriptor.setVersion( version ); // ---------------------------------------------------------------------- // Lifecycle handler // ---------------------------------------------------------------------- String lifecycleHandler = getParameter( parameters, PLEXUS_LIFECYCLE_HANDLER_PARAMETER ); componentDescriptor.setLifecycleHandler( lifecycleHandler ); // ---------------------------------------------------------------------- // Lifecycle handler // ---------------------------------------------------------------------- String instatiationStrategy = getParameter( parameters, PLEXUS_INSTANTIATION_STARTEGY_PARAMETER ); componentDescriptor.setInstantiationStrategy( instatiationStrategy ); // ---------------------------------------------------------------------- // Alias // ---------------------------------------------------------------------- componentDescriptor.setAlias( getParameter( parameters, PLEXUS_ALIAS_PARAMETER ) ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- findExtraParameters( PLEXUS_COMPONENT_TAG, parameters ); // ---------------------------------------------------------------------- // Requirements // ---------------------------------------------------------------------- findRequirements( classCache, componentDescriptor, javaClass ); // ---------------------------------------------------------------------- // Description // ---------------------------------------------------------------------- String comment = javaClass.getComment(); if ( comment != null ) { int i = comment.indexOf( '.' ); if ( i > 0 ) { comment = comment.substring( 0, i + 1 ); // include the dot } } componentDescriptor.setDescription( comment ); // ---------------------------------------------------------------------- // Configuration // ---------------------------------------------------------------------- XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( "configuration" ); findConfiguration( configuration, javaClass ); componentDescriptor.setConfiguration( configuration ); return componentDescriptor; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private final static List IGNORED_INTERFACES = Collections.unmodifiableList( Arrays.asList( new String[]{ LogEnabled.class.getName(), Initializable.class.getName(), Configurable.class.getName(), Contextualizable.class.getName(), Disposable.class.getName(), Startable.class.getName(), Suspendable.class.getName(), Serviceable.class.getName(), } ) ); private String findRole( JavaClass javaClass ) { // ---------------------------------------------------------------------- // Remove any Plexus specific interfaces from the calculation // ---------------------------------------------------------------------- List interfaces = new ArrayList( Arrays.asList( javaClass.getImplementedInterfaces() ) ); for ( Iterator it = interfaces.iterator(); it.hasNext(); ) { JavaClass ifc = (JavaClass) it.next(); if ( IGNORED_INTERFACES.contains( ifc.getFullyQualifiedName() ) ) { it.remove(); } } // ---------------------------------------------------------------------- // For each implemented interface, check to see if it's a candiate // interface // ---------------------------------------------------------------------- String role = null; String className = javaClass.getName(); for ( Iterator it = interfaces.iterator(); it.hasNext(); ) { JavaClass ifc = (JavaClass) it.next(); String fqn = ifc.getFullyQualifiedName(); String pkg = ifc.getPackage(); if ( pkg == null ) { int index = fqn.lastIndexOf( '.' ); if ( index == -1 ) { // ----------------------------------------------------------------------- // This is a special case which will happen in two cases: // 1) The component is in the default/root package // 2) The interface is in another build, typically in an -api package // while the code beeing gleaned in in the -impl build. // // Since it's most likely in another package than in the default package // prepend the gleaned class' package // ----------------------------------------------------------------------- pkg = javaClass.getPackage(); fqn = pkg + "." + fqn; } else { pkg = fqn.substring( 0, index ); } } if ( fqn == null ) { fqn = ifc.getName(); } String name = fqn.substring( pkg.length() + 1 ); if ( className.endsWith( name ) ) { if ( role != null ) { log.warn( "Found several possible roles for component " + "'" + javaClass.getFullyQualifiedName() + "', " + "will use '" + role + "', found: " + ifc.getName() + "." ); } role = fqn; } } if ( role == null ) { JavaClass superClass = javaClass.getSuperJavaClass(); if ( superClass != null ) { role = findRole( superClass ); } } return role; } private void findRequirements( JavaClassCache classCache, ComponentDescriptor componentDescriptor, JavaClass javaClass ) { JavaField[] fields = javaClass.getFields(); // ---------------------------------------------------------------------- // Search the super class for requirements // ---------------------------------------------------------------------- if ( javaClass.getSuperJavaClass() != null ) { findRequirements( classCache, componentDescriptor, javaClass.getSuperJavaClass() ); } // ---------------------------------------------------------------------- // Search the current class for requirements // ---------------------------------------------------------------------- for ( int i = 0; i < fields.length; i++ ) { JavaField field = fields[i]; DocletTag tag = field.getTagByName( PLEXUS_REQUIREMENT_TAG ); if ( tag == null ) { continue; } Map parameters = new HashMap( tag.getNamedParameterMap() ); // ---------------------------------------------------------------------- // Role // ---------------------------------------------------------------------- String requirementClass = field.getType().getJavaClass().getFullyQualifiedName(); boolean isMap = requirementClass.equals( Map.class.getName() ) || requirementClass.equals( Collection.class.getName() ); try { isMap = isMap || Collection.class.isAssignableFrom( Class.forName( requirementClass ) ); } catch ( ClassNotFoundException e ) { // ignore the assignable Collection test, though this should never happen } boolean isList = requirementClass.equals( List.class.getName() ); ComponentRequirement cr; String hint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER ); if ( isMap || isList ) { cr = new ComponentRequirementList(); String hintList = getParameter( parameters, PLEXUS_ROLE_HINT_LIST_PARAMETER ); if ( hintList != null ) { String[] hintArr = hintList.split( "," ); ( (ComponentRequirementList) cr).setRoleHints( Arrays.asList( hintArr ) ); } } else { cr = new ComponentRequirement(); cr.setRoleHint( hint ); } String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER ); if ( role == null ) { cr.setRole( requirementClass ); } else { cr.setRole( role ); } cr.setFieldName( field.getName() ); if ( isMap || isList ) { if ( hint != null ) { log.warn( "Field: '" + field.getName() + "': A role hint cannot be specified if the " + "field is a java.util.Map or a java.util.List" ); continue; } if ( role == null ) { log.warn( "Field: '" + field.getName() + "': A java.util.Map or java.util.List " + "requirement has to specify a '" + PLEXUS_ROLE_PARAMETER + "' parameter on " + "the @" + PLEXUS_REQUIREMENT_TAG + " tag so Plexus can know which components to " + "put in the map or list." ); continue; } JavaClass roleClass = classCache.getClassByName( role ); if ( role.indexOf( '.' ) == -1 && StringUtils.isEmpty( roleClass.getPackage() ) ) { role = javaClass.getPackage() + "." + roleClass.getName(); } cr.setRole( role ); findExtraParameters( PLEXUS_REQUIREMENT_TAG, parameters ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- componentDescriptor.addRequirement( cr ); } } private void findConfiguration( XmlPlexusConfiguration configuration, JavaClass javaClass ) throws ComponentGleanerException { JavaField[] fields = javaClass.getFields(); // ---------------------------------------------------------------------- // Search the super class for configurable fields. // ---------------------------------------------------------------------- if ( javaClass.getSuperJavaClass() != null ) { findConfiguration( configuration, javaClass.getSuperJavaClass() ); } // ---------------------------------------------------------------------- // Search the current class for configurable fields. // ---------------------------------------------------------------------- for ( int i = 0; i < fields.length; i++ ) { JavaField field = fields[i]; DocletTag tag = field.getTagByName( PLEXUS_CONFIGURATION_TAG ); if ( tag == null ) { continue; } Map parameters = new HashMap( tag.getNamedParameterMap() ); /* don't use the getParameter helper as we like empty strings */ String defaultValue = (String) parameters.remove( PLEXUS_DEFAULT_VALUE_PARAMETER ); if ( defaultValue == null ) { log.warn( "Component: " + javaClass.getName() + ", field name: '" + field.getName() + "': " + "Currently configurable fields will not be written to the descriptor " + "without a default value." ); continue; } String name = deHump( field.getName() ); XmlPlexusConfiguration c; c = new XmlPlexusConfiguration( name ); c.setValue( defaultValue ); log.debug( " Configuration: {}={}", name, defaultValue ); configuration.addChild( c ); findExtraParameters( PLEXUS_CONFIGURATION_TAG, parameters ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void findExtraParameters( String tagName, Map parameters ) { for ( Iterator it = parameters.keySet().iterator(); it.hasNext(); ) { String s = (String) it.next(); log.warn( "Extra parameter on the '" + tagName + "' tag: '" + s + "'." ); } } private String getParameter( Map parameters, String parameter ) { String value = (String) parameters.remove( parameter ); if ( StringUtils.isEmpty( value ) ) { return null; } return value; } }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/gleaner/ComponentGleanerSupport.java0000644000175000017500000000476510700073353033102 0ustar twernertwerner/* * Copyright (C) 2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.cdc.gleaner; import java.util.Collection; import java.util.Map; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Support for component gleaner implementations. * * @version $Id: ComponentGleanerSupport.java 6923 2007-10-01 04:26:19Z user57 $ */ public abstract class ComponentGleanerSupport { private static final String EMPTY_STRING = ""; protected final Logger log = LoggerFactory.getLogger(getClass()); protected String filterEmptyAsNull(final String value) { if (value == null) { return null; } else if (EMPTY_STRING.equals(value.trim())) { return null; } else { return value; } } protected boolean isRequirementListType(final Class type) { // assert type != null; return Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type); } protected void addChildConfiguration(final ComponentDescriptor component, final PlexusConfiguration config) { // assert component != null; // assert config != null; if (!component.hasConfiguration()) { component.setConfiguration(new XmlPlexusConfiguration("configuration")); } component.getConfiguration().addChild(config); } protected String deHump(final String string) { // assert string != null; StringBuffer buff = new StringBuffer(); for (int i = 0; i < string.length(); i++) { if (i != 0 && Character.isUpperCase(string.charAt(i))) { buff.append('-'); } buff.append(string.charAt(i)); } return buff.toString().trim().toLowerCase(); } }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentGleaner.java0000644000175000017500000000351010700073353030053 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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 com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaClassCache; import org.codehaus.plexus.cdc.gleaner.SourceComponentGleaner; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; /** * @author Jason van Zyl * @version $Id: ComponentGleaner.java 6923 2007-10-01 04:26:19Z user57 $ * * @deprecated Use {#link ClassComponentGleaner} and {@link SourceComponentGleaner}. */ public interface ComponentGleaner { String ROLE = ComponentGleaner.class.getName(); ComponentDescriptor glean( JavaClassCache classCache, JavaClass javaClass ) throws ComponentDescriptorCreatorException; } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorCreatorException.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorCreatorException.ja0000644000175000017500000000326210700073353033470 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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: ComponentDescriptorCreatorException.java 6923 2007-10-01 04:26:19Z user57 $ * * @deprecated Use {#link ComponentDescriptorExtractor}. */ public class ComponentDescriptorCreatorException extends Exception { public ComponentDescriptorCreatorException( String message ) { super( message ); } public ComponentDescriptorCreatorException( String message, Throwable cause ) { super( message, cause ); } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/DefaultComponentDescriptorWriter.java0000644000175000017500000002234110715477763033344 0ustar twernertwerner/* * The MIT License * * Copyright (c) 2007, 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. */ package org.codehaus.plexus.cdc; import java.io.IOException; import java.io.Writer; import java.util.Iterator; import java.util.List; import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.component.repository.cdc.ComponentRequirement; import org.codehaus.plexus.component.repository.cdc.ComponentRequirementList; import org.codehaus.plexus.component.repository.cdc.ComponentSetDescriptor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; import org.codehaus.plexus.util.xml.XMLWriter; /** * Serializes a {@link ComponentSetDescriptor}. * * @author Kenney Westerhof * @author Jason van Zyl * @author Trygve Laugstøl */ public class DefaultComponentDescriptorWriter implements ComponentDescriptorWriter { private static final String LS = System.getProperty( "line.separator" ); public void writeDescriptorSet( Writer writer, ComponentSetDescriptor componentSetDescriptor, boolean containerDescriptor ) throws ComponentDescriptorWriteException, IOException { try { XMLWriter w = new PrettyPrintXMLWriter( writer ); w.startElement( containerDescriptor ? "plexus" : "component-set" ); writeComponents( w, componentSetDescriptor.getComponents() ); writeDependencies( w, componentSetDescriptor.getDependencies() ); w.endElement(); writer.write( LS ); // Flush, but don't close the writer... we are not its owner writer.flush(); } catch ( PlexusConfigurationException e ) { throw new ComponentDescriptorWriteException( "Internal error while writing out the configuration", e ); } } private void writeComponents( XMLWriter w, List componentDescriptors ) throws ComponentDescriptorWriteException, PlexusConfigurationException { if ( componentDescriptors == null ) { return; } w.startElement( "components" ); for ( Iterator i = componentDescriptors.iterator(); i.hasNext(); ) { w.startElement( "component" ); ComponentDescriptor cd = (ComponentDescriptor) i.next(); element( w, "role", cd.getRole() ); element( w, "role-hint", cd.getRoleHint() ); element( w, "implementation", cd.getImplementation() ); element( w, "version", cd.getVersion() ); element( w, "component-type", cd.getComponentType() ); element( w, "instantiation-strategy", cd.getInstantiationStrategy() ); element( w, "lifecycle-handler", cd.getLifecycleHandler() ); element( w, "component-profile", cd.getComponentProfile() ); element( w, "component-composer", cd.getComponentComposer() ); element( w, "component-configurator", cd.getComponentConfigurator() ); element( w, "component-factory", cd.getComponentFactory() ); element( w, "description", cd.getDescription() ); element( w, "alias", cd.getAlias() ); element( w, "isolated-realm", Boolean.toString(cd.isIsolatedRealm()) ); writeRequirements( w, cd.getRequirements() ); writeConfiguration( w, cd.getConfiguration() ); w.endElement(); } w.endElement(); } public void writeDependencies( XMLWriter w, List deps ) { if ( deps == null || deps.size() == 0 ) { return; } w.startElement( "dependencies" ); for ( int i = 0; i < deps.size(); i++ ) { writeDependencyElement( (ComponentDependency) deps.get( i ), w ); } w.endElement(); } private void writeDependencyElement( ComponentDependency dependency, XMLWriter w ) { w.startElement( "dependency" ); String groupId = dependency.getGroupId(); element( w, "groupId", groupId ); String artifactId = dependency.getArtifactId(); element( w, "artifactId", artifactId ); String type = dependency.getType(); if ( type != null ) { element( w, "type", type ); } String version = dependency.getVersion(); element( w, "version", version ); w.endElement(); } private void writeRequirements( XMLWriter w, List requirements ) { if ( requirements == null || requirements.size() == 0 ) { return; } w.startElement( "requirements" ); for ( Iterator j = requirements.iterator(); j.hasNext(); ) { ComponentRequirement cr = (ComponentRequirement) j.next(); w.startElement( "requirement" ); element( w, "role", cr.getRole() ); if ( cr instanceof ComponentRequirementList ) { List hints = ( (ComponentRequirementList) cr ).getRoleHints(); if ( hints != null ) { w.startElement( "role-hints" ); for ( Iterator k = hints.iterator(); k.hasNext(); ) { String roleHint = (String) k.next(); w.startElement( "role-hint" ); w.writeText( roleHint ); w.endElement(); } w.endElement(); } } else { element( w, "role-hint", cr.getRoleHint() ); } element( w, "field-name", cr.getFieldName() ); w.endElement(); } w.endElement(); } private void writeConfiguration( XMLWriter w, PlexusConfiguration configuration ) throws ComponentDescriptorWriteException, PlexusConfigurationException { if ( configuration == null || configuration.getChildCount() == 0 ) { return; } if ( !configuration.getName().equals( "configuration" ) ) { throw new ComponentDescriptorWriteException( "The root node of the configuration must be 'configuration'."); } writePlexusConfiguration( w, configuration ); } private void writePlexusConfiguration( XMLWriter xmlWriter, PlexusConfiguration c ) throws PlexusConfigurationException { if ( c.getAttributeNames().length == 0 && c.getChildCount() == 0 && c.getValue() == null ) { return; } xmlWriter.startElement( c.getName() ); // ---------------------------------------------------------------------- // Write the attributes // ---------------------------------------------------------------------- String[] attributeNames = c.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; xmlWriter.addAttribute( attributeName, c.getAttribute( attributeName ) ); } // ---------------------------------------------------------------------- // Write the children // ---------------------------------------------------------------------- PlexusConfiguration[] children = c.getChildren(); if ( children.length > 0 ) { for ( int i = 0; i < children.length; i++ ) { writePlexusConfiguration( xmlWriter, children[i] ); } } else { String value = c.getValue(); if ( value != null ) { xmlWriter.writeText( value ); } } xmlWriter.endElement(); } private void element( XMLWriter w, String name, String value ) { if ( value == null ) { return; } w.startElement( name ); w.writeText( value ); w.endElement(); } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorCreator.java0000644000175000017500000000412310700073353032135 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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 org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: ComponentDescriptorCreator.java 6923 2007-10-01 04:26:19Z user57 $ * * @deprecated Use {#link ComponentDescriptorExtractor}. */ public interface ComponentDescriptorCreator { String ROLE = ComponentDescriptorCreator.class.getName(); void processSources( File[] sourceDirectories, File outputDirectory ) throws ComponentDescriptorCreatorException; void processSources( File[] sourceDirectories, File outputDirectory, boolean containerDescriptor, ComponentDescriptor[] roleDefaults ) throws ComponentDescriptorCreatorException; void mergeDescriptors( File outputDescriptor, List descriptors ) throws ComponentDescriptorCreatorException; } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/DefaultComponentDescriptorCreator.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/DefaultComponentDescriptorCreator.java0000644000175000017500000003407610777433450033470 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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 com.thoughtworks.qdox.JavaDocBuilder; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaSource; import org.codehaus.plexus.cdc.merge.MergeException; import org.codehaus.plexus.cdc.merge.Merger; import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.component.repository.cdc.ComponentRequirement; import org.codehaus.plexus.component.repository.cdc.ComponentSetDescriptor; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XMLWriter; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * So, in this case it is easy enough to determine the role and the implementation. * We could also employ some secondary checks like looking for particular super classes * or whatever. We can always use the @tags to be explicit but in most cases we can * probably determine the correct component descriptor without requiring @tags. * * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: DefaultComponentDescriptorCreator.java 7273 2008-04-10 15:50:00Z brett $ * @todo glean configuration information from types of the parameters but also * allow OCL type constraints for validation. We'll hook in something simple like * regex as for most cases I think some simple regex could catch most problems. I * don't want to have to use MSV or something like that which which triple the size * of a deployment. *

* This is for a single project with a single POM, multiple components * with all deps in the POM. * * @deprecated Use {#link ComponentDescriptorExtractor}. */ public class DefaultComponentDescriptorCreator extends AbstractLogEnabled implements ComponentDescriptorCreator { private List gleaners; private Merger merger; private ComponentDescriptorWriter writer; // ---------------------------------------------------------------------- // ComponentDescriptorCreator Implementation // ---------------------------------------------------------------------- public void processSources( File[] sourceDirectories, File outputFile ) throws ComponentDescriptorCreatorException { processSources( sourceDirectories, outputFile, false, new ComponentDescriptor[0] ); } public void processSources( File[] sourceDirectories, File outputFile, boolean containerDescriptor, ComponentDescriptor[] roleDefaults ) throws ComponentDescriptorCreatorException { // ---------------------------------------------------------------------- // Check and register all directories to scan // ---------------------------------------------------------------------- JavaSource[] javaSources; JavaDocBuilder builder = new JavaDocBuilder(); getLogger().debug( "Source directories: " ); for ( int it = 0; it < sourceDirectories.length; it++ ) { File sourceDirectory = sourceDirectories[it]; if ( !sourceDirectory.isDirectory() ) { getLogger().debug( "Specified source directory isn't a directory: " + "'" + sourceDirectory.getAbsolutePath() + "'." ); } getLogger().debug( " - " + sourceDirectory.getAbsolutePath() ); builder.addSourceTree( sourceDirectory ); } // ---------------------------------------------------------------------- // Scan the sources // ---------------------------------------------------------------------- javaSources = builder.getSources(); Map defaultsByRole = new HashMap(); if ( roleDefaults != null ) { for ( int i = 0; i < roleDefaults.length; i++ ) { // TODO: fail if role is null defaultsByRole.put( roleDefaults[i].getRole(), roleDefaults[i] ); } } List componentDescriptors = new ArrayList(); Map abstractComponentMap = new HashMap(); for ( int i = 0; i < javaSources.length; i++ ) { if ("package-info.java".equalsIgnoreCase(javaSources[i].getFile().getName())) { // Skip Java5-style package documentation files continue; } JavaClass javaClass = getJavaClass( javaSources[i] ); if (javaClass == null) { continue; } for (Iterator j = gleaners.iterator(); j.hasNext();) { ComponentGleaner gleaner = (ComponentGleaner) j.next(); getLogger().debug("Trying gleaner: " + gleaner); ComponentDescriptor componentDescriptor = gleaner.glean( builder, javaClass ); if ( javaClass.isAbstract() ) { abstractComponentMap.put( javaClass, componentDescriptor ); } else if ( componentDescriptor != null ) { // TODO: better merge, perhaps pass it into glean as the starting point instead if ( defaultsByRole.containsKey( componentDescriptor.getRole() ) ) { ComponentDescriptor desc = (ComponentDescriptor) defaultsByRole.get( componentDescriptor.getRole() ); if ( componentDescriptor.getInstantiationStrategy() == null ) { componentDescriptor.setInstantiationStrategy( desc.getInstantiationStrategy() ); } } // Look at the abstract component of this component and grab all its requirements ComponentDescriptor abstractComponent = (ComponentDescriptor) abstractComponentMap.get( javaClass.getSuperJavaClass() ); if ( abstractComponent != null ) { for ( Iterator k = abstractComponent.getRequirements().iterator(); k.hasNext(); ) { componentDescriptor.addRequirement( ( ComponentRequirement) k.next() ); } } componentDescriptors.add( componentDescriptor ); } } } ComponentSetDescriptor componentSetDescriptor = new ComponentSetDescriptor(); componentSetDescriptor.setComponents( componentDescriptors ); // ---------------------------------------------------------------------- // Convert the Maven dependencies to Plexus component dependencies // ---------------------------------------------------------------------- // List componentDependencies = convertDependencies( mavenProject.getDependencies() ); // // componentSetDescriptor.setDependencies( componentDependencies ); // TODO: for now componentSetDescriptor.setDependencies( Collections.EMPTY_LIST ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- validateConfiguration( componentSetDescriptor ); // ---------------------------------------------------------------------- // Write out the component descriptor // ---------------------------------------------------------------------- if ( componentDescriptors.size() == 0 && componentSetDescriptor.getDependencies().size() == 0 ) { getLogger().debug( "No components or dependencies found, not writing components.xml" ); return; } File parentFile = outputFile.getParentFile(); if ( !parentFile.exists() ) { if ( !parentFile.mkdirs() ) { throw new ComponentDescriptorCreatorException( "Could not make parent directory: '" + parentFile.getAbsolutePath() + "'." ); } } try { writer.writeDescriptorSet( new FileWriter( outputFile ), componentSetDescriptor, containerDescriptor ); } catch ( Exception e ) { throw new ComponentDescriptorCreatorException( "Error while writing the component descriptor to: " + "'" + outputFile.getAbsolutePath() + "'.", e ); } } public void mergeDescriptors( File outputDescriptor, List descriptors ) throws ComponentDescriptorCreatorException { SAXBuilder builder = new SAXBuilder(); Document finalDoc = null; for ( Iterator i = descriptors.iterator(); i.hasNext(); ) { File f = (File) i.next(); try { Document doc = builder.build( f ); if ( finalDoc != null ) { // Last specified has dominance finalDoc = merger.merge( doc, finalDoc ); } else { finalDoc = doc; } } catch ( JDOMException e ) { throw new ComponentDescriptorCreatorException( "Invalid input descriptor for merge: " + f, e ); } catch ( IOException e ) { throw new ComponentDescriptorCreatorException( "Error reading input descriptor for merge: " + f, e ); } catch ( MergeException e ) { throw new ComponentDescriptorCreatorException( "Error merging descriptor: " + f, e ); } } if ( finalDoc != null ) { try { merger.writeMergedDocument( finalDoc, outputDescriptor ); } catch ( IOException e ) { throw new ComponentDescriptorCreatorException( "Error writing merged descriptor: " + outputDescriptor, e ); } } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void validateConfiguration( ComponentSetDescriptor componentSetDescriptor ) throws ComponentDescriptorCreatorException { List dependencies = componentSetDescriptor.getDependencies(); if ( dependencies == null ) { return; } for ( Iterator it = dependencies.iterator(); it.hasNext(); ) { ComponentDependency dependency = (ComponentDependency) it.next(); if ( StringUtils.isEmpty( dependency.getGroupId() ) ) { throw new ComponentDescriptorCreatorException( "Missing dependency element: 'groupId'." ); } if ( StringUtils.isEmpty( dependency.getArtifactId() ) ) { throw new ComponentDescriptorCreatorException( "Missing dependency element: 'artifactId'." ); } if ( StringUtils.isEmpty( dependency.getVersion() ) ) { throw new ComponentDescriptorCreatorException( "Missing dependency element: 'version'." ); } if ( StringUtils.isEmpty( dependency.getType() ) ) { throw new ComponentDescriptorCreatorException( "Missing dependency element: 'type'." ); } } } /** * @deprecated do not use. Signature still here for compilation errors at runtime, * but I doubt this is ever called. */ public void writeDependencies( XMLWriter w, ComponentSetDescriptor componentSetDescriptor ) { throw new UnsupportedOperationException("This operation is no longer supported"); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- // private List convertDependencies( List dependencies ) // { // List componentDependencies = new ArrayList(); // // for ( Iterator i = dependencies.iterator(); i.hasNext(); ) // { // Dependency d = (Dependency) i.next(); // // ComponentDependency cd = new ComponentDependency(); // // cd.setGroupId( d.getGroupId() ); // // cd.setArtifactId( d.getArtifactId() ); // // cd.setVersion( d.getVersion() ); // // componentDependencies.add( cd ); // } // // return componentDependencies; // } private JavaClass getJavaClass( JavaSource javaSource ) { if (javaSource.getClasses().length == 0) { return null; } return javaSource.getClasses()[0]; } } plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/PlexusDefaultComponentGleaner.java0000644000175000017500000004772610700073353032602 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import com.thoughtworks.qdox.model.DocletTag; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaClassCache; import com.thoughtworks.qdox.model.JavaField; import org.codehaus.plexus.component.repository.cdc.ComponentDescriptor; import org.codehaus.plexus.component.repository.cdc.ComponentRequirement; import org.codehaus.plexus.component.repository.cdc.ComponentRequirementList; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.LogEnabled; 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.Disposable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Suspendable; import org.codehaus.plexus.util.StringUtils; /** * @author Trygve Laugstøl * @version $Id: PlexusDefaultComponentGleaner.java 6923 2007-10-01 04:26:19Z user57 $ * * @deprecated Use {#link ComponentDescriptorExtractor}. */ public class PlexusDefaultComponentGleaner extends AbstractLogEnabled implements ComponentGleaner { public static final String PLEXUS_COMPONENT_TAG = "plexus.component"; public static final String PLEXUS_REQUIREMENT_TAG = "plexus.requirement"; private static final String PLEXUS_CONFIGURATION_TAG = "plexus.configuration"; public static final String PLEXUS_VERSION_PARAMETER = "version"; public static final String PLEXUS_ROLE_PARAMETER = "role"; public static final String PLEXUS_ROLE_HINT_PARAMETER = "role-hint"; public static final String PLEXUS_ROLE_HINT_LIST_PARAMETER = "role-hints"; public static final String PLEXUS_ALIAS_PARAMETER = "alias"; private static final String PLEXUS_DEFAULT_VALUE_PARAMETER = "default-value"; private static final String PLEXUS_LIFECYCLE_HANDLER_PARAMETER = "lifecycle-handler"; private static final String PLEXUS_INSTANTIATION_STARTEGY_PARAMETER = "instantiation-strategy"; // XXX This is a duplicate of the constant in PlexusConstants, as we do not want to be tied to a // particular container API public static final String PLEXUS_DEFAULT_HINT = "default"; // ---------------------------------------------------------------------- // ComponentGleaner Implementation // ---------------------------------------------------------------------- public ComponentDescriptor glean( JavaClassCache classCache, JavaClass javaClass ) throws ComponentDescriptorCreatorException { DocletTag tag = javaClass.getTagByName( PLEXUS_COMPONENT_TAG ); if ( tag == null ) { return null; } Map parameters = tag.getNamedParameterMap(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- String fqn = javaClass.getFullyQualifiedName(); getLogger().debug( "Creating descriptor for component: " + fqn ); ComponentDescriptor componentDescriptor = new ComponentDescriptor(); componentDescriptor.setImplementation( fqn ); // ---------------------------------------------------------------------- // Role // ---------------------------------------------------------------------- String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER ); if ( role == null ) { role = findRole( javaClass ); if ( role == null ) { getLogger().warn( "Could not figure out a role for the component '" + fqn + "'. " + "Please specify a role with a parameter '" + PLEXUS_ROLE_PARAMETER + "' " + "on the @" + PLEXUS_COMPONENT_TAG + " tag." ); return null; } } getLogger().debug( " Role: " + role ); componentDescriptor.setRole( role ); // ---------------------------------------------------------------------- // Role hint // ---------------------------------------------------------------------- String roleHint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER ); if ( roleHint != null ) { getLogger().debug( " Role hint: " + roleHint ); } componentDescriptor.setRoleHint( roleHint ); // ---------------------------------------------------------------------- // Version // ---------------------------------------------------------------------- String version = getParameter( parameters, PLEXUS_VERSION_PARAMETER ); componentDescriptor.setVersion( version ); // ---------------------------------------------------------------------- // Lifecycle handler // ---------------------------------------------------------------------- String lifecycleHandler = getParameter( parameters, PLEXUS_LIFECYCLE_HANDLER_PARAMETER ); componentDescriptor.setLifecycleHandler( lifecycleHandler ); // ---------------------------------------------------------------------- // Lifecycle handler // ---------------------------------------------------------------------- String instatiationStrategy = getParameter( parameters, PLEXUS_INSTANTIATION_STARTEGY_PARAMETER ); componentDescriptor.setInstantiationStrategy( instatiationStrategy ); // ---------------------------------------------------------------------- // Alias // ---------------------------------------------------------------------- componentDescriptor.setAlias( getParameter( parameters, PLEXUS_ALIAS_PARAMETER ) ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- findExtraParameters( PLEXUS_COMPONENT_TAG, parameters ); // ---------------------------------------------------------------------- // Requirements // ---------------------------------------------------------------------- findRequirements( classCache, componentDescriptor, javaClass ); // ---------------------------------------------------------------------- // Description // ---------------------------------------------------------------------- String comment = javaClass.getComment(); if ( comment != null ) { int i = comment.indexOf( '.' ); if ( i > 0 ) { comment = comment.substring( 0, i + 1 ); // include the dot } } componentDescriptor.setDescription( comment ); // ---------------------------------------------------------------------- // Configuration // ---------------------------------------------------------------------- XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( "configuration" ); findConfiguration( configuration, javaClass ); componentDescriptor.setConfiguration( configuration ); return componentDescriptor; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private final static List IGNORED_INTERFACES = Collections.unmodifiableList( Arrays.asList( new String[]{ LogEnabled.class.getName(), Initializable.class.getName(), Configurable.class.getName(), Contextualizable.class.getName(), Disposable.class.getName(), Startable.class.getName(), Suspendable.class.getName(), Serviceable.class.getName(), } ) ); private String findRole( JavaClass javaClass ) { // ---------------------------------------------------------------------- // Remove any Plexus specific interfaces from the calculation // ---------------------------------------------------------------------- List interfaces = new ArrayList( Arrays.asList( javaClass.getImplementedInterfaces() ) ); for ( Iterator it = interfaces.iterator(); it.hasNext(); ) { JavaClass ifc = (JavaClass) it.next(); if ( IGNORED_INTERFACES.contains( ifc.getFullyQualifiedName() ) ) { it.remove(); } } // ---------------------------------------------------------------------- // For each implemented interface, check to see if it's a candiate // interface // ---------------------------------------------------------------------- String role = null; String className = javaClass.getName(); for ( Iterator it = interfaces.iterator(); it.hasNext(); ) { JavaClass ifc = (JavaClass) it.next(); String fqn = ifc.getFullyQualifiedName(); String pkg = ifc.getPackage(); if ( pkg == null ) { int index = fqn.lastIndexOf( '.' ); if ( index == -1 ) { // ----------------------------------------------------------------------- // This is a special case which will happen in two cases: // 1) The component is in the default/root package // 2) The interface is in another build, typically in an -api package // while the code beeing gleaned in in the -impl build. // // Since it's most likely in another package than in the default package // prepend the gleaned class' package // ----------------------------------------------------------------------- pkg = javaClass.getPackage(); fqn = pkg + "." + fqn; } else { pkg = fqn.substring( 0, index ); } } if ( fqn == null ) { fqn = ifc.getName(); } String name = fqn.substring( pkg.length() + 1 ); if ( className.endsWith( name ) ) { if ( role != null ) { getLogger().warn( "Found several possible roles for component " + "'" + javaClass.getFullyQualifiedName() + "', " + "will use '" + role + "', found: " + ifc.getName() + "." ); } role = fqn; } } if ( role == null ) { JavaClass superClass = javaClass.getSuperJavaClass(); if ( superClass != null ) { role = findRole( superClass ); } } return role; } private void findRequirements( JavaClassCache classCache, ComponentDescriptor componentDescriptor, JavaClass javaClass ) { JavaField[] fields = javaClass.getFields(); // ---------------------------------------------------------------------- // Search the super class for requirements // ---------------------------------------------------------------------- if ( javaClass.getSuperJavaClass() != null ) { findRequirements( classCache, componentDescriptor, javaClass.getSuperJavaClass() ); } // ---------------------------------------------------------------------- // Search the current class for requirements // ---------------------------------------------------------------------- for ( int i = 0; i < fields.length; i++ ) { JavaField field = fields[i]; DocletTag tag = field.getTagByName( PLEXUS_REQUIREMENT_TAG ); if ( tag == null ) { continue; } Map parameters = new HashMap( tag.getNamedParameterMap() ); // ---------------------------------------------------------------------- // Role // ---------------------------------------------------------------------- String requirementClass = field.getType().getJavaClass().getFullyQualifiedName(); boolean isMap = requirementClass.equals( Map.class.getName() ) || requirementClass.equals( Collection.class.getName() ); try { isMap = isMap || Collection.class.isAssignableFrom( Class.forName( requirementClass ) ); } catch ( ClassNotFoundException e ) { // ignore the assignable Collection test, though this should never happen } boolean isList = requirementClass.equals( List.class.getName() ); ComponentRequirement cr; String hint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER ); if ( isMap || isList ) { cr = new ComponentRequirementList(); String hintList = getParameter( parameters, PLEXUS_ROLE_HINT_LIST_PARAMETER ); if ( hintList != null ) { String[] hintArr = hintList.split( "," ); ( (ComponentRequirementList) cr).setRoleHints( Arrays.asList( hintArr ) ); } } else { cr = new ComponentRequirement(); cr.setRoleHint( hint ); } String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER ); if ( role == null ) { cr.setRole( requirementClass ); } else { cr.setRole( role ); } cr.setFieldName( field.getName() ); if ( isMap || isList ) { if ( hint != null ) { getLogger().warn( "Field: '" + field.getName() + "': A role hint cannot be specified if the " + "field is a java.util.Map or a java.util.List" ); continue; } if ( role == null ) { getLogger().warn( "Field: '" + field.getName() + "': A java.util.Map or java.util.List " + "requirement has to specify a '" + PLEXUS_ROLE_PARAMETER + "' parameter on " + "the @" + PLEXUS_REQUIREMENT_TAG + " tag so Plexus can know which components to " + "put in the map or list." ); continue; } JavaClass roleClass = classCache.getClassByName( role ); if ( role.indexOf( '.' ) == -1 && StringUtils.isEmpty( roleClass.getPackage() ) ) { role = javaClass.getPackage() + "." + roleClass.getName(); } cr.setRole( role ); findExtraParameters( PLEXUS_REQUIREMENT_TAG, parameters ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- componentDescriptor.addRequirement( cr ); } } private void findConfiguration( XmlPlexusConfiguration configuration, JavaClass javaClass ) throws ComponentDescriptorCreatorException { JavaField[] fields = javaClass.getFields(); // ---------------------------------------------------------------------- // Search the super class for configurable fields. // ---------------------------------------------------------------------- if ( javaClass.getSuperJavaClass() != null ) { findConfiguration( configuration, javaClass.getSuperJavaClass() ); } // ---------------------------------------------------------------------- // Search the current class for configurable fields. // ---------------------------------------------------------------------- for ( int i = 0; i < fields.length; i++ ) { JavaField field = fields[i]; DocletTag tag = field.getTagByName( PLEXUS_CONFIGURATION_TAG ); if ( tag == null ) { continue; } Map parameters = new HashMap( tag.getNamedParameterMap() ); /* don't use the getParameter helper as we like empty strings */ String defaultValue = (String) parameters.remove( PLEXUS_DEFAULT_VALUE_PARAMETER ); if ( defaultValue == null ) { getLogger().warn( "Component: " + javaClass.getName() + ", field name: '" + field.getName() + "': " + "Currently configurable fields will not be written to the descriptor " + "without a default value." ); continue; } String name = deHump( field.getName() ); XmlPlexusConfiguration c; c = new XmlPlexusConfiguration( name ); c.setValue( defaultValue ); getLogger().debug( " Configuration: " + name + "=" + defaultValue ); configuration.addChild( c ); findExtraParameters( PLEXUS_CONFIGURATION_TAG, parameters ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private String deHump( String string ) { StringBuffer sb = new StringBuffer(); for ( int i = 0; i < string.length(); i++ ) { if ( i != 0 && Character.isUpperCase( string.charAt( i ) ) ) { sb.append( '-' ); } sb.append( string.charAt( i ) ); } return sb.toString().trim().toLowerCase(); } private void findExtraParameters( String tagName, Map parameters ) { for ( Iterator it = parameters.keySet().iterator(); it.hasNext(); ) { String s = (String) it.next(); getLogger().warn( "Extra parameter on the '" + tagName + "' tag: '" + s + "'." ); } } private String getParameter( Map parameters, String parameter ) { String value = (String) parameters.remove( parameter ); if ( StringUtils.isEmpty( value ) ) { return null; } return value; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorWriteException.javaplexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorWriteException.java0000644000175000017500000000332210700073353033507 0ustar twernertwernerpackage org.codehaus.plexus.cdc; /* * 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: ComponentDescriptorWriteException.java 6923 2007-10-01 04:26:19Z user57 $ */ public class ComponentDescriptorWriteException extends Exception { public ComponentDescriptorWriteException( String message ) { super( message ); } public ComponentDescriptorWriteException( String message, Throwable cause ) { super( message, cause ); } public ComponentDescriptorWriteException( Throwable cause ) { super( cause ); } }plexus-cdc-1.0-alpha-14/src/main/java/org/codehaus/plexus/cdc/ComponentDescriptorWriter.java0000644000175000017500000000311310700073353032010 0ustar twernertwerner/* * The MIT License * * Copyright (c) 2007, 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. */ package org.codehaus.plexus.cdc; import java.io.IOException; import java.io.Writer; import org.codehaus.plexus.component.repository.cdc.ComponentSetDescriptor; /** * @author Kenney Westerhof */ public interface ComponentDescriptorWriter { void writeDescriptorSet( Writer writer, ComponentSetDescriptor componentSetDescriptor, boolean containerDescriptor ) throws ComponentDescriptorWriteException, IOException; } plexus-cdc-1.0-alpha-14/src/main/resources/0000755000175000017500000000000011117672311020411 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/resources/META-INF/0000755000175000017500000000000011117672311021551 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/resources/META-INF/plexus/0000755000175000017500000000000011117672311023071 5ustar twernertwernerplexus-cdc-1.0-alpha-14/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000365110700073353026003 0ustar twernertwerner org.codehaus.plexus.cdc.gleaner.SourceComponentGleaner qdox org.codehaus.plexus.cdc.gleaner.QDoxComponentGleaner org.codehaus.plexus.cdc.ComponentDescriptorWriter org.codehaus.plexus.cdc.DefaultComponentDescriptorWriter org.codehaus.plexus.cdc.merge.Merger componentsXml org.codehaus.plexus.cdc.merge.ComponentsXmlMerger org.codehaus.plexus.cdc.merge.Merger plexusXml org.codehaus.plexus.cdc.merge.PlexusXmlMerger org.codehaus.plexus.cdc.ComponentDescriptorCreator org.codehaus.plexus.cdc.DefaultComponentDescriptorCreator org.codehaus.plexus.cdc.ComponentGleaner gleaners org.codehaus.plexus.cdc.merge.Merger plexusXml org.codehaus.plexus.cdc.ComponentDescriptorWriter plexus-cdc-1.0-alpha-14/README.txt0000644000175000017500000000040210777725005016370 0ustar twernertwernerThe org.codehaus.plexus.component.repository.cdc package contains some classes copied from the container before it started using the "default" role hints. This can be removed once all supported maven versions are using a container newer than 1.0-alpha-19. plexus-cdc-1.0-alpha-14/pom.xml0000644000175000017500000000420611042213231016170 0ustar twernertwerner 4.0.0 org.codehaus.plexus plexus-tools 1.0.11 plexus-cdc Plexus Component Descriptor Creator 1.0-alpha-14 org.slf4j slf4j-api 1.4.3 com.thoughtworks.qdox qdox 1.6.3 jdom jdom 1.0 org.slf4j slf4j-simple 1.4.3 test scm:svn:http://svn.codehaus.org/plexus/plexus-tools/tags/plexus-tools-1.0.11/plexus-cdc scm:svn:https://svn.codehaus.org/plexus/plexus-tools/tags/plexus-tools-1.0.11/plexus-cdc http://fisheye.codehaus.org/browse/plexus/plexus-tools/tags/plexus-tools-1.0.11plexus-cdc