public RemoteInterfaceDescriptor getRemoteDescriptor(Class type) {
    TypeDescriptor td = getDescriptor(type);
    RemoteInterfaceDescriptor result = td.getRemoteInterface();

    if (result != null) {
      return result;
    }

    RemoteDescriptor desc;

    if (java.rmi.Remote.class.isAssignableFrom(type)) {
      if (type.isInterface()) {
        desc = new RemoteInterfaceDescriptor(type, this);
      } else {
        desc = new RemoteClassDescriptor(type, this);
      }

      desc.init();
    } else {
      throw new IllegalArgumentException(
          "class " + type.toString() + " does not implement" + " java.rmi.Remote");
    }

    result = desc.getRemoteInterface();
    td.setRemoteInterface(result);

    return result;
  }
  public CurrentLiveVersion(
      ReloadableType reloadableType, String versionstamp, byte[] newbytedata) {
    if (GlobalConfiguration.logging && log.isLoggable(Level.FINER)) {
      log.entering(
          "CurrentLiveVersion",
          "<init>",
          " new version of "
              + reloadableType.getName()
              + " loaded, version stamp '"
              + versionstamp
              + "'");
    }
    this.reloadableType = reloadableType;
    this.typeDescriptor =
        reloadableType.getTypeRegistry().getExtractor().extract(newbytedata, true);
    this.versionstamp = versionstamp;

    if (GlobalConfiguration.assertsMode) {
      if (!this.typeDescriptor.getName().equals(reloadableType.typedescriptor.getName())) {
        throw new IllegalStateException(
            "New version has wrong name.  Expected "
                + reloadableType.typedescriptor.getName()
                + " but was "
                + typeDescriptor.getName());
      }
    }

    newbytedata =
        GlobalConfiguration.callsideRewritingOn
            ? MethodInvokerRewriter.rewrite(reloadableType.typeRegistry, newbytedata)
            : newbytedata;

    this.incrementalTypeDescriptor = new IncrementalTypeDescriptor(reloadableType.typedescriptor);
    this.incrementalTypeDescriptor.setLatestTypeDescriptor(this.typeDescriptor);

    // Executors for interfaces simply hold annotations
    this.executor =
        reloadableType
            .getTypeRegistry()
            .executorBuilder
            .createFor(reloadableType, versionstamp, typeDescriptor, newbytedata);

    if (GlobalConfiguration.classesToDump != null
        && GlobalConfiguration.classesToDump.contains(reloadableType.getSlashedName())) {
      Utils.dump(
          Utils.getExecutorName(reloadableType.getName(), versionstamp).replace('.', '/'),
          this.executor);
    }
    if (!typeDescriptor.isInterface()) {
      this.dispatcherName = Utils.getDispatcherName(reloadableType.getName(), versionstamp);
      this.executorName = Utils.getExecutorName(reloadableType.getName(), versionstamp);
      this.dispatcher =
          DispatcherBuilder.createFor(reloadableType, incrementalTypeDescriptor, versionstamp);
    }
    reloadableType.typeRegistry.checkChildClassLoader(reloadableType);
    define();
  }
  public LockTableDescriptor(TypeDescriptor type) {
    Assert.condition(type.isDistinctLockTableName(), "Type must support lock table option.");

    this.type = type;

    Assert.condition(
        !StringUtils.isEmpty(type.getTableAlias()), "Type must have a default alias defined.");

    this.tableAlias = type.getTableAlias() + "_lck";
  }
 @SuppressWarnings({"unchecked", "rawtypes"})
 static ComponentBuilder<?> wrapWithCondition(
     ComponentDescriptor descriptor, ComponentBuilder<?> builder) {
   TypeDescriptor typeDescriptor = descriptor.getTypeDescriptor();
   if (typeDescriptor == null) return builder;
   String conditionText = typeDescriptor.getCondition();
   if (!StringUtil.isEmpty(conditionText)) {
     Expression<Boolean> condition = new ScriptExpression<Boolean>(conditionText);
     return new ConditionalComponentBuilder(builder, condition);
   } else return builder;
 }
 /**
  * Computes the display string for any value, for a specific type.
  *
  * @param desc the field descriptor - custom formatters are extracted from this descriptor.
  * @param t the value to print
  * @return the formatted string
  */
 public static <T> String print(TypeDescriptor desc, T t) {
   if (t == null) {
     return "";
   }
   if (desc != null && conversion.canConvert(desc, TypeDescriptor.valueOf(String.class))) {
     return (String) conversion.convert(t, desc, TypeDescriptor.valueOf(String.class));
   } else if (conversion.canConvert(t.getClass(), String.class)) {
     return conversion.convert(t, String.class);
   } else {
     return t.toString();
   }
 }
 protected static ComponentBuilder<?> createScriptBuilder(
     ComponentDescriptor component, BeneratorContext context) {
   TypeDescriptor type = component.getTypeDescriptor();
   if (type == null) return null;
   String scriptText = type.getScript();
   if (scriptText == null) return null;
   Script script = ScriptUtil.parseScriptText(scriptText);
   Generator<?> generator = new ScriptGenerator(script);
   generator =
       DescriptorUtil.createConvertingGenerator(component.getTypeDescriptor(), generator, context);
   return builderFromGenerator(generator, component, context);
 }
 private static ComponentBuilder<?> builderFromGenerator(
     Generator<?> source, ComponentDescriptor descriptor, BeneratorContext context) {
   boolean nullability = DescriptorUtil.isNullable(descriptor, context);
   Double nullQuota = descriptor.getNullQuota();
   if (nullQuota != null && nullQuota != 0)
     source = context.getGeneratorFactory().applyNullSettings(source, nullability, nullQuota);
   TypeDescriptor typeDescriptor = descriptor.getTypeDescriptor();
   String scope = (typeDescriptor != null ? typeDescriptor.getScope() : null);
   if (descriptor instanceof ArrayElementDescriptor) {
     int index = ((ArrayElementDescriptor) descriptor).getIndex();
     return new ArrayElementBuilder(index, source, scope);
   } else return new PlainEntityComponentBuilder(descriptor.getName(), source, scope);
 }
 /**
  * Create a new conversion exception.
  *
  * @param value the value we tried to convert
  * @param sourceType the value's original type
  * @param targetType the value's target type
  * @param cause the cause of the conversion failure
  */
 public ConversionFailedException(
     TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) {
   super(
       "Unable to convert value "
           + value
           + " from type '"
           + sourceType.getName()
           + "' to type '"
           + targetType.getName()
           + "'",
       cause);
   this.sourceType = sourceType;
   this.targetType = targetType;
 }
