public void open( boolean readOnly )
	throws ReadOnlyException,
	       IOException {


	if( !readOnly )
	    throw new ReadOnlyException( "This DirectoryResource implementation only supports read-only access at the moment." );

	if( this.inputStream != null ) 	    
	    throw new IOException( "Cannot re-open DirectoryResource; it's already open." );

	if( !this.dir.isDirectory() ) 
	    throw new IOException( "Cannot open DirectoryResource; file '"+this.requestURI.getPath()+"' is not a directory." );


	
	// Print the directory listing into a buffer!
	getLogger().log( Level.INFO,
			 getClass().getName() + ".open(...)",
			 "Going to generate directory listing for '"+this.requestURI.getPath()+"'." );


	// Call the subclasses directory listing generator :)
	ByteArrayOutputStream out = new ByteArrayOutputStream( 1024 );
	this.generateDirectoryListing( this.sessionID, out );
	out.close();

	// Apply the MIME type (also specified in the subclass).
	this.getMetaData().setMIMEType( this.getDirectoryListingType() );
	


	// This initializes the input stream!
	byte[] rawData = out.toByteArray();
	this.inputStream = new ByteArrayInputStream( rawData );
	this.length = rawData.length;


	// Store the current modification date!
	this.getMetaData().setLastModified( new Date(System.currentTimeMillis()) );
	
    }