pier        00/12/08 01:44:04

  Modified:    catalina/src/share/org/apache/catalina/connector/warp
                        WarpConnectionHandler.java
  Log:
  Configure all Catalina objects (Hosts and Applications/Contexts) from
  data gathered in the connection stage of the protocol.
  
  Revision  Changes    Path
  1.7       +47 -11    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConnectionHandler.java
  
  Index: WarpConnectionHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConnectionHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WarpConnectionHandler.java        2000/12/08 02:57:05     1.6
  +++ WarpConnectionHandler.java        2000/12/08 09:44:04     1.7
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a>
    * @author Copyright &copy; 1999, 2000 <a href="http://www.apache.org">The
    *         Apache Software Foundation.
  - * @version CVS $Id: WarpConnectionHandler.java,v 1.6 2000/12/08 02:57:05 pier Exp $
  + * @version CVS $Id: WarpConnectionHandler.java,v 1.7 2000/12/08 09:44:04 pier Exp $
    */
   public class WarpConnectionHandler extends WarpHandler {
       /** The WarpReader associated with this WarpConnectionHandler. */
  @@ -91,36 +91,69 @@
        *         false if this was the last packet.
        */
       public boolean process(int type, byte buffer[]) {
  +        WarpEngine engine=(WarpEngine)this.getConnector().getContainer();
  +
           this.reader.reset(buffer);
           this.packet.reset();
           try {
               switch (type) {
  -                case WarpConstants.TYP_CONINIT_HST:
  +                case WarpConstants.TYP_CONINIT_HST: {
                       String name=reader.readString()+":"+reader.readShort();
                       
                       // Retrieve this host id
  -                    int hid=this.getConnector().setupHost(name);
  -                    if (DEBUG) this.debug("Created new host "+name+" ID="+hid);
  +                    int hid=engine.setupChild(name).getHostID();
  +                    if (DEBUG) this.debug("Host "+name+" has ID="+hid);
   
                       // Send the HOST ID back to the WARP client
                       this.packet.reset();
                       this.packet.writeShort(hid);
                       this.send(WarpConstants.TYP_CONINIT_HID,this.packet);
                       break;
  +                }
  +
  +                case WarpConstants.TYP_CONINIT_APP: {
  +                    int hid=reader.readShort();
  +                    String name=reader.readString();
  +                    String path=reader.readString();
  +
  +                    // Retrieve this host (based on the host ID)
  +                    WarpHost host=(WarpHost)engine.findChild(hid);
  +                    if (host==null) {
  +                        this.log("Host ID "+hid+" not found");
  +                        this.packet.reset();
  +                        this.send(WarpConstants.TYP_CONINIT_ERR,this.packet);
  +                        return(false);
  +                    }
   
  -                case WarpConstants.TYP_CONINIT_APP:
  +                    // Retrieve this application (based on the path)
  +                    WarpContext cont=(WarpContext)host.findChild(path);
  +                    // Check if we can find it by application name
  +                    if (cont==null)
  +                        cont=(WarpContext)host.findChild('/'+name);
   
  -                    // Retrieve this application id
  -                    int aid=321;
  -                    if (DEBUG) this.debug("CONINIT_APP "+reader.readString()+
  -                                          ":"+reader.readString()+"="+aid);
  +                    // We definitely didn't find the application
  +                    if (cont==null) {
  +                        this.log("Application "+name+" with path "+path+
  +                                 " not found");
  +                        this.packet.reset();
  +                        this.send(WarpConstants.TYP_CONINIT_ERR,this.packet);
  +                        return(false);
  +                    }
  +
  +                    // Ok, we found the right application
  +                    int aid=cont.getApplicationID();
  +                    cont.setPath(path);
  +                    cont.setDisplayName(name);
  +                    if (DEBUG) this.debug("Application "+name+" mapped in "+
  +                                          host.getName()+path+" has ID "+aid);
                       // Send the APPLICATION ID back to the WARP client
                       this.packet.reset();
                       this.packet.writeShort(aid);
                       this.send(WarpConstants.TYP_CONINIT_AID,this.packet);
                       break;
  +                }
   
  -                case WarpConstants.TYP_CONINIT_REQ:
  +                case WarpConstants.TYP_CONINIT_REQ: {
                       // Create a new WarpRequestHandler and register it with
                       // an unique RID.
                       int r=this.request;
  @@ -144,12 +177,15 @@
                       this.packet.writeShort(r);
                       this.send(WarpConstants.TYP_CONINIT_RID,this.packet);
                       break;
  -                default:
  +                }
  +
  +                default: {
                       this.log("Wrong packet type "+type+". Closing connection");
                       // Post an error message back to the WARP client
                       this.packet.reset();
                       this.send(WarpConstants.TYP_CONINIT_ERR,this.packet);
                       return(false);
  +                }
               }
               return(true);
           } catch (IOException e) {
  
  
  

Reply via email to