Package java.lang.reflect

Examples of java.lang.reflect.Type


        DefaultValue defaultValueAnnotation = ip.getAnnotated().getAnnotation(DefaultValue.class);
        return defaultValueAnnotation == null ? null : defaultValueAnnotation.value();
    }

    private Class<?> resolveExpectedType(final InjectionPoint ip) {
        Type t = ip.getType();
        if (t instanceof ParameterizedType && ((ParameterizedType) t).getActualTypeArguments().length == 1) {
            return (Class<?>) ((ParameterizedType) t).getActualTypeArguments()[0];
        } else if (t instanceof Class) {
            return (Class<?>) t;
        } else {
View Full Code Here


        DefaultValue defaultValueAnnotation = ip.getAnnotated().getAnnotation(DefaultValue.class);
        return defaultValueAnnotation == null ? null : defaultValueAnnotation.value();
    }

    private Class<?> resolveExpectedType(final InjectionPoint ip) {
        Type t = ip.getType();
        if (t instanceof ParameterizedType && ((ParameterizedType) t).getActualTypeArguments().length == 1) {
            return (Class<?>) ((ParameterizedType) t).getActualTypeArguments()[0];
        } else if (t instanceof Class) {
            return (Class<?>) t;
        } else {
View Full Code Here

        DefaultValue defaultValueAnnotation = ip.getAnnotated().getAnnotation(DefaultValue.class);
        return defaultValueAnnotation == null ? null : defaultValueAnnotation.value();
    }

    private Class<?> resolveExpectedType(final InjectionPoint ip) {
        Type t = ip.getType();
        if (t instanceof ParameterizedType && ((ParameterizedType) t).getActualTypeArguments().length == 1) {
            return (Class<?>) ((ParameterizedType) t).getActualTypeArguments()[0];
        } else if (t instanceof Class) {
            return (Class<?>) t;
        } else {
View Full Code Here

   */
  public Object invoke(MethodInvocation invocation)
    throws Throwable {

    // get return type
    Type retType = (invocation.getMethod().getGenericReturnType() != null)
      ? invocation.getMethod().getGenericReturnType()
      : invocation.getMethod().getReturnType();

    // invoke it
    return jsonRpcHttpClient.invoke(
View Full Code Here

        if (isOutBound && callback.getWebResult() != null) {
            Method method = callback.getMethod();
            if (JAXBUtils.isAsync(method)) {
                Method syncMethod = callback.getSyncMethod();
                Type gtype = method.getGenericReturnType();
               
                if (Future.class.equals(method.getReturnType())) {
                    Type types[] = method.getGenericParameterTypes();
                    if (types.length > 0 && types[types.length - 1] instanceof ParameterizedType) {
                        gtype = types[types.length - 1];
                    }
                }
                if (gtype instanceof ParameterizedType
View Full Code Here

        return iMethod;
    }

    public static Class<?> getProviderParameterType(EndpointImpl endpoint) {
        //The Provider Implementor inherits out of Provier<T>
        Type intfTypes[] = endpoint.getImplementorClass().getGenericInterfaces();
        for (Type t : intfTypes) {
            Class<?> clazz = JAXBEncoderDecoder.getClassFromType(t);
            if (Provider.class == clazz) {
                Type paramTypes[] = ((ParameterizedType)t).getActualTypeArguments();
                return JAXBEncoderDecoder.getClassFromType(paramTypes[0]);
            }
        }
       
        return null;
View Full Code Here

                        }
                    }
                    if (error) {
                        break;
                    }
                    Type targetType = getActualBeanType(ip.getType());
                    if (!(targetType instanceof Class)) {
                        event.addDefinitionError(new IllegalArgumentException(messages.rawTypeRequired(
                                paramAnnotationType.getSimpleName(), ip)));
                        break;
                    }
View Full Code Here

     * It is implemented by inspecting all bindings of the injector.
     */
    @Override
    public void init(ServletConfig config) throws ServletException {
        for (Key<?> key : injector.getBindings().keySet()) {
            Type type = key.getTypeLiteral().getType();
            if (type instanceof Class<?>) {
                Class<?> klass = (Class<?>) type;
                if (Renderable.class.isAssignableFrom(klass)) {
                    Renderable p = (Renderable)injector.getInstance(klass);
                    Named annotation = klass.getAnnotation(Named.class);
View Full Code Here

      throw new IllegalArgumentException("Actual types of the generic type are erased: "+targetType);
  }
    }

    private synchronized Template lookupGenericImpl(final ParameterizedType targetType) {
  Type rawType = targetType.getRawType();
  GenericTemplate tmpl = genericCache.get(rawType);
  if (tmpl == null) {
      return null;
  }
View Full Code Here

@Test
public class GenericTest {

  public void testInspect() throws Exception, NoSuchMethodException {
    Class<?> sc = Skill.class;
    Type gs = sc.getGenericSuperclass();
    System.out.println(gs);
    Method a = Skill.class.getMethod("getId");
    System.out.println(a.getReturnType());

    List<Skill> skills = CollectUtils.newArrayList();
View Full Code Here

TOP

Related Classes of java.lang.reflect.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.