All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.as.ee.component.NamespaceContextInterceptor Maven / Gradle / Ivy

There is a newer version: 35.0.0.Beta1
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.ee.component;

import org.jboss.as.naming.WritableServiceBasedNamingStore;
import org.jboss.as.naming.context.NamespaceContextSelector;
import org.jboss.invocation.Interceptor;
import org.jboss.invocation.InterceptorContext;
import org.jboss.msc.service.ServiceName;

/**
 * An interceptor which imposes the given namespace context selector.
 *
 * @author David M. Lloyd
 */
public final class NamespaceContextInterceptor implements Interceptor {
    private final NamespaceContextSelector selector;
    private final ServiceName deploymentUnitServiceName;

    public NamespaceContextInterceptor(final NamespaceContextSelector selector, final ServiceName deploymentUnitServiceName) {
        this.selector = selector;
        this.deploymentUnitServiceName = deploymentUnitServiceName;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        NamespaceContextSelector.pushCurrentSelector(selector);
        try {
            WritableServiceBasedNamingStore.pushOwner(deploymentUnitServiceName);
            try {
                return context.proceed();
            } finally {
                WritableServiceBasedNamingStore.popOwner();
            }
        } finally {
            NamespaceContextSelector.popCurrentSelector();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy