Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/tracing/NullProviderFactory.java
38829 views
/*1* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.tracing;2627import java.lang.reflect.Method;2829import com.sun.tracing.ProviderFactory;30import com.sun.tracing.Provider;3132/**33* Factory class to create tracing Providers.34*35* This factory will create tracing instances that do nothing.36* It is used when no tracing is desired, but Provider instances still37* must be generated so that tracing calls in the application continue to38* run.39*40* @since 1.741*/42public class NullProviderFactory extends ProviderFactory {4344/**45* Creates and returns a Null provider.46*47* See comments at {@code ProviderSkeleton.createProvider()} for more48* details.49*50* @return a provider whose probe trigger are no-ops.51*/52public <T extends Provider> T createProvider(Class<T> cls) {53NullProvider provider = new NullProvider(cls);54provider.init();55return provider.newProxyInstance();56}57}5859class NullProvider extends ProviderSkeleton {6061NullProvider(Class<? extends Provider> type) {62super(type);63}6465protected ProbeSkeleton createProbe(Method m) {66return new NullProbe(m.getParameterTypes());67}68}6970class NullProbe extends ProbeSkeleton {7172public NullProbe(Class<?>[] parameters) {73super(parameters);74}7576public boolean isEnabled() {77return false;78}7980public void uncheckedTrigger(Object[] args) {81}82}83848586