1 package org.apache.maven.tools.plugin.javadoc; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import com.sun.tools.doclets.Taglet; 23 import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation; 24 25 import java.util.Map; 26 27 /** 28 * The <tt>@threadSafe</tt> tag is used to indicate that a mojo is thread-safe and can be run in parallel 29 * <br/> 30 * The following is a sample declaration: 31 * <pre> 32 * /** 33 *  * Dummy Mojo. 34 *  * 35 *  * @threadSafe <true|false> 36 *  * ... 37 *  */ 38 * public class MyMojo extends AbstractMojo{} 39 * </pre> 40 * To use it, calling the <code>Javadoc</code> tool with the following: 41 * <pre> 42 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoThreadSafeTypeTaglet' 43 * </pre> 44 * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following: 45 * <pre> 46 * javadoc ... -tag 'threadSafe:t:Indicates the mojo is thread-safe' 47 * </pre> 48 * 49 * @see <a href="package-summary.html#package_description">package-summary.html</a> 50 * 51 * @author Kristian Rosenvold 52 * @version $Id$ 53 */ 54 public class MojoThreadSafeTypeTaglet 55 extends AbstractMojoTypeTaglet 56 { 57 /** The Javadoc annotation */ 58 private static final String NAME = JavaMojoAnnotation.THREAD_SAFE; 59 60 /** The Javadoc text which will be added to the generated page. */ 61 protected static final String HEADER = "Mojo is thread safe"; 62 63 /** 64 * @return By default, return the string defined in {@linkplain #HEADER}. 65 * @see AbstractMojoTaglet#getHeader() 66 * @see #HEADER 67 */ 68 public String getHeader() 69 { 70 return HEADER; 71 } 72 73 /** 74 * @return <code>true|false</code> since <code>@requiresProject</code> has value. 75 * @see AbstractMojoTaglet#getAllowedValue() 76 */ 77 public String getAllowedValue() 78 { 79 return "true|false"; 80 } 81 82 /** 83 * @return <code>null</code> since <code>@requiresProject</code> has no parameter. 84 * @see AbstractMojoTaglet#getAllowedParameterNames() 85 */ 86 public String[] getAllowedParameterNames() 87 { 88 return null; 89 } 90 91 /** 92 * @return By default, return the name of this taglet. 93 * @see com.sun.tools.doclets.Taglet#getName() 94 * @see MojoThreadSafeTypeTaglet#NAME 95 */ 96 public String getName() 97 { 98 return NAME; 99 } 100 101 /** 102 * Register this Taglet. 103 * 104 * @param tagletMap the map to register this tag to. 105 */ 106 public static void register( Map<String, Taglet> tagletMap ) 107 { 108 MojoThreadSafeTypeTaglet tag = new MojoThreadSafeTypeTaglet(); 109 Taglet t = tagletMap.get( tag.getName() ); 110 if ( t != null ) 111 { 112 tagletMap.remove( tag.getName() ); 113 } 114 tagletMap.put( tag.getName(), tag ); 115 } 116 }