List of usage examples for java.lang Class getMethods
@CallerSensitive public Method[] getMethods() throws SecurityException
From source file:com.swtxml.util.reflector.MethodQuery.java
private Collection<Method> getMethods(Class<?> type) { if (visibility == Visibility.PUBLIC && subclasses == Subclasses.INCLUDE) { return Arrays.asList(type.getMethods()); } else if (visibility == Visibility.PRIVATE && subclasses == Subclasses.INCLUDE) { return getAllMethods(type); }// w ww . ja v a 2 s. co m throw new UnsupportedOperationException( "Querying with " + visibility + " and " + subclasses + " not supported at the moment."); }
From source file:ar.com.jrules.core.service.LoadJRules.java
private boolean haveAnyMethodWithJRuleImplementation(Class<?> clazz) { for (Method method : clazz.getMethods()) { if (method.getAnnotation(ExecuteRule.class) != null) { return true; }// w w w . j a va 2 s . c o m } return false; }
From source file:mp.platform.cyclone.webservices.AuthInterceptor.java
/** * Resolve the possible operations for the current request *//* w w w .j a v a2 s. c om*/ private ServiceOperation[] resolveOperations(final SoapMessage message) { final MessageInfo messageInfo = message.get(MessageInfo.class); final OperationInfo operation = messageInfo.getOperation(); final QName operationQName = operation.getName(); // Try to find the operations in the cache ServiceOperation[] operations = cachedOperations.get(operationQName); if (operations == null) { // Cache miss... find the interface method final String operationName = operationQName.getLocalPart(); final String serviceName = operation.getInterface().getService().getName().getLocalPart(); final Class<?> serviceInterface = CyclosWebServicesClientFactory.serviceInterfaceForName(serviceName); for (final Method m : serviceInterface.getMethods()) { if (m.getName().equals(operationName)) { final Permission permission = m.getAnnotation(Permission.class); operations = permission == null ? new ServiceOperation[0] : permission.value(); break; } } // Store the operations on the cache for further access cachedOperations.put(operationQName, operations); } return operations; }
From source file:ar.com.allium.rules.core.service.LoadAlliumRules.java
private boolean haveAnyMethodWithAlliumRuleImplementation(Class<?> clazz) { for (Method method : clazz.getMethods()) { if (method.getAnnotation(ExecuteRule.class) != null) { return true; }/*from w w w . j a v a2 s.co m*/ } return false; }
From source file:org.atteo.moonshine.websocket.jsonmessages.HandlerDispatcher.java
public <T> SenderProvider<T> addSender(Class<T> klass) { checkState(klass.isInterface(), "Provided Class object must represent an interface"); for (Method method : klass.getMethods()) { registerSenderMethod(method);/* ww w. ja v a 2s . c o m*/ } @SuppressWarnings("unchecked") final Class<T> proxyClass = (Class<T>) Proxy.getProxyClass(Thread.currentThread().getContextClassLoader(), klass); class SenderInvocationHandler implements InvocationHandler { private final Session session; public SenderInvocationHandler(Session session) { this.session = session; } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String request = encoderObjectMapper.writeValueAsString(args[0]); session.getBasicRemote().sendText(request); return null; } } return new SenderProvider<T>() { @Override public T get(Session session) { try { return proxyClass.getConstructor(new Class<?>[] { InvocationHandler.class }) .newInstance(new SenderInvocationHandler(session)); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException(ex); } } }; }
From source file:com.github.lightdocs.ModelBuilder.java
/** * @param cls/* www. j a va 2 s .co m*/ * required * @return true if there is any Path or GET/POST/etc annotation. */ private boolean hasPathAnnotation(Class<?> cls) { if (cls.isAnnotationPresent(Path.class)) { return true; } else { for (Method m : cls.getMethods()) { if (m.isAnnotationPresent(Path.class)) { return true; } } return false; } }
From source file:info.magnolia.content2bean.impl.TypeMappingImpl.java
/** * Find a method.//from w ww . j a va2 s . c o m * * @param numberOfParameters */ protected Method getExactMethod(Class<?> type, String name, int numberOfParameters) { Method[] methods = type.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getName().equals(name)) { // TODO - CAUTION: in case there's several methods with the same name and the same numberOfParameters // this method might pick the "wrong" one. We should think about adding a check and throw an exceptions // if there's more than one match! if (method.getParameterTypes().length == numberOfParameters) { return method; } } } return null; }
From source file:info.magnolia.jcr.node2bean.impl.TypeMappingImpl.java
/** * Find a method.//from w w w.j a v a2s . c o m * * @param numberOfParameters * @deprecated since 5.0 - use setters */ protected Method getExactMethod(Class<?> type, String name, int numberOfParameters) { Method[] methods = type.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getName().equals(name)) { // TODO - CAUTION: in case there's several methods with the same // name and the same numberOfParameters // this method might pick the "wrong" one. We should think about // adding a check and throw an exceptions // if there's more than one match! if (method.getParameterTypes().length == numberOfParameters) { return method; } } } return null; }
From source file:com.comphenix.pulse.Button.java
private Method findObsfucatedMethod(Class<BlockButton> clazz) { Class<?>[] expected = new Class<?>[] { World.class, int.class, int.class, int.class, Random.class }; // Find the correct method to call for (Method method : clazz.getMethods()) { if (ArrayUtils.isEquals(method.getParameterTypes(), expected)) { return method; }//w w w. java 2s. c o m } // Damn throw new RuntimeException("Unable to find updateTick-method in BlockButton."); }
From source file:de.ufinke.cubaja.sql.ObjectFactoryGenerator.java
private void createSetterMap(Class<?> clazz) { setterMap = new HashMap<String, SetterEntry>(); for (Method method : clazz.getMethods()) { if (method.getReturnType() == Void.TYPE) { String methodName = method.getName(); SearchEntry searchEntry = searchMap.get(methodName); if (searchEntry != null && method.getReturnType() == Void.TYPE) { int position = searchEntry.position; Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1) { TypeCombination combination = new TypeCombination(searchEntry.sqlType, parameterTypes[0]); ObjectFactoryType type = ObjectFactoryType.getType(combination); if (type != null) { SetterEntry entry = setterMap.get(methodName); if (entry == null || type.getPriority() < entry.type.getPriority()) { setterMap.put(methodName, new SetterEntry(methodName, type, position)); searchEntry.setterFound = true; }//from w w w . j a va 2s. c o m } } } } } }