01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
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 org.romaframework.aspect.view.form;
18:
19: import org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21: import org.apache.commons.pool.BaseKeyedPoolableObjectFactory;
22: import org.romaframework.aspect.view.ViewAspect;
23: import org.romaframework.core.config.RomaApplicationContext;
24: import org.romaframework.core.schema.SchemaObject;
25:
26: /**
27: * Form pool and factory.
28: *
29: * @author Luca Garulli (luca.garulli@assetdata.it)
30: */
31: public class FormFactory extends BaseKeyedPoolableObjectFactory {
32:
33: public FormFactory() {
34: super ();
35: }
36:
37: /*
38: * Instance the implementation when requested from the pool manager.
39: *
40: * @see org.apache.commons.pool.BasePoolableObjectFactory#makeObject()
41: */
42: @Override
43: public Object makeObject(Object iSchema) throws Exception {
44: SchemaObject entity = (SchemaObject) iSchema;
45:
46: ContentForm form = RomaApplicationContext.getInstance()
47: .getBean(ViewAspect.class).createForm(entity, null);
48:
49: form.setMetaDataSchema(entity);
50:
51: form.render();
52:
53: if (log.isDebugEnabled())
54: log
55: .debug("[FormFactory.makeObject] Creating new ContentForm: "
56: + entity.getSchemaClass().getName());
57:
58: return form;
59: }
60:
61: @Override
62: public void activateObject(Object iFormName, Object iFormInstance) {
63: if (iFormInstance instanceof ContentForm) {
64: ((ContentForm) iFormInstance).activate();
65: }
66: }
67:
68: @Override
69: public void passivateObject(Object iFormName, Object iFormInstance) {
70: if (iFormInstance instanceof ContentForm) {
71: ((ContentForm) iFormInstance).passivate();
72: }
73: }
74:
75: private static Log log = LogFactory.getLog(FormFactory.class);
76:
77: }
|