wiki:MolgenisServlet

Version 1 (modified by jvelde, 14 years ago) (diff)

--

This servlet is the entry point for the database connection, user login, and user interfaces. It is a generated class that should not be present in the subversion repository. An example of this class:

/*
 * Created by: org.molgenis.generators.server.MolgenisServletGen
 * Date: October 4, 2010
 */

package app.servlet;

import java.io.File;

import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.sql.DataSource;

import org.molgenis.framework.security.Login;

import org.molgenis.framework.db.Database;
import org.molgenis.framework.db.DatabaseException;
import org.molgenis.framework.ui.UserInterface;
import org.molgenis.framework.server.AbstractMolgenisServlet;

import org.molgenis.util.EmailService;
import org.molgenis.util.SimpleEmailService;

import org.molgenis.framework.db.jdbc.JndiDataSourceWrapper;

public class MolgenisServlet extends AbstractMolgenisServlet
{

	private static final long serialVersionUID = 3141439968743510237L;

	public Database getDatabase() throws DatabaseException, NamingException
	{
		DataSource dataSource = (DataSource) getServletContext().getAttribute("DataSource");
		return new app.JDBCDatabase(dataSource, new File("xgap"));
	}

	public Login createLogin(Database db, HttpServletRequest request)
	{
		return new org.molgenis.framework.security.SimpleLogin();
	}

	public UserInterface createUserInterface(Login userLogin)
	{
		UserInterface app = new UserInterface(userLogin);
		app.setLabel("XGAP 1.4 distro prototype");
		app.setVersion("3.3.3");

		EmailService service = new SimpleEmailService();
		service.setSmtpProtocol("smtp");
		service.setSmtpHostname("localhost");
		service.setSmtpPort(25);
		service.setSmtpUser("");
		service.setSmtpPassword("");
		app.setEmailService(service);

		new app.ui.Molgenis_headerPlugin(app);
		new app.ui.MainMenu(app);
		return app;
	}

	public static String getMolgenisVariantID()
	{
		return "xgap_1_4_distro";
	}

	@Override
	public Object getSoapImpl() throws DatabaseException, NamingException
	{
		return new app.servlet.SoapApi((Database) getDatabase());
	}
}