Package org.jboss.osgi.deployment.deployer

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


        }
    }

    private ServiceName installBundleFromURL(BundleManagerService bundleManager, URL bundleURL, Integer startLevel) throws Exception {
        BundleInfo info = BundleInfo.createBundleInfo(bundleURL);
        Deployment dep = DeploymentFactory.createDeployment(info);
        if (startLevel != null) {
            dep.setStartLevel(startLevel.intValue());
        }
        return bundleManager.installBundle(serviceTarget, dep);
    }
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

        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

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

        Module module = depUnit.getAttachment(Attachments.MODULE);
        Deployment osgiDep = depUnit.getAttachment(OSGiConstants.DEPLOYMENT_KEY);
        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

        ModuleIdentifier identifier = moduleMetaData.getIdentifier();
        File bundleFile = getRepositoryEntry(bundlesDir, identifier);
        if (bundleFile != null) {
            URL url = bundleFile.toURI().toURL();
            BundleInfo info = BundleInfo.createBundleInfo(url);
            Deployment dep = DeploymentFactory.createDeployment(info);
            Integer startLevel = moduleMetaData.getStartLevel();
            if (startLevel != null)
                dep.setStartLevel(startLevel.intValue());
            return bundleManager.installBundle(serviceTarget, dep);
        } else {
            ModuleLoader moduleLoader = Module.getBootModuleLoader();
            Module module = moduleLoader.loadModule(identifier);
            OSGiMetaData metadata = getModuleMetadata(module);
View Full Code Here

                }
                if (bundlesToStart != null) {
                    PackageAdmin packageAdmin = injectedPackageAdmin.getValue();
                    for (Tuple tuple : bundlesToStart.values()) {
                        Bundle bundle = tuple.controller.getValue();
                        Deployment dep = tuple.deployment;
                        if (dep.isAutoStart()) {
                            try {
                                int bundleType = packageAdmin.getBundleType(bundle);
                                if (bundleType != BUNDLE_TYPE_FRAGMENT) {
                                    bundle.start(Bundle.START_TRANSIENT | Bundle.START_ACTIVATION_POLICY);
                                }
View Full Code Here

                            userBundle = AbstractUserBundle.assertBundleState(event.getBundle());
                        } catch (RuntimeException ex) {
                            // ignore
                            return;
                        }
                        Deployment deployment = userBundle.getDeployment();
                        ServiceName serviceName = deployment.getAttachment(ServiceName.class);
                        if (serviceName != null) {
                            ServiceController<?> controller = serviceContainer.getService(serviceName);
                            if (controller != null) {
                                controller.setMode(ServiceController.Mode.REMOVE);
                            }
                        }
                    }
                }
            };
            sysContext.addBundleListener(uninstallListener);

            // Create the list of {@link Deployment}s for the configured modules
            List<Deployment> deployments = new ArrayList<Deployment>();
            BundleDeploymentPlugin depPlugin = bundleManager.getPlugin(BundleDeploymentPlugin.class);
            for (OSGiModule module : injectedConfig.getValue().getModules()) {
                ModuleIdentifier identifier = module.getIdentifier();
                Deployment dep = depPlugin.createDeployment(identifier);
                dep.setAutoStart(module.isStart());
                deployments.add(dep);
            }

            // Deploy the bundles through the {@link DeployerService}
            ServiceReference sref = sysContext.getServiceReference(DeployerService.class.getName());
View Full Code Here

    @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 manifest from the deployment's virtual file
        VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
View Full Code Here

    public static void addService(DeploymentUnitContext context) {

        // Attach the {@link DeploymentService} name so we remove that service on Bundle.uninstall()
        ServiceName deploymentServiceName = DeploymentService.getServiceName(context.getName());
        Deployment deployment = DeploymentAttachment.getDeploymentAttachment(context);
        deployment.addAttachment(ServiceName.class, deploymentServiceName);

        BatchBuilder batchBuilder = context.getBatchBuilder();
        OSGiDeploymentService service = new OSGiDeploymentService(deployment);
        ServiceName serviceName = OSGiDeploymentService.SERVICE_NAME.append(deploymentServiceName.getSimpleName());
        BatchServiceBuilder<Deployment> serviceBuilder = batchBuilder.addService(serviceName, service);
View Full Code Here

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

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

        // Check for attached BundleInfo
        BundleInfo info = BundleInfoAttachment.getBundleInfoAttachment(context);
        if (deployment == null && info != null) {
            deployment = DeploymentFactory.createDeployment(info);
            deployment.addAttachment(BundleInfo.class, info);
            DeploymentAttachment.attachDeployment(context, deployment);
        }

        // Check for attached OSGiMetaData
        OSGiMetaData metadata = OSGiMetaDataAttachment.getOSGiMetaDataAttachment(context);
        if (deployment == null && metadata != null) {
            VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
            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);
            DeploymentAttachment.attachDeployment(context, deployment);
        }

        // Check for attached XModule
        XModule resModule = XModuleAttachment.getXModuleAttachment(context);
        if (deployment == null && resModule != null) {
            VirtualFile virtualFile = VirtualFileAttachment.getVirtualFileAttachment(context);
            String location = virtualFile.getPathName();
            String symbolicName = resModule.getName();
            Version version = resModule.getVersion();
            deployment = DeploymentFactory.createDeployment(AbstractVFS.adapt(virtualFile), location, symbolicName, version);
            deployment.addAttachment(XModule.class, resModule);
            DeploymentAttachment.attachDeployment(context, deployment);
        }

        // Create the {@link OSGiDeploymentService}
        if (deployment != null) {

            // Prevent garbage collection of the MountHandle which will close the file
            MountHandle mount = context.getAttachment(MountHandle.ATTACHMENT_KEY);
            deployment.addAttachment(MountHandle.class, mount);

            OSGiDeploymentService.addService(context);
        }
    }
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.