Package org.jboss.as.controller.client.helpers.standalone

Examples of org.jboss.as.controller.client.helpers.standalone.DeploymentPlan


            } else {
                final InetAddress host = hostAddress();
                getLog().info(String.format("Executing goal %s on server %s (%s) port %s.", goal(), host.getHostName(), host.getHostAddress(), port()));
                final ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client());
                final DeploymentPlanBuilder builder = manager.newDeploymentPlan();
                final DeploymentPlan plan = createPlan(builder);
                if (plan.getDeploymentActions().size() > 0) {
                    final ServerDeploymentPlanResult planResult = manager.execute(plan).get();
                    // Check the results
                    for (DeploymentAction action : plan.getDeploymentActions()) {
                        final ServerDeploymentActionResult actionResult = planResult.getDeploymentActionResult(action.getId());
                        final ServerUpdateActionResult.Result result = actionResult.getResult();
                        switch (result) {
                            case FAILED:
                                throw new MojoExecutionException("Deployment failed.", actionResult.getDeploymentException());
View Full Code Here


    }

    @Override
    public void deploy(final URL archiveURL) throws Exception {
        final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan().add(archiveURL).andDeploy();
        final DeploymentPlan plan = builder.build();
        final DeploymentAction deployAction = builder.getLastAction();
        final String uniqueId = deployAction.getDeploymentUnitUniqueName();
        executeDeploymentPlan(plan, deployAction);
        url2Id.put(archiveURL, uniqueId);
    }
View Full Code Here

    @Override
    public void undeploy(final URL archiveURL) throws Exception {
        final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
        final String uniqueName = url2Id.get(archiveURL);
        if (uniqueName != null) {
            final DeploymentPlan plan = builder.undeploy(uniqueName).remove(uniqueName).build();
            final DeploymentAction deployAction = builder.getLastAction();
            try {
                executeDeploymentPlan(plan, deployAction);
            } finally {
                url2Id.remove(archiveURL);
View Full Code Here

                    OSGiDeploymentLatchService.addService(serviceTarget, contextName);

                    // Build and execute the deployment plan
                    InputStream inputStream = dep.getRoot().openStream();
                    builder = builder.add(contextName, inputStream).andDeploy();
                    DeploymentPlan plan = builder.build();
                    DeploymentAction deployAction = builder.getLastAction();
                    executeDeploymentPlan(plan, deployAction);

                    // Pickup the installed bundle
                    final CountDownLatch latch = new CountDownLatch(1);
                    ServiceName serviceName = OSGiDeploymentLatchService.getServiceName(contextName);
                    ServiceController<?> controller = serviceContainer.getService(serviceName);
                    controller.addListener(new AbstractServiceListener<Object>() {

                        @Override
                        public void listenerAdded(ServiceController<? extends Object> controller) {
                            if (controller.getState() == State.UP)
                                serviceStarted(controller);
                            else if (controller.getState() == State.START_FAILED)
                                serviceFailed(controller, controller.getStartException());
                        }

                        @Override
                        public void serviceStarted(ServiceController<? extends Object> controller) {
                            log.tracef("Service started: %s", controller.getName());
                            controller.removeListener(this);
                            latch.countDown();
                        }

                        @Override
                        public void serviceFailed(ServiceController<? extends Object> controller, StartException reason) {
                            log.tracef(reason, "Service failed: %s", controller.getName());
                            controller.removeListener(this);
                            latch.countDown();
                        }
                    });
                    try {
                        latch.await(10, TimeUnit.SECONDS);
                        if (controller.getState() == State.START_FAILED)
                            throw controller.getStartException();
                        if (controller.getState() != State.UP)
                            throw new BundleException("OSGiDeploymentService not available: " + serviceName);

                        Deployment bundleDep = (Deployment) controller.getValue();
                        bundle = bundleDep.getAttachment(Bundle.class);
                    } finally {
                        controller.setMode(Mode.REMOVE);
                    }
                } catch (RuntimeException rte) {
                    throw rte;
                } catch (BundleException ex) {
                    throw ex;
                } catch (Exception ex) {
                    throw new BundleException("Cannot deploy bundle: " + dep, ex);
                }
                finally {
                    DeploymentHolderService.removeService(serviceContainer, contextName);
                }

                if (bundle == null)
                    throw new IllegalStateException("Cannot find bundle: " + contextName);

                return bundle;
            }

            @Override
            protected void uninstallBundle(Deployment dep, Bundle bundle) throws BundleException {
                try {
                    // If there is no {@link OSGiDeploymentService} for the given bundle
                    // we unregister the deployment explicitly from the {@link BundleManager}
                    String contextName = DeploymentHolderService.getContextName(dep);
                    ServiceName serviceName = OSGiDeploymentService.getServiceName(contextName);
                    ServiceController<?> controller = serviceContainer.getService(serviceName);
                    if (controller == null) {
                        getBundleManager().uninstallBundle(dep);
                        return;
                    }

                    // Sanity check that the {@link DeploymentService} is there
                    final CountDownLatch latch = new CountDownLatch(1);
                    controller.addListener(new AbstractServiceListener<Object>() {

                        @Override
                        public void listenerAdded(ServiceController<? extends Object> controller) {
                            if (controller.getState() == State.REMOVED)
                                serviceRemoved(controller);
                            else if (controller.getState() == State.START_FAILED)
                                serviceFailed(controller, controller.getStartException());
                        }

                        @Override
                        public void serviceRemoved(ServiceController<? extends Object> controller) {
                            log.tracef("Service removed: %s", controller.getName());
                            controller.removeListener(this);
                            latch.countDown();
                        }

                        @Override
                        public void serviceFailed(ServiceController<? extends Object> controller, StartException reason) {
                            log.tracef(reason, "Service failed: %s", controller.getName());
                            controller.removeListener(this);
                            latch.countDown();
                        }
                    });

                    // Undeploy through the deployment manager
                    DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
                    builder = builder.undeploy(contextName).remove(contextName);
                    DeploymentPlan plan = builder.build();
                    DeploymentAction removeAction = builder.getLastAction();
                    executeDeploymentPlan(plan, removeAction);

                    latch.await(10, TimeUnit.SECONDS);
                    if (controller.getState() == State.START_FAILED)
View Full Code Here

    @Override
    public String deploy(URL url) throws Exception {
        DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
        builder = builder.add(url).andDeploy();
        DeploymentPlan plan = builder.build();
        DeploymentAction deployAction = builder.getLastAction();
        return executeDeploymentPlan(plan, deployAction);
    }
View Full Code Here

    @Override
    public String deploy(String name, InputStream input) throws Exception {
        DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
        builder = builder.add(name, input).andDeploy();
        DeploymentPlan plan = builder.build();
        DeploymentAction deployAction = builder.getLastAction();
        return executeDeploymentPlan(plan, deployAction);
    }
View Full Code Here

    @Override
    public void undeploy(String uniqueName) {
        try {
            DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
            DeploymentPlan plan = builder.undeploy(uniqueName).remove(uniqueName).build();
            Future<ServerDeploymentPlanResult> future = deploymentManager.execute(plan);
            future.get();
        } catch (Throwable ex) {
            ROOT_LOGGER.cannotUndeploy(ex, uniqueName);
        }
View Full Code Here

    }

    @Override
    public void deploy(URL archiveURL) throws Exception {
        final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan().add(archiveURL).andDeploy();
        final DeploymentPlan plan = builder.build();
        final DeploymentAction deployAction = builder.getLastAction();
        final String uniqueId = deployAction.getDeploymentUnitUniqueName();
        executeDeploymentPlan(plan, deployAction);
        url2Id.put(archiveURL, uniqueId);
    }
View Full Code Here

    @Override
    public void undeploy(final URL archiveURL) throws Exception {
        final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
        final String uniqueName = url2Id.get(archiveURL);
        if (uniqueName != null) {
            final DeploymentPlan plan = builder.undeploy(uniqueName).remove(uniqueName).build();
            final DeploymentAction deployAction = builder.getLastAction();
            try {
                executeDeploymentPlan(plan, deployAction);
            } finally {
                url2Id.remove(archiveURL);
View Full Code Here

    @Override
    public void deploy(TargetModuleID targetModuleID) throws Exception {
        log.infof("Begin deploy: %s", targetModuleID);
        DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
        builder = builder.add(targetModuleID.getModuleID(), new URL(targetModuleID.getModuleID())).andDeploy();
        DeploymentPlan plan = builder.build();
        DeploymentAction deployAction = builder.getLastAction();
        String runtimeName = executeDeploymentPlan(plan, deployAction);
        runtimeNames.put(targetModuleID, runtimeName);
        log.infof("End deploy: %s", targetModuleID);
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.controller.client.helpers.standalone.DeploymentPlan

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.