@Override
 public List<DataRecord> visit(Alias alias) {
   alias.getTypedExpression().accept(this);
   FieldMetadata aliasField =
       new SimpleTypeFieldMetadata(
           explicitProjection,
           false,
           lastField.isMany(),
           lastField.isMandatory(),
           alias.getAliasName(),
           lastField.getType(),
           Collections.<String>emptyList(),
           Collections.<String>emptyList(),
           Collections.<String>emptyList(),
           StringUtils.EMPTY);
   ValueBuilder previousValueBuilder = recordProjection.remove(lastField);
   if (previousValueBuilder == null) {
     AggregateValueBuilder previous = aggregateProjection.remove(lastField);
     aggregateProjection.put(aliasField, previous);
   } else {
     recordProjection.put(aliasField, previousValueBuilder);
   }
   return records;
 }
示例#2
0
  /** Create the default set of framework (launch) properties. */
  protected void initProperties(FrameworkContext fwCtx) {
    setPropertyIfNotSet(Constants.FRAMEWORK_BOOTDELEGATION, "");
    setPropertyIfNotSet(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT);
    setPropertyIfNotSet(Constants.FRAMEWORK_EXECPERMISSION, "");

    if (!props.containsKey(Constants.FRAMEWORK_EXECUTIONENVIRONMENT)) {
      StringBuffer ee = new StringBuffer();
      // Always allow ee minimum
      ee.append("OSGi/Minimum-1.0");
      ee.append(",OSGi/Minimum-1.1");
      ee.append(",OSGi/Minimum-1.2");
      // Set up the default ExecutionEnvironment
      if (1 == javaVersionMajor) {
        for (int i = javaVersionMinor; i > 1; i--) {
          ee.append((i > 5) ? ",JavaSE-1." : ",J2SE-1.");
          ee.append(i);
        }
      }
      props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee.toString());
    }

    setPropertyIfNotSet(Constants.FRAMEWORK_LANGUAGE, Locale.getDefault().getLanguage());
    setPropertyIfNotSet(Constants.FRAMEWORK_LIBRARY_EXTENSIONS, "");

    setPropertyIfNotSet(
        Constants.FRAMEWORK_OS_NAME, Alias.unifyOsName(System.getProperty("os.name")));

    if (!props.containsKey(Constants.FRAMEWORK_OS_VERSION)) {
      String ver = System.getProperty("os.version");
      int maj = 0;
      int min = 0;
      int mic = 0;
      String qual = null;
      if (ver != null) {
        // Convert os.version to a reasonable default
        try {
          StringTokenizer st = new StringTokenizer(ver.trim(), ".");
          maj = Integer.parseInt(st.nextToken());
          if (st.hasMoreTokens()) {
            qual = st.nextToken();
            min = Integer.parseInt(qual);
            qual = null;
            if (st.hasMoreTokens()) {
              qual = st.nextToken();
              mic = Integer.parseInt(qual);
              qual = null;
              if (st.hasMoreTokens()) {
                qual = st.nextToken();
              }
            }
          }
        } catch (Exception ignore) {
        }
      }
      Version osVersion;
      try {
        osVersion = new Version(maj, min, mic, qual);
      } catch (IllegalArgumentException skip) {
        osVersion = new Version(maj, min, mic, null);
      }
      props.put(Constants.FRAMEWORK_OS_VERSION, osVersion.toString());
    }

    setPropertyIfNotSet(
        Constants.FRAMEWORK_PROCESSOR, Alias.unifyProcessor(System.getProperty("os.arch")));

    setPropertyIfNotSet(Constants.FRAMEWORK_SECURITY, "");

    setPropertyIfNotSet(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, "1");

    setPropertyIfNotSet(Constants.FRAMEWORK_STORAGE, "fwdir");

    setPropertyIfNotSet(Constants.FRAMEWORK_STORAGE_CLEAN, "");

    // NYI, fill this with values
    setPropertyIfNotSet(Constants.FRAMEWORK_SYSTEMPACKAGES, "");

    setPropertyIfNotSet(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "");

    setPropertyIfNotSet(Constants.FRAMEWORK_TRUST_REPOSITORIES, "");

    // NYI
    setPropertyIfNotSet(Constants.FRAMEWORK_WINDOWSYSTEM, "");

    // Impl. constants
    props.put(Constants.FRAMEWORK_VERSION, FrameworkContext.SPEC_VERSION);
    props.put(Constants.FRAMEWORK_VENDOR, "Knopflerfish");
    props.put(Constants.SUPPORTS_FRAMEWORK_REQUIREBUNDLE, TRUE);
    props.put(Constants.SUPPORTS_FRAMEWORK_FRAGMENT, TRUE);
    // Only first framework support framework extension
    // NYI! Improve this in the future
    props.put(
        Constants.SUPPORTS_FRAMEWORK_EXTENSION,
        getClass().getClassLoader() instanceof URLClassLoader && fwCtx.id == 0 ? TRUE : FALSE);
    // Only first framework can support bootclasspath extension
    // NYI! Improve this in the future
    setPropertyIfNotSet(Constants.SUPPORTS_BOOTCLASSPATH_EXTENSION, FALSE);
    if (getBooleanProperty(Constants.SUPPORTS_BOOTCLASSPATH_EXTENSION)
        && !(getClass().getClassLoader() instanceof URLClassLoader && fwCtx.id == 1)) {
      props.put(Constants.SUPPORTS_BOOTCLASSPATH_EXTENSION, FALSE);
    }
  }
 @Override
 public Collection<? extends ComplexTypeMetadata> visit(Alias alias) {
   alias.getTypedExpression().accept(this);
   return closure;
 }