Applications now create a site identifier at init time which can be used
to identify sites in the course of operating the application. git-svn-id: https://samskivert.googlecode.com/svn/trunk@405 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Application.java,v 1.1 2001/10/31 09:44:22 mdb Exp $
|
// $Id: Application.java,v 1.2 2001/11/01 01:02:20 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -22,7 +22,9 @@ package com.samskivert.velocity;
|
|||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import com.samskivert.servlet.IndiscriminateSiteIdentifier;
|
||||||
import com.samskivert.servlet.MessageManager;
|
import com.samskivert.servlet.MessageManager;
|
||||||
|
import com.samskivert.servlet.SiteIdentifier;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,6 +62,15 @@ public class Application
|
|||||||
return _msgmgr;
|
return _msgmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the site identifier in effect for figuring out which site
|
||||||
|
* through which a user is making a request.
|
||||||
|
*/
|
||||||
|
public SiteIdentifier getSiteIdentifier ()
|
||||||
|
{
|
||||||
|
return _siteIdent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If an application wishes to make use of the translation facilities
|
* If an application wishes to make use of the translation facilities
|
||||||
* provided by the message manager, it need only provide the path to
|
* provided by the message manager, it need only provide the path to
|
||||||
@@ -73,6 +84,17 @@ public class Application
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to instantiate the site identifier that we'd like to use in
|
||||||
|
* this application. This will be an instance of {@link
|
||||||
|
* IndiscriminateSiteIdentifier} unless the derived application class
|
||||||
|
* overrides this method and creates something more to its liking.
|
||||||
|
*/
|
||||||
|
protected SiteIdentifier createSiteIdentifer (ServletContext ctx)
|
||||||
|
{
|
||||||
|
return new IndiscriminateSiteIdentifier();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience function for translating messages.
|
* A convenience function for translating messages.
|
||||||
*/
|
*/
|
||||||
@@ -128,7 +150,7 @@ public class Application
|
|||||||
* @param logicPkg the base package for all of the logic
|
* @param logicPkg the base package for all of the logic
|
||||||
* implementations for this application.
|
* implementations for this application.
|
||||||
*/
|
*/
|
||||||
public void preInit (String logicPkg)
|
public void preInit (ServletContext ctx, String logicPkg)
|
||||||
{
|
{
|
||||||
// remove any trailing dot
|
// remove any trailing dot
|
||||||
if (logicPkg.endsWith(".")) {
|
if (logicPkg.endsWith(".")) {
|
||||||
@@ -142,6 +164,9 @@ public class Application
|
|||||||
if (bpath != null) {
|
if (bpath != null) {
|
||||||
_msgmgr = new MessageManager(bpath);
|
_msgmgr = new MessageManager(bpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create our site identifier
|
||||||
|
_siteIdent = createSiteIdentifer(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,6 +187,13 @@ public class Application
|
|||||||
return _logicPkg + path;
|
return _logicPkg + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The prefix that we use to generate fully qualified logic class
|
||||||
|
* names. */
|
||||||
protected String _logicPkg;
|
protected String _logicPkg;
|
||||||
|
|
||||||
|
/** A reference to our message manager or null if we have none. */
|
||||||
protected MessageManager _msgmgr;
|
protected MessageManager _msgmgr;
|
||||||
|
|
||||||
|
/** A reference to our site identifier. */
|
||||||
|
protected SiteIdentifier _siteIdent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DispatcherServlet.java,v 1.3 2001/10/31 11:07:55 mdb Exp $
|
// $Id: DispatcherServlet.java,v 1.4 2001/11/01 01:02:20 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -182,7 +182,7 @@ public class DispatcherServlet extends VelocityServlet
|
|||||||
if (StringUtil.blank(logicPkg)) {
|
if (StringUtil.blank(logicPkg)) {
|
||||||
logicPkg = "";
|
logicPkg = "";
|
||||||
}
|
}
|
||||||
_app.preInit(logicPkg);
|
_app.preInit(getServletContext(), logicPkg);
|
||||||
_app.init(getServletContext());
|
_app.init(getServletContext());
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user