1 16 package org.apache.cocoon.portlet; 17 18 import org.apache.log.format.Formatter; 19 import org.apache.log.output.AbstractOutputTarget; 20 21 import javax.portlet.PortletContext; 22 23 30 public class PortletOutputLogTarget extends AbstractOutputTarget { 31 32 private PortletContext context; 33 34 public PortletOutputLogTarget(PortletContext context) { 35 this.context = context; 36 open(); 37 } 38 39 public PortletOutputLogTarget(PortletContext context, Formatter formatter) { 40 super(formatter); 41 this.context = context; 42 open(); 43 } 44 45 protected void write(String message) { 46 PortletContext context = this.context; 47 if (context != null) { 48 synchronized (context) { 49 context.log(message); 50 } 51 } 52 } 53 54 public synchronized void close() { 55 super.close(); 56 this.context = null; 57 } 58 } 59 | Popular Tags |