Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 92534 invoked from network); 12 Oct 2010 18:08:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 Oct 2010 18:08:07 -0000 Received: (qmail 75621 invoked by uid 500); 12 Oct 2010 18:08:04 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 75419 invoked by uid 500); 12 Oct 2010 18:08:04 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 75410 invoked by uid 99); 12 Oct 2010 18:08:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Oct 2010 18:08:04 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.96.62.16] (HELO qmta01.westchester.pa.mail.comcast.net) (76.96.62.16) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Oct 2010 18:07:55 +0000 Received: from omta06.westchester.pa.mail.comcast.net ([76.96.62.51]) by qmta01.westchester.pa.mail.comcast.net with comcast id HstH1f00916LCl051u7agU; Tue, 12 Oct 2010 18:07:34 +0000 Received: from [192.168.1.202] ([69.143.109.145]) by omta06.westchester.pa.mail.comcast.net with comcast id Hu7Z1f00e38FjT13Su7a2F; Tue, 12 Oct 2010 18:07:34 +0000 Message-ID: <4CB4A3E4.7040103@christopherschultz.net> Date: Tue, 12 Oct 2010 14:07:32 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Disable class monitoring for reloading container classes References: <4CAE3C0B.2060901@christopherschultz.net> <4CAE4113.5000209@pidster.com> <4CAF339F.5070806@christopherschultz.net> <4CAFC571.60908@christopherschultz.net> <99C8B2929B39C24493377AC7A121E21F99EC0C85CD@USEA-EXCH8.na.uis.unisys.com> <4CB079B7.807@ice-sa.com> <4CB09E02.3050609@ice-sa.com> <99C8B2929B39C24493377AC7A121E21F99ED0A4FFD@USEA-EXCH8.na.uis.unisys.com> <4CB1BB16.8090001@ice-sa.com> In-Reply-To: <4CB1BB16.8090001@ice-sa.com> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 André, On 10/10/2010 9:09 AM, André Warnier wrote: > What would be really nice, is if someone wrote a quick Java equivalent > to the perl script I submitted. See below. There's actually more code than absolutely necessary, but it's more straightforward this way. > Now if you *really* insist, the modified version of the perl program, > below, will explicitly use a couple of C functions, themselves using the > builtin C structures to get the file's "last modified" time. > > Running C in perl, scary stuff.. Are you submitting an application for an obfuscated C program, here? Sheesh. What's wrong with a little C code? Amazing: the C code is shorter than the Java code. *shrug* Time.java (apologies for any re-formatting done by my emailer) - --------- import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; public class Time { public static void main(String[] args) throws Exception { if(args.length < 1) { System.out.println("Usage: java Time "); System.exit(1); } // GMT current time Calendar now = Calendar.getInstance(TimeZone.getTimeZone("GMT")); System.out.println("Current GMT time (no DST): " + format(now)); // local current time now = Calendar.getInstance(); // default = local System.out.println("Current local time (with DST): " + format(now)); // File timestamp System.out.println("File [" + args[0] + "]"); File file = new File(args[0]); long timestamp = file.lastModified(); System.out.println("last modified timestamp: " + timestamp); System.out.println("the file was last modified " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds ago"); Calendar tstamp = Calendar.getInstance(TimeZone.getTimeZone("GMT")); tstamp.setTimeInMillis(file.lastModified()); System.out.println("last modified as GMT time (no DST): " + format(tstamp)); tstamp = Calendar.getInstance(); // default=local tstamp.setTimeInMillis(file.lastModified()); System.out.println("last modified as local time: " + format(tstamp)); } public static String format(Calendar c) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); // format.setTimeZone(tz); format.setTimeZone(c.getTimeZone()); return format.format(c.getTime()); } } time.c - ------ #include #include #include #include int main(int argc, char *argv[]) { time_t now; struct tm *gmt; struct tm *local; struct stat *fileinfo; int retval; char *filename; if(argc < 2) { printf("missing filename\n"); return 1; } filename = argv[1]; gmt = (struct tm*)malloc(sizeof(struct tm)); local = (struct tm*)malloc(sizeof(struct tm)); time(&now); gmtime_r(&now, gmt); localtime_r(&now, local); /* note: asctime adds a newline */ printf("System raw timestamp: %ld\n", now); printf("Current GMT time (no DST): %s", asctime(gmt)); printf("Current local time (with DST): %s", asctime(local)); fileinfo = (struct stat *)malloc(sizeof(struct stat)); printf("File [%s]:\n", filename); if(stat(filename, fileinfo)) { perror(filename); } else { gmtime_r(&(fileinfo->st_mtime), gmt); localtime_r(&(fileinfo->st_mtime), local); printf("last modified timestamp: %ld\n", (long)fileinfo->st_mtime); printf("the file was last modified %ld seconds ago\n", (now - fileinfo->st_mtime)); printf("last modified as GMT time (no DST): %s", asctime(gmt)); printf("last modified as local time (with DST): %s", asctime(local)); } return 0; } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAky0o+QACgkQ9CaO5/Lv0PBbvACeLdBAsYKcpP95KkKvJQCNhBP5 TbUAnAxjQk/yLYhSvoq/uWbcl6b6mbv2 =7yhg -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org