View Javadoc

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