/* (non-Javadoc)
@see javax.servlet.ServletOutputStream#setWriteListener(javax.servlet.WriteListener)
769177
@Override
    public void setWriteListener(WriteListener appWLObject) {
        //Throw a NullPointerException if the WriteListener passed in was null
        if(appWLObject == null){            

            Tr.error(tc, "writelistener.is.null");  
            throw new NullPointerException(Tr.formatMessage(tc, "writelistener.is.null"));
        } 
        if(_outHelper.isOutputStream_closed() || _outHelper.isOutputStream_close_initiated_but_not_Flush_ready()){
            Tr.error(tc, "stream.is.closed.no.read.write");                         
            throw new IllegalStateException(Tr.formatMessage(tc, "stream.is.closed.no.read.write"));           
        }
        //Throw an IllegalStateException is there was already a WriteListener set for this InputStream
        if(this._listener != null){            
            Tr.error(tc, "writelistener.already.started");                         
            throw new IllegalStateException(Tr.formatMessage(tc, "writelistener.already.started"));
        } 
        this._listener = appWLObject;        
        //Create the ThreadContextManager to save off the threads information to pass onto new threads
        ThreadContextManager tcm = new ThreadContextManager();
        //Create a new callback
        this.callback = new UpgradeAsyncWriteCallback(this._listener, this , tcm, _outHelper._upConn);                         
        _outHelper.setWriteListenerCallBack(callback);
        _outHelper.set_listener(_listener);

        //Create the WriteListenerRunnable to call onWritePossible on a new thread
        UpgradeWriteListenerRunnable wlRunnable = new UpgradeWriteListenerRunnable(this._listener, this , tcm, callback);

        // make sure no more write allowed on this Thread as this set
        // WriteListener.
        WebContainerRequestState reqState = WebContainerRequestState.getInstance(true);
//        reqState.setAttribute("com.ibm.ws.webcontainer.upgrade.ThisThreadSetWL", true);
        reqState.removeAttribute("com.ibm.ws.webcontainer.upgrade.WriteAllowedonThisThread");

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
            Tr.debug(tc, "setWriteListener: start new thread with wlRunnable");
        }

        try {
            com.ibm.ws.webcontainer.osgi.WebContainer.getExecutorService().execute(wlRunnable);
        } catch (Exception e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "setWriteListener: An exception occurred during the execute : " + e);
            }
            this.callback.error(_outHelper.get_vc(), e);                
        }


    }
454817
public void setListener(T listener) {
		Assert.notNull(listener, "Listener must not be null");
		Assert.isTrue(isSupportedType(listener), "Listener is not of a supported type");
		this.listener = listener;
	}
79616
public void write(String s) throws IOException {
	    if (writer != null) {
	        writer.write(s);
	    } else {
	        write(s, 0, s.length());
	    }
    }
1225319
@Override
    public void writeExternal(ObjectOutput s) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Serializing " + this);
        }
        super.writeExternal(s);
    }
19917
private void writeObject(java.io.ObjectOutputStream out) throws IOException
	{
		if (delegateMethods != null)
		{
			delegateMethods.clear();
		}

		out.defaultWriteObject();
	}
1355614
private synchronized void writeObject(java.io.ObjectOutputStream s)
        throws IOException
    {
        if (scope_ifname_set) {
            ifname = scope_ifname.getName();
        }
        s.defaultWriteObject();
    }
807818
public void write(final int b) {
        Holder<T> log = getOrReset();
        if (b == '\n') {
            flushEventBuffer();
        } else if (b == '\r') {
            log.setCrchar(true);
        } else {
            if (log.isCrchar()) {
                flushEventBuffer();
                resetEventBuffer();
            }
            log.getBuffer().write((byte) b);
        }

    }
1079177
def write(self, data):
        
        
        # Do the write
        self.backingStream.write(data)
        
        for listener in self.writeListeners:
            # Send out notifications
            listener(len(data))
145148
private void writeEjbModule(String filename) {
        Element element = writeModule();
        Element ejb = doc.createElement("ejb");
        element.appendChild(ejb);
        ejb.setTextContent(filename);
    }
719943
public void write()
        throws IOException
    {
        BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( m_outputStream ) );
        for( String line : m_content )
        {
            writer.write( line );
            writer.newLine();
        }
        writer.flush();
        writer.close();
    }
1354838
protected final void write(String string)
            throws JspException
    {
        JspContext ctxt = getJspContext();
        JspWriter writer = ctxt.getOut();
        try {
            writer.print(string);
        }
        catch (IOException e) {
            logger.error(Bundle.getString("Tags_WriteException"), e);
            if (ctxt instanceof PageContext)
                RequestUtils.saveException((PageContext) ctxt, e);
            JspException jspException = new JspException(e.getMessage(), e);

            // todo: future cleanup
            // The 2.5 Servlet api will set the initCause in the Throwable superclass during construction,
            // this will cause an IllegalStateException on the following call.
            if (jspException.getCause() == null) {
                jspException.initCause(e);
            }
            throw jspException;
        }
    }
66844
@Override
    public void setReadListener(ReadListener arg0) {
        if(closed) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                Tr.error(tc, "stream.is.closed.no.read.write");
            throw new IllegalStateException(Tr.formatMessage(tc, "stream.is.closed.no.read.write"));
        }
        _inBuffer.setupReadListener(arg0, this);
    }
639590
public void addListener(final WebAppListener listener) {
		NullArgumentException.validateNotNull(listener, "Listener");
		NullArgumentException.validateNotNull(listener.getListenerClass(),
				"Listener class");
		if (!listeners.contains(listener)) {
			listeners.add(listener);
		}
	}
749871
public final synchronized void addListener(EventListener l) {
        if(l ==null) {
            throw new IllegalArgumentException("Listener " + l +
                                               " is null");
        }
        if(listeners == EMPTY_LISTENERS) {
            listeners = new EventListener[1];
            listeners[0] = l;
        }
        else {
            int i = listeners.length;
            EventListener[] tmp = new EventListener[i+1];
            System.arraycopy(listeners, 0, tmp, 0, i);

            tmp[i] = l;
            listeners = tmp;
        }
    }
109880
private static void generateToCConnectionListener(Map<String, List<TraceEvent>> events, FileWriter fw)
      throws Exception
   {
      writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
      writeEOL(fw);
      writeString(fw, "                      \"http://www.w3.org/TR/html4/loose.dtd\">");
      writeEOL(fw);

      writeString(fw, "<html>");
      writeEOL(fw);

      writeString(fw, "<head>");
      writeEOL(fw);

      writeString(fw, "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">");
      writeEOL(fw);

      writeString(fw, "<title>Reference: ConnectionListener</title>");
      writeEOL(fw);

      writeString(fw, "</head>");
      writeEOL(fw);

      writeString(fw, "<body style=\"background: #D7D7D7;\">");
      writeEOL(fw);

      writeString(fw, "<h1>Reference: ConnectionListener</h1>");
      writeEOL(fw);

      writeString(fw, "<table>");
      writeEOL(fw);
      
      writeString(fw, "<tr>");
      writeEOL(fw);

      writeString(fw, "<td><b>ConnectionListener</b></td>");
      writeEOL(fw);

      writeString(fw, "<td><b>ManagedConnectionPool</b></td>");
      writeEOL(fw);

      writeString(fw, "<td><b>Pool</b></td>");
      writeEOL(fw);

      writeString(fw, "</tr>");
      writeEOL(fw);

      for (Map.Entry<String, List<TraceEvent>> entry : events.entrySet())
      {
         TraceEvent te = entry.getValue().get(0);

         writeString(fw, "<tr>");
         writeEOL(fw);

         writeString(fw, "<td><a href=\"" + te.getPool() + "/" + te.getConnectionListener() + "/index.html\">" +
                     te.getConnectionListener() + "</a></td>");
         writeEOL(fw);
         
         writeString(fw, "<td>" + te.getManagedConnectionPool() + "</td>");
         writeEOL(fw);
      
         writeString(fw, "<td><a href=\"" + te.getPool() + "/index.html\">" + te.getPool() + "</a></td>");
         writeEOL(fw);
      
         writeString(fw, "</tr>");
         writeEOL(fw);
      }

      writeString(fw, "</table>");
      writeEOL(fw);

      writeString(fw, "<p>");
      writeEOL(fw);

      writeString(fw, "<a href=\"index.html\">Back</a>");
      writeEOL(fw);

      writeString(fw, "</body>");
      writeEOL(fw);

      writeString(fw, "</html>");
      writeEOL(fw);
   }
8420
public void write(Writer out)
         throws IOException
    {
        writeHtmlHead(out);
        writeBodyTag(out);
        writeElements(out);
        writeHtmlEnd(out);
    }
772638
public void setWriter(Object sysLogHolder, Object sysErrHolder) {
        this.sysOutHolder = (SystemLogHolder) sysLogHolder;
        this.sysErrHolder = (SystemLogHolder) sysErrHolder;
    }