/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
package com.pragprog.dhnako.carserv.wicket.ui;

import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebRequest;
import org.nakedobjects.metamodel.config.ConfigurationBuilderDefault;
import org.nakedobjects.runtime.system.NakedObjectsSystemBootstrapper;
import org.nakedobjects.runtime.system.DeploymentType;
import org.nakedobjects.runtime.system.NakedObjectsSystem;
import org.nakedobjects.runtime.system.SystemConstants;

import com.pragprog.dhnako.carserv.wicket.app.NakedObjectsAuthenticatedWebSession;
import com.pragprog.dhnako.carserv.wicket.app.NakedObjectsWebRequestCycle;
import com.pragprog.dhnako.carserv.wicket.ui.security.CarServSignInPage;

public class NakedObjectsApplication extends AuthenticatedWebApplication {
	@SuppressWarnings("unused")
	private NakedObjectsSystem system;

	public NakedObjectsApplication() {

		ConfigurationBuilderDefault configurationBuilder = new ConfigurationBuilderDefault();
		configurationBuilder.add(SystemConstants.NOSPLASH_KEY, ""+true);
		
		NakedObjectsSystemBootstrapper systemBootstrapper = 
			new NakedObjectsSystemBootstrapper(configurationBuilder, getClass());
		
		system = systemBootstrapper.bootSystem(DeploymentType.EXPLORATION);
	}

	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		return CarServSignInPage.class;
	}

	public Class<?> getHomePage() {
		return Index.class;
	}

	@Override
	public RequestCycle newRequestCycle(Request request, Response response) {
		return new NakedObjectsWebRequestCycle(this, (WebRequest) request,
				response);
	}

	@Override
	protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
		return NakedObjectsAuthenticatedWebSession.class;
	}
}
