Changeset 100 for java/main/src/main/java/com/framsticks/util
- Timestamp:
- 07/12/13 23:41:06 (11 years ago)
- Location:
- java/main/src/main/java/com/framsticks/util
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/Logging.java
r96 r100 1 1 package com.framsticks.util; 2 2 3 import org.apache.log 4j.Logger;3 import org.apache.logging.log4j.Logger; 4 4 5 5 import com.framsticks.util.dispatching.ExceptionResultHandler; … … 28 28 }; 29 29 } 30 31 public static <T> T passThru(Logger log, String header, T value) { 32 log.info("{}: {}", header, value); 33 return value; 34 } 30 35 } -
java/main/src/main/java/com/framsticks/util/Misc.java
r88 r100 1 1 package com.framsticks.util; 2 2 3 // import org.apache.log 4j.Logger;3 // import org.apache.logging.log4j.Logger; 4 4 5 5 /** … … 8 8 public class Misc { 9 9 // private static final Logger log = 10 // Log ger.getLogger(Misc.class);10 // LogManager.getLogger(Misc.class); 11 11 12 12 public static class WithType { … … 34 34 35 35 public static boolean equals(Object a, Object b) { 36 // log.info("equality of " + withType(a) + " ? " +withType(b));36 // log.info("equality of {} ? {}", withType(a), withType(b)); 37 37 if (a != null) { 38 38 return (b != null && a.equals(b)); -
java/main/src/main/java/com/framsticks/util/dispatching/AbstractJoinable.java
r97 r100 10 10 11 11 import org.apache.commons.collections.CollectionUtils; 12 import org.apache.log4j.Logger; 12 import org.apache.logging.log4j.Logger; 13 import org.apache.logging.log4j.LogManager; 13 14 14 15 import com.framsticks.util.FramsticksException; … … 16 17 public abstract class AbstractJoinable implements Joinable { 17 18 18 private static final Logger log = Log ger.getLogger(AbstractJoinable.class);19 private static final Logger log = LogManager.getLogger(AbstractJoinable.class); 19 20 20 21 protected final Set<JoinableParent> owners = new HashSet<JoinableParent>(); … … 41 42 } 42 43 } 43 log.debug("state: " +b);44 log.debug("state: {}", b); 44 45 } 45 46 … … 53 54 this.state = state; 54 55 55 log.debug( this + " is notifying " + joinableListeners.size() + " parents");56 log.debug("{} is notifying {} parents", this, joinableListeners.size()); 56 57 57 58 List<JoinableParent> parents = new LinkedList<>(); … … 141 142 } 142 143 start = owners.isEmpty(); 143 log.debug( owner + " is using " +this);144 log.debug("{} is using {}", owner, this); 144 145 owners.add(owner); 145 146 joinableListeners.add(owner); … … 161 162 } 162 163 // assert owners.containsKey(owner); 163 log.debug( owner + " is droping " +this);164 log.debug("{} is droping {}", owner, this); 164 165 owners.remove(owner); 165 166 stop = owners.isEmpty(); -
java/main/src/main/java/com/framsticks/util/dispatching/Dispatching.java
r99 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import com.framsticks.util.FramsticksException; … … 9 10 */ 10 11 public abstract class Dispatching { 11 private static final Logger log = Log ger.getLogger(Dispatching.class);12 private static final Logger log = LogManager.getLogger(Dispatching.class); 12 13 13 14 public static boolean isThreadSafe() { … … 57 58 58 59 public static void use(final Joinable joinable, final JoinableParent owner) { 59 log.debug("using " + joinable + " by " +owner);60 log.debug("using {} by {}", joinable, owner); 60 61 if (joinable.use(owner)) { 61 log.debug("started " +joinable);62 log.debug("started {}", joinable); 62 63 } else { 63 log.debug("start of " + joinable + " already happened");64 log.debug("start of {} already happened", joinable); 64 65 } 65 66 } 66 67 67 68 public static void drop(final Joinable joinable, final JoinableParent owner) { 68 log.debug("droping " + joinable + " by " +owner);69 log.debug("droping {} by {}", joinable, owner); 69 70 if (joinable.drop(owner)) { 70 log.debug("stoped " +joinable);71 log.debug("stoped {}", joinable); 71 72 } else { 72 log.debug("stop of " + joinable + " deferred");73 log.debug("stop of {} deferred", joinable); 73 74 } 74 75 } 75 76 76 77 public static void join(Joinable joinable) throws InterruptedException { 77 log.debug("joining " +joinable);78 log.debug("joining {}", joinable); 78 79 try { 79 80 joinable.join(); 80 81 } catch (InterruptedException e) { 81 log.debug("failed to join " +joinable);82 log.debug("failed to join {}", joinable); 82 83 throw e; 83 84 } 84 log.debug("joined " +joinable);85 log.debug("joined {}", joinable); 85 86 } 86 87 … … 92 93 @Override 93 94 protected void runAt() { 94 log.debug("joinable " + joinable + " is notifying parent " + parent + " about change to " +state);95 log.debug("joinable {} is notifying parent {} about change to {}", joinable, parent, state); 95 96 parent.childChangedState(joinable, state); 96 97 } … … 108 109 109 110 public static void joinAbsolutely(Joinable joinable) { 110 log.debug("joining absolutely " +joinable);111 log.debug("joining absolutely {}", joinable); 111 112 while (true) { 112 113 try { … … 116 117 // throw new FramsticksException().msg("failed to join").arg("dispatcher", dispatcher).cause(e); 117 118 } 118 log.debug("waiting for " +joinable);119 log.debug("waiting for {}", joinable); 119 120 wait(joinable, 500); 120 121 } -
java/main/src/main/java/com/framsticks/util/dispatching/Monitor.java
r96 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 import com.framsticks.util.dispatching.Dispatching; 5 6 import java.lang.Thread; … … 7 8 public class Monitor implements JoinableParent { 8 9 private static final Logger log = 9 Log ger.getLogger(Monitor.class);10 LogManager.getLogger(Monitor.class); 10 11 11 12 protected final Joinable joinable; … … 30 31 Runtime.getRuntime().addShutdownHook(shutdownHook); 31 32 32 log.debug( this + " is using");33 log.debug("{} is using", this); 33 34 Dispatching.use(joinable, this); 34 35 return this; … … 41 42 42 43 public Monitor waitFor() { 43 log.debug( this + " is waiting");44 log.debug("{} is waiting", this); 44 45 synchronized (this) { 45 46 while (joinable.getState().ordinal() < JoinableState.FINISHING.ordinal()) { … … 47 48 } 48 49 } 49 log.debug( this + " ended waiting");50 log.debug("{} ended waiting", this); 50 51 return this; 51 52 } … … 53 54 54 55 public Monitor drop() { 55 log.debug( this + " is droping");56 log.debug("{} is droping", this); 56 57 Dispatching.drop(joinable, this); 57 58 return this; … … 59 60 60 61 public Monitor join() { 61 log.debug( this + " is joining");62 log.debug("{} is joining", this); 62 63 Dispatching.joinAbsolutely(joinable); 63 log.debug( this + " is joined");64 log.debug("{} is joined", this); 64 65 65 66 try { … … 78 79 this.notify(); 79 80 } 80 log.debug( this + " received notification about transition to " +state);81 log.debug("{} received notification about transition to {}", this, state); 81 82 } 82 83 -
java/main/src/main/java/com/framsticks/util/dispatching/Thread.java
r99 r100 1 1 package com.framsticks.util.dispatching; 2 2 3 import org.apache.log4j.Logger; 3 import org.apache.logging.log4j.Logger; 4 import org.apache.logging.log4j.LogManager; 4 5 5 6 import java.util.LinkedList; … … 15 16 public class Thread<C> extends AbstractJoinable implements JoinableDispatcher<C> { 16 17 17 private static final Logger log = Log ger.getLogger(Thread.class);18 private static final Logger log = LogManager.getLogger(Thread.class); 18 19 19 20 protected final java.lang.Thread thread; … … 46 47 47 48 protected void routine() { 48 log.debug("starting thread " +this);49 log.debug("starting thread {}", this); 49 50 assert getMonitor() != null; 50 51 ExceptionHandler exceptionHandler = getMonitor().getTaskExceptionHandler(); … … 83 84 } 84 85 } 85 log.debug("finishing thread " +this);86 log.debug("finishing thread {}", this); 86 87 finish(); 87 88 } … … 138 139 protected void joinableJoin() throws InterruptedException { 139 140 thread.join(500); 140 log.debug("joined " +this);141 log.debug("joined {}", this); 141 142 } 142 143 -
java/main/src/main/java/com/framsticks/util/lang/Casting.java
r99 r100 29 29 return class_.cast(object); 30 30 } 31 32 public static <T> T nullOrThrowCast(Class<T> class_, Object object) { 33 if (object == null) { 34 return null; 35 } 36 return class_.cast(object); 37 } 31 38 } -
java/main/src/main/java/com/framsticks/util/lang/FlagsUtil.java
r99 r100 2 2 3 3 import java.lang.reflect.Field; 4 import org.apache.log4j.Logger; 4 import org.apache.logging.log4j.Logger; 5 import org.apache.logging.log4j.LogManager; 5 6 6 7 import com.framsticks.util.lang.Delimeted; … … 8 9 public final class FlagsUtil { 9 10 10 private final static Logger log = Log ger.getLogger(FlagsUtil.class);11 private final static Logger log = LogManager.getLogger(FlagsUtil.class); 11 12 12 13 private FlagsUtil() { … … 41 42 allFlags |= Integer.parseInt(field.get(null).toString()); 42 43 } catch (SecurityException e) { 43 log.warn("security exception was thrown while trying to read flag ( " + flag + ")");44 log.warn("security exception was thrown while trying to read flag ({})", flag); 44 45 } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { 45 log.warn("selected flag is not known ( " + flag + ")");46 log.warn("selected flag is not known ({})", flag); 46 47 } 47 48 }
Note: See TracChangeset
for help on using the changeset viewer.