Beispiel #9
0
    /**
     * Add type descriptor.
     *
     * @param clsName Class name.
     * @param idMapper ID mapper.
     * @param serializer Serializer.
     * @param affKeyFieldName Affinity key field name.
     * @param isEnum Enum flag.
     * @param canOverride Whether this descriptor can be override.
     * @throws BinaryObjectException If failed.
     */
    private void add(
        String clsName,
        BinaryIdMapper idMapper,
        BinarySerializer serializer,
        String affKeyFieldName,
        boolean isEnum,
        boolean canOverride)
        throws BinaryObjectException {
      TypeDescriptor desc =
          new TypeDescriptor(clsName, idMapper, serializer, affKeyFieldName, isEnum, canOverride);

      TypeDescriptor oldDesc = descs.get(clsName);

      if (oldDesc == null) descs.put(clsName, desc);
      else oldDesc.override(desc);
    }
  public boolean mustUseExecutorForThisMethod(int methodId) {
    // Rule1: if it is a new method, we must use the executor

    compute();
    // If it is a catcher method that now has an implementation, we must use the executor
    MethodMember method = initialTypeDescriptor.getMethod(methodId);
    if (MethodMember.isCatcher(method)) {
      // Has it now been provided??  If it has not we can just return immediately
      boolean found = false;
      for (MethodMember method2 : newOrChangedMethods) {
        if (method2.shouldReplace(method)) { // modifiers? what of static/nonstatic et al
          // We should not consider modifiers or exceptions in this test!
          // otherwise we will end up not finding a method that really should replace / override
          // the catcher.
          found = true;
          if (MethodMember.isCatcher(method2)) {
            return false;
          }
        }
      }
      if (!found) {
        // not provided!  New type descriptor doesn't include catchers
        return false;
      }
    }
    return true;
  }
 /**
  * Get the identifiable type that corresponds to the most specific mapped superclass or entity
  * extended by the entity or mapped superclass.
  *
  * @return the super type.
  */
 public IdentifiableTypeDescriptor getSuperType() {
   final TypeDescriptor superType = TypeDescriptor.getInstance(getJavaType().getSuperclass());
   if (superType instanceof IdentifiableTypeDescriptor) {
     return (IdentifiableTypeDescriptor) superType;
   } else {
     return null;
   }
 }
