List of usage examples for org.springframework.util ReflectionUtils invokeMethod
@Nullable public static Object invokeMethod(Method method, @Nullable Object target)
From source file:org.eclipse.gemini.blueprint.test.internal.holder.ReflectionOsgiHolder.java
public Long getTestBundleId() { return (Long) ReflectionUtils.invokeMethod(GET_TEST_BUNDLE_ID, instance); }
From source file:org.shept.persistence.provider.hibernate.HibernateAssociationProvider.java
@SuppressWarnings({ "rawtypes" }) @Override/* w w w .j av a2 s . c o m*/ public List<?> loadListFirst() { ReloadableAssociation ass = (ReloadableAssociation) getFilterDefinition(); Object model = ass.getSourceModel(); // reload the object again ... // hibernateDao.getHibernateTemplate().refresh(model) won't work, so here's a workaround ... // ... to get rid of this dreaded and random LazyLoadingExceptions when opening the link ... Object idxObj = DaoUtils.getIdValue((HibernateDaoSupport) this.dao, model); if (idxObj == null) { // can't load from database so we have nothing here ... // we should not use existing transient objects from the cache ! return new ArrayList(); } model = getHibernateTemplate().load(model.getClass(), (Serializable) idxObj); Object res = ReflectionUtils.invokeMethod(ass.getAssociationMethod(), model); if (!(res instanceof List)) { throw new DataLoadException("Could not provide the requested data '" + ass.getAssociationMethod().getName() + "' from DataSource '" + ass.getSourceModel().getClass() + ". Result is '" + res + "' but a List is required"); } eol = true; return (List<?>) res; }
From source file:org.eclipse.gemini.blueprint.test.internal.holder.ReflectionOsgiHolder.java
public String getTestClassName() { return (String) ReflectionUtils.invokeMethod(GET_TEST_CLASS_NAME, instance); }
From source file:org.cloudfoundry.reconfiguration.spring.AbstractHibernateBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getDialect(SessionFactory factory) { Method method = ReflectionUtils.findMethod(factory.getClass(), "getDialect"); return ReflectionUtils.invokeMethod(method, factory); }
From source file:org.cloudfoundry.reconfiguration.spring.AbstractJpaBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getDialect(Object factory) { Method method = ReflectionUtils.findMethod(factory.getClass(), "getDialect"); return ReflectionUtils.invokeMethod(method, factory); }
From source file:org.kmnet.com.fw.common.codelist.EnumCodeList.java
/** * Constructor.//from ww w . j av a2s. com * * @param enumClass Enum class of which this codelist consists. Must implement {@link CodeListItem} * @throws java.lang.IllegalArgumentException if the given class does not implement {@link CodeListItem} */ public EnumCodeList(Class<? extends Enum<?>> enumClass) { Assert.isTrue(CodeListItem.class.isAssignableFrom(enumClass), "the given enumClass must implement " + CodeListItem.class); Map<String, String> codeList = new LinkedHashMap<String, String>(); Method method = ReflectionUtils.findMethod(enumClass, "values"); Enum<?>[] result = (Enum<?>[]) ReflectionUtils.invokeMethod(method, enumClass); for (Enum<?> e : result) { CodeListItem item = (CodeListItem) e; codeList.put(item.getCodeValue(), item.getCodeLabel()); } this.codeListMap = Collections.unmodifiableMap(codeList); }
From source file:org.eclipse.gemini.blueprint.test.internal.holder.ReflectionOsgiHolder.java
public String getTestMethodName() { return (String) ReflectionUtils.invokeMethod(GET_TEST_METHOD_NAME, instance); }
From source file:org.shept.persistence.provider.DaoUtils.java
/** * Checking if it is a new model (identifier == null) If the index is a * compound index we must check all components if just one of them is null * /* w w w .j av a 2 s . c om*/ * @param index * @return */ public static boolean isNewModel(DaoSupport dao, Object model) { ClassMetadata modelMeta = getClassMetadata(dao, model); if (null == modelMeta) { return false; } Object idValue = modelMeta.getIdentifier(model, EntityMode.POJO); if (idValue == null) { return true; } Type type = modelMeta.getIdentifierType(); if (!(type instanceof ComponentType)) { return false; } // didn't manage to get the individual objects of a compound index out of // the Hibernate metaModel API although that should be possible ... PropertyDescriptor[] desc = BeanUtils.getPropertyDescriptors(idValue.getClass()); for (int i = 0; i < desc.length; i++) { Method mth = desc[i].getReadMethod(); Object val = ReflectionUtils.invokeMethod(mth, idValue); if (null == val) { return true; } } return false; }
From source file:com.cloudera.csd.validation.references.components.ReflectionHelper.java
/** * Invoke the method against the target object with no * arguments. If there is an exception invoking the method, * an IllegalStateException is thrown./* w w w . ja va2 s. co m*/ * * @param method the method. * @param target the object to execute the method against. * @return the result of the method call. */ @Nullable public static Object invokeMethod(Method method, Object target) { return ReflectionUtils.invokeMethod(method, target); }
From source file:org.reusables.dbunit.handler.HibernateSessionFactoryOperationHandler.java
/** * @param sessionFactory The session factory to use. * @return The session to use to handle the operation. * @since 1.2.0//from ww w .j ava 2s . c om */ protected Session getSession(final SessionFactory sessionFactory) { // The return value differs between Hibernate 3.x and 4.x; for cross-compilation purposes, // we have to use reflection here as long as we keep supporting Hibernate 3.x. final Method method = ClassUtils.getMethod(sessionFactory.getClass(), "getCurrentSession"); return (Session) ReflectionUtils.invokeMethod(method, sessionFactory); }