Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 import java.util.Set;
 import  javax.enterprise.inject.spi.Bean;
 import  javax.enterprise.inject.spi.BeanManager;
 import  javax.inject.Inject;
import  org.apache.deltaspike.core.api.provider.BeanManagerProvider;
import  org.kie.api.runtime.KieSession;
import  org.slf4j.Logger;
import  org.slf4j.LoggerFactory;

We use this class in order to use (user) classes from Kjar deployments in serialization. Users may send inputs to the REST API that contain instances of these classes as parameters to KieSession operations.
public class JaxbContextResolver implements ContextResolver<JAXBContext> {
    private static final Logger logger = LoggerFactory.getLogger(JaxbContextResolver.class);
    public void configure() {
        if ( == null) {
            .info("JaxbContextResolver does not support CDI injection, looking up DynamicJaxbContext programmatically");
            BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
            try {
                Set<Bean<?>> beans = beanManager.getBeans( DynamicJaxbContext.class );
                if (beans != null && !beans.isEmpty()) {
                    Bean<?> bean = (Bean<?>) beans.iterator().next();
                     = (DynamicJaxbContextbeanManager.getReference(beanDynamicJaxbContext.class,
            } catch (Exception e) {
                .warn("Unable to retrieve DynamicJaxbContext programmatically from cdi container due to {}"e.getMessage());
    public JAXBContext getContext(Class<?> type) {
        return ;
New to GrepCode? Check out our FAQ X