001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.aop.framework; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * Delegate interface for a configured AOP proxy, allowing for the creation 023 * of actual proxy objects. 024 * 025 * <p>Out-of-the-box implementations are available for JDK dynamic proxies 026 * and for CGLIB proxies, as applied by {@link DefaultAopProxyFactory}. 027 * 028 * @author Rod Johnson 029 * @author Juergen Hoeller 030 * @see DefaultAopProxyFactory 031 */ 032public interface AopProxy { 033 034 /** 035 * Create a new proxy object. 036 * <p>Uses the AopProxy's default class loader (if necessary for proxy creation): 037 * usually, the thread context class loader. 038 * @return the new proxy object (never {@code null}) 039 * @see Thread#getContextClassLoader() 040 */ 041 Object getProxy(); 042 043 /** 044 * Create a new proxy object. 045 * <p>Uses the given class loader (if necessary for proxy creation). 046 * {@code null} will simply be passed down and thus lead to the low-level 047 * proxy facility's default, which is usually different from the default chosen 048 * by the AopProxy implementation's {@link #getProxy()} method. 049 * @param classLoader the class loader to create the proxy with 050 * (or {@code null} for the low-level proxy facility's default) 051 * @return the new proxy object (never {@code null}) 052 */ 053 Object getProxy(@Nullable ClassLoader classLoader); 054 055}