01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.comp;
15:
16: import org.itsnat.core.ItsNatDocument;
17: import org.itsnat.core.NameValue;
18: import org.w3c.dom.Node;
19:
20: /**
21: * This listener type is used to add new user defined components to the framework.
22: * If it was previously registered the listener is called when the framework needs
23: * to create a component instance.
24: *
25: *
26: * @author Jose Maria Arranz Santamaria
27: * @see ItsNatComponentManager#createItsNatComponent(Node,String,NameValue[])
28: * @see org.itsnat.core.DocumentTemplate#addCreateItsNatComponentListener(CreateItsNatComponentListener)
29: */
30: public interface CreateItsNatComponentListener {
31: /**
32: * Is called <i>before</i> calling the default component
33: * factory of the framework. This is an opportunity to create a user defined component
34: * because the returned object will be used by the framework if non-null, if returned null the framework
35: * will use the next user defined factory if any or the default factory.
36: *
37: * <p>Method parameters are the same as the factory method
38: * {@link ItsNatComponentManager#createItsNatComponent(Node,String,NameValue[])}
39: * </p>
40: *
41: *
42: * @param node the node to associate the new component.
43: * @param compType the component type, may be null.
44: * @param artifacts declared artifacts, may be null.
45: * @param compMgr the component manager used to create the component.
46: * @return the new component, if null the framework will use the next user defined factory if any or the default factory.
47: */
48: public ItsNatComponent before(Node node, String compType,
49: NameValue[] artifacts, ItsNatComponentManager compMgr);
50:
51: /**
52: * Is called <i>after</i> a component was created (user or framework defined).
53: * This is the opportunity to initialize the component before is returned to normal use.
54: * In fact nothing prevents to return a different component (component replaced)
55: * or return null (component rejected).
56: *
57: * @param comp the component to initialize/replace/reject, never is null.
58: * @return the same component, a different component or null.
59: */
60: public ItsNatComponent after(ItsNatComponent comp);
61: }
|