1 29 30 package nextapp.echo2.webrender.service; 31 32 import java.io.IOException ; 33 34 import nextapp.echo2.webrender.Connection; 35 import nextapp.echo2.webrender.Service; 36 import nextapp.echo2.webrender.util.Resource; 37 38 41 public class StaticTextService 42 implements Service { 43 44 56 public static StaticTextService forResource(String id, String contentType, String resourceName) { 57 String content = Resource.getResourceAsString(resourceName); 58 return new StaticTextService(id, contentType, content); 59 } 60 61 private String id; 62 private String content; 63 private String contentType; 64 65 72 public StaticTextService(String id, String contentType, String content) { 73 super(); 74 this.id = id; 75 this.contentType = contentType; 76 this.content = content; 77 } 78 79 82 public String getId() { 83 return id; 84 } 85 86 89 public int getVersion() { 90 return 0; 91 } 92 93 96 public void service(Connection conn) throws IOException { 97 conn.getResponse().setContentType(contentType); 98 conn.getWriter().print(content); 99 } 100 } 101 | Popular Tags |