List of usage examples for java.lang System identityHashCode
@HotSpotIntrinsicCandidate public static native int identityHashCode(Object x);
From source file:de.ailis.midi4js.Midi4JS.java
/** * Creates a new receiver and returns the handle on it. * * @return The handle for the receiver.//from w ww.j a v a 2 s. c o m */ public int createReceiver() { final Receiver receiver = new MessageReceiver(this); final int handle = System.identityHashCode(receiver); this.receiverMap.put(handle, receiver); return handle; }
From source file:com.ayuget.redface.ui.fragment.PostsFragment.java
/** * Defer posts loading until current fragment is visible in the ViewPager. Avoids screwing with * forum's read/unread markers.//w ww .ja va 2 s.co m */ @Subscribe public void onPageSelectedEvent(PageSelectedEvent event) { if (!isInitialPage() && event.getTopic() == topic && event.getPage() == currentPage && isVisible()) { Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) received event for page %d selected", System.identityHashCode(this), currentPage, event.getPage())); if (displayedPosts != null && displayedPosts.size() == 0) { loadPage(currentPage); } } }
From source file:com.ayuget.redface.ui.fragment.PostsFragment.java
@Subscribe public void onPageRefreshRequestEvent(PageRefreshRequestEvent event) { if (event.getTopic().getId() == topic.getId() && isVisible()) { Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) -> Refresh requested event", System.identityHashCode(this), currentPage)); savePageScrollPosition();/* w ww . j av a2 s .co m*/ showLoadingIndicator(); loadPage(currentPage); } }
From source file:com.meltmedia.cadmium.servlets.ClassLoaderLeakPreventor.java
public void contextDestroyed(ServletContextEvent servletContextEvent) { final boolean jvmIsShuttingDown = isJvmShuttingDown(); if (jvmIsShuttingDown) { info("JVM is shutting down - skip cleanup"); return; // Don't do anything more }//from www . ja va2 s . c om info(getClass().getName() + " shutting down context by removing known leaks (CL: 0x" + Integer.toHexString(System.identityHashCode(getWebApplicationClassLoader())) + ")"); ////////////////// // Fix known leaks ////////////////// java.beans.Introspector.flushCaches(); // Clear cache of strong references // Apache Commons Pool can leave unfinished threads. Anything specific we can do? clearBeanELResolverCache(); fixBeanValidationApiLeak(); fixJsfLeak(); fixGeoToolsLeak(); // Can we do anything about Google Guice ? // Can we do anything about Groovy http://jira.codehaus.org/browse/GROOVY-4154 ? clearIntrospectionUtilsCache(); // Can we do anything about Logback http://jira.qos.ch/browse/LBCORE-205 ? // Force the execution of the cleanup code for JURT; see https://issues.apache.org/ooo/show_bug.cgi?id=122517 forceStartOpenOfficeJurtCleanup(); //////////////////// // Fix generic leaks // Deregister JDBC drivers contained in web application deregisterJdbcDrivers(); // Unregister MBeans loaded by the web application class loader unregisterMBeans(); // Deregister shutdown hooks - execute them immediately deregisterShutdownHooks(); deregisterPropertyEditors(); deregisterSecurityProviders(); clearDefaultAuthenticator(); deregisterRmiTargets(); clearThreadLocalsOfAllThreads(); stopThreads(); destroyThreadGroups(); unsetCachedKeepAliveTimer(); try { try { // First try Java 1.6 method final Method clearCache16 = ResourceBundle.class.getMethod("clearCache", ClassLoader.class); debug("Since Java 1.6+ is used, we can call " + clearCache16); clearCache16.invoke(null, getWebApplicationClassLoader()); } catch (NoSuchMethodException e) { // Not Java 1.6+, we have to clear manually final Map<?, ?> cacheList = getStaticFieldValue(ResourceBundle.class, "cacheList"); // Java 5: SoftCache extends AbstractMap final Iterator<?> iter = cacheList.keySet().iterator(); Field loaderRefField = null; while (iter.hasNext()) { Object key = iter.next(); // CacheKey if (loaderRefField == null) { // First time loaderRefField = key.getClass().getDeclaredField("loaderRef"); loaderRefField.setAccessible(true); } WeakReference<ClassLoader> loaderRef = (WeakReference<ClassLoader>) loaderRefField.get(key); // LoaderReference extends WeakReference ClassLoader classLoader = loaderRef.get(); if (isWebAppClassLoaderOrChild(classLoader)) { info("Removing ResourceBundle from cache: " + key); iter.remove(); } } } } catch (Exception ex) { error(ex); } // (CacheKey of java.util.ResourceBundle.NONEXISTENT_BUNDLE will point to first referring classloader...) // Release this classloader from Apache Commons Logging (ACL) by calling // LogFactory.release(getCurrentClassLoader()); // Use reflection in case ACL is not present. // Do this last, in case other shutdown procedures want to log something. final Class logFactory = findClass("org.apache.commons.logging.LogFactory"); if (logFactory != null) { // Apache Commons Logging present info("Releasing web app classloader from Apache Commons Logging"); try { logFactory.getMethod("release", java.lang.ClassLoader.class).invoke(null, getWebApplicationClassLoader()); } catch (Exception ex) { error(ex); } } }
From source file:org.nuxeo.ecm.core.repository.jcr.JCRSession.java
@Override public String toString() { String sessionStr = session == null ? "N/A" : session.toString(); return System.identityHashCode(this) + ":" + sid + ':' + sessionStr; }
From source file:org.pentaho.reporting.engine.classic.core.cache.CachingDataFactory.java
private TableModel queryInternal(final String query, final DataRow parameters, final QueryStyle queryStyle) throws ReportDataFactoryException { if (profileDataSources && CachingDataFactory.logger.isDebugEnabled()) { CachingDataFactory.logger/* w w w .ja va2 s . co m*/ .debug(System.identityHashCode(Thread.currentThread()) + ": Query processing time: Starting"); } final long startTime = System.currentTimeMillis(); try { final StaticDataRow params = new StaticDataRow(parameters); final TableModel dataFromQuery; switch (queryStyle) { case FreeForm: dataFromQuery = backend.queryFreeForm(query, params); break; case Static: dataFromQuery = backend.queryStatic(query, params); break; case General: dataFromQuery = backend.queryData(query, params); break; default: throw new IllegalStateException(); } if (dataFromQuery == null) { // final DefaultTableModel value = new DefaultTableModel(); if (debugDataSources && CachingDataFactory.logger.isDebugEnabled()) { CachingDataFactory.logger.debug("Query failed for query '" + query + '\''); } return null; } else { if (debugDataSources && CachingDataFactory.logger.isDebugEnabled()) { CachingDataFactory.printTableModelContents(dataFromQuery); } // totally new query here. CachingDataFactory.logger.debug("Query returned a data-set for query '" + query + '\''); return dataFromQuery; } } finally { final long queryTime = System.currentTimeMillis(); if (profileDataSources && CachingDataFactory.logger.isDebugEnabled()) { CachingDataFactory.logger.debug(System.identityHashCode(Thread.currentThread()) + ": Query processing time: " + ((queryTime - startTime) / 1000.0)); } } }
From source file:com.genologics.ri.userdefined.UDF.java
/** * Create a message for the MissingUDFException when {@code failMessage} is not set. * * @param thing The object the UDF is set on. * @param name The name of the UDF.//from w ww . j a va 2s. c o m * @param failMessage The fail message supplied by the caller. * * @return A suitable failure message for the exception. */ private static String getMissingUDFMessage(Object thing, String name, String failMessage) { if (failMessage == null) { if (thing == null) { failMessage = "UDF \"" + name + "\" does not exist because 'thing' is null."; } else { String better = "UDF \"{0}\" does not exist on {1} {2}"; if (thing instanceof LimsEntityLinkable<?>) { LimsEntityLinkable<?> linkable = (LimsEntityLinkable<?>) thing; failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()), linkable.getLimsid()); } else if (thing instanceof Locatable) { Locatable locatable = (Locatable) thing; failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()), locatable.getUri()); } else { failMessage = MessageFormat.format(better, name, ClassUtils.getShortClassName(thing.getClass()), Integer.toHexString(System.identityHashCode(thing))); } } } return failMessage; }
From source file:org.mule.transformer.AbstractTransformer.java
@Override public String toString() { StringBuffer sb = new StringBuffer(80); sb.append(ClassUtils.getSimpleName(this.getClass())); sb.append("{this=").append(Integer.toHexString(System.identityHashCode(this))); sb.append(", name='").append(name).append('\''); sb.append(", ignoreBadInput=").append(ignoreBadInput); sb.append(", returnClass=").append(returnType); sb.append(", sourceTypes=").append(sourceTypes); sb.append('}'); return sb.toString(); }
From source file:org.kitodo.filemanagement.locking.LockManagement.java
/** * With this method, file management reports that it has opened a read * channel for a URI. It wraps around the stream with a stream guard because * the lock management must be able to detect when the stream is shut down * because it depends on whether the lock in question can be reset, is * automatically reset, or other locks can be granted or not. * /*from w ww . j av a 2 s. co m*/ * @param uri * URI to which a read channel was opened * @param readChannel * the opened input stream * @param lockingResult * the authorization object * @return the input stream that the user should use. The input stream is * wrapped in an instance of a vigilant input stream that notifies * the lock management when the stream is closed. */ public InputStream reportGrant(URI uri, InputStream readChannel, LockResult lockingResult) { GrantedAccess permissions = (GrantedAccess) lockingResult; if (logger.isTraceEnabled()) { logger.trace("For {}, the reading channel {} was opened to {}.", permissions, Integer.toHexString(System.identityHashCode(readChannel)), uri); } AbstractLock lock = permissions.getLock(uri); if (lock instanceof UpgradeableReadLock) { ((UpgradeableReadLock) lock).noteReadingStarts(); } VigilantInputStream vigilantInputStream = new VigilantInputStream(uri, readChannel, streamManagement, permissions); streamManagement.registerStreamGuard(vigilantInputStream); return vigilantInputStream; }
From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicesAndRoutingPage.java
protected TableViewer createTable(Composite tableContainer) { Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL); table.setLinesVisible(true);// w w w. j a va2s .c o m table.setHeaderVisible(true); TableViewer viewer = new TableViewerBuilder(table, tableContainer).column("Name").align(SWT.LEFT).weight(2) .minWidth(50).buildColumn().column("Service Port").align(SWT.LEFT).weight(1).minWidth(25) .buildColumn().column("Pod Port").align(SWT.LEFT).weight(1).minWidth(25).buildColumn() .column(new ColumnLabelProvider() { @Override public Image getImage(Object element) { boolean selected = ((ServicePortAdapter) element).isRoutePort(); return selected ? OpenShiftImages.CHECKED_IMG : OpenShiftImages.UNCHECKED_IMG; } @Override public String getText(Object element) { return null; } }).name("Used by route").align(SWT.LEFT).weight(1).buildColumn().buildViewer(); viewer.addDoubleClickListener(new EditHandler()); /* * required because otherwise values are cached and causes the ObservableMapLabelProvider * not to be updated because remove are not propagated. */ viewer.setComparer(new IElementComparer() { @Override public int hashCode(Object element) { return System.identityHashCode(element); } @Override public boolean equals(Object a, Object b) { return a == b; } }); return viewer; }