use of jodd.madvoc.config.MadvocConfigurator in project jodd by oblac.
the class Madvoc method start.
private void start(ServletContext servletContext) {
if (servletContext != null) {
this.servletContext = servletContext;
servletContext.setAttribute(MADVOC_ATTR, this);
}
// create and initialize web application
webapp = createWebApplication();
webapp.initWebApplication();
// init logger
log = LoggerFactory.getLogger(Madvoc.class);
log.info("Madvoc starting...");
if (webapp.getClass().equals(WebApplication.class)) {
log.info("Default Madvoc web application created.");
} else {
log.info("Madvoc web application: " + webAppClass.getName());
}
// params
if (paramsFiles != null) {
Props params = loadMadvocParams(paramsFiles);
webapp.defineParams(params);
}
// configure
webapp.registerMadvocComponents();
madvocConfig = webapp.getComponent(MadvocConfig.class);
if (madvocConfig == null) {
throw new MadvocException("Madvoc configuration not found");
}
webapp.init(madvocConfig, servletContext);
// filters
FiltersManager filtersManager = webapp.getComponent(FiltersManager.class);
if (filtersManager == null) {
throw new MadvocException("Madvoc filers manager not found");
}
webapp.initFilters(filtersManager);
// interceptors
InterceptorsManager interceptorsManager = webapp.getComponent(InterceptorsManager.class);
if (interceptorsManager == null) {
throw new MadvocException("Madvoc interceptors manager not found");
}
webapp.initInterceptors(interceptorsManager);
// actions
ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
if (actionsManager == null) {
throw new MadvocException("Madvoc actions manager not found");
}
webapp.initActions(actionsManager);
// results
ResultsManager resultsManager = webapp.getComponent(ResultsManager.class);
if (resultsManager == null) {
throw new MadvocException("Madvoc results manager not found");
}
webapp.initResults(resultsManager);
// configure with external configurator
MadvocConfigurator configurator = loadMadvocConfig();
webapp.configure(configurator);
// prepare web application
madvocController = webapp.getComponent(MadvocController.class);
if (madvocController == null) {
throw new MadvocException("Madvoc controller not found");
}
madvocController.init(servletContext);
// web app is ready
webapp.ready();
}
use of jodd.madvoc.config.MadvocConfigurator in project jodd by oblac.
the class Madvoc method loadMadvocConfig.
/**
* Loads {@link jodd.madvoc.config.MadvocConfigurator}. If class name is <code>null</code>,
* {@link jodd.madvoc.config.AutomagicMadvocConfigurator} will be created.
*/
protected MadvocConfigurator loadMadvocConfig() {
if ((madvocConfiguratorClassName != null) && (madvocConfiguratorClass != null)) {
throw new MadvocException("Ambiguous MadvocConfigurator setting");
}
if ((madvocConfiguratorClassName == null) && (madvocConfiguratorClass == null)) {
log.info("Configuring Madvoc using default automagic configurator");
return new AutomagicMadvocConfigurator();
}
MadvocConfigurator configurator;
try {
if (madvocConfiguratorClass == null) {
madvocConfiguratorClass = ClassLoaderUtil.loadClass(madvocConfiguratorClassName);
}
configurator = (MadvocConfigurator) madvocConfiguratorClass.newInstance();
log.info("Configuring Madvoc using configurator: " + madvocConfiguratorClass.getName());
} catch (Exception ex) {
throw new MadvocException("Unable to load Madvoc configurator class: " + madvocConfiguratorClassName, ex);
}
return configurator;
}
Aggregations