Package org.jboss.osgi.deployment.deployer

Examples of org.jboss.osgi.deployment.deployer.Deployment


    @Override
    public void processDeployment(DeploymentUnitContext context) throws DeploymentUnitProcessingException {

        // Check if we already have an OSGi deployment
        Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
        if (deployment != null)
            return;

        // Get the OSGi XService properties
        String resName = "META-INF/jbosgi-xservice.properties";
        VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
        VirtualFile xserviceFile = virtualFile.getChild(resName);
        if (xserviceFile.exists()) {
            try {
                OSGiMetaData metadata = OSGiMetaDataBuilder.load(xserviceFile.openStream());
                String location = virtualFile.getPathName();
                String symbolicName = metadata.getBundleSymbolicName();
                Version version = metadata.getBundleVersion();
                deployment = DeploymentFactory.createDeployment(AbstractVFS.adapt(virtualFile), location, symbolicName, version);
                deployment.addAttachment(OSGiMetaData.class, metadata);
                OSGiMetaDataAttachment.attachOSGiMetaData(context, metadata);
                DeploymentAttachment.attachDeployment(context, deployment);
            } catch (IOException ex) {
                throw new DeploymentUnitProcessingException("Cannot parse: " + xserviceFile);
            }
View Full Code Here


            if (arqConfig.getTestClasses().contains(className) == false)
                throw new ClassNotFoundException(className);

            DeploymentUnit depunit = arqConfig.getDeploymentUnitContext();
            Module module = depunit.getAttachment(Attachments.MODULE);
            Deployment osgidep = OSGiDeploymentAttachment.getDeployment(depunit);
            if (module != null && osgidep != null)
                throw new IllegalStateException("Found MODULE attachment for Bundle deployment: " + depunit);

            Class<?> testClass = null;
            if (module != null) {
                ServiceContainerAssociation.setServiceContainer(serviceContainer);
                ServerDeploymentManagerAssociation.setServerDeploymentManager(deploymentManager);
                testClass = module.getClassLoader().loadClass(className);
            }

            else if (osgidep != null) {
                Bundle bundle = osgidep.getAttachment(Bundle.class);
                BundleAssociation.setBundle(bundle);
                ServiceContainerAssociation.setServiceContainer(serviceContainer);
                ServerDeploymentManagerAssociation.setServerDeploymentManager(deploymentManager);
                Framework framework = awaitActiveOSGiFramework();
                BundleContextAssociation.setBundleContext(framework.getBundleContext());
View Full Code Here

        DeploymentTrackerService tracker = new DeploymentTrackerService(arqConfig);
        ServiceBuilder<Object> serviceBuilder = serviceTarget.addService(SERVICE_NAME_BASE.append(phaseContext.getDeploymentUnit().getName()), tracker);
        serviceBuilder.addDependency(ArquillianService.SERVICE_NAME, ArquillianService.class, tracker.injectedArquillianService);

        // If this is an OSGi deployment, add a dependency on the associated service
        Deployment osgiDeployment = OSGiDeploymentAttachment.getDeployment(phaseContext.getDeploymentUnit());
        if (osgiDeployment != null) {
            ServiceName serviceName = BundleInstallService.getServiceName(phaseContext.getDeploymentUnit().getName());
            serviceBuilder.addDependency(serviceName);
            osgiDeployment.setAutoStart(false);
        }
        serviceBuilder.install();
    }
View Full Code Here

        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
        final String contextName = depUnit.getName();

        // Check if we already have a BundleInfo
        BundleInfo info = depUnit.getAttachment(OSGiConstants.BUNDLE_INFO_KEY);
        Deployment deployment = BundleInstallIntegration.getDeployment(contextName);
        if (info != null || deployment != null)
            return;

        // Get the manifest from the deployment's virtual file
        Manifest manifest = depUnit.getAttachment(Attachments.OSGI_MANIFEST);
View Full Code Here

        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
        final String contextName = depUnit.getName();

        // Check if {@link BundleInstallIntegration} provided the {@link Deployment}
        Deployment deployment = BundleInstallIntegration.removeDeployment(contextName);
        if (deployment != null) {
            deployment.setAutoStart(false);
        }

        // Check for attached BundleInfo
        BundleInfo info = depUnit.getAttachment(OSGiConstants.BUNDLE_INFO_KEY);
        if (deployment == null && info != null) {
            deployment = DeploymentFactory.createDeployment(info);
            deployment.addAttachment(BundleInfo.class, info);

            // Prevent autostart of ARQ deployments
            DotName runWithName = DotName.createSimple("org.junit.runner.RunWith");
            CompositeIndex compositeIndex = depUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
            List<AnnotationInstance> runWithList = compositeIndex.getAnnotations(runWithName);
            deployment.setAutoStart(runWithList.isEmpty());
        }

        // Attach the deployment and activate the framework
        if (deployment != null) {
            phaseContext.getServiceRegistry().getRequiredService(Services.FRAMEWORK_ACTIVE).setMode(Mode.ACTIVE);
View Full Code Here

    }

    @Override
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
        final Deployment deployment = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY);
        if (deployment != null) {
            ServiceName serviceName;
            try {
                final BundleManager bundleManager = depUnit.getAttachment(OSGiConstants.BUNDLE_MANAGER_KEY);
                if (!deploymentTracker.isClosed() && deploymentTracker.hasDeploymentName(depUnit.getName())) {
View Full Code Here

    }

    private ServiceName installBundleFromURL(URL bundleURL, String location, Integer level, ServiceListener<Bundle> listener) throws Exception {
        BundleManager bundleManager = injectedBundleManager.getValue();
        BundleInfo info = BundleInfo.createBundleInfo(AbstractVFS.toVirtualFile(bundleURL), location);
        Deployment dep = DeploymentFactory.createDeployment(info);
        if (level != null) {
            dep.setStartLevel(level.intValue());
            dep.setAutoStart(true);
        }
        StorageStateProvider storageProvider = injectedStorageProvider.getValue();
        StorageState storageState = storageProvider.getByLocation(dep.getLocation());
        if (storageState != null) {
            dep.addAttachment(StorageState.class, storageState);
        }
        return bundleManager.installBundle(dep, listener);
    }
View Full Code Here

        if (testClasses.contains(className) == false)
            throw new ClassNotFoundException("Class '" + className + "' not found in: " + testClasses);

        Module module = depUnit.getAttachment(Attachments.MODULE);
        Deployment osgidep = OSGiDeploymentAttachment.getDeployment(depUnit);
        if (module == null && osgidep == null)
            throw new IllegalStateException("Cannot determine deployment type: " + depUnit);
        if (module != null && osgidep != null)
            throw new IllegalStateException("Found MODULE attachment for Bundle deployment: " + depUnit);

        Class<?> testClass;
        if (osgidep != null) {
            Bundle bundle = osgidep.getAttachment(Bundle.class);
            testClass = bundle.loadClass(className);
            BundleAssociation.setBundle(bundle);
        } else {
            testClass = module.getClassLoader().loadClass(className);
        }
View Full Code Here

        // Construct and attach the {@link BundleInfo}
        try {
            String contextName = deploymentUnit.getName();
            ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
            Deployment holderdep = DeploymentHolderService.getDeployment(serviceRegistry, contextName);
            String location = holderdep != null ? holderdep.getLocation() : contextName;
            info = BundleInfo.createBundleInfo(AbstractVFS.adapt(virtualFile), location);
            BundleInfoAttachment.attachBundleInfo(deploymentUnit, info);
        } catch (BundleException ex) {
            throw new DeploymentUnitProcessingException("Cannot create bundle deployment from: " + virtualFile);
        }
View Full Code Here

                        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;
View Full Code Here

TOP

Related Classes of org.jboss.osgi.deployment.deployer.Deployment

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.