CVS: plexus-components/summit/src/java/org/apache/plexus/summit AbstractSummitComponent.java,1.1.1.1,1.2 DefaultSummitView.java,1.1.1.1,1.2 Summit.java,1.4,1.5 SummitComponent.java,1.1.1.1,1.2 SummitConstants.java,1.3,1.4
[email protected] Thu, 1 May 2003 14:28:42 -0500
| Newsgroups | gmane.comp.java.plexus.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit
In directory eng.werken.com:/tmp/cvs-serv17379/src/java/org/apache/plexus/summit
Modified Files:
AbstractSummitComponent.java DefaultSummitView.java
Summit.java SummitComponent.java SummitConstants.java
Log Message:
o Removed the multiple View notion.
o Using a service manager instead of the components being service managers.
Index: AbstractSummitComponent.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/AbstractSummitComponent.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- AbstractSummitComponent.java 15 Feb 2003 03:55:45 -0000 1.1.1.1
+++ AbstractSummitComponent.java 1 May 2003 19:28:39 -0000 1.2
@@ -56,13 +56,13 @@
* ----------------------------------------------------------------------------
*/
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
-import org.apache.plexus.service.ServiceBroker;
-import org.apache.plexus.service.Serviceable;
-import org.apache.plexus.context.Contextualizable;
-import org.apache.plexus.context.PlexusContext;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.plexus.logging.AbstractLogEnabled;
/**
* <p>The base class for all the various components used in Summit:</p>
@@ -91,9 +91,9 @@
public abstract class AbstractSummitComponent
extends AbstractLogEnabled
implements SummitComponent, Serviceable, Contextualizable
-{
- /** The service broker that created this object */
- private ServiceBroker broker;
+{
+ /** The service manager that created this object */
+ private ServiceManager manager;
/** The application view id */
private String applicationViewId;
@@ -106,40 +106,33 @@
{
return applicationViewName;
}
-
+
/** @see org.apache.plexus.summit.SummitComponent#getApplicationViewId() */
public String getApplicationViewId()
{
return applicationViewId;
}
-
- /** @see org.apache.plexus.summit.SummitComponent#getServiceBroker() */
- public ServiceBroker getServiceBroker()
+
+ public ServiceManager getServiceManager()
{
- return broker;
+ return manager;
}
/**
* Obtain and store a reference to the SummitView that
* instantiated this component.
- *
+ *
* @param context The context received from the parent container.
* @throws ContextException If there is an error contextualizing.
*/
- public void contextualize( PlexusContext context ) throws ContextException
+ public void contextualize( Context context )
+ throws ContextException
{
- applicationViewId =
- ( String ) context.get( SummitConstants.SUMMIT_VIEW_ID_KEY );
-
- applicationViewName =
- ( String ) context.get( SummitConstants.SUMMIT_VIEW_NAME_KEY );
}
-
- /**
- * @see org.apache.plexus.service.Serviceable#service(org.apache.plexus.service.ServiceBroker)
- */
- public void service( ServiceBroker broker ) throws ServiceException
+
+ public void service( ServiceManager manager )
+ throws ServiceException
{
- this.broker = broker;
+ this.manager = manager;
}
}
Index: DefaultSummitView.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/DefaultSummitView.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- DefaultSummitView.java 15 Feb 2003 03:55:47 -0000 1.1.1.1
+++ DefaultSummitView.java 1 May 2003 19:28:39 -0000 1.2
@@ -58,10 +58,9 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
-import org.apache.plexus.context.PlexusContext;
-import org.apache.plexus.context.DefaultPlexusContext;
-import org.apache.plexus.service.PlexusServiceBroker;
+import org.apache.plexus.logging.AbstractLogEnabled;
import org.apache.plexus.summit.exception.SummitException;
/**
@@ -73,17 +72,19 @@
* @todo Logging on a per application view basis
* @todo Fix the classloading and get rid of Class.forName(...)
*/
-public class DefaultSummitView extends PlexusServiceBroker
+public class DefaultSummitView
+ extends AbstractLogEnabled
+ implements SummitView
{
/** The ID of this view. */
private String id;
/** The name of this view. */
private String name;
-
+
/** The context that is to be used when contextualizing. */
- private DefaultPlexusContext summitContext;
-
+ private Context summitContext;
+
/**
* Obtain the context from the parent container and create a new
* child-context that contains a reference to this instance so
@@ -93,21 +94,19 @@
* @param context The context received from the parent container.
* @throws ContextException If there is an error contextualizing.
*/
- public void contextualize( PlexusContext context ) throws ContextException
+ public void contextualize( Context context )
+ throws ContextException
{
- super.contextualize( context );
- summitContext = new DefaultPlexusContext( context );
}
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
- public void configure( Configuration config ) throws ConfigurationException
+ public void configure( Configuration config )
+ throws ConfigurationException
{
- super.configure( config );
-
- id = config.getChild("id").getValue();
- name = config.getChild("name").getValue();
+ id = config.getChild( "id" ).getValue();
+ name = config.getChild( "name" ).getValue();
}
/** Initialize the application view. */
@@ -117,19 +116,14 @@
try
{
getLogger().info( "Initializing SummitView " + id );
-
- summitContext.put( SummitConstants.SUMMIT_VIEW_KEY, this );
- summitContext.put( SummitConstants.SUMMIT_VIEW_ID_KEY, id );
- summitContext.put( SummitConstants.SUMMIT_VIEW_NAME_KEY, name );
-
- // Set our parent PSB's to use this context when creating new components.
- setContainerContext( summitContext );
- super.initialize();
+ //summitContext.put( SummitConstants.SUMMIT_VIEW_KEY, this );
+ //summitContext.put( SummitConstants.SUMMIT_VIEW_ID_KEY, id );
+ //summitContext.put( SummitConstants.SUMMIT_VIEW_NAME_KEY, name );
}
- catch (Throwable e)
+ catch ( Throwable e )
{
- throw new SummitException("View initialization error!", e);
+ throw new SummitException( "View initialization error!", e );
}
}
}
Index: Summit.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/Summit.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Summit.java 25 Feb 2003 20:42:32 -0000 1.4
+++ Summit.java 1 May 2003 19:28:39 -0000 1.5
@@ -56,28 +56,18 @@
* ----------------------------------------------------------------------------
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.plexus.configuration.PlexusConfigurationHelper;
-import org.apache.plexus.service.ServiceBroker;
import org.apache.plexus.servlet.PlexusServlet;
import org.apache.plexus.summit.exception.ExceptionHandler;
import org.apache.plexus.summit.pipeline.Pipeline;
import org.apache.plexus.summit.rundata.RunData;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
/**
* <p>Summit is a controller Servlet.</p>
@@ -87,82 +77,33 @@
* @todo Hide use of the descriptors with facade util class.
*/
public class Summit
- extends PlexusServlet
+ extends PlexusServlet
{
- /** Logger. **/
- private final static Log log = LogFactory.getLog(Summit.class);
-
- /** First request flag. */
- private static boolean firstDoGet = true;
-
- /** Configuration for controller servlet. */
- private static Configuration configuration;
-
- /** Collection of application views. */
- private static Map applicationViews;
-
- /** Default application */
- private static String defaultApplicationView;
+ private SummitView applicationView;
/**
* Intialize Servlet.
*/
- public final void init(ServletConfig config)
+ public final void init( ServletConfig config )
throws ServletException
{
- super.init(config);
+ super.init( config );
+
+ //log.info( "Loading Summit configuration" );
+ //log.info( "Initializing Application Views" );
try
{
- log.info("Loading Summit configuration");
-
- String configurationInitParameter = config.getInitParameter( "configuration" );
- File configFile = new File(config.getServletContext().getRealPath(""),configurationInitParameter);
- setConfiguration(PlexusConfigurationHelper.build(configFile.getAbsolutePath()));
-
- log.info("Initializing Application Views");
-
-
- // Store the application views.
-
- applicationViews = new HashMap();
-
- Configuration[] views =
- getConfiguration().getChild("applicationViews").getChildren();
-
- for ( int i = 0; i < views.length; i++ )
- {
- String viewId = views[i].getValue();
-
- ServiceBroker view = null;
- try
- {
- view = (ServiceBroker) getServiceBroker().lookup(
- ServiceBroker.ROLE,
- viewId);
- }
- catch (ServiceException e)
- {
- throw new ServletException(
- "Could not find the application view " + viewId +
- ". Summit Init Failed",
- e );
- }
-
- applicationViews.put( viewId, view);
- defaultApplicationView = viewId;
- }
- }
- catch ( ConfigurationException e )
+ applicationView = (SummitView) getServiceManager().lookup( SummitView.ROLE );
+ }
+ catch ( ServiceException e )
{
- throw new ServletException(
- "Error with your servlet configuration. Summit Init Failed",
- e );
+ throw new ServletException( "Could not find the application applicationView. Summit Init Failed", e );
}
-
- log.info("Summit Initialization complete, Ready to service requests.");
- }
+ //log.info( "Summit Initialization complete, Ready to service requests." );
+
+ }
// -------------------------------------------------------------------
// R E Q U E S T P R O C E S S I N G
@@ -176,40 +117,37 @@
* @exception IOException a servlet exception.
* @exception ServletException a servlet exception.
*/
- public final void doGet(HttpServletRequest req, HttpServletResponse res)
+ public final void doGet( HttpServletRequest req, HttpServletResponse res )
throws IOException, ServletException
{
- // Retrieve the requested application view.
- ServiceBroker applicationView =
- ( ServiceBroker ) applicationViews.get(defaultApplicationView);
-
try
{
- RunData data = ( RunData ) applicationView.lookup( RunData.ROLE );
+ RunData data = (RunData) getServiceManager().lookup( RunData.ROLE );
data.setRequest( req );
data.setResponse( res );
data.setServletConfig( getServletConfig() );
- data.setRootServiceBroker( getServiceBroker() );
-
- // Execute the pipeline for this application view.
- Pipeline pipeline = ( Pipeline ) applicationView.lookup( Pipeline.ROLE );
+ data.setRootServiceManager( getServiceManager() );
+
+ // Execute the pipeline for this application applicationView.
+ Pipeline pipeline = (Pipeline) getServiceManager().lookup( Pipeline.ROLE );
pipeline.invoke( data );
}
- catch (Throwable t)
+ catch ( Throwable t )
{
t.printStackTrace();
try
{
ExceptionHandler handler =
- ( ExceptionHandler ) applicationView.lookup( ExceptionHandler.ROLE );
+ (ExceptionHandler) getServiceManager().lookup( ExceptionHandler.ROLE );
+
// Not quite sure what to do here, we may not have a
// RunData object as the result of a ServiceException,
// perhaps we should change the interface of
// ExceptionHandler to take the request, response, and
- // application view instead of RunData?? --pete
-
+ // application applicationView instead of RunData?? --pete
+
//handler.handleException( data, t );
}
catch ( ServiceException e )
@@ -226,10 +164,10 @@
* @exception IOException a servlet exception.
* @exception ServletException a servlet exception.
*/
- public final void doPost(HttpServletRequest req, HttpServletResponse res)
+ public final void doPost( HttpServletRequest req, HttpServletResponse res )
throws IOException, ServletException
{
- doGet(req, res);
+ doGet( req, res );
}
// -------------------------------------------------------------------
@@ -243,12 +181,12 @@
public final void destroy()
{
// What do we need to systematically destroy.
- log.info("Done shutting down!");
+ //log.info( "Done shutting down!" );
}
- // ------------------------------------------------------------------------
- // A C C E S S O R S
- // ------------------------------------------------------------------------
+ // ----------------------------------------------------------------------
+ // Accessors
+ // ----------------------------------------------------------------------
/**
* Return the servlet info.
@@ -258,20 +196,5 @@
public final String getServletInfo()
{
return "Summit Servlet @VERSION@";
- }
-
- public static void setConfiguration(Configuration c)
- {
- configuration = c;
- }
-
- /**
- * Get the configuration for this turbine webapp.
- *
- * @return Turbine configuration.
- */
- public static Configuration getConfiguration()
- {
- return configuration;
}
}
Index: SummitComponent.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/SummitComponent.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- SummitComponent.java 15 Feb 2003 03:55:47 -0000 1.1.1.1
+++ SummitComponent.java 1 May 2003 19:28:39 -0000 1.2
@@ -56,7 +56,7 @@
* ----------------------------------------------------------------------------
*/
-import org.apache.plexus.service.ServiceBroker;
+import org.apache.avalon.framework.service.ServiceManager;
/**
* Interface which Summit components must inherit to participate
@@ -67,7 +67,7 @@
* Components wishing to use other components within the view must use
* <tt>getServiceBroker</tt>. There are a few convience methods that
* can obtain information about the current application view.
- *
+ *
* @author <a href="mailto:[email protected]">Jason van Zyl</a>
* @author <a href="mailto:[email protected]">Pete Kazmier</a>
* @version $Id$
@@ -91,10 +91,10 @@
/**
* Gets the ServiceBroker associated with the current view. This
* will allow a component to get other components within the
- * application view.
+ * application view.
*
* @return ServiceBroker The service broker used to obtain other
* components within the current view.
*/
- public ServiceBroker getServiceBroker();
+ public ServiceManager getServiceManager();
}
Index: SummitConstants.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/summit/src/java/org/apache/plexus/summit/SummitConstants.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- SummitConstants.java 16 Feb 2003 15:24:01 -0000 1.3
+++ SummitConstants.java 1 May 2003 19:28:39 -0000 1.4
@@ -72,22 +72,22 @@
/** Application root. */
public final static String APPLICATION_ROOT = "applicationRoot";
-
+
/** Description of the Field */
public final static String WEBAPP_ROOT = "webappRoot";
-
+
/** Description of the Field */
public final static String WEB_CONTEXT = "webContext";
-
+
/** Description of the Field */
public final static String LOGGING_ROOT = "loggingRoot";
-
+
/** Tag for view context. */
public final static String VIEW_CONTEXT = "viewContext";
-
+
/** Tag for stack trace. */
public final static String STACK_TRACE = "stackTrace";
-
+
/** Tag for the default application view. */
public final static String DEFAULT_APPLICATION_VIEW = "defaultApplicationView";
@@ -99,10 +99,10 @@
/** Key used to store the summit view's name in the context. **/
public static final String SUMMIT_VIEW_NAME_KEY = "summit:view:name";
-
+
/** The action for a request. */
public static final String ACTION = "action";
-
+
/** The target for a request. */
- public static final String TARGET = "target";
+ public static final String TARGET = "target";
}