Example usage for org.springframework.util ObjectUtils identityToString

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

Introduction

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

Prototype

public static String identityToString(@Nullable Object obj) 

Source Link

Document

Return a String representation of an object's overall identity.

Usage

From source file:org.impalaframework.module.runtime.BaseModuleRuntime.java

public final RuntimeModule loadRuntimeModule(Application application, ModuleDefinition definition) {

    final ClassLoaderRegistry classLoaderRegistry = application.getClassLoaderRegistry();

    try {//from  www. j a v  a 2  s.  c  o m
        beforeModuleLoads(definition);

        RuntimeModule runtimeModule;
        try {
            runtimeModule = doLoadModule(application, definition);
        } catch (RuntimeException e) {
            classLoaderRegistry.removeClassLoader(definition.getName());
            throw e;
        }

        Assert.notNull(classLoaderRegistry);

        final String moduleName = definition.getName();
        //note that GraphClassLoaderFactory will also populate the ClassLoaderRegistry, hence, this check
        if (!classLoaderRegistry.hasClassLoaderFor(moduleName)) {
            classLoaderRegistry.addClassLoader(moduleName, runtimeModule.getClassLoader());

            if (logger.isDebugEnabled()) {
                logger.debug(
                        "Added new class loader " + ObjectUtils.identityToString(runtimeModule.getClassLoader())
                                + " to class loader registry for module: " + moduleName);
            }
        }

        return runtimeModule;
    } finally {
        afterModuleLoaded(definition);
    }
}

From source file:org.impalaframework.service.contribution.ServiceRegistryMonitor.java

void handleReferenceAdded(ServiceRegistryEntry entry) {
    ServiceReferenceFilter filter = serviceActivityNotifiable.getServiceReferenceFilter();

    boolean isStatic = entry.getServiceBeanReference().isStatic();
    if (!isStatic) {
        boolean allowNonStaticReferences = serviceActivityNotifiable.getAllowNonStaticReferences();
        if (!allowNonStaticReferences) {
            if (logger.isDebugEnabled()) {
                logger.debug("Service entry " + entry + " filtered out as bean reference is static, but target "
                        + ObjectUtils.identityToString(serviceActivityNotifiable)
                        + "does not support non-static reference");
            }/*from www. j  a v a2  s.  com*/
            return;
        }
    }

    final boolean typeMatches;

    Class<?>[] exportTypes = serviceActivityNotifiable.getExportTypes();
    if (!ArrayUtils.isNullOrEmpty(exportTypes)) {

        //do check against export types in registry
        typeMatches = getServiceRegistry().isPresentInExportTypes(entry, exportTypes);
    } else {

        //do check against actual implemented types
        typeMatches = matchesTypes(serviceActivityNotifiable, entry);
    }

    if (typeMatches && filter.matches(entry)) {
        serviceActivityNotifiable.add(entry);
    }
}

From source file:org.impalaframework.service.registry.internal.ServiceEventListenerRegistryDelegate.java

/**
 * Adds to global event listeners to which all service registry events will
 * be broadcast. Note that a single event listener instance can only be added once.
 * Any subsequent attempts to add this listener will not have any effect.
 *//*from  w ww .j  ava2 s . c om*/
public boolean addEventListener(ServiceRegistryEventListener listener) {
    Assert.notNull(listener);

    synchronized (listenersLock) {
        if (this.listeners.contains(listener)) {
            logger.warn("Listener " + ObjectUtils.identityToString(listener)
                    + " already a listener for this service registry");
            return false;
        } else {
            this.listeners.add(listener);
            if (logger.isDebugEnabled()) {
                logger.debug("Added service registry listener " + listener);
            }
            return true;
        }
    }
}

From source file:org.impalaframework.web.servlet.invocation.InvocationChain.java

