コード例 #1
0
    /**
     * walks the {@link IObject} argument <em>non-</em>recursively and gathers all {@link IObject}
     * instances which will be linkd to by the creation or updating of the argument. (Previously
     * this was called "locking" since a flag was set on the object to mark it as linked, but this
     * was removed in 4.2)
     *
     * @param iObject A newly created or updated {@link IObject} instance which might possibly lock
     *     other {@link IObject IObjects}. A null argument will return an empty array to be checked.
     * @return A non-null array of {@link IObject IObjects} which will be linked to.
     */
    public IObject[] getLockCandidates(IObject iObject) {
      if (iObject == null) {
        return new IObject[] {};
      }

      Locks l = locksHolder.get(iObject.getClass().getName());
      return l.getLockCandidates(iObject);
    }
 @SubL(source = "cycl/operation-queues.lisp", position = 9125)
 public static final SubLObject local_operation_storage_queue_enqueue(SubLObject operation) {
   {
     final SubLThread thread = SubLProcess.currentSubLThread();
     {
       SubLObject lock = $local_operation_storage_queue_lock$.getDynamicValue(thread);
       SubLObject release = NIL;
       try {
         release = Locks.seize_lock(lock);
         queues.enqueue(operation, $local_operation_storage_queue$.getGlobalValue());
       } finally {
         if ((NIL != release)) {
           Locks.release_lock(lock);
         }
       }
     }
     return NIL;
   }
 }
 @SubL(source = "cycl/operation-queues.lisp", position = 5157)
 public static final SubLObject transcript_queue_dequeue() {
   {
     final SubLThread thread = SubLProcess.currentSubLThread();
     {
       SubLObject ans = NIL;
       SubLObject lock = $transcript_queue_lock$.getDynamicValue(thread);
       SubLObject release = NIL;
       try {
         release = Locks.seize_lock(lock);
         ans = queues.dequeue($transcript_queue$.getGlobalValue());
       } finally {
         if ((NIL != release)) {
           Locks.release_lock(lock);
         }
       }
       return ans;
     }
   }
 }
コード例 #4
0
    /**
     * examines all model objects to see which fields contain a {@link Type} which points to this
     * class. Uses {@link #locksFields(Type[])} since this is the inverse process.
     */
    private String[][] lockedByFields(String klass, Map<String, ClassMetadata> m) {
      if (m == null) {
        throw new InternalException("ClassMetadata map cannot be null.");
      }

      List<String[]> fields = new ArrayList<String[]>();

      for (String k : m.keySet()) {
        ClassMetadata cm = m.get(k);
        Type[] type = cm.getPropertyTypes();
        String[] names = cm.getPropertyNames();
        Locks inverse = locksHolder.get(k);
        for (int i = 0; i < inverse.size(); i++) {

          if (!inverse.include(i)) {
            continue;
          }

          // this is an embedded component and must be treated
          // specially. specifically, that we cannot compare against
          // the top-level returnedClass name but rather against
          // each of the individual subtype returnedClass names.
          if (inverse.hasSubtypes(i)) {
            for (int j = 0; j < inverse.numberOfSubtypes(i); j++) {
              if (inverse.subtypeEquals(i, j, klass)) {
                fields.add(new String[] {k, inverse.subtypeName(i, j)});
              }
            }
          }

          // no subtypes so can compare directly
          else if (klass.equals(type[i].getReturnedClass().getName())) {
            fields.add(new String[] {k, names[i]});
          }
        }
      }
      return fields.toArray(new String[fields.size()][2]);
    }
コード例 #5
0
 public String[][] getLockCandidateChecks(Class<? extends IObject> k, boolean onlyWithGroups) {
   Locks l = locksHolder.get(k.getName());
   return l.getLockCandidateChecks(onlyWithGroups);
 }
