Search in sources :

Example 1 with CurrentUser

use of org.apache.deltaspike.data.api.audit.CurrentUser in project deltaspike by apache.

the class PrincipalProvider method resolvePrincipal.

private Object resolvePrincipal(Object entity, Property<Object> property) {
    CurrentUser principal = AnnotationInstanceProvider.of(CurrentUser.class);
    Class<?> propertyClass = property.getJavaClass();
    Set<Bean<?>> beans = manager.getBeans(propertyClass, principal);
    if (!beans.isEmpty() && beans.size() == 1) {
        Bean<?> bean = beans.iterator().next();
        Object result = manager.getReference(bean, propertyClass, manager.createCreationalContext(bean));
        return result;
    }
    throw new IllegalArgumentException("Principal " + (beans.isEmpty() ? "not found" : "not unique") + " for " + propertyName(entity, property));
}
Also used : CurrentUser(org.apache.deltaspike.data.api.audit.CurrentUser) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Bean (javax.enterprise.inject.spi.Bean)1 CurrentUser (org.apache.deltaspike.data.api.audit.CurrentUser)1