pier 01/05/10 01:54:16 Modified: connectors/lib wa_main.c wa_config.c Makefile.in Log: Modified provider invocation scheme. Revision Changes Path 1.3 +40 -7 jakarta-tomcat-4.0/connectors/lib/wa_main.c Index: wa_main.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/lib/wa_main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- wa_main.c 2001/05/10 06:24:24 1.2 +++ wa_main.c 2001/05/10 08:54:13 1.3 @@ -55,16 +55,25 @@ * * * ========================================================================= */ -/* @version $Id: wa_main.c,v 1.2 2001/05/10 06:24:24 pier Exp $ */ +/* @version $Id: wa_main.c,v 1.3 2001/05/10 08:54:13 pier Exp $ */ #include <wa.h> /* The current APR memory pool. */ apr_pool_t *wa_pool=NULL; /* The list of all deployed applications. */ wa_chain *wa_configuration=NULL; +/* The list of all compiled in providers */ +wa_provider *wa_providers[] = { + //&wa_provider_info, + //&wa_provider_warp, + //&wa_provider_jni, + NULL, +}; /* Initialize the WebApp Library. */ const char *wa_init(void) { + int x=0; + /* Check the main APR pool. */ if (wa_pool==NULL) { if (apr_initialize()!=APR_SUCCESS) @@ -75,14 +84,40 @@ return("Invalid WebApp Library memory pool created"); } + /* Initialize providers */ + while(wa_providers[x]!=NULL) { + const char *ret=wa_providers[x]->init(); + if (ret!=NULL) { + wa_destroy(); + return(ret); + } + x++; + } + + /* Done */ wa_debug(WA_MARK,"WebApp Library initialized (PID=%d)",getpid()); return(NULL); } +/* Startup all providers. */ +void wa_startup(void) { + int x=0; + + while(wa_providers[x]!=NULL) wa_providers[x++]->startup(); + + wa_debug(WA_MARK,"WebApp Library started (PID=%d)",getpid()); +} + /* Clean up the WebApp Library. */ -const char *wa_destroy(void) { - if (wa_pool==NULL) return("WebApp Library not initialized"); +void wa_destroy(void) { + int x=0; + + /* Initialization check */ + if (wa_pool==NULL) return; + /* Destroy providers */ + while(wa_providers[x]!=NULL) wa_providers[x++]->destroy(); + /* Clean up this library and APR */ apr_pool_destroy(wa_pool); wa_pool=NULL; @@ -90,13 +125,12 @@ apr_terminate(); wa_debug(WA_MARK,"WebApp Library destroyed (PID=%d)",getpid()); - return(NULL); } /* Deploy a web-application. */ const char *wa_deploy(wa_application *a, wa_virtualhost *h, wa_connection *c) { wa_chain *elem=NULL; - //const char *ret=NULL; + const char *ret=NULL; /* Check parameters */ if (a==NULL) return("Invalid application for deployment"); @@ -119,8 +153,7 @@ /* Give the opportunity to the provider to be notified of the deployment of this application */ - //ret=c->prov->deploy(a); - //if (ret!=NULL) return(ret); + if ((ret=c->prov->deploy(a))!=NULL) return(ret); /* Append this application to the list of deployed applications in the virtual host */ 1.2 +10 -5 jakarta-tomcat-4.0/connectors/lib/wa_config.c Index: wa_config.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/lib/wa_config.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- wa_config.c 2001/05/10 06:26:55 1.1 +++ wa_config.c 2001/05/10 08:54:14 1.2 @@ -55,7 +55,7 @@ * * * ========================================================================= */ -/* @version $Id: wa_config.c,v 1.1 2001/05/10 06:26:55 pier Exp $ */ +/* @version $Id: wa_config.c,v 1.2 2001/05/10 08:54:14 pier Exp $ */ #include <wa.h> /* Allocate and set up a <code>wa_application</code> member. */ @@ -129,6 +129,7 @@ const char *p, const char *a) { wa_connection *conn=NULL; const char *ret=NULL; + int x=0; /* Check parameters */ if (c==NULL) return("Invalid connection storage location"); @@ -149,10 +150,14 @@ /* Retrieve the provider and set up the conection */ conn->conf=NULL; - //conn->prov=wa_provider_get(p); - //if (conn->prov==NULL) return("Invalid provider name specified"); - //ret=conn->prov->configure(conn,a); - if (ret!=NULL) return(ret); + while(wa_providers[x]!=NULL) { + if(strcasecmp(wa_providers[x]->name,p)==0) { + conn->prov=wa_providers[x]; + break; + } else x++; + } + if (conn->prov==NULL) return("Invalid provider name specified"); + if ((ret=conn->prov->connect(conn,a))!=NULL) return(ret); /* Done */ wa_debug(WA_MARK,"Created connection \"%s\" (Prov: \"%s\" Param: \"%s\")", 1.6 +6 -5 jakarta-tomcat-4.0/connectors/lib/Makefile.in Index: Makefile.in =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/lib/Makefile.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Makefile.in 2001/05/10 06:17:06 1.5 +++ Makefile.in 2001/05/10 08:54:14 1.6 @@ -56,21 +56,22 @@ # ========================================================================= # # @author Pier Fumagalli <mailto:[EMAIL PROTECTED]> -# @version $Id: Makefile.in,v 1.5 2001/05/10 06:17:06 pier Exp $ +# @version $Id: Makefile.in,v 1.6 2001/05/10 08:54:14 pier Exp $ include ../Makedefs OBJS = wa_main.o wa_config.o wa_request.o +PROVS = # pr_info.o pr_warp.o pr_jni.o LIB = libwebapp.a all: $(LIB) -$(LIB): $(OBJS) +$(LIB): $(OBJS) $(PROVS) @echo - Linking library $(LIB) - @$(AR) -cr $(LIB) $(OBJS) + @$(AR) -cr $(LIB) $(OBJS) $(PROVS) @$(RANLIB) $(LIB) clean: - @echo Removing object files $(OBJS) $(LIB) - @rm -f $(OBJS) $(LIB) + @echo Removing object files $(OBJS) $(PROVS) $(LIB) + @rm -f $(OBJS) $(PROVS) $(LIB)