Java Code Examples for org.apache.cxf.jaxrs.utils.ResourceUtils#findResourceConstructor()

The following examples show how to use org.apache.cxf.jaxrs.utils.ResourceUtils#findResourceConstructor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlueprintResourceFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: PerRequestResourceProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: SpringResourceFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
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");
    }

}
 
Example 4
Source File: CdiResourceProvider.java    From tomee with Apache License 2.0 5 votes vote down vote up
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");
    }
}