/** * Always returns false. * @return always false */ public boolean isDebugEnabled() { return X_Log.loggable(LogLevel.DEBUG); }
private static void touch(Package java) { X_Log.info(java); }
@Override public Model setProperty(final String key, final Object value) { try { map.put(key, value); } catch (final Throwable e) { X_Log.error(e); } return this; }
private static void rm(String kill, boolean recursive) { File f = new File(kill); if (recursive) { HashSet<File> cycle = new HashSet<File>(); rmRecursive(f, cycle); } if (f.exists() && !f.delete()) { X_Log.warn(FileServiceImpl.class, "Unable to delete file ",f); } }
@Override public final void onEnd() { X_Log.trace(getClass(),"ending", this); try { for (LineReader delegate : delegates.forEach()) { X_Log.debug(getClass(),"ending delegate", delegate.getClass(), delegate); delegate.onEnd(); } } finally { finished = true; onEnd0(); } synchronized (delegates) { delegates.notifyAll(); } }
public static ClasspathResourceMap compileScopeScanner(MavenProject project, MavenSession session) { URL[] urls = compileScopeUrls(project, session); X_Log.trace(X_Maven.class,"Compile scope URLS",urls); return X_Scanner.scanClassloader(URLClassLoader.newInstance(urls)); }
@Override protected ConcurrentEnvironment initialize(Thread key, UncaughtExceptionHandler params) { if (key.getState() == State.TERMINATED) { //send an exception... params.uncaughtException(key, new ThreadDeath()); } if (key.isInterrupted()) { params.uncaughtException(key, new InterruptedException()); } X_Log.debug("Initializing Concurrent Environment", key); return initializeEnvironment(key, params); } @Override
private static void rmRecursive(File f, HashSet<File> cycle) { if (cycle.add(f)) { if (f.isDirectory()) { for (File child : f.listFiles()) { rmRecursive(child, cycle); // Prevent symlink cycle recursion } if (!f.delete()) { X_Log.warn(FileServiceImpl.class,"Unable to delete",f); } } else if (f.isFile()) { if (!f.delete()) { X_Log.warn(FileServiceImpl.class,"Unable to delete",f); } } } }
@Override protected ClassLoader initialValue() { if (X_Runtime.isDebug()) { X_Log.info("Maven compile scope: "+X_String.joinObjects(urls)); } return new URLClassLoader(urls, X_Maven.class.getClassLoader()); }; };
/** * Always returns false. * @return always false */ public boolean isTraceEnabled() { return X_Log.loggable(LogLevel.TRACE); }
@SuppressWarnings("unchecked") protected <T, U extends UserInterface<T>> U newUi(Class<? extends T> type, Class<? super U> uiType) { if (uiType == null) { throw new NullPointerException("Must specify UI type for "+type); } try { return (U) uiType.newInstance(); } catch (InstantiationException | IllegalAccessException e) { X_Log.error(getClass(), "Unable to instantiate",uiType, e); throw X_Debug.rethrow(e); } }
public synchronized void forwardTo(LineReader callback) { X_Log.debug(getClass(),getClass().getName(),"forwardingTo", callback.getClass().getName(),":", callback); if (b != null) {// not null only after we have started streaming callback.onStart(); for (String line : X_String.splitNewLine(b.toString())) { callback.onLine(line); } } delegates.give(callback); if (finished) { callback.onEnd(); } }
public static void drain(final OutputStream out, final InputStream in) throws IOException { int size = 4096; byte[] buffer = new byte[size]; int read; while ((read = in.read(buffer)) >= 0) { if (read == 0) { try { Thread.sleep(0, 10000); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); X_Log.warn("Interrupted while draining input stream",in,"to output stream",out); return; } continue; } out.write(buffer, 0, read); if (size < 0x10000) { size <<= 0; } buffer = new byte[size]; } }
public static URL[] compileScopeUrls(MavenProject project, MavenSession session) { try { List<String> compile = project.getCompileClasspathElements(); X_Log.info(X_Maven.class,"Compile classpath",compile); X_Log.info(X_Maven.class,"Runtime classpath",project.getRuntimeClasspathElements()); if (project.hasLifecyclePhase("test-classes")) { List<String> testElements = project.getTestClasspathElements(); testElements.addAll(compile); compile = testElements; } URL[] urls = new URL[compile.size()]; for (int i = compile.size(); i-- > 0;) { urls[i] = X_Dev.toUrl(compile.get(i)); } return urls; } catch (DependencyResolutionRequiredException e) { throw X_Debug.rethrow(e); } }
/** * Return true based on X_Log global setting */ public boolean isErrorEnabled() { return X_Log.loggable(LogLevel.ERROR); }
@Override public String getFileMaybeUnzip(String file, int chmod) { File f = new File(file); if (f.getAbsolutePath().contains("jar!")) { try { return unzip(file, new JarFile(f), chmod); } catch (IOException e) { X_Log.error(getClass(), "Unable to unzip", f, "from file", file,"with chmod",Integer.toHexString(chmod), e); } } return getPath(file); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public RemovalHandler lock(SuccessHandler<AsyncLock> onLocked) { // TODO actually push the callback onto a deferred stack, // and return without blocking. try { lock.lock(); onLocked.onSuccess(this); } catch (Throwable e){ if (onLocked instanceof ErrorHandler) { try { ((ErrorHandler)onLocked).onError(e); } catch (Throwable ignored) {} } else { X_Log.warn("Error occured while performing lock callback on "+onLocked, onLocked); } } return RemovalHandler.DoNothing; }
/** * Return true based on X_Log global setting */ public boolean isInfoEnabled() { return X_Log.loggable(LogLevel.INFO); }
@Override public File chmod(int chmod, File file) { assertValidChmod(chmod); Set<PosixFilePermission> perms = getPermissions(chmod); try { Files.setPosixFilePermissions(Paths.get(file.getCanonicalPath()), perms); } catch (IOException e) { X_Log.warn(getClass(), "Could not chmod file",file,"with permissions","0x"+Integer.toHexString(chmod), e); X_Debug.maybeRethrow(e); } return file; }
/** * Return true based on X_Log global setting */ public boolean isWarnEnabled() { return X_Log.loggable(LogLevel.WARN); }