001: package vicazh.hyperpool.stream.net.http.html;
002:
003: import java.io.*;
004: import java.text.*;
005: import java.util.*;
006: import vicazh.hyperpool.stream.*;
007: import vicazh.hyperpool.stream.net.*;
008: import vicazh.hyperpool.stream.net.http.Session;
009:
010: /**
011: * The antivirus service
012: *
013: * @author Victor Zhigunov
014: * @version 0.4.0
015: */
016: public class AntivirusService extends ReportService implements
017: AntivirusServiceMBean, Serializable {
018: public AntivirusService() {
019: }
020:
021: int timeout;
022:
023: String base;
024:
025: ClassLoader loader;
026:
027: OutService outservice;
028:
029: AntivirusClamAVService clamservice;
030:
031: String prefix;
032:
033: /**
034: * @param cachesize
035: * cache size
036: * @param timeout
037: * socket timeout
038: * @param base
039: * resource bundle base name
040: * @param loader
041: * resource bundle class loader
042: * @param prefix
043: * temp files prefix
044: */
045: public AntivirusService(int cachesize, int timeout, String base,
046: ClassLoader loader, String prefix) {
047: super (cachesize);
048: this .timeout = timeout;
049: this .base = base;
050: this .loader = loader;
051: this .prefix = prefix;
052: outservice = new OutService(timeout);
053: clamservice = new AntivirusClamAVService();
054: clamservice.setElement(outservice);
055: }
056:
057: private long buffer;
058:
059: public long getBuffer() {
060: return buffer;
061: }
062:
063: public void setBuffer(long buffer) {
064: this .buffer = buffer;
065: }
066:
067: public Connection getConnection() {
068: return new AntivirusConnection(this );
069: }
070:
071: synchronized void store(Session session, Date date)
072: throws FileNotFoundException {
073: pack();
074: if (session.getClient().getFile() == null || date == null)
075: return;
076: store(date);
077: String delimiter = getDelimiter();
078: ps.print(DateFormat.getDateTimeInstance().format(date));
079: ps.print(delimiter);
080: ps.print(((AntivirusConnection) session.connection).client);
081: ps.print(delimiter);
082: ps.print(((AntivirusStream) session.getServer()).getText());
083: ps.print(delimiter);
084: ps.println(session.getClient().getFile());
085: ps.flush();
086: }
087:
088: private String url;
089:
090: public void setUrl(String url) {
091: this .url = url;
092: }
093:
094: public String getUrl() {
095: return url;
096: }
097:
098: private String host;
099:
100: public void setHost(String host) {
101: if (outservice != null)
102: outservice.setHost(host);
103: this .host = host;
104: }
105:
106: public String getHost() {
107: return host;
108: }
109:
110: private int port;
111:
112: public void setPort(int port) {
113: if (outservice != null)
114: outservice.setPort(port);
115: this .port = port;
116: }
117:
118: public int getPort() {
119: return port;
120: }
121:
122: private String theme;
123:
124: public String getTheme() {
125: return theme;
126: }
127:
128: public void setTheme(String theme) {
129: this .theme = theme;
130: }
131:
132: public void setAttribute(String name, Object value)
133: throws Exception {
134: if (name.equals(FileServiceMBean.OPTIONS)) {
135: setHost(((AntivirusService) value).getHost());
136: setPort(((AntivirusService) value).getPort());
137: setBuffer(((AntivirusService) value).getBuffer());
138: setTheme(((AntivirusService) value).getTheme());
139: setUrl(((AntivirusService) value).getUrl());
140: }
141: super.setAttribute(name, value);
142: }
143: }
|