87 * @author Kohsuke Kawaguchi |
87 * @author Kohsuke Kawaguchi |
88 * @author Jitendra Kotamraju |
88 * @author Jitendra Kotamraju |
89 */ |
89 */ |
90 public class HttpAdapter extends Adapter<HttpAdapter.HttpToolkit> { |
90 public class HttpAdapter extends Adapter<HttpAdapter.HttpToolkit> { |
91 |
91 |
|
92 private static final Logger LOGGER = Logger.getLogger(HttpAdapter.class.getName()); |
|
93 |
92 /** |
94 /** |
93 * {@link com.sun.xml.internal.ws.api.server.SDDocument}s keyed by the query string like "?abc". |
95 * {@link com.sun.xml.internal.ws.api.server.SDDocument}s keyed by the query string like "?abc". |
94 * Used for serving documents via HTTP GET. |
96 * Used for serving documents via HTTP GET. |
95 * |
97 * |
96 * Empty if the endpoint doesn't have {@link com.sun.xml.internal.ws.api.server.ServiceDefinition}. |
98 * Empty if the endpoint doesn't have {@link com.sun.xml.internal.ws.api.server.ServiceDefinition}. |
850 pw.println(header.getKey() + ": " + value); |
852 pw.println(header.getKey() + ": " + value); |
851 } |
853 } |
852 } |
854 } |
853 } |
855 } |
854 } |
856 } |
855 buf.writeTo(baos); |
857 if (buf.size() > dump_threshold) { |
|
858 byte[] b = buf.getRawData(); |
|
859 baos.write(b, 0, dump_threshold); |
|
860 pw.println(); |
|
861 pw.println(WsservletMessages.MESSAGE_TOO_LONG(HttpAdapter.class.getName() + ".dumpTreshold")); |
|
862 } else { |
|
863 buf.writeTo(baos); |
|
864 } |
856 pw.println("--------------------"); |
865 pw.println("--------------------"); |
857 |
866 |
858 String msg = baos.toString(); |
867 String msg = baos.toString(); |
859 if (dump) { |
868 if (dump) { |
860 System.out.println(msg); |
869 System.out.println(msg); |
944 /** |
953 /** |
945 * Dumps what goes across HTTP transport. |
954 * Dumps what goes across HTTP transport. |
946 */ |
955 */ |
947 public static volatile boolean dump = false; |
956 public static volatile boolean dump = false; |
948 |
957 |
|
958 public static volatile int dump_threshold = 4096; |
|
959 |
949 public static volatile boolean publishStatusPage = true; |
960 public static volatile boolean publishStatusPage = true; |
950 |
961 |
951 public static synchronized void setPublishStatus(boolean publish) { |
962 public static synchronized void setPublishStatus(boolean publish) { |
952 publishStatusPage = publish; |
963 publishStatusPage = publish; |
953 } |
964 } |
954 |
965 |
955 static { |
966 static { |
956 try { |
967 try { |
957 dump = Boolean.getBoolean(HttpAdapter.class.getName()+".dump"); |
968 dump = Boolean.getBoolean(HttpAdapter.class.getName() + ".dump"); |
958 } catch( Throwable t ) { |
969 } catch (SecurityException se) { |
959 // OK to ignore this |
970 if (LOGGER.isLoggable(Level.CONFIG)) { |
|
971 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.", |
|
972 new Object[] {HttpAdapter.class.getName() + ".dump"}); |
|
973 } |
960 } |
974 } |
961 try { |
975 try { |
962 setPublishStatus(System.getProperty(HttpAdapter.class.getName()+".publishStatusPage").equals("true")); |
976 dump_threshold = Integer.getInteger(HttpAdapter.class.getName() + ".dumpTreshold", 4096); |
963 } catch( Throwable t ) { |
977 } catch (SecurityException se) { |
964 // OK to ignore this |
978 if (LOGGER.isLoggable(Level.CONFIG)) { |
|
979 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.", |
|
980 new Object[] {HttpAdapter.class.getName() + ".dumpTreshold"}); |
|
981 } |
|
982 } |
|
983 try { |
|
984 setPublishStatus(Boolean.getBoolean(HttpAdapter.class.getName() + ".publishStatusPage")); |
|
985 } catch (SecurityException se) { |
|
986 if (LOGGER.isLoggable(Level.CONFIG)) { |
|
987 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.", |
|
988 new Object[] {HttpAdapter.class.getName() + ".publishStatusPage"}); |
|
989 } |
965 } |
990 } |
966 } |
991 } |
967 |
992 |
968 public static void setDump(boolean dumpMessages) { |
993 public static void setDump(boolean dumpMessages) { |
969 HttpAdapter.dump = dumpMessages; |
994 HttpAdapter.dump = dumpMessages; |
970 } |
995 } |
971 private static final Logger LOGGER = Logger.getLogger(HttpAdapter.class.getName()); |
|
972 } |
996 } |