Example usage for org.springframework.util ObjectUtils getIdentityHexString

List of usage examples for org.springframework.util ObjectUtils getIdentityHexString

Introduction

In this page you can find the example usage for org.springframework.util ObjectUtils getIdentityHexString.

Prototype

public static String getIdentityHexString(Object obj) 

Source Link

Document

Return a hex String form of an object's identity hash code.

Usage

From source file:org.springmodules.cache.serializable.ObjectWrapperTests.java

public void testToStringWithValueNotBeingString() {
    wrapper.setValue(new Integer(10));
    String actual = wrapper.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(wrapper)
            + "[value=10]";
    assertEquals(wrapper.toString(), actual);
}

From source file:org.springmodules.cache.interceptor.caching.CachedTests.java

public void testToStringWithModelIdEqualToNull() {
    attribute.setModelId(null);/*w  w  w.j av  a  2s.  c om*/
    String actual = attribute.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(attribute)
            + "[modelId=null]";
    assertEquals(attribute.toString(), actual);
}

From source file:org.springextensions.db4o.ObjectServerFactoryBean.java

@PostConstruct
public void initialize() throws Exception {
    if (filename == null) {
        throw new IllegalArgumentException("filename is required");
    }/*from   ww  w. j a  v a 2  s . c  o  m*/

    if (serverConfiguration == null) {
        server = Db4oClientServer.openServer(filename, port);
    } else {
        logger.info("using configuration: server");
        server = Db4oClientServer.openServer(serverConfiguration, filename, port);
    }

    logger.info("opened object server {} at port {}", ObjectUtils.getIdentityHexString(server),
            server.ext().port());
    logger.info("db4o {}", Db4oVersion.NAME);

    if (users != null) {
        for (Object o : users.entrySet()) {
            Entry entry = (Entry) o;
            String username = (String) entry.getKey();
            String password = (String) entry.getValue();
            server.grantAccess(username, password);
            logger.debug("access granted to user '{}' with password '{}'", username,
                    ObjectServerUtils.maskString(password));
        }
    }
}

From source file:org.springmodules.cache.provider.ehcache.EhCacheCachingModelTests.java

public void testToStringWithCacheNameNotEqualToNull() {
    model.setCacheName("main");
    String actual = model.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(model)
            + "[cacheName='main', blocking=false, cacheEntryFactory=null]";
    assertEquals(model.toString(), actual);
}

From source file:org.springmodules.cache.provider.ehcache.EhCacheCachingModelTests.java

public void testToStringWithBlockingTrue() {
    model.setCacheName("main");
    model.setBlocking(true);/* w w w.j  a  va2s .c  om*/
    String actual = model.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(model)
            + "[cacheName='main', blocking=true, cacheEntryFactory=null]";
    assertEquals(model.toString(), actual);
}

From source file:org.springmodules.util.Objects.java

/**
 * <p>/*from  w  w  w  .ja va 2  s .  c om*/
 * Returns a <code>StringBuffer</code> containing:
 * <ol>
 * <li>the class name of the given object</li>
 * <li>the character '@'</li>
 * <li>the hex string for the object's identity hash code</li>
 * </ol>
 * </p>
 * <p>
 * This method will return an empty <code>StringBuffer</code> if the given
 * object is <code>null</code>.
 * </p>
 * 
 * @param obj
 *          the given object.
 * @return a <code>StringBuffer</code> containing identity information of
 *         the given object.
 */
public static StringBuffer identityToString(Object obj) {
    StringBuffer buffer = new StringBuffer();
    if (obj != null) {
        buffer.append(obj.getClass().getName());
        buffer.append("@");
        buffer.append(ObjectUtils.getIdentityHexString(obj));
    }
    return buffer;
}

From source file:org.springextensions.db4o.ObjectServerFactoryBean.java

@PreDestroy
public void destroy() throws Exception {
    logger.info("closing object server {}", ObjectUtils.getIdentityHexString(server));
    server.close();//from  www . j a  v  a2s  .co m
}

From source file:org.springmodules.cache.provider.ehcache.EhCacheCachingModelTests.java

public void testToStringWithCacheEntryFactoryNotEqualToNull() {
    model.setCacheName("main");
    model.setBlocking(true);//from  ww  w  . ja va 2  s .co  m
    model.setCacheEntryFactory(new NullCacheEntryFactory());
    String actual = model.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(model)
            + "[cacheName='main', blocking=true, cacheEntryFactory=" + NullCacheEntryFactory.class.getName()
            + "]";
    assertEquals(model.toString(), actual);
}

From source file:org.springextensions.db4o.ObjectContainerFactoryBean.java

@PreDestroy
public void destroy() {
    logger.info("closing object container {}", ObjectUtils.getIdentityHexString(container));
    container.close();
}

From source file:org.springmodules.cache.provider.ehcache.EhCacheFlushingModelTests.java

public void testToStringWithCacheNamesEqualToNull() {
    model.setCacheNames((String[]) null);
    model.setFlushBeforeMethodExecution(true);

    String actual = model.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(model)
            + "[cacheNames=null, flushBeforeMethodExecution=true]";
    assertEquals(model.toString(), actual);
}