tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arieh Markel <Arieh.Mar...@Central.Sun.COM>
Subject Re: Starting HttpServer from Java app...
Date Wed, 19 Jan 2000 18:22:23 GMT
I am actually doing exactly what you are trying to do.

> Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm
> X-No-Archive: yes
> list-help: <mailto:tomcat-dev-help@jakarta.apache.org>
> list-unsubscribe: <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> list-post: <mailto:tomcat-dev@jakarta.apache.org>
> Delivered-To: mailing list tomcat-dev@jakarta.apache.org
> From: Dustin Callaway <DCallaway@hfnweb.com>
> To: "'tomcat-dev@jakarta.apache.org'" <tomcat-dev@jakarta.apache.org>
> Subject: Starting HttpServer from Java app...
> 
> Has anyone figured out how to start the Tomcat HttpServer from within a Java
> application? Both the Tomcat binaries and source code include a sample file
> called SimpleStartup.java that supposedly demonstrates how to do this.
> However, this program does not compile due to some API problems. The errant
> code looks like this:
> 
> int port = 8080;
> InetAddress inet = null; // null uses all inets on the machine
> String hostname = null;
> HttpServer server = new HttpServer(port, inet, hostname);
> try {
>     URL url = resolveURL("webpages");
>     server.setDocumentBase(url);  <<<<<<<<<<<<<<<<<<<<
this method does not
> exist
>     System.out.println("Starting with docbase of: " + url);
>     server.start();
> }

However, instead of using the 'raw' HttpServer class, I am taking advantage
of the shell.Startup class.

I am invoking is as follows:

	Startup.configure (evaluateArgs());
	
where args is one of the valid switch/value combinations that are allowed:

below is a function that evaluates the deployment arguments for me:


    public static String[]  evaluateArgs ()
    {
        ArrayList al = new ArrayList();

        al.add ("-config");
        al.add (getConfigFile());

        al.add ("-docbase");
        al.add (getDocumentBase());

        al.add ("-adminport");
        al.add ("0");

        String[] argv = (String[]) al.toArray (new String[al.size()]);

        return argv;
    }

Arieh

PS: alternatively, you could modify the shell.Startup class and make it do
    whatever you want. The principles there, of configuration of Contexts
    and ContextManagers are valuable.
--
 Arieh Markel		                Sun Microsystems Inc.
 Network Storage                        500 Eldorado Blvd. MS UBRM11-194
 e-mail: arieh.markel@sun.COM           Broomfield, CO 80021
 Let's go Panthers !!!!                 Phone: (303) 272-8547 x78547
 (e-mail me with subject SEND PUBLIC KEY to get public key)


Mime
View raw message