List of usage examples for java.lang.reflect Method toString
public String toString()
From source file:ca.uhn.fhir.rest.method.MethodUtil.java
public static Integer findIdParameterIndex(Method theMethod, FhirContext theContext) { Integer index = MethodUtil.findParamAnnotationIndex(theMethod, IdParam.class); if (index != null) { Class<?> paramType = theMethod.getParameterTypes()[index]; if (IIdType.class.equals(paramType)) { return index; }// w w w. ja v a 2 s . c om boolean isRi = theContext.getVersion().getVersion().isRi(); boolean usesHapiId = IdDt.class.equals(paramType); if (isRi == usesHapiId) { throw new ConfigurationException( "Method uses the wrong Id datatype (IdDt / IdType) for the given context FHIR version: " + theMethod.toString()); } } return index; }
From source file:org.flite.cach3.aop.ReadThroughSingleCacheAdvice.java
@Around("getSingle()") public Object cacheSingle(final ProceedingJoinPoint pjp) throws Throwable { // If we've disabled the caching programmatically (or via properties file) just flow through. if (isCacheDisabled()) { LOG.debug("Caching is disabled."); return pjp.proceed(); }/*from w w w . j a v a 2s. com*/ final MemcachedClientIF cache = getMemcachedClient(); // This is injected caching. If anything goes wrong in the caching, LOG the crap outta it, // but do not let it surface up past the AOP injection itself. final String baseKey; final String cacheKey; final ReadThroughSingleCache annotation; final AnnotationInfo info; final Object[] args = pjp.getArgs(); try { final Method methodToCache = getMethodToCache(pjp); annotation = methodToCache.getAnnotation(ReadThroughSingleCache.class); info = getAnnotationInfo(annotation, methodToCache.getName(), getJitterDefault()); baseKey = generateBaseKeySingle(args, info, methodToCache.toString()); cacheKey = buildCacheKey(baseKey, info.getAsString(AType.NAMESPACE, null), info.getAsString(AType.KEY_PREFIX, null)); final Object result = cache.get(cacheKey); if (result != null) { return (result instanceof PertinentNegativeNull) ? null : result; } } catch (Throwable ex) { if (LOG.isDebugEnabled()) { LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error.", ex); } else { LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error: " + ex.getMessage()); } return pjp.proceed(); } final Object result = pjp.proceed(); // This is injected caching. If anything goes wrong in the caching, LOG the crap outta it, // but do not let it surface up past the AOP injection itself. try { final Object submission = (result == null) ? new PertinentNegativeNull() : result; boolean cacheable = true; if (submission instanceof CacheConditionally) { cacheable = ((CacheConditionally) submission).isCacheable(); } if (cacheable) { cache.set(cacheKey, calculateJitteredExpiration(info.getAsInteger(AType.EXPIRATION), info.getAsInteger(AType.JITTER)), submission); } // Notify the observers that a cache interaction happened. final List<ReadThroughSingleCacheListener> listeners = getPertinentListeners( ReadThroughSingleCacheListener.class, info.getAsString(AType.NAMESPACE)); if (listeners != null && !listeners.isEmpty()) { for (final ReadThroughSingleCacheListener listener : listeners) { try { listener.triggeredReadThroughSingleCache(info.getAsString(AType.NAMESPACE), info.getAsString(AType.KEY_PREFIX, null), baseKey, result, args); } catch (Exception ex) { LOG.warn("Problem when triggering a listener.", ex); } } } } catch (Throwable ex) { if (LOG.isDebugEnabled()) { LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error.", ex); } else { LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error: " + ex.getMessage()); } } return result; }
From source file:com.googlecode.jdbcproc.daofactory.DaoMethodInfoFactory.java
/** * Creates method info for bets performance * @param daoMethod method//from ww w. j a va 2s . c o m * @return method info */ public DaoMethodInvoker createDaoMethodInvoker(Method daoMethod) { AStoredProcedure procedureAnnotation = daoMethod.getAnnotation(AStoredProcedure.class); Assert.notNull(procedureAnnotation, "Method must have @AStoredProcedure annotation"); String procedureName = procedureAnnotation.name(); Assert.hasText(procedureName, "Method " + daoMethod.toString() + " has empty name() parameter in @AStoredProcedure annotation"); StoredProcedureInfo procedureInfo = storedProcedureInfoManager.getProcedureInfo(procedureName); if (LOG.isDebugEnabled()) { LOG.debug(" Found procedure info: " + procedureInfo); } Assert.notNull(procedureInfo, "There is no procedure '" + procedureName + "' in database"); String callString = createCallString(procedureInfo); boolean isReturnIterator = BlockFactoryUtils.isReturnIterator(daoMethod); return new DaoMethodInvoker(procedureInfo.getProcedureName(), callString, registerOutParametersBlockService.create(procedureInfo), parametersSetterBlockService.create(jdbcTemplate, parameterConverterService, daoMethod, procedureInfo, theMetaLoginInfoService), callableStatementExecutorBlockService.create(daoMethod, procedureInfo), outputParametersGetterBlockService.create(parameterConverterService, daoMethod, procedureInfo), resultSetConverterBlockService.create(daoMethod, procedureInfo, parameterConverterService), isReturnIterator, theSetStrategyFactory, theGetStrategyFactory); }
From source file:org.jcurl.demo.tactics.old.ActionRegistry.java
private Action findAction(final Map<Method, Action> m, final Method method) { if (m == null) throw new IllegalArgumentException(method.getDeclaringClass().getName()); final Action ret = m.get(method); if (ret == null) throw new IllegalArgumentException(method.toString()); return ret;/*from w ww . j a va2s . c o m*/ }
From source file:net.nelz.simplesm.aop.CacheBase.java
protected Method getKeyMethod(final Object keyObject) throws NoSuchMethodException { final Method storedMethod = methodStore.find(keyObject.getClass()); if (storedMethod != null) { return storedMethod; }/*from w w w . jav a 2s. co m*/ final Method[] methods = keyObject.getClass().getDeclaredMethods(); Method targetMethod = null; for (final Method method : methods) { if (method != null && method.getAnnotation(CacheKeyMethod.class) != null) { if (method.getParameterTypes().length > 0) { throw new InvalidAnnotationException( String.format("Method [%s] must have 0 arguments to be annotated with [%s]", method.toString(), CacheKeyMethod.class.getName())); } if (!String.class.equals(method.getReturnType())) { throw new InvalidAnnotationException( String.format("Method [%s] must return a String to be annotated with [%s]", method.toString(), CacheKeyMethod.class.getName())); } if (targetMethod != null) { throw new InvalidAnnotationException(String.format( "Class [%s] should have only one method annotated with [%s]. See [%s] and [%s]", keyObject.getClass().getName(), CacheKeyMethod.class.getName(), targetMethod.getName(), method.getName())); } targetMethod = method; } } if (targetMethod == null) { targetMethod = keyObject.getClass().getMethod("toString", null); } methodStore.add(keyObject.getClass(), targetMethod); return targetMethod; }
From source file:net.nelz.simplesm.aop.CacheBase.java
protected void verifyReturnTypeIsList(final Method method, final Class annotationClass) { if (verifyTypeIsList(method.getReturnType())) { return;//from w ww . j av a 2 s . c om } throw new InvalidAnnotationException(String.format( "The annotation [%s] is only valid on a method that returns a [%s]. " + "[%s] does not fulfill this requirement.", ReadThroughMultiCache.class.getName(), List.class.getName(), method.toString())); }
From source file:com.chiorichan.configuration.serialization.ConfigurationSerialization.java
protected ConfigurationSerializable deserializeViaMethod(Method method, Map<String, Object> args) { try {/*ww w. j a v a 2 s .c o m*/ ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); if (result == null) { Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization: method returned null"); } else { return result; } } catch (Throwable ex) { Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization", ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; }
From source file:org.jcurl.demo.tactics.old.ActionRegistry.java
public JMenu createJMenu(final Object controller) { final Class<?> clz = controller.getClass(); final JCMenu ca = clz.getAnnotation(JCMenu.class); if (ca == null) return null; // first get all candidates final Map<Integer, Method> sorted = new TreeMap<Integer, Method>(); for (final Method me : clz.getMethods()) { final JCAction ma = me.getAnnotation(JCAction.class); if (ma == null || ma.idx() < 0) continue; if (sorted.put(ma.idx(), me) != null) throw new IllegalStateException(ma.idx() + ": " + me.toString()); }/*from w w w. ja v a 2s.co m*/ // create the menu final JMenu ret = new JMenu(stripMnemonic(ca.value())); { final Character mne = findMnemonic(ca.value()); if (mne != null) ret.setMnemonic(mne); } // add the menu items in natural order for (final Entry<Integer, Method> elem : sorted.entrySet()) addMenuItem(controller, ret, elem.getValue()); return ret; }
From source file:bammerbom.ultimatecore.bukkit.configuration.ConfigurationSerialization.java
protected ConfigurationSerializable deserializeViaMethod(Method method, Map<String, ?> args) { try {//from www . j av a 2 s.co m ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); if (result == null) { Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization: method returned null"); } else { return result; } } catch (Throwable ex) { Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization", ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; }
From source file:com.google.code.ssm.aop.CacheBase.java
protected void verifyReturnTypeIsList(final Method method, final Class<?> annotationClass) { if (!verifyTypeIsList(method.getReturnType())) { throw new InvalidAnnotationException(String.format( "The annotation [%s] is only valid on a method that returns a [%s] or its subclass. " + "[%s] does not fulfill this requirement.", annotationClass.getName(), List.class.getName(), method.toString())); }/* w w w.ja v a2 s . c o m*/ }