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  /***
23   * A JDO enhancer, or byte-code enhancer, modifies the byte-codes of
24   * Java class files to enable transparent loading and storing of the
25   * fields of the persistent instances.
26   *
27   * @author Martin Zaun
28   */
29  public interface ClassFileEnhancer
30  {
31      /***
32       * Enhances a given class according to the JDO meta-data. If the
33       * input class has been enhanced or not - the output stream is
34       * always written, either with the enhanced class or with the
35       * non-enhanced class.
36       *
37       * @param in The byte-code of the class to be enhanced.
38       * @param out The byte-code of the enhanced class.
39       * @return  <code>true</code> if the class has been enhanced,
40       *          <code>false</code> otherwise.
41       */
42     boolean enhanceClassFile(InputStream in,
43                              OutputStream out)
44          throws EnhancerUserException, EnhancerFatalError;
45  
46  
47      /***
48       * Enhances a given class according to the JDO meta-data. If the
49       * input class has been enhanced or not - the output stream is
50       * always written, either with the enhanced class or with the
51       * non-enhanced class.
52       * <p>
53       * Furthermore, the enhancer has to set the classname of
54       * the enhanced class to the output stream wrapper object (it's
55       * possible to get the input stream without knowing the classname).
56       *
57       * @param in  The byte-code of the class to be enhanced.
58       * @param out The byte-code of the enhanced class.
59       * @return  <code>true</code> if the class has been enhanced,
60       *          <code>false</code> otherwise.
61       */
62      boolean enhanceClassFile(InputStream in,
63                               OutputStreamWrapper out)
64              throws EnhancerUserException, EnhancerFatalError;
65  }