public void invoke(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
        throws ServletException, IOException {

    if (filterCount < filters.size()) {
        int currentCount = filterCount;
        filterCount++;//  ww  w.  ja va 2s .  c o m

        Filter filter = filters.get(currentCount);

        if (logger.isDebugEnabled())
            logger.debug("Getting filter for " + currentCount + ObjectUtils.identityToString(filter));

        filter.doFilter(request, response, this);
    } else if (servlet != null) {
        servlet.service(request, response);
    } else {
        incomplete = true;
    }
}

From source file:org.springframework.batch.core.scope.context.StepContextRepeatCallback.java

/**
 * Manage the {@link StepContext} lifecycle. Business processing should be
 * delegated to {@link #doInChunkContext(RepeatContext, ChunkContext)}. This
 * is to ensure that the current thread has a reference to the context, even
 * if the callback is executed in a pooled thread. Handles the registration
 * and unregistration of the step context, so clients should not duplicate
 * those calls./*  w  w  w . ja v a 2 s.  co m*/
 *
 * @see RepeatCallback#doInIteration(RepeatContext)
 */
@Override
public RepeatStatus doInIteration(RepeatContext context) throws Exception {

    // The StepContext has to be the same for all chunks,
    // otherwise step-scoped beans will be re-initialised for each chunk.
    StepContext stepContext = StepSynchronizationManager.register(stepExecution);
    if (logger.isDebugEnabled()) {
        logger.debug("Preparing chunk execution for StepContext: " + ObjectUtils.identityToString(stepContext));
    }

    ChunkContext chunkContext = attributeQueue.poll();
    if (chunkContext == null) {
        chunkContext = new ChunkContext(stepContext);
    }

    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Chunk execution starting: queue size=" + attributeQueue.size());
        }
        return doInChunkContext(context, chunkContext);
    } finally {
        // Still some stuff to do with the data in this chunk,
        // pass it back.
        if (!chunkContext.isComplete()) {
            attributeQueue.add(chunkContext);
        }
        StepSynchronizationManager.close();
    }
}

From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(getClass().getName());
    if (this.wrappedObject != null) {
        sb.append(": wrapping object [").append(ObjectUtils.identityToString(this.wrappedObject)).append("]");
    } else {/*from   w w  w.  j  a va  2s.  co m*/
        sb.append(": no wrapped object set");
    }
    return sb.toString();
}

From source file:org.springframework.integration.stomp.AbstractStompSessionManager.java

@Override
public String toString() {
    return ObjectUtils.identityToString(this) + " {connecting=" + this.connecting + ", connected="
            + this.connected + ", name='" + this.name + '\'' + '}';
}

From source file:org.springframework.messaging.support.MessageHeaderAccessor.java

protected String getShortPayloadLogMessage(Object payload) {
    if (payload instanceof String) {
        String payloadText = (String) payload;
        return (payloadText.length() < 80) ? " payload=" + payloadText
                : " payload=" + payloadText.substring(0, 80) + "...(truncated)";
    } else if (payload instanceof byte[]) {
        byte[] bytes = (byte[]) payload;
        if (isReadableContentType()) {
            Charset charset = getContentType().getCharSet();
            charset = (charset != null ? charset : DEFAULT_CHARSET);
            return (bytes.length < 80) ? " payload=" + new String(bytes, charset)
                    : " payload=" + new String(Arrays.copyOf(bytes, 80), charset) + "...(truncated)";
        } else {/*from  www  .  ja  va  2 s . c o m*/
            return " payload=byte[" + bytes.length + "]";
        }
    } else {
        String payloadText = payload.toString();
        return (payloadText.length() < 80) ? " payload=" + payloadText
                : " payload=" + ObjectUtils.identityToString(payload);
    }
}

From source file:org.springframework.web.context.ContextLoader.java

protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac,
        ServletContext sc) {/*from w w w. j  ava 2  s.  c  om*/
    if (ObjectUtils.identityToString(wac).equals(wac.getId())) {
        // The application context id is still set to its original default value
        // -> assign a more useful id based on available information
        String idParam = sc.getInitParameter(CONTEXT_ID_PARAM);
        if (idParam != null) {
            wac.setId(idParam);
        } else {
            // Generate default id...
            wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX
                    + ObjectUtils.getDisplayString(sc.getContextPath()));
        }
    }

    wac.setServletContext(sc);
    String configLocationParam = sc.getInitParameter(CONFIG_LOCATION_PARAM);
    if (configLocationParam != null) {
        wac.setConfigLocation(configLocationParam);
    }

    // The wac environment's #initPropertySources will be called in any case when the context
    // is refreshed; do it eagerly here to ensure servlet property sources are in place for
    // use in any post-processing or initialization that occurs below prior to #refresh
    ConfigurableEnvironment env = wac.getEnvironment();
    if (env instanceof ConfigurableWebEnvironment) {
        ((ConfigurableWebEnvironment) env).initPropertySources(sc, null);
    }

    customizeContext(sc, wac);
    wac.refresh();
}

From source file:org.tinygroup.weblayer.webcontext.parser.util.BeanWrapperImpl.java

public String toString() {
    StringBuffer sb = new StringBuffer(getClass().getName());
    if (this.object != null) {
        sb.append(": wrapping object [").append(ObjectUtils.identityToString(this.object)).append("]");
    } else {//from   ww  w .j ava2  s. c  o  m
        sb.append(": no wrapped object set");
    }
    return sb.toString();
}