Package org.osgi.framework

Examples of org.osgi.framework.BundleException


                    return true;
                }
            }
            catch (Exception ex)
            {
                throw new BundleException(
                    "Error evaluating osversion: " + osversions[i], ex);
            }
        }
        return false;
    }
View Full Code Here


            Filter filter = FrameworkUtil.createFilter(expr);
            return filter.match(dict);
        }
        catch (Exception ex)
        {
            throw new BundleException(
                "Error evaluating filter expression: " + expr, ex);
        }
    }
View Full Code Here

    public Bundle install(BundleFramework framework, AriesApplication app) throws BundleException
    {
      if (bundleInfo != null ) {
        return framework.getIsolatedBundleContext().installBundle(bundleInfo.getLocation());
      } else {
        throw new BundleException("Unable to install the bundle, as the BundleInfo is null.");
      }
    }
View Full Code Here

                bundleContext = osgiRuntime .getBundleContext();      
            }
        } catch (BundleException e) {
           throw e;
        } catch (Exception e) {
            throw new BundleException("Could not start OSGi runtime", e);
        }
       
       
        return bundleContext;
    }
View Full Code Here

        try {
            is.mark(256 * 1024);
            JarInputStream jar = new JarInputStream(is);
            Manifest m = jar.getManifest();
            if (m == null) {
                throw new BundleException("Manifest not present in the first entry of the zip " + bundleLocation);
            }
            String sn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
            if (sn == null) {
                throw new BundleException("Jar is not a bundle, no Bundle-SymbolicName " + bundleLocation);
            }
            // remove attributes from the symbolic name (like ;blueprint.graceperiod:=false suffix)
            int attributeIndexSep = sn.indexOf(';');
            if (attributeIndexSep != -1) {
                sn = sn.substring(0, attributeIndexSep);
View Full Code Here

                }
            } else {
                System.err.println("The current artifact " + file.getName() + " does not exist.");
            }
        } catch (Exception e) {
            throw new BundleException("The current project artifact cannot be installed (" + e.getMessage() + ")");
        }
       
       
    }
View Full Code Here

        } catch (RuntimeException rte) {
            throw rte;
        } catch (BundleException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new BundleException(MESSAGES.cannotDeployBundle(dep), ex);
        }
    }
View Full Code Here

    ArrayList headerElements = new ArrayList(10);
    Tokenizer tokenizer = new Tokenizer(value);
    parseloop: while (true) {
      String next = tokenizer.getString(";,"); //$NON-NLS-1$
      if (next == null)
        throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
      ArrayList headerValues = new ArrayList();
      StringBuffer headerValue = new StringBuffer(next);
      headerValues.add(next);

      if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
        Debug.print("parseHeader: " + next); //$NON-NLS-1$
      boolean directive = false;
      char c = tokenizer.getChar();
      // Header values may be a list of ';' separated values.  Just append them all into one value until the first '=' or ','
      while (c == ';') {
        next = tokenizer.getString(";,=:"); //$NON-NLS-1$
        if (next == null)
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
        c = tokenizer.getChar();
        while (c == ':') { // may not really be a :=
          c = tokenizer.getChar();
          if (c != '=') {
            String restOfNext = tokenizer.getToken(";,=:"); //$NON-NLS-1$
            if (restOfNext == null)
              throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
            next += ":" + c + restOfNext; //$NON-NLS-1$
            c = tokenizer.getChar();
          } else
            directive = true;
        }
        if (c == ';' || c == ',' || c == '\0') /* more */{
          headerValues.add(next);
          headerValue.append(";").append(next); //$NON-NLS-1$
          if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
            Debug.print(";" + next); //$NON-NLS-1$
        }
      }
      // found the header value create a manifestElement for it.
      ManifestElement manifestElement = new ManifestElement();
      manifestElement.value = headerValue.toString();
      manifestElement.valueComponents = (String[]) headerValues.toArray(new String[headerValues.size()]);

      // now add any attributes/directives for the manifestElement.
      while (c == '=' || c == ':') {
        while (c == ':') { // may not really be a :=
          c = tokenizer.getChar();
          if (c != '=') {
            String restOfNext = tokenizer.getToken("=:"); //$NON-NLS-1$
            if (restOfNext == null)
              throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
            next += ":" + c + restOfNext; //$NON-NLS-1$
            c = tokenizer.getChar();
          } else
            directive = true;
        }
        String val = tokenizer.getString(";,"); //$NON-NLS-1$
        if (val == null)
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);

        if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
          Debug.print(";" + next + "=" + val); //$NON-NLS-1$ //$NON-NLS-2$
        try {
          if (directive)
            manifestElement.addDirective(next, val);
          else
            manifestElement.addAttribute(next, val);
          directive = false;
        } catch (Exception e) {
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR, e);
        }
        c = tokenizer.getChar();
        if (c == ';') /* more */{
          next = tokenizer.getToken("=:"); //$NON-NLS-1$
          if (next == null)
            throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
          c = tokenizer.getChar();
        }
      }
      headerElements.add(manifestElement);
      if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
        Debug.println(""); //$NON-NLS-1$
      if (c == ',') /* another manifest element */
        continue parseloop;
      if (c == '\0') /* end of value */
        break parseloop;
      throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
    }
    int size = headerElements.size();
    if (size == 0)
      return (null);

View Full Code Here

        if (line.charAt(0) == ' ') /* continuation */
        {
          if (firstLine) /* if no previous line */
          {
            throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_SPACE, line), BundleException.MANIFEST_ERROR);
          }
          value.append(line.substring(1));
          continue;
        }

        if (!firstLine) {
          headers.put(header, value.toString().trim());
          value.setLength(0); /* clear StringBuffer */
        }

        int colon = line.indexOf(':');
        if (colon == -1) /* no colon */
        {
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_LINE_NOCOLON, line), BundleException.MANIFEST_ERROR);
        }
        header = line.substring(0, colon).trim();
        value.append(line.substring(colon + 1));
        firstLine = false;
      }
View Full Code Here

  public void updateContent(InputStream content) throws BundleException {
    super.update(content);
  }

  public void update() throws BundleException {
    throw new BundleException("Cannot update composite bundles", BundleException.INVALID_OPERATION); //$NON-NLS-1$
  }
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleException

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.