major refactoring, using only Operation<T> instead of OperationWithTransformationSupport which is currently not applicable the way we use the operation return type

This commit is contained in:
Axel Uhl committed 2014-11-07 23:45:05 +01:00
1 parent bbc2796d59
commit cd28a65394
76 files changed
+289 -114

No files matched your search

@@ -0,0 +1,21 @@
package com.sap.sse;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class BuildVersion {
public static String getBuildVersion() {
String version = "Unknown or Development (" + System.getProperty("com.sap.sailing.server.name") + ")";
File versionfile = new File(System.getProperty("jetty.home") + File.separator + "version.txt");
if (versionfile.exists()) {
try {
version = new BufferedReader(new FileReader(versionfile)).readLine();
} catch (Exception ex) {
/* ignore */
}
}
return version;
}
}
@@ -0,0 +1,21 @@
package com.sap.sse;
/**
* Classes implementing this interface have their instance life cycle managed by a {@link SharedDomainFactory}. This is important
* particularly during de-serialization when the de-serialized instance needs to be replaced by an instance managed by
* the domain factory.<p>
*
* If the de-serializing stream is a {@link ObjectInputStreamResolvingAgainstDomainFactory} stream, it will automatically
* do a {@link #resolve(Object)} for instances whose classes implement this interface. Implementing classes need to
* delegate accordingly to the domain factory passed as argument.
*
* @param <C> cache type
*
* @author Axel Uhl (D043530)
*
*/
public interface IsManagedByCache<C> {
IsManagedByCache<C> resolve(C domainFactory);
}
@@ -0,0 +1,66 @@
package com.sap.sse.util.impl;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Stream decorator that counts the bytes sent through an {@link OutputStream}. Logs
* that number in configurable way using a {@link Logger}.
*
* @author Axel Uhl
*/
public class CountingOutputStream extends FilterOutputStream {
private static final Logger logger = Logger.getLogger(CountingOutputStream.class.getName());
private long count;
private final long logEveryHowManyBytes;
private long lastMultiple;
private final Level level;
private final String name;
public CountingOutputStream(OutputStream out, long logEveryHowManyBytes, Level logLevel, String name) {
super(out);
this.level = logLevel;
this.name = name;
this.logEveryHowManyBytes = logEveryHowManyBytes;
}
@Override
public void write(int b) throws IOException {
super.write(b);
count(1);
}
private void count(int bytesWritten) {
count += bytesWritten;
if (count >= (lastMultiple+1)*logEveryHowManyBytes) {
lastMultiple++;
log();
}
}
private void log() {
logger.log(level, "wrote "+count+" bytes "+(count>1000?"("+count/1000+" kB)":"")+" to "+name);
}
@Override
public void write(byte[] b) throws IOException {
super.write(b);
count(b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len);
count(len);
}
@Override
public void close() throws IOException {
super.close();
log();
}
}
@@ -0,0 +1,29 @@
package com.sap.sse.util.impl;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
/**
* A thread factory by which the priority of the threads created can be set to something different from normal.
*
* @author Axel Uhl (D043530)
*
*/
public class ThreadFactoryWithPriority implements ThreadFactory {
private ThreadFactory defaultFactory;
private final int priority;
public ThreadFactoryWithPriority(int priority) {
defaultFactory = Executors.defaultThreadFactory();
this.priority = priority;
}
@Override
public Thread newThread(Runnable r) {
Thread result = defaultFactory.newThread(r);
result.setPriority(priority);
return result;
}
}