Beispiel #12
0
  /**
   * Initializes the expression
   *
   * @param tp the type prefix
   * @param td the type descriptor. The element type of the enclosed initializer will be
   *     automatically and recursively set.
   * @exception IllegalArgumentException if tp is null or td is null
   */
  public ArrayAllocation(TypeName tp, TypeDescriptor td, SourceInfo si) {
    super(si);

    if (tp == null) throw new IllegalArgumentException("tp == null");
    if (td == null) throw new IllegalArgumentException("td == null");
    elementType = tp;
    typeDescriptor = td;
    td.initialize(tp);
  }
 /**
  * Defines this version. Called up front but can also be called later if the ChildClassLoader in a
  * type registry is discarded and recreated.
  */
 public void define() {
   staticInitializer = null;
   haveLookedForStaticInitializer = false;
   if (!typeDescriptor.isInterface()) {
     try {
       dispatcherClass =
           reloadableType.typeRegistry.defineClass(dispatcherName, dispatcher, false);
     } catch (RuntimeException t) {
       // TODO check for something strange.  something to do with the file detection misbehaving,
       // see the same file attempted to be reloaded twice...
       if (t.getMessage().indexOf("duplicate class definition") == -1) {
         throw t;
       } else {
         t.printStackTrace();
       }
     }
   }
   try {
     executorClass = reloadableType.typeRegistry.defineClass(executorName, executor, false);
   } catch (RuntimeException t) {
     // TODO check for something strange.  something to do with the file detection misbehaving, see
     // the same file attempted to be reloaded twice...
     if (t.getMessage().indexOf("duplicate class definition") == -1) {
       throw t;
     } else {
       t.printStackTrace();
     }
   }
   if (!typeDescriptor.isInterface()) {
     try {
       dispatcherInstance = dispatcherClass.newInstance();
     } catch (InstantiationException e) {
       throw new RuntimeException("Unable to build dispatcher class instance", e);
     } catch (IllegalAccessException e) {
       throw new RuntimeException("Unable to build dispatcher class instance", e);
     }
   }
 }
  public boolean hasBeenDeleted(int methodId) {
    compute();
    MethodMember method = initialTypeDescriptor.getMethod(methodId);

    boolean a = false;
    for (MethodMember m : deletedMethods) {
      if (m.equals(method)) {
        a = true;
        break;
      }
    }

    // alternative mechanism
    //		boolean b = true;
    //		for (MethodMember m : this.latestTypeDescriptor.getMethods()) {
    //			if (m.equals(method)) {
    //				b = wasDeleted(m);
    //				break;
    //			}
    //		}

    return a;
  }
 // TODO can we speed this up?
 public boolean hasConstructorChanged(int ctorId) {
   // need to find the constructor that id is for
   MethodMember mm = typeDescriptor.getConstructor(ctorId);
   return hasConstructorChanged(mm);
 }
  private void compute() {
    if ((bits & BIT_COMPUTED_DIFF) != 0) {
      return;
    }
    latestMethods = new HashMap<String, MethodMember>();
    newOrChangedMethods = new ArrayList<MethodMember>();
    deletedMethods = new ArrayList<MethodMember>();
    // Process the methods in the latest copy, compared to the original
    for (MethodMember latest : latestTypeDescriptor.getMethods()) {

      // Did this method exist in the original? Ask by name and descriptor
      MethodMember original =
          initialTypeDescriptor.getByDescriptor(latest.getName(), latest.getDescriptor());

      // If it did not exist, tag it
      if (original == null) {
        latest.bits |= MethodMember.IS_NEW;
        newOrChangedMethods.add(latest);
      } else {
        if (!original.equals(latest)) { // check more than just name/descriptor
          newOrChangedMethods.add(latest);
        }
        // If originally it was a catcher and now it is no longer a catcher (an impl has been
        // provided), record it
        if (MethodMember.isCatcher(original) && !MethodMember.isCatcher(latest)) {
          latest.bits |= MethodMember.IS_NEW;
          newOrChangedMethods.add(latest);
        }
        // TODO [perf] not convinced this can occur? Think it through
        if (MethodMember.isSuperDispatcher(original) && !MethodMember.isSuperDispatcher(latest)) {
          latest.bits |= MethodMember.IS_NEW;
          newOrChangedMethods.add(latest);
        }

        // If it now is a catcher where it didn't used to be, it has been deleted
        if (MethodMember.isCatcher(latest) && !MethodMember.isCatcher(original)) {
          latest.bits |= MethodMember.WAS_DELETED;
        }
        latest.original = original;
        // Keep track of important changes:
        if (original.modifiers != latest.modifiers) {
          // Determine if a change was made from static to non-static or vice versa
          boolean wasStatic = original.isStatic();
          boolean isStatic = latest.isStatic();
          if (wasStatic != isStatic) {
            if (wasStatic) {
              // has been made non-static
              latest.bits |= MethodMember.MADE_NON_STATIC;
            } else {
              // has been made static
              latest.bits |= MethodMember.MADE_STATIC;
            }
          }
          // Determine if a change was made with regards visibility
          int oldVisibility = original.modifiers & ACC_PUBLIC_PRIVATE_PROTECTED;
          int newVisibility = latest.modifiers & ACC_PUBLIC_PRIVATE_PROTECTED;
          if (oldVisibility != newVisibility) {
            latest.bits |= MethodMember.VISIBILITY_CHANGE;
          }
        }
        // TODO do we care about exceptions changing?  It doesn't make it a new method.
        // TODO if we do, upgrade this check to remember the precise changes?
        //				int oExceptionsLength = original.exceptions == null ? 0 : original.exceptions.length;
        //				int nExceptionsLength = latest.exceptions == null ? 0 : latest.exceptions.length;
        //				if (oExceptionsLength != nExceptionsLength) {
        //					latest.bits |= MethodMember.EXCEPTIONS_CHANGE;
        //				} else {
        //					for (int i = 0; i < oExceptionsLength; i++) {
        //						if (!original.exceptions[i].equals(latest.exceptions[i])) {
        //							latest.bits |= MethodMember.EXCEPTIONS_CHANGE;
        //						}
        //					}
        //				}
      }
      String nadKey = new StringBuilder(latest.getName()).append(latest.getDescriptor()).toString();
      latestMethods.put(nadKey, latest);
    }
    for (MethodMember initialMethod : initialTypeDescriptor.getMethods()) {
      if (MethodMember.isCatcher(initialMethod)) {
        continue;
      }
      if (!latestTypeDescriptor.defines(initialMethod)) {
        deletedMethods.add(initialMethod);
      }
    }
    bits |= BIT_COMPUTED_DIFF;
  }
