Commit Graph

604 Commits

Author SHA1 Message Date
mdb b1f9ac47a3 If we tell log4j who we are, it will figure out the caller properly.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2316 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-28 18:33:07 +00:00
mdb 84597c3b99 Added log4j support to the log wrapper. It is enabled if the log4j
configuration system property is set (and a particular logger is not
specifically configured).


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2315 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-28 18:02:37 +00:00
mdb 301a695cd8 Accept our new logger as well as Java loggers.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2314 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 19:36:54 +00:00
mdb 9a5968fe08 Use new logging shim.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2313 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 18:40:39 +00:00
mdb 4af8953a19 A simple log wrapper that allows samskivert itself and libraries that depend on
samskivert to use logging services without creating a dependency on a logging
implementation.

This is basically what JCL (Jakarta Commons Logging) does except they do
auto-detection based on what's in the classpath and we're only going to
auto-detect log4j and only use it if we see that a log4j configuration has been
provided via a system property (or maybe not at all, I'm not sure yet). The
point is avoid the major gripe about JCL which is that when you stick some
logging system's jar file into your classpath for some other dependency (or
it's there for unknown reasons like maybe your servlet container uses it), all
of a sudden your log output disappears or breaks.

I had an idea while doing this and couldn't resist slipping it in: all of the
logging methods take varargs additional parameters which are a set of key/value
pairs to append to the log message in our standard format with an optional
final exception to be logged as well.

So instead of:

  log.warning("Oh crap, the fibbleminscher has exploded [state=" + 15 + 
              ", monkeys=" + StringUtil.toString(_monkeys) + "].");

You do:

  log.warning("Oh crap, the fibbleminscher has exploded.", "state", 15,
              "monkeys", _monkeys);

The formatter automatically does the StringUtil.toString magic on the arguments
(and does it safely so that if toString throws an exception the log message
isn't lost). You can also throw an exception in the mix:

  log.warning("Oh crap, the fibbleminscher has exploded.", "state", 15,
              "monkeys", _monkeys, ioe);

Or supply one with no parameters:

  log.warning("Oh mammy!", ioe);

Or even just log an exception if you have nothing pithy to add:

  log.warning(ioe);

Some research shows that other people have started doing this in their logging
systems as well under the fancier name of parameterized logging. The big
benefit is that you can pass objects that are expensive to toString() and avoid
toString()ing them unless you're actually going to generate the log message.
In our case we also get the benefit of our standard formatting and less
cluttered code (begone lots of + ", ...=" + typing).

I'm going to be doing away with the old samskivert Log code and converting all
of our libraries (and projects) to use this new shim so that we can easily
switch to using log4j, which for other reasons we want to use instead of Java's
built-in logging.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2311 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 18:36:32 +00:00
ray 7adef99c05 Per Charlie's suggestion, throw an unchecked exception if schedule() is called
with fixedRate=false when a RunQueue has been specified.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2309 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 21:21:06 +00:00
ray 97684500b6 Added a note explaining why this may not actually work as Charlie wants it to
without some restructuring of his code.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2308 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 19:38:42 +00:00
ray c074f73bcb Patch from Charlie Groves to expose Timer's ability to schedule at a
fixed delay. We haven't needed this before now.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2307 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 19:34:23 +00:00
ray f37ba48cce git-svn-id: https://samskivert.googlecode.com/svn/trunk@2306 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-05-19 18:32:58 +00:00
mdb c51b652abd Created a unit for when we just want to write something to the database and do
nothing with the results.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2305 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-18 11:11:28 +00:00
ray 328fae15e6 git-svn-id: https://samskivert.googlecode.com/svn/trunk@2303 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-05-16 03:20:27 +00:00
ray fbfd736f25 We need parens so that operators are evaluated in the right order.
This adds extra params around a bunch of things. I'll let the gods of Depot
sort that out.

BTW: Arithmetic.Div is still totally broken. It somehow booches the prepared
statement. I tried changing the operator String to "//" and that sorta worked,
but then the next operator over was missing...
I'm working around this using Mul, but it'd be nice..


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2302 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-16 02:10:07 +00:00
ray 77378ac880 Added static compare() methods for all the primitive types,
except where Sun has already done it for us.
- We always return 1, 0, or -1.
- We guard against overflows for ints and longs.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2300 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-07 00:42:18 +00:00
ray 8b06f28a9e Formatting tweaks I had laying around.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2299 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-30 21:06:38 +00:00
ray 104d861719 Changed the TimerTask being used to be a static inner class with an
explicit reference back to the Interval so that we can clear that
reference when the Interval is cancelled. The reason for this is that
TimerTasks sit on the Timer's internal queue until their scheduled
execution time, even if they've been cancelled. We want to allow
any references that the Interval has to be gc-able after cancellation.

Note two things:
- Once an interval is cancelled, calls to getInterval() or toString()
on the RunBuddy are invalid, even if the calls are happening inside
expired(). This probably will only affect you if you cancel() the interval
in the expired() method, but maybe I should prevent badness here anyway...
- Interval has potential for a small slip that would prevent gc. If
multiple threads are scheduling and cancelling an interval simultaneously,
it's possible (since I avoid synchronizing anywhere) for a task to
be created that incorrectly thinks it should be alive. It will never
expire(), as once it tries to it will discover that it's invalid
and will cancel at that time, but in the meanwhile the task has been
holding onto a reference to the Interval. This would not be an error,
just a non-optimal memory situation, it would rarely occur, and it
probably can never occur in most of our code since we tend to use
a single thread for scheduling and cancelling Intervals.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2298 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-29 20:41:58 +00:00
mdb 0cf663e07b Added copyMergedOutput().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2297 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-28 22:00:55 +00:00
mdb 099f6be796 git-svn-id: https://samskivert.googlecode.com/svn/trunk@2296 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-04-25 18:32:44 +00:00
mdb 954715191a Pass -Dcom.samskivert.jdbc.depot.debug=true to have Depot log queries before
they are executed.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2295 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-23 23:29:07 +00:00
zell f95e741c20 Yank our nomenclature into consistency -- indices, not indexes; fields(), not fieldNames(), as per Ray's suggestion.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2294 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-14 20:18:45 +00:00
mdb 18e8371dac Static methods can do type magic and save us from repeating ourselves.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2293 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-08 17:30:35 +00:00
mdb e4eed9d775 If we encounter an error posting ourselves to a run-queue when we expire, log
something useful.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2292 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-08 01:20:55 +00:00
zell ef15c874fa The query is in no way guaranteed to uniquely keyed rows, so let's stuff the result into a Set. We should probably add the 'unique' modifier to the actual query, but that requires a bit more cross-dialect-and-version research than I'm willing to give it just now.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2291 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-06 14:57:14 +00:00
mdb 9bf52de99f Don't let invoker units be posted after the invoker has been shutdown.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2290 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-04 17:29:39 +00:00
mdb 72c63304f8 If someone call's setPreferredSize(), we should use that size.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2289 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-04 00:39:10 +00:00
ray c7e70fbab6 Now that generics provide us with some compile-time checking of the
class argument, let's stop with the runtime checking.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2288 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-03 02:29:02 +00:00
mdb 93dad1abbb Update comments.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2287 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-01 21:40:11 +00:00
mdb a44f502997 Nix @Table, move its fields into @Entity.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2286 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-01 21:27:20 +00:00
mdb 0c5e9d9801 Throw a useful error message when we are asked to create a primary key with
mixed null and non-null values.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2285 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-29 23:19:42 +00:00
mdb 2bf18551f2 Support update partial with a Key<T>.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2284 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-29 00:32:19 +00:00
andrzej 024932d4c4 Implement propertyNames in the Properties object returned by
getFilteredProperties so that it works with getSubProperties.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2283 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-27 20:01:20 +00:00
mdb 3dce990f2b Missed a spot.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2282 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-26 03:00:10 +00:00
mdb 5180c61046 A utility class for copying the output of a process to a Logger.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2281 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-26 02:55:58 +00:00
mdb cdc5941479 Widen 'em up!
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2280 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-21 21:33:39 +00:00
mjohnson 277454fe78 Allow a null FieldDescriptor array so that a dummy FieldMask can be
created which let's anything go


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2279 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-21 01:47:46 +00:00
mjohnson 6253530d1e Add a (easily overriden) refreshSession
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2278 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-12 22:06:31 +00:00
zell 2da510c744 Don't try to build an UPDATE statement at all if no key were set on the record sent into store(). Also throw a sensible (if scaredy-cat) exception rather than an NPE if no WHERE clause were given to an UPDATE. We probably do want to allow rampant nutty 20,000-row UPDATEs at some point, but not because of an accidental null key.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2277 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-03-10 22:28:11 +00:00
mdb 195c16e06a It used to be that if you created a TextLayout with a font render context that
indicated the use of antialiasing, rendering that TextLayout would render with
antialiasing. However, it seems that some JVMs don't do that, so we need to
manually enable antialiasing before rendering the TextLayout. Such are the
millions of tiny inconsistencies that undermine write once run anywhere.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2276 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-29 20:11:03 +00:00
mdb 8b7610f188 Added sha1hex(), moved protected methods down below public.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2275 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-26 22:46:40 +00:00
mdb 75d4cd3f72 We need to guard against simultaneous calls to getCache().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2274 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-14 18:55:21 +00:00
mdb fa3bb14298 Added NotEquals.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2273 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-12 21:52:44 +00:00
mdb c5d9fbe949 None of these constructors actually throw a PersistenceException, so we'll go
ahead and not declare that they do.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2272 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-07 19:59:54 +00:00
mdb 93670b9d30 Operate on List not ArrayList. Widening.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2271 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-07 19:54:57 +00:00
samskivert@gmail.com c96bcb7bce Added a brevifying factory method:
ExpiringReference<OMGLongName> ref = ExpiringReference.create(foo, 1000);


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2270 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-02-06 21:45:53 +00:00
ray 24f524549b Don't require intervention to work in applets, just fix ourselves.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2269 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-01-31 04:27:48 +00:00
mdb 2338ec8e32 Spelling fixes from Dave.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2268 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-01-14 23:41:09 +00:00
mdb 6954e1a61b Optimization suggested by Ray.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2267 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2007-12-17 22:25:57 +00:00
mdb 43ec6f629c Let's encapsulate Sun's signal stuff so that we can avoid having their verbose
annoying (unsuppressable) warning messages in our various projects that
actually want to receive signals.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2266 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2007-12-17 22:23:25 +00:00
mdb f35af58377 Added ObjectUtil.compare(Comparable,Comparable) which sorts nulls before
non-nulls; added ComparableTuple which sorts first on its left element (nulls
sorting before non-nulls) and then on its right.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2265 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2007-12-17 21:56:17 +00:00
mdb 47c97d6356 Nixed redundant cast.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2264 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2007-12-17 19:47:27 +00:00
mdb f0b4c1f338 Another type clarification.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2263 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2007-12-17 19:46:28 +00:00