org.apache.cxf.jaxrs.utils.ResourceUtils.findResourceConstructor()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.apache.cxf.jaxrs.utils.ResourceUtils.findResourceConstructor方法的一些代码示例,展示了ResourceUtils.findResourceConstructor的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceUtils.findResourceConstructor方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.utils.ResourceUtils
类名称:ResourceUtils
方法名:findResourceConstructor

ResourceUtils.findResourceConstructor介绍

暂无

代码示例

代码示例来源:origin: org.apache.openejb/openejb-cxf-rs

private void validateConstructorExists() {
  // only validate it here otherwise we'll fail for CDI injections
  constructor = ResourceUtils.findResourceConstructor(clazz, true);
  if (constructor == null) {
    throw new RuntimeException("Resource class " + clazz + " has no valid constructor");
  }
}

代码示例来源:origin: apache/cxf

public static Object createProviderInstance(Class<?> cls) {
  try {
    Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
    if (c != null && c.getParameterTypes().length == 0) {
      return c.newInstance();
    }
    return c;
  } catch (Throwable ex) {
    throw new RuntimeException("Provider " + cls.getName() + " can not be created", ex);
  }
}

代码示例来源:origin: apache/cxf

public static Feature createFeatureInstance(Class<? extends Feature> cls) {
  try {
    Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
    if (c == null) {
      throw new RuntimeException("No valid constructor found for " + cls.getName());
    }
    return (Feature) c.newInstance();
  } catch (Throwable ex) {
    throw new RuntimeException("Feature " + cls.getName() + " can not be created", ex);
  }
}

代码示例来源:origin: apache/cxf

public PerRequestResourceProvider(Class<?> clazz) {
  c = ResourceUtils.findResourceConstructor(clazz, true);
  if (c == null) {
    throw new RuntimeException("Resource class " + clazz
                  + " has no valid constructor");
  }
  params = c.getParameterTypes();
  anns = c.getParameterAnnotations();
  genericTypes = c.getGenericParameterTypes();
  postConstructMethod = ResourceUtils.findPostConstructMethod(clazz);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz);
}

代码示例来源:origin: org.apache.camel/camel-cxf

@Override
public Object invoke(Object proxy, Method method, Object[] parameters) throws Throwable {
  Object result = null;
  Class<?> returnType = method.getReturnType();
  if (!returnType.isAssignableFrom(Void.class)) {
    // create a instance to return
    if (returnType.isInterface()) {
      // create a new proxy for it
      result = Proxy.newProxyInstance(returnType.getClassLoader(), new Class[] {returnType},
                      new SubResourceClassInvocationHandler());
    } else {
      // get the constructor and create a new instance
      Constructor<?> c = ResourceUtils.findResourceConstructor(returnType, true);
      result = c.newInstance(new Object[] {});
    }
  }
  return result;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public PerRequestResourceProvider(Class<?> clazz) {
  c = ResourceUtils.findResourceConstructor(clazz, true);
  if (c == null) {
    throw new RuntimeException("Resource class " + clazz
                  + " has no valid constructor");
  }
  postConstructMethod = ResourceUtils.findPostConstructMethod(clazz);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

protected Object createSingletonInstance(Class<?> cls, Map<String, List<String>> props, ServletConfig sc) 
  throws ServletException {
  Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
  if (c == null) {
    throw new ServletException("No valid constructor found for " + cls.getName());

代码示例来源:origin: apache/cxf

protected Object createSingletonInstance(Class<?> cls, Map<String, List<String>> props, ServletConfig sc)
  throws ServletException {
  Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
  if (c == null) {
    throw new ServletException("No valid constructor found for " + cls.getName());

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

private void init() {
  Class<?> type = ClassHelper.getRealClassFromClass(ac.getType(beanId));
  if (Proxy.isProxyClass(type)) {
    type = ClassHelper.getRealClass(ac.getBean(beanId));
  }
  c = ResourceUtils.findResourceConstructor(type, !isSingleton());
  if (c == null) {
    throw new RuntimeException("Resource class " + type
                  + " has no valid constructor");
  }
  postConstructMethod = ResourceUtils.findPostConstructMethod(type, postConstructMethodName);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(type, preDestroyMethodName);
  isSingleton = ac.isSingleton(beanId);
  if (!isSingleton) {
    isPrototype = ac.isPrototype(beanId);
  }
}

代码示例来源:origin: apache/cxf

private void init() {
  type = ClassHelper.getRealClassFromClass(ac.getType(beanId));
  if (Proxy.isProxyClass(type)) {
    type = ClassHelper.getRealClass(ac.getBean(beanId));
  }
  isSingleton = ac.isSingleton(beanId);
  postConstructMethod = ResourceUtils.findPostConstructMethod(type, postConstructMethodName);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(type, preDestroyMethodName);
  if (isSingleton()) {
    try {
      singletonInstance = ac.getBean(beanId);
    } catch (BeansException ex) {
      // ignore for now, try resolving resource constructor later
    }
    if (singletonInstance != null) {
      return;
    }
  } else {
    isPrototype = ac.isPrototype(beanId);
  }
  c = ResourceUtils.findResourceConstructor(type, !isSingleton());
  if (c == null) {
    throw new RuntimeException("Resource class " + type
                  + " has no valid constructor");
  }
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

private void init() {
  Class<?> type = ClassHelper.getRealClassFromClass(blueprintContainer.getComponentInstance(beanId)
                           .getClass());
  if (Proxy.isProxyClass(type)) {
    type = ClassHelper.getRealClass(blueprintContainer.getComponentInstance(beanId));
  }
  c = ResourceUtils.findResourceConstructor(type, !isSingleton());
  if (c == null) {
    throw new RuntimeException("Resource class " + type + " has no valid constructor");
  }
  postConstructMethod = ResourceUtils.findPostConstructMethod(type);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(type);
  Object component = blueprintContainer.getComponentMetadata(beanId);
  if (component instanceof BeanMetadata) {
    BeanMetadata local = (BeanMetadata) component;
    isSingleton = BeanMetadata.SCOPE_SINGLETON.equals(local.getScope())  
      || (local.getScope() == null && local.getId() != null);
  }
}

代码示例来源:origin: apache/cxf

private void init() {
  Class<?> type = ClassHelper.getRealClassFromClass(blueprintContainer.getComponentInstance(beanId)
                           .getClass());
  if (Proxy.isProxyClass(type)) {
    type = ClassHelper.getRealClass(blueprintContainer.getComponentInstance(beanId));
  }
  c = ResourceUtils.findResourceConstructor(type, !isSingleton());
  if (c == null) {
    throw new RuntimeException("Resource class " + type + " has no valid constructor");
  }
  postConstructMethod = ResourceUtils.findPostConstructMethod(type);
  preDestroyMethod = ResourceUtils.findPreDestroyMethod(type);
  Object component = blueprintContainer.getComponentMetadata(beanId);
  if (component instanceof BeanMetadata) {
    BeanMetadata local = (BeanMetadata) component;
    isSingleton = BeanMetadata.SCOPE_SINGLETON.equals(local.getScope())
      || (local.getScope() == null && local.getId() != null);
  }
}

相关文章

微信公众号

最新文章

更多