Package org.jboss.as.web.deployment.WebDeploymentService

Examples of org.jboss.as.web.deployment.WebDeploymentService.ContextActivator


            }

            // OSGi web applications are activated in {@link WebContextActivationProcessor} according to bundle lifecycle changes
            if (deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST)) {
                webappBuilder.setInitialMode(Mode.NEVER);
                ContextActivator activator = new ContextActivator(webappBuilder.install());
                deploymentUnit.putAttachment(ContextActivator.ATTACHMENT_KEY, activator);
            } else {
                webappBuilder.setInitialMode(Mode.ACTIVE);
                webappBuilder.install();
            }
View Full Code Here


public class WebContextActivationProcessor implements DeploymentUnitProcessor {

    @Override
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
        ContextActivator activator = depUnit.getAttachment(ContextActivator.ATTACHMENT_KEY);
        XBundle bundle = depUnit.getAttachment(OSGiConstants.BUNDLE_KEY);
        if (activator != null && bundle != null) {
            // Add the {@link ContextActivator} to the {@link XBundleRevision}
            XBundleRevision brev = bundle.getBundleRevision();
            brev.addAttachment(ContextActivator.class, activator);

            // Start the context when the bundle will get started automatically
            Deployment deployment = bundle.adapt(Deployment.class);
            if (deployment.isAutoStart()) {
                activator.startAsync();
            }
        }
    }
View Full Code Here

        }
    }

    @Override
    public void undeploy(final DeploymentUnit depUnit) {
        ContextActivator activator = depUnit.getAttachment(ContextActivator.ATTACHMENT_KEY);
        XBundle bundle = depUnit.getAttachment(OSGiConstants.BUNDLE_KEY);
        if (activator != null && bundle != null) {
            bundle.adapt(Deployment.class).removeAttachment(ContextActivator.class);
        }
    }
View Full Code Here

    @Override
    public void invoke(int state, InvocationContext context) {
        XBundle bundle = (XBundle) context.getBundle();
        XBundleRevision brev = bundle.getBundleRevision();
        ContextActivator activator = brev.getAttachment(ContextActivator.class);
        if (activator != null) {
            switch (state) {
                case Bundle.ACTIVE:
                    try {
                        injectBundleContext(activator.getContext(), bundle.getBundleContext());
                        if (!activator.start(4, TimeUnit.SECONDS)) {
                            throw new LifecycleInterceptorException(MESSAGES.startContextFailed());
                        }
                    } catch (TimeoutException ex) {
                        throw new LifecycleInterceptorException(ex.getMessage(), ex);
                    }
                    break;
                case Bundle.RESOLVED:
                    activator.stop(4, TimeUnit.SECONDS);
                    uninjectBundleContext(activator.getContext());
                    break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.web.deployment.WebDeploymentService.ContextActivator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.