List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:org.codehaus.groovy.grails.web.pages.GroovyPage.java
public void setHtmlParts(String[] htmlParts) { this.htmlParts = htmlParts; this.htmlPartsSet = new HashSet<Integer>(); if (htmlParts != null) { for (String htmlPart : htmlParts) { if (htmlPart != null) { htmlPartsSet.add(System.identityHashCode(htmlPart)); }/*from www.j a v a 2 s . co m*/ } } }
From source file:org.eclipse.smila.processing.pipelets.xmlprocessing.util.XMLUtils.java
/** * A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD <strong>NOT </strong> be seen by the * user, not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs. * //from w ww . j a v a2 s. c o m * Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the * ejbCreate method. * * @param o * a Object * @return a String */ public static final String generateGUID(Object o) { final Log log = LogFactory.getLog(XMLUtils.class); final StringBuffer tmpBuffer = new StringBuffer(16); if (s_hexServerIP == null) { java.net.InetAddress localInetAddress = null; try { // get the inet address localInetAddress = java.net.InetAddress.getLocalHost(); } catch (java.net.UnknownHostException uhe) { // todo: find better way to get around this... final String msg = "ConfigurationUtil: Could not get the local IP address using InetAddress.getLocalHost()!"; System.err.println(msg); if (log.isErrorEnabled()) { log.error(uhe); } return null; } final byte[] serverIP = localInetAddress.getAddress(); s_hexServerIP = hexFormat(getInt(serverIP), 8); } final String hashcode = hexFormat(System.identityHashCode(o), 8); tmpBuffer.append(s_hexServerIP); tmpBuffer.append(hashcode); final long timeNow = System.currentTimeMillis(); final int timeLow = (int) timeNow & 0xFFFFFFFF; final int node = SEEDER.nextInt(); final StringBuffer guid = new StringBuffer(32); guid.append(hexFormat(timeLow, 8)); guid.append(tmpBuffer.toString()); guid.append(hexFormat(node, 8)); return guid.toString(); }
From source file:com.invalidcodeexception.experiment.langstringbuilder.lang3.UnsafeToStringBuilder.java
/** * <p>Appends with the same format as the default <code>Object toString() * </code> method. Appends the class name followed by * {@link System#identityHashCode(java.lang.Object)}.</p> * * @param object the <code>Object</code> whose class name and id to output * @return this// ww w . ja va 2s. com * @since 2.0 */ public UnsafeToStringBuilder appendAsObjectToString(Object object) { if (object == null) { throw new NullPointerException("Cannot get the toString of a null identity"); } buffer.append(object.getClass().getName()).append('@') .append(Integer.toHexString(System.identityHashCode(object))); return this; }
From source file:org.apache.ranger.plugin.policyevaluator.RangerDefaultPolicyEvaluator.java
protected boolean isAccessAllowed(String user, Set<String> userGroups, String accessType) { if (LOG.isDebugEnabled()) { LOG.debug("==> RangerDefaultPolicyEvaluator.isAccessAllowed(" + user + ", " + userGroups + ", " + accessType + ")"); }//from w ww . j a va 2 s . c om boolean ret = false; RangerPerfTracer perf = null; if (RangerPerfTracer.isPerfTraceEnabled(PERF_POLICY_REQUEST_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_POLICY_REQUEST_LOG, "RangerPolicyEvaluator.isAccessAllowed(hashCode=" + Integer.toHexString(System.identityHashCode(this)) + "," + perfTag + ")"); } RangerPolicyItemEvaluator item = this.getDeterminingPolicyItem(user, userGroups, accessType); if (item != null && item.getPolicyItemType() == RangerPolicyItemEvaluator.POLICY_ITEM_TYPE_ALLOW) { ret = true; } RangerPerfTracer.log(perf); if (LOG.isDebugEnabled()) { LOG.debug("<== RangerDefaultPolicyEvaluator.isAccessAllowed(" + user + ", " + userGroups + ", " + accessType + "): " + ret); } return ret; }
From source file:org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor.java
/** * Returns a brief description of this <code>ClientHealthMonitor</code> * * @since GemFire 5.1/* w w w .j a v a 2 s .c om*/ */ @Override public String toString() { return "ClientHealthMonitor@" + Integer.toHexString(System.identityHashCode(this)); }
From source file:org.jdesktop.swingworker.AccumulativeRunnable.java
/** * returns workersExecutorService./*w ww. j a v a 2 s . co m*/ * * returns the service stored in the appContext or creates it if * necessary. If the last one it triggers autoShutdown thread to * get started. * * @return ExecutorService for the {@code SwingWorkers} * @see #startAutoShutdownThread */ private static synchronized ExecutorService getWorkersExecutorService() { if (executorService == null) { //this creates non-daemon threads. ThreadFactory threadFactory = new ThreadFactory() { final AtomicInteger threadNumber = new AtomicInteger(1); public Thread newThread(final Runnable r) { StringBuilder name = new StringBuilder("SwingWorker-pool-"); name.append(System.identityHashCode(this)); name.append("-thread-"); name.append(threadNumber.getAndIncrement()); Thread t = new Thread(r, name.toString());; if (t.isDaemon()) t.setDaemon(false); if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); return t; } }; /* * We want a to have no more than MAX_WORKER_THREADS * running threads. * * We want a worker thread to wait no longer than 1 second * for new tasks before terminating. */ executorService = new ThreadPoolExecutor(0, MAX_WORKER_THREADS, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory) { private final ReentrantLock pauseLock = new ReentrantLock(); private final Condition unpaused = pauseLock.newCondition(); private boolean isPaused = false; private final ReentrantLock executeLock = new ReentrantLock(); @Override public void execute(Runnable command) { /* * ThreadPoolExecutor first tries to run task * in a corePool. If all threads are busy it * tries to add task to the waiting queue. If it * fails it run task in maximumPool. * * We want corePool to be 0 and * maximumPool to be MAX_WORKER_THREADS * We need to change the order of the execution. * First try corePool then try maximumPool * pool and only then store to the waiting * queue. We can not do that because we would * need access to the private methods. * * Instead we enlarge corePool to * MAX_WORKER_THREADS before the execution and * shrink it back to 0 after. * It does pretty much what we need. * * While we changing the corePoolSize we need * to stop running worker threads from accepting new * tasks. */ //we need atomicity for the execute method. executeLock.lock(); try { pauseLock.lock(); try { isPaused = true; } finally { pauseLock.unlock(); } setCorePoolSize(MAX_WORKER_THREADS); super.execute(command); setCorePoolSize(0); pauseLock.lock(); try { isPaused = false; unpaused.signalAll(); } finally { pauseLock.unlock(); } } finally { executeLock.unlock(); } } @Override protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); pauseLock.lock(); try { while(isPaused) { unpaused.await(); } } catch(InterruptedException ignore) { } finally { pauseLock.unlock(); } } }; } return executorService; }
From source file:org.apache.geode.internal.cache.GemFireCacheImpl.java
/** * This is for debugging cache-open issues (esp. * {@link org.apache.geode.cache.CacheExistsException}) *///from w w w. j a v a 2 s. c o m @Override public String toString() { final StringBuffer sb = new StringBuffer(); sb.append("GemFireCache["); sb.append("id = " + System.identityHashCode(this)); sb.append("; isClosing = " + this.isClosing); sb.append("; isShutDownAll = " + isCacheAtShutdownAll()); sb.append("; created = " + this.creationDate); sb.append("; server = " + this.isServer); sb.append("; copyOnRead = " + this.copyOnRead); sb.append("; lockLease = " + this.lockLease); sb.append("; lockTimeout = " + this.lockTimeout); // sb.append("; rootRegions = (" + this.rootRegions + ")"); // sb.append("; cacheServers = (" + this.cacheServers + ")"); // sb.append("; regionAttributes = (" + this.listRegionAttributes()); // sb.append("; gatewayHub = " + gatewayHub); if (this.creationStack != null) { sb.append("\nCreation context:\n"); OutputStream os = new OutputStream() { @Override public void write(int i) { sb.append((char) i); } }; PrintStream ps = new PrintStream(os); this.creationStack.printStackTrace(ps); } sb.append("]"); return sb.toString(); }
From source file:com.enioka.jqm.api.HibernateClient.java
private String getStringPredicate(String fieldName, List<String> filterValues, Map<String, Object> prms) { if (filterValues != null && !filterValues.isEmpty()) { String res = ""; for (String filterValue : filterValues) { if (filterValue == null) { continue; }//from w w w. j a va 2s. com if (!filterValue.isEmpty()) { String prmName = fieldName.split("\\.")[fieldName.split("\\.").length - 1] + System.identityHashCode(filterValue); prms.put(prmName, filterValue); if (filterValue.contains("%")) { res += String.format("(h.%s LIKE :%s) OR ", fieldName, prmName); } else { res += String.format("(h.%s = :%s) OR ", fieldName, prmName); } } else { res += String.format("(h.%s IS NULL OR h.%s = '') OR ", fieldName, fieldName); } } if (!res.isEmpty()) { res = "AND (" + res.substring(0, res.length() - 4) + ") "; return res; } } return ""; }
From source file:org.apache.openjpa.kernel.FetchConfigurationImpl.java
public String toString() { return "FetchConfiguration@" + System.identityHashCode(this) + " (" + _availableDepth + ")" + getPathString();//from w w w .ja va2 s .co m }
From source file:org.apache.ranger.plugin.policyengine.RangerPolicyEngineImpl.java
@Override public void cleanup() { if (LOG.isDebugEnabled()) { LOG.debug("==> RangerPolicyEngineImpl.cleanup()"); }/* w ww . j a va 2s .c o m*/ RangerPerfTracer perf = null; if (RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) { perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "RangerPolicyEngine.cleanUp(hashCode=" + Integer.toHexString(System.identityHashCode(this)) + ")"); } preCleanup(); if (CollectionUtils.isNotEmpty(allContextEnrichers)) { for (RangerContextEnricher contextEnricher : allContextEnrichers) { contextEnricher.cleanup(); } } this.allContextEnrichers = null; RangerPerfTracer.log(perf); if (LOG.isDebugEnabled()) { LOG.debug("<== RangerPolicyEngineImpl.cleanup()"); } }