View Javadoc

1   /*
2    * Copyright Openmind http://www.openmindonline.it
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package it.openutils.spring.rmibernate.server.aspects;
18  
19  import it.openutils.spring.rmibernate.shared.LazyReference;
20  
21  import java.lang.reflect.Method;
22  
23  import net.sf.cglib.proxy.MethodInterceptor;
24  import net.sf.cglib.proxy.MethodProxy;
25  
26  
27  /**
28   * Aspect on lazy fields to intercept writeReplace
29   * @author mmolaschi
30   * @version $Id: LazyReferenceAspect.java 716 2008-03-03 14:35:57Z fcarone $
31   */
32  public class LazyReferenceAspect implements MethodInterceptor
33  {
34  
35      private LazyReference lazyReference;
36  
37      public LazyReference getLazyReference()
38      {
39          return lazyReference;
40      }
41  
42      public void setLazyReference(LazyReference lazyReference)
43      {
44          this.lazyReference = lazyReference;
45      }
46  
47      /**
48       * {@inheritDoc}
49       */
50      public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable
51      {
52          return lazyReference;
53      }
54  
55  }