Package org.apache.aries.application

Examples of org.apache.aries.application.DeploymentMetadata


    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
    app = manager.resolve(app);
   
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
   
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
   
    assertEquals(provision.toString(), 3, provision.size());
   
    List<String> bundleSymbolicNames = new ArrayList<String>();
   
View Full Code Here


    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("testRequireBundle.eba")));
   
    app = manager.resolve(app);
   
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
   
    List<DeploymentContent> depContents = depMeta.getApplicationDeploymentContents();

    List<String> bundleSymbolicNames = new ArrayList<String>();
   
    for (DeploymentContent dep : depContents) {
      bundleSymbolicNames.add(dep.getContentName());
View Full Code Here

   * Create an AriesApplication from a .eba file: a zip file with a '.eba' extension
   * as per http://incubator.apache.org/aries/applications.html
   */
  public AriesApplication createApplication(IDirectory ebaFile) throws ManagementException {
    ApplicationMetadata applicationMetadata = null;
    DeploymentMetadata deploymentMetadata = null;
    Map<String, BundleConversion> modifiedBundles = new HashMap<String, BundleConversion>();
    AriesApplicationImpl application = null;
    String appPath = ebaFile.toString();
    try {  
      // try to read the app name out of the application.mf
      Manifest applicationManifest = parseApplicationManifest (ebaFile);
      String appName = applicationManifest.getMainAttributes().getValue(AppConstants.APPLICATION_NAME);

      //If the application name is null, we will try to get the file name.
      if (appName == null || appName.isEmpty()) {
          String fullPath = appPath;
          if (fullPath.endsWith("/")) {
            fullPath = fullPath.substring(0, fullPath.length() -1)
          }
             
          int last_slash = fullPath.lastIndexOf("/");
          appName = fullPath.substring(last_slash + 1, fullPath.length());
      }
                 
      IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF);
      /* We require that all other .jar and .war files included by-value be valid bundles
       * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate
       * wars to wabs, plain jars to bundles
       */
      Set<BundleInfo> extraBundlesInfo = new HashSet<BundleInfo>();
      for (IFile f : ebaFile) {
        if (f.isDirectory()) {
          continue;
        }
        BundleManifest bm = getBundleManifest (f);
        if (bm != null) {
          if (bm.isValid()) {
            extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.toURL().toExternalForm()));
          } else if (deploymentManifest == null) {
            // We have a jar that needs converting to a bundle, or a war to migrate to a WAB
            // We only do this if a DEPLOYMENT.MF does not exist.
            BundleConversion convertedBinary = null;
            Iterator<BundleConverter> converters = _bundleConverters.iterator();
            List<ConversionException> conversionExceptions = Collections.emptyList();
            while (converters.hasNext() && convertedBinary == null) {
              try {
                convertedBinary = converters.next().convert(ebaFile, f);
              } catch (ServiceException sx) {
                // We'll get this if our optional BundleConverter has not been injected.
              } catch (ConversionException cx) {
                conversionExceptions.add(cx);
              }
            }
            if (conversionExceptions.size() > 0) {
              for (ConversionException cx : conversionExceptions) {
                _logger.error("APPMANAGEMENT0004E", new Object[]{f.getName(), appName, cx});
              }
              throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0005E", appName));
            }
            if (convertedBinary != null) {
              modifiedBundles.put (f.getName(), convertedBinary);            
              extraBundlesInfo.add(convertedBinary.getBundleInfo(_applicationMetadataFactory));
            }
          }
        }
      }
      // if Application-Content header was not specified build it based on the bundles included by value
      if (applicationManifest.getMainAttributes().getValue(AppConstants.APPLICATION_CONTENT) == null) {
          String appContent = buildAppContent(extraBundlesInfo);
          applicationManifest.getMainAttributes().putValue(AppConstants.APPLICATION_CONTENT, appContent);
      }
     
      ManifestDefaultsInjector.updateManifest(applicationManifest, appName, ebaFile);
      applicationMetadata = _applicationMetadataFactory.createApplicationMetadata(applicationManifest);
     
      if (deploymentManifest != null) {
        deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest);
       
        // Validate: symbolic names must match
        String appSymbolicName = applicationMetadata.getApplicationSymbolicName();
        String depSymbolicName = deploymentMetadata.getApplicationSymbolicName();
        if (!appSymbolicName.equals(depSymbolicName)) {
          throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", appName, appSymbolicName, depSymbolicName));
        }
      }

View Full Code Here

  }

  public AriesApplication resolve(AriesApplication originalApp, ResolveConstraint... constraints) throws ResolverException {
    AriesApplicationImpl application = new AriesApplicationImpl(originalApp.getApplicationMetadata(), originalApp.getBundleInfo(), _localPlatform);
    Set<BundleInfo> additionalBundlesRequired = _resolver.resolve(application, constraints);
    DeploymentMetadata deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(application, additionalBundlesRequired);
    application.setDeploymentMetadata(deploymentMetadata);
    // Store a reference to any modified bundles
    if (originalApp instanceof AriesApplicationImpl) {
        // TODO: are we really passing streams around ?
        application.setModifiedBundles(((AriesApplicationImpl) originalApp).getModifiedBundles());
View Full Code Here

  public ApplicationContextImpl (BundleContext b, AriesApplication app) throws BundleException, ManagementException {
    _bundleContext = b;
    _application = app;
    _bundles = new HashMap<BundleInfo, Bundle>();
   
    DeploymentMetadata meta = _application.getDeploymentMetadata();
               
    AriesApplicationResolver resolver = null;
    PackageAdmin packageAdmin = null;
   
    ServiceReference resolverRef = b.getServiceReference(AriesApplicationResolver.class.getName());
    ServiceReference packageAdminRef = b.getServiceReference(PackageAdmin.class.getName());
   
    try {           
      resolver = getService(resolverRef, AriesApplicationResolver.class);
      packageAdmin = getService(packageAdminRef, PackageAdmin.class);
   
      List<DeploymentContent> bundlesToInstall = new ArrayList<DeploymentContent>(meta.getApplicationDeploymentContents());
      bundlesToInstall.addAll(meta.getApplicationProvisionBundles());
   
      for (DeploymentContent content : bundlesToInstall) {
        String bundleSymbolicName = content.getContentName();
        Version bundleVersion = content.getExactVersion();
       
View Full Code Here

    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
    app = manager.resolve(app);
   
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
   
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
   
    assertEquals(provision.toString(), 3, provision.size());
   
    List<String> bundleSymbolicNames = new ArrayList<String>();
   
View Full Code Here

TOP

Related Classes of org.apache.aries.application.DeploymentMetadata

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.