コード例 #6
0
    /**
     * Initializes the metadata needed by this instance.
     *
     * @param sessionFactory
     * @see SessionFactory#getAllClassMetadata()
     */
    public void setSessionFactory(SessionFactory sessionFactory) {

      if (initialized) {
        return; // EARLY EXIT !!
      }

      log.info("Calculating ExtendedMetadata...");

      SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory;
      Map<String, ClassMetadata> m = sessionFactory.getAllClassMetadata();

      // do Locks() first because they are used during the
      // calculation of LockedBy()
      for (String key : m.keySet()) {
        ClassMetadata cm = m.get(key);
        locksHolder.put(key, new Locks(cm));
      }

      // now that all Locks() are available, determine LockedBy()
      for (String key : m.keySet()) {
        lockedByHolder.put(key, lockedByFields(key, m));
      }

      for (String key : m.keySet()) {
        ClassMetadata cm = m.get(key);
        immutablesHolder.put(key, new Immutables(cm));
      }

      for (Map.Entry<String, ClassMetadata> entry : m.entrySet()) {
        String key = entry.getKey();
        ClassMetadata cm = entry.getValue();
        key = key.substring(key.lastIndexOf(".") + 1).toLowerCase();
        if (hibernateClasses.containsKey(key)) {
          throw new RuntimeException("Duplicate keys!: " + key);
        }
        hibernateClasses.put(key, cm.getMappedClass(EntityMode.POJO));
      }

      for (String key : m.keySet()) {
        Map<String, Relationship> value = new HashMap<String, Relationship>();
        ClassMetadata cm = m.get(key);
        for (Class<?> c : hierarchy(m, key)) {
          Locks locks = locksHolder.get(c.getName());
          locks.fillRelationships(sfi, value);
        }

        // FIXME: using simple name rather than FQN
        Map<String, Relationship> value2 = new HashMap<String, Relationship>();
        for (Map.Entry<String, Relationship> i : value.entrySet()) {
          String k = i.getKey();
          k = k.substring(k.lastIndexOf(".") + 1);
          value2.put(k, i.getValue());
        }
        relationships.put(key.substring(key.lastIndexOf(".") + 1), value2);
      }

      Set<Class<IAnnotated>> anns = new HashSet<Class<IAnnotated>>();
      Set<Class<Annotation>> anns2 = new HashSet<Class<Annotation>>();
      for (String key : m.keySet()) {
        ClassMetadata cm = m.get(key);
        Map<String, String> queries = countQueriesAndEditTargets(key, lockedByHolder.get(key));
        collectionCountHolder.putAll(queries);

        // Checking classes, specifically for ITypes
        Class c = cm.getMappedClass(EntityMode.POJO);
        if (IAnnotated.class.isAssignableFrom(c)) {
          anns.add(c);
        }
        if (Annotation.class.isAssignableFrom(c)) {
          anns2.add(c);
        }
      }
      annotatableTypes.addAll(anns);
      annotationTypes.addAll(anns2);
      initialized = true;
    }
 public static final SubLObject init_operation_queues_file() {
   $local_queue$ =
       deflexical(
           "*LOCAL-QUEUE*",
           ((NIL != Symbols.boundp($sym0$_LOCAL_QUEUE_))
               ? ((SubLObject) $local_queue$.getGlobalValue())
               : queues.create_queue()));
   $local_queue_lock$ =
       defparameter("*LOCAL-QUEUE-LOCK*", Locks.make_lock($str1$Local_Queue_Lock));
   $remote_queue$ =
       deflexical(
           "*REMOTE-QUEUE*",
           ((NIL != Symbols.boundp($sym3$_REMOTE_QUEUE_))
               ? ((SubLObject) $remote_queue$.getGlobalValue())
               : queues.create_queue()));
   $remote_queue_lock$ =
       defparameter("*REMOTE-QUEUE-LOCK*", Locks.make_lock($str4$Remote_Queue_Lock));
   $transcript_queue$ =
       deflexical(
           "*TRANSCRIPT-QUEUE*",
           ((NIL != Symbols.boundp($sym5$_TRANSCRIPT_QUEUE_))
               ? ((SubLObject) $transcript_queue$.getGlobalValue())
               : queues.create_queue()));
   $transcript_queue_lock$ =
       defparameter("*TRANSCRIPT-QUEUE-LOCK*", Locks.make_lock($str6$Transcript_Queue_Lock));
   $hl_transcript_queue$ =
       deflexical(
           "*HL-TRANSCRIPT-QUEUE*",
           ((NIL != Symbols.boundp($sym7$_HL_TRANSCRIPT_QUEUE_))
               ? ((SubLObject) $hl_transcript_queue$.getGlobalValue())
               : queues.create_queue()));
   $hl_transcript_queue_lock$ =
       defparameter("*HL-TRANSCRIPT-QUEUE-LOCK*", Locks.make_lock($str8$HL_Transcript_Queue_Lock));
   $auxiliary_queue$ =
       deflexical(
           "*AUXILIARY-QUEUE*",
           ((NIL != Symbols.boundp($sym9$_AUXILIARY_QUEUE_))
               ? ((SubLObject) $auxiliary_queue$.getGlobalValue())
               : queues.create_queue()));
   $auxiliary_queue_lock$ =
       defparameter("*AUXILIARY-QUEUE-LOCK*", Locks.make_lock($str10$Auxiliary_Queue_Lock));
   $transmit_queue$ =
       deflexical(
           "*TRANSMIT-QUEUE*",
           ((NIL != Symbols.boundp($sym11$_TRANSMIT_QUEUE_))
               ? ((SubLObject) $transmit_queue$.getGlobalValue())
               : queues.create_queue()));
   $transmit_queue_lock$ =
       defparameter("*TRANSMIT-QUEUE-LOCK*", Locks.make_lock($str12$Transmit_Queue_Lock));
   $local_operation_storage_queue$ =
       deflexical(
           "*LOCAL-OPERATION-STORAGE-QUEUE*",
           ((NIL != Symbols.boundp($sym13$_LOCAL_OPERATION_STORAGE_QUEUE_))
               ? ((SubLObject) $local_operation_storage_queue$.getGlobalValue())
               : queues.create_queue()));
   $local_operation_storage_queue_lock$ =
       defparameter(
           "*LOCAL-OPERATION-STORAGE-QUEUE-LOCK*",
           Locks.make_lock($str14$Local_Operation_Queue_Lock));
   $within_a_remote_opP$ = defparameter("*WITHIN-A-REMOTE-OP?*", NIL);
   $hl_transcripts_enabledP$ = defparameter("*HL-TRANSCRIPTS-ENABLED?*", NIL);
   $hl_transcript_special_operators$ = deflexical("*HL-TRANSCRIPT-SPECIAL-OPERATORS*", $list17);
   return NIL;
 }