01: /*
02: * Copyright 2002,2003 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 net.sf.cglib.proxy;
18:
19: /**
20: * All enhanced instances returned by the {@link Enhancer} class implement this interface.
21: * Using this interface for new instances is faster than going through the <code>Enhancer</code>
22: * interface or using reflection. In addition, to intercept methods called during
23: * object construction you <b>must</b> use these methods instead of reflection.
24: * @author Juozas Baliuka <a href="mailto:baliuka@mwm.lt">baliuka@mwm.lt</a>
25: * @version $Id: Factory.java,v 1.13 2004/06/24 21:15:20 herbyderby Exp $
26: */
27: public interface Factory {
28: /**
29: * Creates new instance of the same type, using the no-arg constructor.
30: * The class of this object must have been created using a single Callback type.
31: * If multiple callbacks are required an exception will be thrown.
32: * @param callback the new interceptor to use
33: * @return new instance of the same type
34: */
35: Object newInstance(Callback callback);
36:
37: /**
38: * Creates new instance of the same type, using the no-arg constructor.
39: * @param callbacks the new callbacks(s) to use
40: * @return new instance of the same type
41: */
42: Object newInstance(Callback[] callbacks);
43:
44: /**
45: * Creates a new instance of the same type, using the constructor
46: * matching the given signature.
47: * @param types the constructor argument types
48: * @param args the constructor arguments
49: * @param callbacks the new interceptor(s) to use
50: * @return new instance of the same type
51: */
52: Object newInstance(Class[] types, Object[] args,
53: Callback[] callbacks);
54:
55: /**
56: * Return the <code>Callback</code> implementation at the specified index.
57: * @param index the callback index
58: * @return the callback implementation
59: */
60: Callback getCallback(int index);
61:
62: /**
63: * Set the callback for this object for the given type.
64: * @param index the callback index to replace
65: * @param callback the new callback
66: */
67: void setCallback(int index, Callback callback);
68:
69: /**
70: * Replace all of the callbacks for this object at once.
71: * @param callbacks the new callbacks(s) to use
72: */
73: void setCallbacks(Callback[] callbacks);
74:
75: /**
76: * Get the current set of callbacks for ths object.
77: * @return a new array instance
78: */
79: Callback[] getCallbacks();
80: }
|