code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
@Override
public void shutdown()
{
// Stop the appender from delivering new messages to us
ServiceManagerAppender.shutdown();
// Before shutting down synchronously transfer all the pending logs
try
{
final LinkedList<LogLine> copy;
synchronized (incoming)
{
if (!incoming.isEmpty())
{
... | java |
public List<CarbonProfile> getProfileList()
{
final List<CarbonProfile> profiles = new ArrayList<CarbonProfile>();
Element profileList = element.getChild("ProfileList");
if (profileList != null)
{
for (Element profileElement : profileList.getChildren())
{
CarbonProfile profile = new CarbonProfile(p... | java |
Node compile(final Object root)
{
if (compiled == null)
{
compiled = compileExpression(root, this.expr);
parsed = null;
if (this.notifyOnCompiled != null)
this.notifyOnCompiled.accept(this.expr, this);
}
return compiled;
} | java |
public final ReturnValue sendCommand(final String sCommandName, final String... arguments) throws JNRPEClientException {
return sendRequest(new JNRPERequest(sCommandName, arguments));
} | java |
private static void printVersion() {
System.out.println("jcheck_nrpe version " + JNRPEClient.class.getPackage().getImplementationVersion());
System.out.println("Copyright (c) 2013 Massimiliano Ziccardi");
System.out.println("Licensed under the Apache License, Version 2.0");
System.out.p... | java |
@SuppressWarnings("unchecked")
private static void printUsage(final Exception e) {
printVersion();
StringBuilder sbDivider = new StringBuilder("=");
if (e != null) {
System.out.println(e.getMessage() + "\n");
}
HelpFormatter hf = new HelpFormatter();
wh... | java |
public boolean isFinished()
{
if (finished)
return true;
try
{
final int code = exitCode();
finished(code);
return true;
}
catch (IllegalThreadStateException e)
{
return false;
}
} | java |
protected Thread copy(final InputStream in, final Writer out)
{
Runnable r = () -> {
try
{
StreamUtil.streamCopy(in, out);
}
catch (IOException e)
{
try
{
out.flush();
}
catch (Throwable t)
{
}
unexpectedFailure(e);
}
};
Thread t = new Thread(r);
t.setNa... | java |
protected void configure(ServletContainerDispatcher dispatcher) throws ServletException
{
// Make sure we are registered with the Guice registry
registry.register(this, true);
// Configure the dispatcher
final Registry resteasyRegistry;
final ResteasyProviderFactory providerFactory;
{
final ResteasyReq... | java |
private static String parseExpecting(final Stage stage) {
StringBuilder expected = new StringBuilder();
for (String key : stage.getTransitionNames()) {
expected.append(',').append(stage.getTransition(key).expects());
}
return expected.substring(1);
} | java |
public static File createTempFile(final String prefix, final String suffix)
{
try
{
File tempFile = File.createTempFile(prefix, suffix);
if (tempFile.exists())
{
if (!tempFile.delete())
throw new RuntimeException("Could not delete new temp file: " + tempFile);
}
return tempFile;
}
catc... | java |
@Deprecated
public static boolean safeMove(File src, File dest) throws SecurityException
{
assert (src.exists());
final boolean createDestIfNotExist = true;
try
{
if (src.isFile())
FileUtils.moveFile(src, dest);
else
FileUtils.moveDirectoryToDirectory(src, dest, createDestIfNotExist);
retu... | java |
public static boolean delete(File f) throws IOException
{
assert (f.exists());
if (f.isDirectory())
{
FileUtils.deleteDirectory(f);
return true;
}
else
{
return f.delete();
}
} | java |
public static boolean smartEquals(File one, File two, boolean checkName) throws IOException
{
if (checkName)
{
if (!one.getName().equals(two.getName()))
{
return false;
}
}
if (one.isDirectory() == two.isDirectory())
{
if (one.isDirectory())
{
File[] filesOne = one.listFiles();
Fi... | java |
public CarbonReply send(Element element) throws CarbonException
{
try
{
final String responseXml = send(serialise(element));
return new CarbonReply(deserialise(responseXml));
}
catch (CarbonException e)
{
throw e;
}
catch (Exception e)
{
throw new CarbonException(e);
}
} | java |
private synchronized void setService( final T newService )
{
if( m_service != newService )
{
LOG.debug( "Service changed [" + m_service + "] -> [" + newService + "]" );
final T oldService = m_service;
m_service = newService;
if( m_serviceListener != n... | java |
private synchronized void resolveService()
{
T newService = null;
final Iterator<T> it = m_serviceCollection.iterator();
while( newService == null && it.hasNext() )
{
final T candidateService = it.next();
if( !candidateService.equals( getService() ) )
... | java |
@Override
protected void onStart()
{
m_serviceCollection = new ServiceCollection<T>( m_context, m_serviceClass, new CollectionListener() );
m_serviceCollection.start();
} | java |
@Override
protected void onStop()
{
if( m_serviceCollection != null )
{
m_serviceCollection.stop();
m_serviceCollection = null;
}
setService( null );
} | java |
public ProcessBuilder getProcessBuilder()
{
if (spawned)
return builder; // throw new IllegalStateException("Cannot call spawn twice!");
if (runAs != null)
{
String command = cmd.get(0);
if (command.charAt(0) == '-' && !SudoFeature.hasArgumentsEnd())
throw new IllegalArgumentException("Command to ... | java |
private int percent(final long val, final long total) {
if (total == 0) {
return 100;
}
if (val == 0) {
return 0;
}
double dVal = (double) val;
double dTotal = (double) total;
return (int) (dVal / dTotal * 100);
} | java |
private String format(final long bytes) {
if (bytes > MB) {
return String.valueOf(bytes / MB) + " MB";
}
return String.valueOf(bytes / KB) + " KB";
} | java |
private boolean passes(final AuthScope scope, final AuthConstraint constraint, final CurrentUser user)
{
if (scope.getSkip(constraint))
{
if (log.isTraceEnabled())
log.trace("Allowing method invocation (skip=true).");
return true;
}
else
{
final boolean pass = user.hasRole(scope.getRole(constra... | java |
void addInstance(final Class<?> discoveredType, final Object newlyConstructed)
{
WeakHashMap<Object, Void> map;
synchronized (instances)
{
map = instances.get(discoveredType);
if (map == null)
{
map = new WeakHashMap<>();
instances.put(discoveredType, map);
}
}
synchronized (map)
{
... | java |
public static String doGET(final URL url, final Properties requestProps, final Integer timeout, boolean includeHeaders, boolean ignoreBody)
throws Exception {
return doRequest(url, requestProps, timeout, includeHeaders, ignoreBody, "GET");
} | java |
public static String doPOST(final URL url, final Properties requestProps, final Integer timeout, final String encodedData,
boolean includeHeaders, boolean ignoreBody) throws IOException {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
setRequestProperties(requestProps, co... | java |
public static void sendPostData(HttpURLConnection conn, String encodedData) throws IOException {
StreamManager sm = new StreamManager();
try {
conn.setDoOutput(true);
conn.setRequestMethod("POST");
if (conn.getRequestProperty("Content-Type") == null) {
... | java |
public static void setRequestProperties(final Properties props, HttpURLConnection conn, Integer timeout) {
if (props != null) {
if (props.get("User-Agent") == null) {
conn.setRequestProperty("User-Agent", "Java");
}
for (Entry entry : props.entrySet()) {
... | java |
public static String parseHttpResponse(HttpURLConnection conn, boolean includeHeaders, boolean ignoreBody) throws IOException {
StringBuilder buff = new StringBuilder();
if (includeHeaders) {
buff.append(conn.getResponseCode()).append(' ').append(conn.getResponseMessage()).append('\n');
... | java |
private List<Metric> checkAlive(final Connection c, final ICommandLine cl) throws BadThresholdException, SQLException {
List<Metric> metricList = new ArrayList<Metric>();
Statement stmt = null;
ResultSet rs = null;
long lStart = System.currentTimeMillis();
try {
... | java |
private List<Metric> checkTablespace(final Connection c, final ICommandLine cl) throws BadThresholdException, SQLException {
// Metric : tblspace_usage
List<Metric> metricList = new ArrayList<Metric>();
String sTablespace = cl.getOptionValue("tablespace").toUpperCase();
// FIXME : a ... | java |
private List<Metric> checkCache(final Connection c, final ICommandLine cl) throws BadThresholdException, SQLException {
List<Metric> metricList = new ArrayList<Metric>();
// Metrics cache_buf, cache_lib
String sQry1 = "select (1-(pr.value/(dbg.value+cg.value)))*100" + " from v$sysstat pr, v$sy... | java |
@Transactional
public void rotateUserAccessKey(final int id)
{
final UserEntity account = getById(id);
if (account != null)
{
// Set the secondary token to the old primary token
account.setAccessKeySecondary(account.getAccessKey());
// Now regenerate the primary token
account.setAccessKey(SimpleId... | java |
private String hashPassword(String password)
{
return BCrypt.hash(password.toCharArray(), BCrypt.DEFAULT_COST);
} | java |
public static String formatSize(final long value) {
double size = value;
DecimalFormat df = new DecimalFormat("#.##");
if (size >= GB) {
return df.format(size / GB) + " GB";
}
if (size >= MB) {
return df.format(size / MB) + " MB";
}
if (siz... | java |
public static boolean extractArchive(File tarFile, File extractTo)
{
try
{
TarArchive ta = getArchive(tarFile);
try
{
if (!extractTo.exists())
if (!extractTo.mkdir())
throw new RuntimeException("Could not create extract dir: " + extractTo);
ta.extractContents(extractTo);
}
finall... | java |
public static boolean addFilesToExistingJar(File jarFile,
String basePathWithinJar,
Map<String, File> files,
ActionOnConflict action) throws IOException
{
// get a temp file
File ... | java |
public static <T> List<T> list(Iterable<T> iterable)
{
List<T> list = new ArrayList<T>();
for (T item : iterable)
{
list.add(item);
}
return list;
} | java |
public static <T> List<T> last(final List<T> src, int count)
{
if (count >= src.size())
{
return new ArrayList<T>(src);
}
else
{
final List<T> dest = new ArrayList<T>(count);
final int size = src.size();
for (int i = size - count; i < size; i++)
{
dest.add(src.get(i));
}
return des... | java |
public static <T> List<T> tail(List<T> list)
{
if (list.isEmpty())
return Collections.emptyList();
else
return list.subList(1, list.size());
} | java |
public static int[] flip(int[] src, int[] dest, final int start, final int length)
{
if (dest == null || dest.length < length)
dest = new int[length];
int srcIndex = start + length;
for (int i = 0; i < length; i++)
{
dest[i] = src[--srcIndex];
}
return dest;
} | java |
public static <T> List<T> concat(final Collection<? extends T>... lists)
{
ArrayList<T> al = new ArrayList<T>();
for (Collection<? extends T> list : lists)
if (list != null)
al.addAll(list);
return al;
} | java |
public static <T> Set<T> union(final Collection<? extends T>... lists)
{
Set<T> s = new HashSet<T>();
for (Collection<? extends T> list : lists)
if (list != null)
s.addAll(list);
return s;
} | java |
private ThymeleafTemplater getOrCreateTemplater()
{
ThymeleafTemplater templater = this.templater.get();
// Lazy-create a ThymeleafTemplater
if (templater == null)
{
final TemplateEngine engine = getOrCreateEngine();
templater = new ThymeleafTemplater(engine, configuration, metrics, userProvider);
... | java |
public static boolean isPrimitive(final Object value)
{
return (value == null ||
value instanceof String ||
value instanceof Number ||
value instanceof Boolean ||
value instanceof DateTime ||
value instanceof Date ||
value instanceof SampleCount ||
... | java |
public String toPerformanceString() {
final StringBuilder res =
new StringBuilder()
.append(
quote(metric.getMetricName()))
.append('=')
.append((metric.getMetricValue(prefix)).toPrettyPrinte... | java |
private String quote(final String lbl) {
if (lbl.indexOf(' ') == -1) {
return lbl;
}
return new StringBuffer("'").append(lbl).append('\'').toString();
} | java |
public String getSchema(Class<?> clazz)
{
if (clazz == Integer.class || clazz == Integer.TYPE)
{
return "integer [" + Integer.MIN_VALUE + " to " + Integer.MAX_VALUE + "]";
}
else if (clazz == Long.class || clazz == Long.TYPE)
{
return "long [" + Long.MIN_VALUE + " to " + Long.MAX_VALUE + "]";
}
els... | java |
public MetricBuilder withValue(Number value, String prettyPrintFormat) {
current = new MetricValue(value.toString(), prettyPrintFormat);
return this;
} | java |
public MetricBuilder withMinValue(Number value, String prettyPrintFormat) {
min = new MetricValue(value.toString(), prettyPrintFormat);
return this;
} | java |
public MetricBuilder withMaxValue(Number value, String prettyPrintFormat) {
max = new MetricValue(value.toString(), prettyPrintFormat);
return this;
} | java |
public MetricBuilder withMessage(String messagePattern, Object ...params) {
this.metricMessage = MessageFormat.format(messagePattern, params);
return this;
} | java |
@Deprecated
public ResultSetConstraint build(Map<String, List<String>> constraints)
{
return builder(constraints).build();
} | java |
@Inject
@SuppressWarnings("unchecked")
public void setTypeLiteral(TypeLiteral<T> clazz)
{
if (clazz == null)
throw new IllegalArgumentException("Cannot set null TypeLiteral on " + this);
if (this.clazz != null && !this.clazz.equals(clazz.getRawType()))
throw new IllegalStateException("Cannot call setTypeLi... | java |
public Collection<ID> getIds(final WebQuery constraints)
{
return (Collection<ID>) find(constraints, JPASearchStrategy.ID).getList();
} | java |
private SSLEngine getSSLEngine() throws KeyStoreException,
CertificateException,
IOException,
UnrecoverableKeyException,
KeyManagementException {
// Open the KeyStore Stream
final StreamManager streamManager = new Strea... | java |
private ServerBootstrap getServerBootstrap(final boolean useSSL) {
final CommandInvoker invoker = new CommandInvoker(pluginRepository, commandRepository, acceptParams, getExecutionContext());
final ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, worker... | java |
public SampleCount resample(Timebase newRate)
{
if (!this.rate.equals(newRate))
{
final long newSamples = getSamples(newRate);
return new SampleCount(newSamples, newRate);
}
else
{
// Same rate, no need to resample
return this;
}
} | java |
@Override
protected void onStart()
{
m_mappings = new HashMap<Bundle, List<T>>();
// listen to bundles events
m_context.addBundleListener( m_bundleListener = new SynchronousBundleListener()
{
public void bundleChanged( final BundleEvent bundleEvent )
... | java |
@Override
protected void onStop()
{
m_context.removeBundleListener( m_bundleListener );
final Bundle[] toBeRemoved =
m_mappings.keySet().toArray( new Bundle[m_mappings.keySet().size()] );
for( Bundle bundle : toBeRemoved )
{
unregister( bundle );
... | java |
public final CommandRepository createCommandRepository() {
CommandRepository cr = new CommandRepository();
for (Command c : commandSection.getAllCommands()) {
CommandDefinition cd = new CommandDefinition(c.getName(), c.getPlugin());
cd.setArgs(c.getCommandLine());
c... | java |
private void init(final String commandName, final String... arguments) {
if (arguments != null) {
if (arguments.length == 1) {
init(commandName, arguments[0]);
return;
}
String[] ary = new String[arguments.length];
for (int i = 0;... | java |
private void init(final String commandName, final String argumentsString) {
String fullCommandString;
String tmpArgumentsString = argumentsString;
if (tmpArgumentsString != null && !tmpArgumentsString.isEmpty() && tmpArgumentsString.charAt(0) == '!') {
tmpArgumentsString = tmpArgum... | java |
public final String[] getArguments() {
// extracting params
String[] partsAry = split(this.packet.getBufferAsString());
String[] argsAry = new String[partsAry.length - 1];
System.arraycopy(partsAry, 1, argsAry, 0, argsAry.length);
return argsAry;
} | java |
private String[] split(final String sCommandLine) {
return it.jnrpe.utils.StringUtils.split(sCommandLine, '!', false);
} | java |
private UserEntity ensureRolesFetched(final UserEntity user)
{
if (user != null)
user.getRoles().stream().map(r -> r.getId()).collect(Collectors.toList());
return user;
} | java |
private UserLogin tryBasicAuthLogin(UserLogin login, UserAuthenticationService authService, HttpServletRequest request)
{
final String header = request.getHeader(HttpHeaderNames.AUTHORIZATION);
if (header != null)
{
final String[] credentials = BasicAuthHelper.parseHeader(header);
if (credentials != null... | java |
private void prune()
{
if (useSoftReferences)
{
Iterator<Map.Entry<String, Object>> it = cache.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<String, Object> entry = it.next();
if (dereference(entry.getValue()) == null)
it.remove();
}
}
} | java |
public final ThresholdsEvaluatorBuilder withLegacyThreshold(final String metric, final String okRange, final String warnRange,
final String critRange) throws BadThresholdException {
LegacyRange ok = null, warn = null, crit = null;
if (okRange != null) {
ok = new LegacyRange(okRa... | java |
public static synchronized void register(Class<?> clazz)
{
if (clazz.isAnnotationPresent(javax.ws.rs.ext.Provider.class))
{
classes.add(clazz);
revision++;
}
else
{
throw new RuntimeException("Class " + clazz.getName() + " is not annotated with javax.ws.rs.ext.Provider");
}
} | java |
private static PipedInputStream createInputStream( final Jar jar )
throws IOException
{
final CloseAwarePipedInputStream pin = new CloseAwarePipedInputStream();
final PipedOutputStream pout = new PipedOutputStream( pin );
new Thread()
{
public void run()
... | java |
private static void checkMandatoryProperties( final Analyzer analyzer,
final Jar jar,
final String symbolicName )
{
final String importPackage = analyzer.getProperty( Analyzer.IMPORT_PACKAGE );
if( im... | java |
public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties ... | java |
private static void throwAsMalformedURLException( final String message, final Exception cause )
throws MalformedURLException
{
final MalformedURLException exception = new MalformedURLException( message );
exception.initCause( cause );
throw exception;
} | java |
private void validateHibernateProperties(final GuiceConfig configuration, final Properties hibernateProperties)
{
final boolean allowCreateSchema = configuration.getBoolean(GuiceProperties.HIBERNATE_ALLOW_HBM2DDL_CREATE, false);
if (!allowCreateSchema)
{
// Check that hbm2ddl is not set to a prohibited value... | java |
public static ReturnValueBuilder forPlugin(final String name, final ThresholdsEvaluator thr) {
if (thr != null) {
return new ReturnValueBuilder(name, thr);
}
return new ReturnValueBuilder(name, new ThresholdsEvaluatorBuilder().create());
} | java |
private void formatResultMessage(final Metric pluginMetric) {
if (StringUtils.isEmpty(pluginMetric.getMessage())) {
return;
}
if (StringUtils.isEmpty(retValMessage)) {
retValMessage = pluginMetric.getMessage();
return;
}
retValMessage += " " +... | java |
public static String getLocalhost() throws RuntimeException
{
String hostname = null;
try
{
InetAddress addr = InetAddress.getLocalHost();
hostname = addr.getHostName();
}
catch (UnknownHostException e)
{
throw new RuntimeException("[FileHelper] {getLocalhost}: Can't get local hostname");
}
... | java |
public static String getLocalIp() throws RuntimeException
{
try
{
InetAddress addr = getLocalIpAddress();
return addr.getHostAddress();
}
catch (RuntimeException e)
{
throw new RuntimeException("[FileHelper] {getLocalIp}: Unable to find the local machine", e);
}
} | java |
public static InetAddress getLocalIpAddress() throws RuntimeException
{
try
{
List<InetAddress> ips = getLocalIpAddresses(false, true);
for (InetAddress ip : ips)
{
log.debug("[IpHelper] {getLocalIpAddress} Considering locality of " + ip.getHostAddress());
if (!ip.isAnyLocalAddress() && (ip insta... | java |
public static InetAddress getLocalIpAddress(String iface) throws RuntimeException
{
try
{
NetworkInterface nic = NetworkInterface.getByName(iface);
Enumeration<InetAddress> ips = nic.getInetAddresses();
InetAddress firstIP = null;
while (ips != null && ips.hasMoreElements())
{
InetAddress ip =... | java |
public static List<InetAddress> getLocalIpAddresses(boolean pruneSiteLocal, boolean pruneDown) throws RuntimeException
{
try
{
Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
List<InetAddress> addresses = new Vector<InetAddress>();
while (nics.hasMoreElements())
{
Net... | java |
public static String getMacFor(NetworkInterface iface) throws SocketException, NoMacAddressException
{
assert (iface != null);
byte[] hwaddr = iface.getHardwareAddress();
if (hwaddr == null || hwaddr.length == 0)
{
throw new NoMacAddressException("Interface " + iface.getName() + " has no physical address ... | java |
public static NetworkInterface getInterfaceForLocalIp(InetAddress addr) throws SocketException, NoInterfaceException
{
assert (getLocalIpAddresses(false).contains(addr)) : "IP is not local";
NetworkInterface iface = NetworkInterface.getByInetAddress(addr);
if (iface != null)
return iface;
else
throw ne... | java |
public static InetAddress ntoa(final int address)
{
try
{
final byte[] addr = new byte[4];
addr[0] = (byte) ((address >>> 24) & 0xFF);
addr[1] = (byte) ((address >>> 16) & 0xFF);
addr[2] = (byte) ((address >>> 8) & 0xFF);
addr[3] = (byte) (address & 0xFF);
return InetAddress.getByAddress(addr);... | java |
public static boolean isPubliclyRoutable(final InetAddress addrIP)
{
if (addrIP == null)
throw new NullPointerException("isPubliclyRoutable requires an IP address be passed to it!");
return !addrIP.isSiteLocalAddress() && !addrIP.isLinkLocalAddress() && !addrIP.isLoopbackAddress();
} | java |
public WebQuery buildQuery()
{
Map<String, List<String>> map = new HashMap<>(constraints);
applyDefault(WQUriControlField.FETCH, map, defaultFetch);
applyDefault(WQUriControlField.EXPAND, map, defaultExpand);
applyDefault(WQUriControlField.ORDER, map, defaultOrder);
applyDefault(WQUriControlField.OFFSET, ma... | java |
private void configurePlugins(final File fDir) throws PluginConfigurationException {
LOG.trace("READING PLUGIN CONFIGURATION FROM DIRECTORY {}", fDir.getName());
StreamManager streamMgr = new StreamManager();
File[] vfJars = fDir.listFiles(JAR_FILE_FILTER);
if (vfJars == null || vfJars... | java |
public final void load(final File fDirectory) throws PluginConfigurationException {
File[] vFiles = fDirectory.listFiles();
if (vFiles != null) {
for (File f : vFiles) {
if (f.isDirectory()) {
configurePlugins(f);
}
}
}
... | java |
public static Session getSession(final ICommandLine cl) throws Exception {
JSch jsch = new JSch();
Session session = null;
int timeout = DEFAULT_TIMEOUT;
int port = cl.hasOption("port") ? Integer.parseInt(cl.getOptionValue("port")) : +DEFAULT_PORT;
String hostname = cl.getOptionV... | java |
public Timeout getTimeoutLeft()
{
final long left = getTimeLeft();
if (left != 0)
return new Timeout(left, TimeUnit.MILLISECONDS);
else
return Timeout.ZERO;
} | java |
public static Deadline soonest(Deadline... deadlines)
{
Deadline min = null;
if (deadlines != null)
for (Deadline deadline : deadlines)
{
if (deadline != null)
{
if (min == null)
min = deadline;
else if (deadline.getTimeLeft() < min.getTimeLeft())
{
min = deadline;
}
... | java |
public RestFailure renderFailure(Throwable e)
{
// Strip away ApplicationException wrappers
if (e.getCause() != null && (e instanceof ApplicationException))
{
return renderFailure(e.getCause());
}
RestFailure failure = new RestFailure();
failure.id = getOrGenerateFailureId();
failure.date = new Date(... | java |
public HibernateTransaction start()
{
final Session session = sessionProvider.get();
final Transaction tx = session.beginTransaction();
return new HibernateTransaction(tx);
} | java |
public void execute(Runnable statements)
{
try (HibernateTransaction tx = start().withAutoRollback())
{
statements.run();
// Success, perform a TX commit
tx.commit();
}
} | java |
public void addCommitAction(final Runnable action) throws HibernateException
{
if (action == null)
return; // ignore null actions
addAction(new BaseSessionEventListener()
{
@Override
public void transactionCompletion(final boolean successful)
{
if (successful)
action.run();
}
});
} | java |
public void deleteOnRollback(final Collection<File> files)
{
addRollbackAction(new Runnable()
{
@Override
public void run()
{
for (File file : files)
{
if (log.isTraceEnabled())
log.trace("Delete file on transaction rollback: " + file);
final boolean success = FileUtils.deleteQuie... | java |
public Object newInstanceWithId(final Object id)
{
try
{
final Object o = clazz.newInstance();
idProperty.set(o, id);
return o;
}
catch (Throwable e)
{
throw new RuntimeException("Cannot create new instance of " +
clazz +
" with ID " +... | java |
public EntityGraph getDefaultGraph(final Session session)
{
if (this.defaultExpandGraph == null)
{
final EntityGraph<?> graph = session.createEntityGraph(clazz);
populateGraph(graph, getEagerFetch());
this.defaultExpandGraph = graph;
return graph;
}
else
{
return this.defaultExpandGraph;
... | java |
private void populateGraph(final EntityGraph<?> graph, final Set<String> fetches)
{
Map<String, Subgraph<?>> created = new HashMap<>();
for (String fetch : fetches)
{
final String[] parts = StringUtils.split(fetch, '.');
// Starts of null (meaning parent is the root graph), updated as we go through path ... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.