Beispiel #17
0
 /**
  * Note: This method <em>doesn't</em> follow the usual convention of firing a property change. If
  * that functionality is needed, the code should be fixed.
  *
  * @param init An initializer, assumed to already be set up with a valid element type. (The
  *     ArrayInitializer constructor will set up the element type automatically, but this method
  *     does not.)
  */
 public void setInitialization(ArrayInitializer init) {
   typeDescriptor.initialization = init;
 }
 public String getSchemaName() {
   return type.getSchemaName();
 }
 public String getTableName() {
   return type.getLockTableName();
 }
Beispiel #20
0
 public Access type() {
   TypeDescriptor d = new TypeDescriptor(p, typeDescriptor);
   return d.type();
 }
Beispiel #21
0
 public List parameterListSkipFirst() {
   TypeDescriptor d = new TypeDescriptor(p, parameterDescriptors);
   return d.parameterListSkipFirst();
 }
  public TypeRepository(org.omg.CORBA.ORB orb) {
    this.orb = orb;
    TypeDescriptor desc;

    desc = new AnyDescriptor(java.lang.Object.class, this);
    classMap.put(java.lang.Object.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new AnyDescriptor(java.lang.Object.class, this);
    classMap.put(java.lang.Object.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new StringDescriptor(this);
    classMap.put(String.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new ClassDescriptor(this);
    classMap.put(Class.class, desc);
    classMap.put(javax.rmi.CORBA.ClassDesc.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new DateValueDescriptor(this);
    classMap.put(java.util.Date.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new AnyDescriptor(java.io.Externalizable.class, this);
    classMap.put(java.io.Externalizable.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new AnyDescriptor(java.io.Serializable.class, this);
    classMap.put(java.io.Serializable.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);

    desc = new AnyDescriptor(java.rmi.Remote.class, this);
    classMap.put(java.rmi.Remote.class, desc);
    desc.init();
    repidMap.put(desc.getRepositoryID(), desc);
  }
  /* (non-Javadoc)
   * @see org.alfresco.config.element.GenericConfigElement#combine(org.alfresco.config.ConfigElement)
   */
  public ConfigElement combine(ConfigElement element) {
    WebFrameworkConfigElement configElement = (WebFrameworkConfigElement) element;

    // new combined element
    WebFrameworkConfigElement combinedElement = new WebFrameworkConfigElement();

    // copy in our things
    combinedElement.formats.putAll(this.formats);
    combinedElement.errorHandlers.putAll(this.errorHandlers);
    combinedElement.systemPages.putAll(this.systemPages);
    combinedElement.tagLibraries.putAll(this.tagLibraries);
    combinedElement.types.putAll(this.types);
    combinedElement.pageTypes.putAll(this.pageTypes);
    combinedElement.resourceLoaders.putAll(this.resourceLoaders);
    combinedElement.resourceResolvers.putAll(this.resourceResolvers);
    combinedElement.resourcesDeniedPaths.addAll(this.resourcesDeniedPaths);
    combinedElement.runtimeConfigs.putAll(this.runtimeConfigs);

    // override with things from the merging object
    combinedElement.formats.putAll(configElement.formats);
    combinedElement.errorHandlers.putAll(configElement.errorHandlers);
    combinedElement.systemPages.putAll(configElement.systemPages);
    combinedElement.tagLibraries.putAll(configElement.tagLibraries);
    combinedElement.types.putAll(configElement.types);
    combinedElement.pageTypes.putAll(configElement.pageTypes);
    combinedElement.resourceLoaders.putAll(configElement.resourceLoaders);
    combinedElement.resourceResolvers.putAll(configElement.resourceResolvers);
    combinedElement.resourcesDeniedPaths.addAll(configElement.resourcesDeniedPaths);
    combinedElement.runtimeConfigs.putAll(configElement.runtimeConfigs);

    // other properties
    combinedElement.isTimerEnabled = this.isTimerEnabled;
    if (configElement.isTimerEnabled) {
      combinedElement.isTimerEnabled = configElement.isTimerEnabled;
    }

    // default services
    combinedElement.defaultLinkBuilderFactoryId = this.defaultLinkBuilderFactoryId;
    if (configElement.defaultLinkBuilderFactoryId != null) {
      combinedElement.defaultLinkBuilderFactoryId = configElement.defaultLinkBuilderFactoryId;
    }
    combinedElement.defaultRequestContextFactoryId = this.defaultRequestContextFactoryId;
    if (configElement.defaultRequestContextFactoryId != null) {
      combinedElement.defaultRequestContextFactoryId = configElement.defaultRequestContextFactoryId;
    }
    combinedElement.defaultUserFactoryId = this.defaultUserFactoryId;
    if (configElement.defaultUserFactoryId != null) {
      combinedElement.defaultUserFactoryId = configElement.defaultUserFactoryId;
    }

    // default application settings
    combinedElement.defaultFormatId = this.defaultFormatId;
    if (configElement.defaultFormatId != null) {
      combinedElement.defaultFormatId = configElement.defaultFormatId;
    }
    combinedElement.defaultRegionChrome = this.defaultRegionChrome;
    if (configElement.defaultRegionChrome != null) {
      combinedElement.defaultRegionChrome = configElement.defaultRegionChrome;
    }
    combinedElement.defaultComponentChrome = this.defaultComponentChrome;
    if (configElement.defaultComponentChrome != null) {
      combinedElement.defaultComponentChrome = configElement.defaultComponentChrome;
    }
    combinedElement.defaultSubComponentChrome = this.defaultSubComponentChrome;
    if (configElement.defaultSubComponentChrome != null) {
      combinedElement.defaultSubComponentChrome = configElement.defaultSubComponentChrome;
    }
    combinedElement.defaultTheme = this.defaultTheme;
    if (configElement.defaultTheme != null) {
      combinedElement.defaultTheme = configElement.defaultTheme;
    }

    combinedElement.surfBug = this.surfBug;
    if (configElement.surfBug != null) {
      combinedElement.surfBug = configElement.surfBug;
    }

    combinedElement.loginCookiesEnabled = this.loginCookiesEnabled;
    if (configElement.loginCookiesEnabled != null) {
      combinedElement.loginCookiesEnabled = configElement.loginCookiesEnabled;
    }

    combinedElement.defaultSiteConfiguration = this.defaultSiteConfiguration;
    if (configElement.defaultSiteConfiguration != null) {
      combinedElement.defaultSiteConfiguration = configElement.defaultSiteConfiguration;
    }

    // default persister setting
    combinedElement.defaultPersisterId = this.defaultPersisterId;
    if (configElement.defaultPersisterId != null) {
      combinedElement.defaultPersisterId = configElement.defaultPersisterId;
    }

    // Whenever two config elements are merged it is important to ensure that the
    // currently configured types are updated with any overridden default persisters.
    // A type is marked as using the default persister if a persister id is not
    // explicitly set. It will be set with the default persister configured in the
    // same file as the type is declared, but the "useDefaultPersister" flag will
    // be set so that it can be overridden if the default persister is updated.
    for (TypeDescriptor type : combinedElement.getTypes()) {
      if (type.useDefaultPerister()) {
        type.setPersisterId(combinedElement.defaultPersisterId);
      }
    }

    // AutoWire Settings
    combinedElement.autowireModeId = this.autowireModeId;
    if (configElement.autowireModeId != null) {
      combinedElement.autowireModeId = configElement.autowireModeId;
    }
    combinedElement.autowireRuntimeId = this.autowireRuntimeId;
    if (configElement.autowireRuntimeId != null) {
      combinedElement.autowireRuntimeId = configElement.autowireRuntimeId;
    }

    // persister config
    combinedElement.persisterConfigDescriptor = this.persisterConfigDescriptor;
    if (configElement.persisterConfigDescriptor != null) {
      combinedElement.persisterConfigDescriptor = configElement.persisterConfigDescriptor;
    }

    // Module deployment settings...
    combinedElement.moduleDeploymentMode = this.moduleDeploymentMode;
    if (configElement.moduleDeploymentMode != null) {
      combinedElement.moduleDeploymentMode = configElement.moduleDeploymentMode;
    }

    combinedElement.enableAutoDeployModules = this.enableAutoDeployModules;
    if (configElement.enableAutoDeployModules != null) {
      combinedElement.enableAutoDeployModules = configElement.enableAutoDeployModules;
    }

    combinedElement.useChecksumDependencies = this.useChecksumDependencies;
    if (configElement.useChecksumDependencies != null) {
      combinedElement.useChecksumDependencies = configElement.useChecksumDependencies;
    }

    combinedElement.generateCssDataImages = this.generateCssDataImages;
    if (configElement.generateCssDataImages != null) {
      combinedElement.generateCssDataImages = configElement.generateCssDataImages;
    }

    combinedElement.aggregateDependencies = this.aggregateDependencies;
    if (configElement.aggregateDependencies != null) {
      combinedElement.aggregateDependencies = configElement.aggregateDependencies;
    }

    combinedElement.calculateWebScriptDependencies = this.calculateWebScriptDependencies;
    if (configElement.calculateWebScriptDependencies != null) {
      combinedElement.calculateWebScriptDependencies = configElement.calculateWebScriptDependencies;
    }

    combinedElement.enableRemoteResourceHandling = this.enableRemoteResourceHandling;
    if (configElement.enableRemoteResourceHandling != null) {
      combinedElement.enableRemoteResourceHandling = configElement.enableRemoteResourceHandling;
    }

    combinedElement.enableExtensionModulesOnGuestPages = this.enableExtensionModulesOnGuestPages;
    if (configElement.enableExtensionModulesOnGuestPages != null) {
      combinedElement.enableExtensionModulesOnGuestPages =
          configElement.enableExtensionModulesOnGuestPages;
    }

    combinedElement.enableDynamicExtensions = this.enableDynamicExtensions;
    if (configElement.enableDynamicExtensions != null) {
      combinedElement.enableDynamicExtensions = configElement.enableDynamicExtensions;
    }

    combinedElement.disableResourceCaching = this.disableResourceCaching;
    if (configElement.disableResourceCaching != null) {
      combinedElement.disableResourceCaching = configElement.disableResourceCaching;
    }

    // Combine any Dojo configurations...
    combineDojoConfiguration(configElement, combinedElement);

    return combinedElement;
  }
  private List getNextSequenceImpl(TypeDescriptor typeDescriptor, Session session) {
    Field[] pkFields = typeDescriptor.getPkFields();

    Assert.condition(
        1 == pkFields.length,
        "Automatic PK values are only supported for types with a single PK field.");

    String createPKStmt =
        dbDescriptor.getCreatePKStatement(
            sqlUtils.getSchemaName(), typeDescriptor.getPkSequence(), this.sequenceBatchSize);

    Field field = pkFields[0];
    if (session.isUsingPreparedStatements(typeDescriptor.getType())) {
      PreparedStatement pkStatement = null;
      try {
        Connection connection = session.getConnection();
        PreparedStatement result;
        try {
          result = connection.prepareStatement(createPKStmt);
        } catch (SQLException x) {
          throw new InternalException(x);
        }
        pkStatement = result;
        ResultSet pkQuery = pkStatement.executeQuery();
        List newIds = new LinkedList();
        while (pkQuery.next()) {
          newIds.add(
              DmlManager.getJavaValue(
                  field.getType(),
                  typeDescriptor.getPersistentField(field).getLength(),
                  pkQuery,
                  1,
                  true,
                  false));
        }
        return newIds;
      } catch (SQLException e) {
        throw new InternalException(e);
      } finally {
        QueryUtils.closeStatement(pkStatement);
      }
    } else {
      Statement pkStmt = null;
      try {
        Connection connection = session.getConnection();
        pkStmt = connection.createStatement();
        ResultSet pkQuery = pkStmt.executeQuery(createPKStmt);
        List newIds = new LinkedList();
        while (pkQuery.next()) {
          newIds.add(
              DmlManager.getJavaValue(
                  field.getType(),
                  typeDescriptor.getPersistentField(field).getLength(),
                  pkQuery,
                  1,
                  true,
                  false));
        }
        return newIds;
      } catch (SQLException e) {
        throw new InternalException(e);
      } finally {
        QueryUtils.closeStatement(pkStmt);
      }
    }
  }
  public TypeDescriptor getDescriptor(Class type) {
    logger.fine("Requesting type descriptor for class " + type.getName());
    TypeDescriptor desc = classMap.get(type);

    if (desc != null) {
      return desc.getSelf();
    }

    if (org.omg.CORBA.portable.IDLEntity.class.isAssignableFrom(type) && isIDLEntity(type)) {
      IDLEntityDescriptor idlDesc = new IDLEntityDescriptor(type, this);
      desc = idlDesc;
      classMap.put(type, desc);
      idlDesc.initIDL();
    } else if (java.lang.Throwable.class.isAssignableFrom(type)) {
      desc = new ExceptionDescriptor(type, this);
      classMap.put(type, desc);
      desc.init();
      repidMap.put(desc.getRepositoryID(), desc);

    } else if (type.isArray()) {
      desc = ArrayDescriptor.get(type, this);
      classMap.put(type, desc);
      desc.init();
      repidMap.put(desc.getRepositoryID(), desc);
    } else if (!type.isInterface() && java.io.Serializable.class.isAssignableFrom(type)) {
      desc = new ValueDescriptor(type, this);
      classMap.put(type, desc);
      desc.init();
      repidMap.put(desc.getRepositoryID(), desc);
    } else if (java.rmi.Remote.class.isAssignableFrom(type)) {
      if (type.isInterface()) {
        desc = new RemoteInterfaceDescriptor(type, this);
      } else {
        desc = new RemoteClassDescriptor(type, this);
      }

      classMap.put(type, desc);
      desc.init();
      repidMap.put(desc.getRepositoryID(), desc);
    } else if (type.isPrimitive()) {
      desc = getSimpleDescriptor(type);
      classMap.put(type, desc);
      repidMap.put(desc.getRepositoryID(), desc);

    } else if (Object.class.isAssignableFrom(type)) {
      if (isAbstractInterface(type)) {

        logger.finer("encoding " + type + " as abstract interface");
        desc = new AbstractObjectDescriptor(type, this);

      } else {

        logger.finer("encoding " + type + " as a abstract value");
        desc = new ValueDescriptor(type, this);
      }

      classMap.put(type, desc);
      desc.init();
      repidMap.put(desc.getRepositoryID(), desc);

    } else {
      throw new RuntimeException("cannot handle class " + type.getName());
    }

    logger.fine("Class " + type.getName() + " resolves to " + desc.getClass().getName());
    return desc;
  }
  @SuppressWarnings("unchecked")
  protected static WebFrameworkConfigElement newInstance(Element elem) {
    WebFrameworkConfigElement configElement = new WebFrameworkConfigElement();

    // formats
    List<Element> formats = elem.elements("format");
    for (Element el : formats) {
      FormatDescriptor descriptor = new FormatDescriptor(el);
      configElement.formats.put(descriptor.getId(), descriptor);
    }

    // error handlers
    List<Element> errorHandlers = elem.elements("error-handler");
    for (Element el : errorHandlers) {
      ErrorHandlerDescriptor descriptor = new ErrorHandlerDescriptor(el);
      configElement.errorHandlers.put(descriptor.getId(), descriptor);
    }

    // system pages
    List<Element> systemPages = elem.elements("system-page");
    for (Element el : systemPages) {
      SystemPageDescriptor descriptor = new SystemPageDescriptor(el);
      configElement.systemPages.put(descriptor.getId(), descriptor);
    }

    // tag libraries
    List<Element> tagLibraries = elem.elements("tag-library");
    for (Element el : tagLibraries) {
      TagLibraryDescriptor descriptor = new TagLibraryDescriptor(el);
      configElement.tagLibraries.put(descriptor.getId(), descriptor);
    }

    // defaults
    Element defaults = elem.element("defaults");
    if (defaults != null) {
      /** SERVICES * */
      String _requestContextFactoryId = defaults.elementTextTrim("request-context-factory");
      if (_requestContextFactoryId != null) {
        configElement.defaultRequestContextFactoryId = _requestContextFactoryId;
      }
      String _linkBuilderFactoryId = defaults.elementTextTrim("link-builder-factory");
      if (_linkBuilderFactoryId != null) {
        configElement.defaultLinkBuilderFactoryId = _linkBuilderFactoryId;
      }
      String _userFactoryId = defaults.elementTextTrim("user-factory");
      if (_userFactoryId != null) {
        configElement.defaultUserFactoryId = _userFactoryId;
      }

      /** SETTINGS * */
      String _format = defaults.elementTextTrim("format");
      if (_format != null) {
        configElement.defaultFormatId = _format;
      }
      String _regionChrome = defaults.elementTextTrim("region-chrome");
      if (_regionChrome != null) {
        configElement.defaultRegionChrome = _regionChrome;
      }
      String _componentChrome = defaults.elementTextTrim("component-chrome");
      if (_componentChrome != null) {
        configElement.defaultComponentChrome = _componentChrome;
      }

      String _subComponentChrome = defaults.elementTextTrim("sub-component-chrome");
      if (_subComponentChrome != null) {
        configElement.defaultSubComponentChrome = _subComponentChrome;
      }

      String _surfBug = defaults.elementTextTrim("surfbug");
      if (_surfBug != null) {
        configElement.surfBug = _surfBug;
      }

      String _loginCookiesEnabled = defaults.elementTextTrim("login-cookies-enabled");
      if (_loginCookiesEnabled != null) {
        configElement.loginCookiesEnabled = Boolean.valueOf(_loginCookiesEnabled);
      }

      String _theme = defaults.elementTextTrim("theme");
      if (_theme != null && _theme.length() != 0) {
        configElement.defaultTheme = _theme;
      }
      List<Element> pageTypes = defaults.elements("page-type");
      for (Element pageType : pageTypes) {
        String pageTypeId = pageType.elementTextTrim("id");
        String pageTypeInstanceId = pageType.elementTextTrim("page-instance-id");
        configElement.pageTypes.put(pageTypeId, pageTypeInstanceId);
      }
      String _siteConfiguration = defaults.elementTextTrim("site-configuration");
      if (_siteConfiguration != null) {
        configElement.defaultSiteConfiguration = _siteConfiguration;
      }

      /** DEFAULT PERSISTER SETTING * */
      String _defaultPersisterId = defaults.elementText("persister");
      if (_defaultPersisterId != null) {
        configElement.defaultPersisterId = _defaultPersisterId;
      }
    }

    //////////////////////////////////////////////////////
    // Debug Timer
    //////////////////////////////////////////////////////

    Element debugElement = elem.element("debug");
    if (debugElement != null) {
      String _isTimerEnabled = debugElement.elementTextTrim("timer");
      if (_isTimerEnabled != null) {
        configElement.isTimerEnabled = Boolean.parseBoolean(_isTimerEnabled);
      }
    }

    //////////////////////////////////////////////////////
    // Type Specific Things
    //////////////////////////////////////////////////////

    List<Element> objectTypes = elem.elements("object-type");
    for (Element el : objectTypes) {
      TypeDescriptor descriptor = new TypeDescriptor(el);
      if (descriptor.useDefaultPerister() && configElement.getDefaultPersisterId() != null) {
        descriptor.setPersisterId(configElement.getDefaultPersisterId());
      }

      configElement.types.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Resource Loaders
    //////////////////////////////////////////////////////

    List<Element> loaders = elem.elements("resource-loader");
    for (Element el : loaders) {
      ResourceLoaderDescriptor descriptor = new ResourceLoaderDescriptor(el);
      configElement.resourceLoaders.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Resource Resolvers
    //////////////////////////////////////////////////////

    List<Element> resolvers = elem.elements("resource-resolver");
    for (Element el : resolvers) {
      ResourceResolverDescriptor descriptor = new ResourceResolverDescriptor(el);
      configElement.resourceResolvers.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Runtime Configuration
    //////////////////////////////////////////////////////
    List<Element> runtimeConfigElements = elem.elements("runtime-config");
    for (Element el : runtimeConfigElements) {
      RuntimeConfigDescriptor descriptor = new RuntimeConfigDescriptor(el);
      configElement.runtimeConfigs.put(descriptor.getId(), descriptor);
    }

    //////////////////////////////////////////////////////
    // Autowire Configuration
    //////////////////////////////////////////////////////
    Element autowireConfigElement = elem.element("autowire");
    if (autowireConfigElement != null) {
      String _autowireModeId = autowireConfigElement.elementTextTrim("mode");
      if (_autowireModeId != null) {
        configElement.autowireModeId = _autowireModeId;
      }
      String _autowireRuntimeId = autowireConfigElement.elementTextTrim("runtime");
      if (_autowireRuntimeId != null) {
        configElement.autowireRuntimeId = _autowireRuntimeId;
      }
    }

    //////////////////////////////////////////////////////
    // Persister Config Descriptor
    //////////////////////////////////////////////////////
    Element persisterConfigElement = elem.element("persisters");
    if (persisterConfigElement != null) {
      configElement.persisterConfigDescriptor =
          new PersisterConfigDescriptor(persisterConfigElement);
    }

    // Module Deployment mode...
    Element moduleDeploymentElement = elem.element("module-deployment");
    if (moduleDeploymentElement != null) {
      String _moduleDeploymentMode = moduleDeploymentElement.elementTextTrim("mode");
      if (_moduleDeploymentMode != null) {
        configElement.moduleDeploymentMode = _moduleDeploymentMode;
      }

      String _enableAutoDeployModules =
          moduleDeploymentElement.elementTextTrim("enable-auto-deploy-modules");
      if (_enableAutoDeployModules != null) {
        configElement.enableAutoDeployModules = Boolean.valueOf(_enableAutoDeployModules);
      }
    }

    // MNT-12724 case, externally specify paths that should be denied by ResourceController
    Element denyAccessPathsElement = elem.element("deny-access-resource-paths");
    if (denyAccessPathsElement != null) {
      List<Element> paths = denyAccessPathsElement.elements("resource-path-pattern");

      for (Element path : paths) {
        configElement.resourcesDeniedPaths.add(Pattern.compile(path.getTextTrim()));
      }
    }

    // When "use-checksum-dependencies" is set to true the JavaScriptDependencyDirective and
    // CssDependencyDirectives will be made available to FreeMarker templates...
    String useChecksumDependencies = elem.elementTextTrim("use-checksum-dependencies");
    if (useChecksumDependencies != null) {
      configElement.useChecksumDependencies = Boolean.valueOf(useChecksumDependencies);
    }

    String generateCssDataImages = elem.elementTextTrim("generate-css-data-images");
    if (generateCssDataImages != null) {
      configElement.generateCssDataImages = Boolean.valueOf(generateCssDataImages);
    }

    String aggregateDependencies = elem.elementTextTrim("aggregate-dependencies");
    if (aggregateDependencies != null) {
      configElement.aggregateDependencies = Boolean.valueOf(aggregateDependencies);
    }

    String calculateWebScriptDependencies =
        elem.elementTextTrim("calculate-webscript-dependencies");
    if (calculateWebScriptDependencies != null) {
      configElement.calculateWebScriptDependencies =
          Boolean.valueOf(calculateWebScriptDependencies);
    }

    String enableRemoteResources = elem.elementTextTrim("enable-remote-resource-resolving");
    if (enableRemoteResources != null) {
      configElement.enableRemoteResourceHandling = Boolean.valueOf(enableRemoteResources);
    }

    String enableGuestPageExtensionModules =
        elem.elementTextTrim("enable-guest-page-extension-modules");
    if (enableGuestPageExtensionModules != null) {
      configElement.enableExtensionModulesOnGuestPages =
          Boolean.valueOf(enableGuestPageExtensionModules);
    }

    String enableDynamicExtensionModules = elem.elementTextTrim("enable-dynamic-extension-modules");
    if (enableDynamicExtensionModules != null) {
      configElement.enableDynamicExtensions = Boolean.valueOf(enableDynamicExtensionModules);
    }

    String disableResourceCaching = elem.elementTextTrim("disable-resource-caching");
    if (disableResourceCaching != null) {
      configElement.disableResourceCaching = Boolean.valueOf(disableResourceCaching);
    }

    // Process any Dojo configuration...
    processDojoConfiguration(configElement, elem);

    return configElement;
  }
 /**
  * Parses this string as instance of a specific field in the given class
  *
  * @param field the related field (custom formatters are extracted from this field annotation)
  * @param text the text to parse
  * @param clazz class representing the required type
  * @return the parsed value
  */
 @SuppressWarnings("unchecked")
 public static <T> T parse(Field field, String text, Class<T> clazz) {
   return (T) conversion.convert(text, new TypeDescriptor(field), TypeDescriptor.valueOf(clazz));
 }
 public boolean hasClinit() {
   return typeDescriptor.hasClinit();
 }
Beispiel #29
0
 /**
  * Note: This method <em>doesn't</em> follow the usual convention of firing a property change. If
  * that functionality is needed, the code should be fixed.
  */
 public void setSizes(List<? extends Expression> sz) {
   typeDescriptor.sizes = (sz == null) ? null : new ArrayList<Expression>(sz);
 }
 public boolean hasConstructorChanged(String descriptor) {
   MethodMember mm = typeDescriptor.getConstructor(descriptor);
   return hasConstructorChanged(mm);
 }