File:  [mozdev] / bookie / Java / bookie / sbtp / Attic / SbtpServiceManager.java
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Mon Nov 27 00:33:36 2000 UTC (18 years, 2 months ago) by will
Branches: MAIN
CVS tags: HEAD
Added yet more packages...

///###////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 Will Sargent
// $Id: SbtpServiceManager.java,v 1.1 2000/11/27 00:33:36 will Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
/**
 * The main service manager.  This is picked up by the server tool.
 */

package bookie.sbtp;

import java.io.*;
import java.util.*;
import freeware.coffee_server.pub.*;

import bookie.sbtp.pub.*;
import bookie.sbtp.protocol.*;

import bookie.sbtp.database.*;

/**
 *
 */
public
class SbtpServiceManager 
    implements CoffeeServiceManager, LogConstants
{
    private BookmarksFactory m_BookmarksFactory;

    public SbtpServiceManager()
    {
	m_BookmarksFactory = null;
    }

    /**
     * Create the service manager with the factory.
     */
    public SbtpServiceManager(BookmarksFactory factory)
    {
	Log.setCurrentLevel(DEBUG);
	m_BookmarksFactory = factory;
    }
    
    public CoffeeService newServiceInstance()
    {
	SbtpService service = new SbtpService();

	service.setBookmarksFactory(m_BookmarksFactory);

	// General commands
  	service.addCommand("help", new SbtpService_HELP());
  	service.addCommand("quit", new SbtpService_QUIT());
	service.addCommand("shut", new SbtpService_SHUT());

	// Bookmark commands
	service.addCommand("addb", new SbtpService_ADDB());
	service.addCommand("getb", new SbtpService_GETB());
	service.addCommand("delb", new SbtpService_DELB());
	service.addCommand("chgb", new SbtpService_CHGB());

	// Folder commands
	service.addCommand("addf", new SbtpService_ADDF());
	service.addCommand("getf", new SbtpService_GETF());
	service.addCommand("delf", new SbtpService_DELF());
	service.addCommand("chgf", new SbtpService_CHGF());

	// Get children
	service.addCommand("getc", new SbtpService_GETC());

	// Separator commands
	service.addCommand("adds", new SbtpService_ADDS());
	service.addCommand("dels", new SbtpService_DELS());

	log(DEBUG, "returning service");
	return service;
    }

    public void configure(Properties configuration)
	throws CoffeeServiceException
    {
	if (configuration == null)
	{
	    throw new CoffeeServiceException("no configuration file");
	}
	
	m_BookmarksFactory = new DatabaseBookmarksFactory();
	m_BookmarksFactory.configure(configuration);
    }

    protected void log(int level, String msg)
    {
	Log.log(this, level, msg);
    }
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>