View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
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 org.apache.jdo.impl.enhancer;
18  
19  import java.io.InputStream;
20  import java.io.OutputStream;
21  
22  import org.apache.jdo.impl.enhancer.util.Support;
23  
24  
25  
26  /***
27   * Timer-wrapper for ClassFileEnhancer instances.
28   *
29   * @author Martin Zaun
30   */
31  public final class ClassFileEnhancerTimer
32      extends Support
33      implements ClassFileEnhancer
34  {
35      // delegate
36      final protected ClassFileEnhancer delegate;
37  
38      /***
39       * Creates an instance.
40       */
41      public ClassFileEnhancerTimer(ClassFileEnhancer delegate)
42      {
43          affirm(delegate);
44          this.delegate = delegate;
45      }
46  
47      public boolean enhanceClassFile(InputStream inClassFile,
48                                      OutputStream outClassFile)
49          throws EnhancerUserException, EnhancerFatalError
50      {
51          try {
52              timer.push("ClassFileEnhancer.enhanceClassFile(InputStream,OutputStream)");
53              return delegate.enhanceClassFile(inClassFile, outClassFile);
54          } finally {
55              timer.pop();
56          }
57      }
58  
59      public boolean enhanceClassFile(InputStream inClassFile,
60                                      OutputStreamWrapper outClassFile)
61          throws EnhancerUserException, EnhancerFatalError
62      {
63          try {
64              timer.push("ClassFileEnhancer.enhanceClassFile(InputStream,OutputStreamWrapper)");
65              return delegate.enhanceClassFile(inClassFile, outClassFile);
66          } finally {
67              timer.pop();
68          }
69      }
70  }