List of usage examples for org.springframework.util ObjectUtils nullSafeClassName
public static String nullSafeClassName(@Nullable Object obj)
From source file:org.spring.data.gemfire.config.DiskStoreBeanPostProcessor.java
@Override public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException { System.out.printf("Post Processing Bean (%1$s) of Type (%2$s) with Name (%3$s)...%n", bean, ObjectUtils.nullSafeClassName(bean), beanName); if (bean instanceof DiskDir) { createIfNotExists((DiskDir) bean); }/*from ww w . j ava 2 s.c o m*/ return bean; }
From source file:org.spring.data.gemfire.config.DiskStoreBeanPostProcessor.java
@SuppressWarnings("unchecked") private <T> T readField(final Object obj, final String fieldName) { try {//from www. ja v a2s .c o m Class type = obj.getClass(); Field field; do { field = type.getDeclaredField(fieldName); type = type.getSuperclass(); } while (field == null && !Object.class.equals(type)); if (field == null) { throw new NoSuchFieldException( String.format("Field (%1$s) does not exist on Object of Class type (%2$s)!", fieldName, ObjectUtils.nullSafeClassName(obj))); } field.setAccessible(true); return (T) field.get(obj); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.spring.data.gemfire.app.dao.provider.DatabaseGemstoneDao.java
@PostConstruct public void init() { try {/* w w w . j a va 2 s . c o m*/ Context jndiContext = getCache().getJNDIContext(); Object dataSourceObject = jndiContext.lookup(GEMFIREDB_JNDI_LOCATION); Assert.isTrue(dataSourceObject instanceof DataSource, String.format("Expected a javax.sql.DataSource object; but was %1$s%n", ObjectUtils.nullSafeClassName(dataSourceObject))); databaseTemplate = new JdbcTemplate((DataSource) dataSourceObject); System.out.printf("%1$s initialized!%n", getClass().getSimpleName()); } catch (NamingException e) { throw new InitializationException( String.format("Failed to initialize %1$s!", getClass().getSimpleName()), e); } }
From source file:org.spring.data.gemfire.cache.PeerCacheFunctionCreationExecutionTest.java
@Test public void testEchoOnMemberUsingGemFire() { Execution memberFunctionExecution = FunctionService .onMember(gemfireConfigurationSettings.getProperty("groups")).withArgs("Hello"); ResultCollector<?, ?> results = memberFunctionExecution.execute("echo"); assertNotNull(results);/*from www . jav a 2 s .c o m*/ Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals("You said 'Hello'!", ((List) result).get(0)); }
From source file:org.spring.data.gemfire.cache.ClientCacheFunctionExecutionTest.java
@Test public void testEchoOnMemberUsingGemFire() { assumeNotNull(onMemberEchoFunction); Execution memberFunctionExecution = FunctionService.onMember("testGroup").withArgs("TEST"); ResultCollector<?, ?> results = memberFunctionExecution.execute("echo"); assertNotNull(results);//from www .j a v a 2s .c o m Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals("You said 'TEST'!", ((List) result).get(0)); }
From source file:org.spring.data.gemfire.cache.PeerCacheFunctionCreationExecutionTest.java
@Ignore @Test//from www. j a v a 2s .c om public void testEchoOnServerUsingGemFire() { Execution memberFunctionExecution = FunctionService.onServer(gemfireCache).withArgs("Hola"); ResultCollector<?, ?> results = memberFunctionExecution.execute("echo"); assertNotNull(results); Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals("You said 'Hola'!", ((List) result).get(0)); }
From source file:org.spring.data.gemfire.cache.ClientCacheFunctionExecutionTest.java
@Test public void testEchoOnServerUsingGemFire() { assumeNotNull(onServerEchoFunction); Execution memberFunctionExecution = FunctionService.onServer(gemfireCache).withArgs("GOODBYE"); ResultCollector<?, ?> results = memberFunctionExecution.execute("echo"); assertNotNull(results);//from w w w . ja v a2s . com Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals("You said 'GOODBYE'!", ((List) result).get(0)); }
From source file:org.spring.data.gemfire.cache.JsonToPdxToObjectDataAccessIntegrationTest.java
protected void log(Object value) { System.out.printf("Object of Type (%1$s) has Value (%2$s)", ObjectUtils.nullSafeClassName(value), value); }
From source file:org.spring.data.gemfire.cache.PeerCacheFunctionCreationExecutionTest.java
@Test public void testRegionSizeOnRegionUsingGemFire() { // TODO file JIRA bug for Spring Data GemFire due to NullPointerException in // DefaultFunctionArgumentResolver.resolveFunctionArguments(30) since the default value for the "arguments" Object // array in GemFire is erroneously null(!) thus requiring a empty Object array to be passed even when the Function // does not require any arguments. Execution regionFunctionExecution = FunctionService.onRegion(appData) .withArgs(new Object[] { appData.getName() }); ResultCollector<?, ?> results = regionFunctionExecution.execute("regionSize"); assertNotNull(results);/* www. j ava2s .c om*/ Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals(EXPECTED_REGION_SIZE, ((List) result).get(0)); }
From source file:org.spring.data.gemfire.cache.ClientCacheFunctionExecutionTest.java
@Test public void testRegionSizeOnRegionUsingGemFire() { Execution regionFunctionExecution = FunctionService.onRegion(appDataProxy) .withArgs(new Object[] { "AppData" }); ResultCollector<?, ?> results = regionFunctionExecution.execute("regionSize"); assertNotNull(results);/*from w w w. j ava2 s. c o m*/ Object result = results.getResult(); assertTrue(String.format("Expected java.util.List; but was (%1$s)!", ObjectUtils.nullSafeClassName(result)), result instanceof List); assertFalse(((List) result).isEmpty()); assertEquals(EXPECTED_REGION_SIZE, ((List) result).get(0)); }