some of the underpinnings of community services
This commit is contained in:
@@ -47,7 +47,8 @@ import com.silverwrist.dynamo.util.*;
|
||||
public class ApplicationContainer
|
||||
implements ResourceProvider, ResourceProviderManager, RendererRegistration, ObjectProvider,
|
||||
EventListenerRegistration, OutputObjectFilterRegistration, QueryRenderer, PostDynamicUpdate,
|
||||
RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration
|
||||
RenderImmediate, RequestPreprocessorRegistration, ExceptionTranslatorRegistration,
|
||||
FinalStageRegistration
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal class recording renderer registrations and providing a
|
||||
@@ -178,6 +179,8 @@ public class ApplicationContainer
|
||||
private HashMap m_update_listeners = new HashMap(); // update listeners
|
||||
private Vector m_request_preprocessors = new Vector(); // request preprocessors
|
||||
private Vector m_exception_xlators = new Vector(); // exception translators
|
||||
private LinkedList m_final_stage_inits = new LinkedList(); // final-stage initialization hooks
|
||||
private LinkedList m_prestage_shutdown = new LinkedList(); // pre-stage shutdown hooks
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
@@ -219,6 +222,7 @@ public class ApplicationContainer
|
||||
m_app_sm.addInitService(PostDynamicUpdate.class,(PostDynamicUpdate)this);
|
||||
m_app_sm.addInitService(RequestPreprocessorRegistration.class,(RequestPreprocessorRegistration)this);
|
||||
m_app_sm.addInitService(ExceptionTranslatorRegistration.class,(ExceptionTranslatorRegistration)this);
|
||||
m_app_sm.addInitService(FinalStageRegistration.class,(FinalStageRegistration)this);
|
||||
|
||||
m_app_sm.addRuntimeService(ResourceProvider.class,(ResourceProvider)this);
|
||||
m_app_sm.addRuntimeService(ObjectProvider.class,(ObjectProvider)this);
|
||||
@@ -327,6 +331,28 @@ public class ApplicationContainer
|
||||
m_identity = buf.toString();
|
||||
logger.info("Server: " + m_identity);
|
||||
|
||||
try
|
||||
{ // Call the "final stage" initialization hooks.
|
||||
logger.info(m_final_stage_inits.size() + " final-stage init hook(s) to call");
|
||||
while (!(m_final_stage_inits.isEmpty()))
|
||||
{ // call the hooks in FIFO order
|
||||
FinalStageInitHook hook = (FinalStageInitHook)(m_final_stage_inits.removeFirst());
|
||||
hook.initialize(m_application,init_svcs);
|
||||
|
||||
} // end while
|
||||
|
||||
m_final_stage_inits = null; // done with this list
|
||||
|
||||
} // end try
|
||||
catch (DynamoException e)
|
||||
{ // final-stage initialization failed - post an error
|
||||
ConfigException ce = new ConfigException(ApplicationContainer.class,"ApplicationContainerMessages",
|
||||
"finalinit.fail",e);
|
||||
ce.setParameter(0,e.getMessage());
|
||||
throw ce;
|
||||
|
||||
} // end catch
|
||||
|
||||
// Fire the "application initialized" events.
|
||||
ApplicationListener[] listeners =
|
||||
(ApplicationListener[])(m_application_listeners.toArray(APP_LISTENER_TEMPLATE));
|
||||
@@ -390,6 +416,16 @@ public class ApplicationContainer
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("ApplicationContainer.destroy(): " + m_prestage_shutdown.size()
|
||||
+ " pre-stage shutdown hooks to call");
|
||||
while (m_prestage_shutdown.size()>0)
|
||||
{ // call the appropriate pre-stage shutdown hooks
|
||||
ComponentShutdown sd = (ComponentShutdown)(m_prestage_shutdown.removeFirst());
|
||||
sd.shutdown();
|
||||
|
||||
} // end while
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("ApplicationContainer.destroy(): " + m_shutdown_list.size() + " objects to blow away");
|
||||
|
||||
@@ -981,6 +1017,26 @@ public class ApplicationContainer
|
||||
|
||||
} // end registerExceptionTranslator
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface FinalStageRegistration
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public synchronized boolean registerFinalStageInitHook(FinalStageInitHook hook)
|
||||
{
|
||||
if ((m_final_stage_inits==null) || (m_application!=null))
|
||||
return false; // too late to register
|
||||
m_final_stage_inits.addLast(hook);
|
||||
return true;
|
||||
|
||||
} // end registerFinalStageInitHook
|
||||
|
||||
public synchronized void registerPreStageShutdown(ComponentShutdown cs)
|
||||
{
|
||||
m_prestage_shutdown.addFirst(cs);
|
||||
|
||||
} // end registerPreStageShutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,3 +25,4 @@ resource.rootErr=The resource root directory {0} does not exist.
|
||||
mountRP.badName=Invalid mount path for resources: {0}
|
||||
mountRP.already=Resource provider already mounted on path {0}.
|
||||
registerRenderer.already=Renderer already registered for class {0}.
|
||||
finalinit.fail=Final-stage initialization failed: {0}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.dynamo.iface;
|
||||
|
||||
import com.silverwrist.dynamo.except.DynamoException;
|
||||
|
||||
public interface FinalStageInitHook
|
||||
{
|
||||
public void initialize(Application application, ServiceProvider services) throws DynamoException;
|
||||
|
||||
} // end interface FinalStageInitHook
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.dynamo.iface;
|
||||
|
||||
public interface FinalStageRegistration
|
||||
{
|
||||
public boolean registerFinalStageInitHook(FinalStageInitHook hook);
|
||||
|
||||
public void registerPreStageShutdown(ComponentShutdown cs);
|
||||
|
||||
} // end interface FinalStageRegistration
|
||||
@@ -19,6 +19,8 @@ package com.silverwrist.dynamo.iface;
|
||||
|
||||
public interface ModuleSite
|
||||
{
|
||||
public String getFilename();
|
||||
|
||||
public ResourceProvider getResourceProvider();
|
||||
|
||||
} // end interface ModuleSite
|
||||
|
||||
@@ -49,6 +49,12 @@ class ModuleLoader extends URLClassLoader implements Module
|
||||
*====================================================================
|
||||
*/
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return m_filename;
|
||||
|
||||
} // end getFilename
|
||||
|
||||
public ResourceProvider getResourceProvider()
|
||||
{
|
||||
return (ResourceProvider)this;
|
||||
@@ -106,20 +112,22 @@ class ModuleLoader extends URLClassLoader implements Module
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private URL m_jar_url;
|
||||
private String m_resource_path;
|
||||
private ModuleFunctions m_modfuncs;
|
||||
private boolean m_initialized = false;
|
||||
private URL m_jar_url; // URL to the module JAR file
|
||||
private String m_filename; // filename of the original JAR file relative to module directory
|
||||
private String m_resource_path; // resource path for the JAR file
|
||||
private ModuleFunctions m_modfuncs; // module functions (the bridge into the module)
|
||||
private boolean m_initialized = false; // have we been initialized?
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ModuleLoader(File modfile) throws ModuleException, MalformedURLException
|
||||
ModuleLoader(File modfile, String filename) throws ModuleException, MalformedURLException
|
||||
{
|
||||
super(new URL[] { modfile.toURL() },ModuleLoader.class.getClassLoader());
|
||||
logger.info("Loading module " + modfile.getAbsolutePath());
|
||||
m_filename = filename;
|
||||
String main_class_name = null;
|
||||
try
|
||||
{ // create a JAR URL and use it to get the JAR attributes
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen
|
||||
|
||||
try
|
||||
{ // create a new ModuleLoader
|
||||
rc = new ModuleLoader(mod_file);
|
||||
rc = new ModuleLoader(mod_file,name);
|
||||
|
||||
} // end try
|
||||
catch (MalformedURLException e)
|
||||
|
||||
Reference in New Issue
Block a user