01: // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
02:
03: package jodd.madvoc;
04:
05: import jodd.petite.PetiteContainer;
06: import jodd.petite.config.AutomagicPetiteConfig;
07: import jodd.madvoc.interceptor.ActionInterceptor;
08:
09: import javax.servlet.ServletContext;
10:
11: /**
12: * {@link WebApplication} that uses {@link jodd.petite.PetiteContainer} for
13: * retreiving all instances.
14: */
15: public class PetiteWebApplication extends WebApplication {
16:
17: protected PetiteContainer pc;
18:
19: public PetiteWebApplication(ServletContext servletContext) {
20: super (servletContext);
21: createPetiteContatiner();
22: }
23:
24: /**
25: * Creates new default {@link jodd.petite.PetiteContainer} that will
26: * autoconfigure itself. Override this method for custom containers.
27: */
28: protected void createPetiteContatiner() {
29: pc = new PetiteContainer();
30: AutomagicPetiteConfig configurator = new AutomagicPetiteConfig();
31: configurator.configure(pc);
32: }
33:
34: public PetiteContainer getPetiteContainer() {
35: return pc;
36: }
37:
38: @Override
39: public ActionInterceptor buildInterceptor(
40: Class<? extends ActionInterceptor> actionInterceptorClass) {
41: return (ActionInterceptor) pc.create(actionInterceptorClass);
42: }
43:
44: @Override
45: public Object buildAction(ActionConfig actionConfig) {
46: return pc.create(actionConfig.actionClass);
47: }
48: }
|