|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package org.geektimes.interceptor; |
| 18 | + |
| 19 | +/** |
| 20 | + * Component Enhancer |
| 21 | + * <p> |
| 22 | + * If a component class declares or inherits a class-level interceptor binding, |
| 23 | + * it must not be declared final, or have any non-static, non-private, final |
| 24 | + * methods. If a component has a class-level interceptor binding and is declared |
| 25 | + * final or has a non-static, non-private, final method, the container automatically |
| 26 | + * detects the problem and treats it as a definition error, and causes deployment to |
| 27 | + * fail. |
| 28 | + * <p> |
| 29 | + * If a non-static, non-private method of a component class declares a method-level |
| 30 | + * interceptor binding, neither the method nor the component class may be declared final. |
| 31 | + * If a non-static, non-private, final method of a component has a method-level interceptor |
| 32 | + * binding, the container automatically detects the problem and treats it as a definition |
| 33 | + * error, and causes deployment to fail. |
| 34 | + * |
| 35 | + * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> |
| 36 | + * @since 1.0.0 |
| 37 | + */ |
| 38 | +public interface ComponentEnhancer { |
| 39 | + |
| 40 | + default <T> T enhance(T component) { |
| 41 | + return enhance(component, (Class<? super T>) component.getClass()); |
| 42 | + } |
| 43 | + |
| 44 | + default <T> T enhance(T component, Class<? super T> componentClass) { |
| 45 | + return enhance(component, componentClass, new Object[0]); |
| 46 | + } |
| 47 | + |
| 48 | + default <T> T enhance(T component, Object... defaultInterceptors) { |
| 49 | + return enhance(component, (Class<? super T>) component.getClass(), defaultInterceptors); |
| 50 | + } |
| 51 | + |
| 52 | + <T> T enhance(T component, Class<? super T> componentClass, Object... defaultInterceptors); |
| 53 | + |
| 54 | +} |
0 commit comments