List of usage examples for org.springframework.util ObjectUtils identityToString
public static String identityToString(@Nullable Object obj)
From source file:org.jdal.aop.SerializableReference.java
public void serialize() { if (useMemoryCache) { this.id = ObjectUtils.identityToString(target); serializedObjects.put(id, target); if (log.isDebugEnabled()) log.debug("Added new serialized reference. serialized objects size [" + serializedObjects.size() + "]"); }// w ww . java 2s. c o m }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoader.java
protected void configureAndRefreshPortletApplicationContext(ConfigurablePortletApplicationContext pac, PortletContext pc) {/*from w ww.j av a 2 s .c om*/ if (ObjectUtils.identityToString(pac).equals(pac.getId())) { // The application context id is still set to its original default value // -> assign a more useful id based on available information String idParam = pc.getInitParameter(CONTEXT_ID_PARAM); if (idParam != null) { pac.setId(idParam); } else { // Generate default id... pac.setId(ConfigurablePortletApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(pc.getPortletContextName())); } } // Determine parent for root web application context, if any. ApplicationContext parent = loadParentContext(pc); pac.setParent(parent); pac.setPortletContext(pc); String initParameter = pc.getInitParameter(CONFIG_LOCATION_PARAM); if (initParameter != null) { pac.setConfigLocation(initParameter); } else { try { pac.setConfigLocation("/WEB-INF/portletApplicationContext.xml"); } catch (UnsupportedOperationException e) { //Ignore, may get triggered if the context doesn't support config locations } } customizeContext(pc, pac); pac.refresh(); }
From source file:org.rosenvold.spring.convention.ConventionBeanFactory.java
protected Map<String, Object> findAutowireCandidates(String beanName, Class requiredType, DependencyDescriptor descriptor) { // System.out.println("beanName = " + beanName + ", requiredType" + requiredType); String[] candidateNames = getCandidateNames(requiredType, descriptor); Map<String, Object> result = new LinkedHashMap<String, Object>(candidateNames.length); for (Class autowiringType : this.resolvableDependenciesLocalCache.keySet()) { if (autowiringType.isAssignableFrom(requiredType)) { Object autowiringValue = this.resolvableDependenciesLocalCache.get(autowiringType); autowiringValue = resolveAutowiringValue(autowiringValue, requiredType); if (requiredType.isInstance(autowiringValue)) { result.put(ObjectUtils.identityToString(autowiringValue), autowiringValue); break; }//from w w w .ja va 2s . c om } } for (String candidateName : candidateNames) { if (!candidateName.equals(beanName) && isAutowireCandidate(candidateName, descriptor)) { result.put(candidateName, getBean(candidateName)); } } return result; }
From source file:com.dhcc.framework.web.context.DhccContextLoader.java
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac, ServletContext sc) {//from ww w .jav a 2 s . c o m Log logger = LogFactory.getLog(DhccContextLoader.class); 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... if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getServletContextName())); } else { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getContextPath())); } } } wac.setServletContext(sc); String initParameter = sc.getInitParameter(CONFIG_LOCATION_PARAM); if (isMicrokernelStart(sc)) { initParameter = "classpath:codeTemplate/applicationSetupContext.xml"; logger.error("because cant't connect to db or setup flg is 0 so init application as Microkernel "); } else { logger.info("initParameter==" + initParameter); } if (initParameter != null) { wac.setConfigLocation(initParameter); } customizeContext(sc, wac); wac.refresh(); }
From source file:net.yasion.common.core.bean.wrapper.impl.ExtendedBeanWrapperImpl.java
@Override public String toString() { StringBuilder sb = new StringBuilder(getClass().getName()); if (this.object != null) { sb.append(": wrapping object [").append(ObjectUtils.identityToString(this.object)).append("]"); } else {/*www. jav a 2 s . c o m*/ sb.append(": no wrapped object set"); } return sb.toString(); }
From source file:org.eclipse.gemini.blueprint.config.internal.adapter.CustomListenerAdapterUtils.java
/** * Invoke the custom listener method. Takes care of iterating through the method map (normally acquired through * {@link #determineCustomMethods(Class, String, Class[])} and invoking the method using the arguments. * //from w ww. ja va2 s. co m * @param target * @param methods * @param service * @param properties */ // the properties field is Dictionary implementing a Map interface static void invokeCustomMethods(Object target, Map<Class<?>, List<Method>> methods, Object service, Map properties) { if (methods != null && !methods.isEmpty()) { boolean trace = log.isTraceEnabled(); Object[] argsWMap = new Object[] { service, properties }; Object[] argsWOMap = new Object[] { service }; for (Iterator<Map.Entry<Class<?>, List<Method>>> iter = methods.entrySet().iterator(); iter .hasNext();) { Map.Entry<Class<?>, List<Method>> entry = iter.next(); Class<?> key = entry.getKey(); // find the compatible types (accept null service) if (service == null || key.isInstance(service)) { List<Method> mts = entry.getValue(); for (Method method : mts) { if (trace) log.trace("Invoking listener custom method " + method); Class<?>[] argTypes = method.getParameterTypes(); Object[] arguments = (argTypes.length > 1 ? argsWMap : argsWOMap); try { ReflectionUtils.invokeMethod(method, target, arguments); } // make sure to log exceptions and continue with the // rest of the methods catch (Exception ex) { Exception cause = ReflectionUtils.getInvocationException(ex); log.warn("Custom method [" + method + "] threw exception when passing service [" + ObjectUtils.identityToString(service) + "]", cause); } } } } } }
From source file:org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.java
/** * Invoke method with signature <code>bla(ServiceReference ref)</code>. * /* ww w . j a v a 2 s .c om*/ * @param target * @param method * @param service */ private void invokeCustomServiceReferenceMethod(Object target, Method method, Object service) { if (method != null) { boolean trace = log.isTraceEnabled(); // get the service reference // find the compatible types (accept null service) if (trace) log.trace("invoking listener custom method " + method); ServiceReference ref = (service != null ? ((ImportedOsgiServiceProxy) service).getServiceReference() : null); try { ReflectionUtils.invokeMethod(method, target, new Object[] { ref }); } // make sure to log exceptions and continue with the // rest of the listeners catch (Exception ex) { Exception cause = ReflectionUtils.getInvocationException(ex); log.warn("custom method [" + method + "] threw exception when passing service [" + ObjectUtils.identityToString(service) + "]", cause); } } }
From source file:org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.java
public void bind(final Object service, final Map properties) throws Exception { boolean trace = log.isTraceEnabled(); if (trace)//w w w.ja v a 2s .c o m log.trace("Invoking bind method for service " + ObjectUtils.identityToString(service) + " with props=" + properties); if (!initialized) retrieveTarget(); boolean isSecurityEnabled = (System.getSecurityManager() != null); AccessControlContext acc = null; if (isSecurityEnabled) { acc = SecurityUtils.getAccFrom(beanFactory); } // first call interface method (if it exists) if (isLifecycleListener) { if (trace) log.trace("Invoking listener interface methods"); try { if (isSecurityEnabled) { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { ((OsgiServiceLifecycleListener) target).bind(service, properties); return null; } }, acc); } else { ((OsgiServiceLifecycleListener) target).bind(service, properties); } } catch (Exception ex) { if (ex instanceof PrivilegedActionException) { ex = ((PrivilegedActionException) ex).getException(); } log.warn("standard bind method on [" + target.getClass().getName() + "] threw exception", ex); } } if (isSecurityEnabled) { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { CustomListenerAdapterUtils.invokeCustomMethods(target, bindMethods, service, properties); invokeCustomServiceReferenceMethod(target, bindReference, service); return null; } }, acc); } else { CustomListenerAdapterUtils.invokeCustomMethods(target, bindMethods, service, properties); invokeCustomServiceReferenceMethod(target, bindReference, service); } }
From source file:org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.java
public void unbind(final Object service, final Map properties) throws Exception { boolean trace = log.isTraceEnabled(); if (!initialized) retrieveTarget();// w w w .java2 s . co m if (trace) log.trace("Invoking unbind method for service " + ObjectUtils.identityToString(service) + " with props=" + properties); boolean isSecurityEnabled = (System.getSecurityManager() != null); AccessControlContext acc = null; if (isSecurityEnabled) { acc = SecurityUtils.getAccFrom(beanFactory); } // first call interface method (if it exists) if (isLifecycleListener) { if (trace) log.trace("Invoking listener interface methods"); try { if (isSecurityEnabled) { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { ((OsgiServiceLifecycleListener) target).unbind(service, properties); return null; } }, acc); } else { ((OsgiServiceLifecycleListener) target).unbind(service, properties); } } catch (Exception ex) { log.warn("Standard unbind method on [" + target.getClass().getName() + "] threw exception", ex); } } if (isSecurityEnabled) { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { CustomListenerAdapterUtils.invokeCustomMethods(target, unbindMethods, service, properties); invokeCustomServiceReferenceMethod(target, unbindReference, service); return null; } }, acc); } else { CustomListenerAdapterUtils.invokeCustomMethods(target, unbindMethods, service, properties); invokeCustomServiceReferenceMethod(target, unbindReference, service); } }
From source file:org.impalaframework.bootstrap.ConfigurationSettings.java
public String toString() { final String newLine = System.getProperty("line.separator"); StringBuffer buffer = new StringBuffer(ObjectUtils.identityToString(this)); buffer.append(newLine);//from w ww .j a v a 2 s. co m buffer.append("Context locations: " + configLocations); buffer.append(newLine); buffer.append("Property settings: "); buffer.append(newLine); final List<String> sortKeys = sortKeys(); for (String key : sortKeys) { String stringValue = propertyValue(key); buffer.append(" ").append(key).append(": ").append(stringValue).append(newLine); } buffer.append("--------"); return buffer.toString(); }