Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.kie.remote.services.jms.request;
 
 import java.util.List;
 
 import  javax.enterprise.context.RequestScoped;
 import  javax.enterprise.inject.Produces;
 
 import  org.jbpm.kie.services.impl.audit.ServicesAwareAuditEventBuilder;
 import  org.jbpm.services.cdi.RequestScopedBackupIdentityProvider;
import  org.kie.internal.identity.IdentityProvider;
import  org.slf4j.Logger;
import  org.slf4j.LoggerFactory;

See the ServicesAwareAuditEventBuilder bean for more context. This bean provides a RequestScopedBackupIdentityProvider instance for JMS requests, which have a Request scope but for which the "normally" provided ("normally" as in with REST requests) IdentityProvider is not available. This due to vagaries of the code, as always.
@RequestScoped
    private static final Logger logger = LoggerFactory.getLogger(RequestMessageBean.class);
    
    private RequestScopedBackupIdentityProvider identityProvider = null;
    
    public RequestScopedBackupIdentityProvider createBackupIdentityProvider(String commandUserList<Stringroles) {
        .debug( "Creating identity provider for user: {}"commandUser);
        ifcommandUser == null ) { 
            commandUser = RequestScopedBackupIdentityProvider.UNKNOWN;
        }
        final String nameValue = commandUser;
        
        this. =  new RequestScopedBackupIdentityProvider() {
            
            private String name = nameValue;
            
            @Override
            public String getName() {
                return ;
            }
        };
        
        return this.;
    }
    
    @Produces
    @RequestScoped
    public RequestScopedBackupIdentityProvider getJmsRequestScopeIdentityProvider() {
        if (this. != null) {
            .debug( "Producing backup identity bean for user: {}" , this..getName() );
            return this.;
        } else {
            .debug( "Unknown user during JMS request" );
            // in case there is none set return dummy one as @RequestScoped producers cannot return null
            return new RequestScopedBackupIdentityProvider() {
                
                @Override
                public String getName() {
                    return RequestScopedBackupIdentityProvider.UNKNOWN;
                }
            };
        }
    }
New to GrepCode? Check out our FAQ X