001package ball.tools.javadoc; 002/*- 003 * ########################################################################## 004 * Utilities 005 * $Id: MavenBootstrapTaglet.html 5431 2020-02-12 19:03:17Z ball $ 006 * $HeadURL: svn+ssh://svn.hcf.dev/var/spool/scm/repository.svn/hcf-dev/blog/2019-03-30-java-interface-facades/src/main/resources/javadoc/src-html/ball/tools/javadoc/MavenBootstrapTaglet.html $ 007 * %% 008 * Copyright (C) 2008 - 2020 Allen D. Ball 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * ########################################################################## 022 */ 023import com.sun.tools.doclets.Taglet; 024import java.util.Map; 025import java.util.ServiceLoader; 026 027/** 028 * {@link AbstractTaglet} whose {@link #register(Map)} method loads all 029 * {@link Taglet}s specified through a {@link ServiceLoader}. Designed to 030 * be specified as {@code <tagletClass/>} in a Maven {@code pom.xml}. 031 * 032 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball} 033 * @version $Revision: 5431 $ 034 */ 035public abstract class MavenBootstrapTaglet extends AbstractTaglet { 036 037 /** 038 * Static method to register all service providers for {@link Taglet}. 039 * 040 * @param map The {@link Map} of {@link Taglet}s. 041 */ 042 public static void register(Map<Object,Object> map) { 043 try { 044 ServiceLoader.load(Taglet.class, 045 MavenBootstrapTaglet.class.getClassLoader()) 046 .iterator() 047 .forEachRemaining(t -> map.putIfAbsent(t.getName(), t)); 048 } catch (Throwable throwable) { 049 throwable.printStackTrace(System.err); 050 051 if (throwable instanceof Error) { 052 throw (Error) throwable; 053 } else { 054 throw new ExceptionInInitializerError(throwable); 055 } 056 } 057 } 058 059 private MavenBootstrapTaglet() { 060 super(false, false, false, false, false, false, false); 061 } 062}