Examples of InstanceAdvisor


Examples of org.jboss.aop.InstanceAdvisor

      {
         Object obj = it.next();

         if (obj instanceof InstanceAdvisor)
         {
            InstanceAdvisor advisor = (InstanceAdvisor) obj;
            BaseInterceptor interceptor = (BaseInterceptor) undoMap.get(advisor);

            if (interceptor == null)
            {
               throw new IllegalStateException("PojoCacheDelegate.undoInterceptorDetach(): null interceptor");
            }

            advisor.appendInterceptor(interceptor);
         }
         else
         {
            BaseInterceptor interceptor = (BaseInterceptor) undoMap.get(obj);
            boolean copyToCache = false;
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

               {
                  Interceptor icptr = null;
                  if (icptrs[i] instanceof PerInstanceInterceptor && !Modifier.isStatic(info.getMethod().getModifiers()))
                  {
                     requiresInstanceAdvisor = true;
                     InstanceAdvisor ia = getProxyInstanceAdvisor();
                     icptr = ((PerInstanceInterceptor)icptrs[i]).getAspectInstance(ia);
                  }
                  else if (icptrs[i] instanceof PerJoinpointInterceptor && !Modifier.isStatic(info.getMethod().getModifiers()))
                  {
                     requiresInstanceAdvisor = true;
                     InstanceAdvisor ia = getProxyInstanceAdvisor();
                     icptr = ((PerJoinpointInterceptor)icptrs[i]).getAspectInstance(ia);
                  }
                  else
                  {
                     icptr = icptrs[i];
                  }
                  allIcptrs.add(icptr);
               }
               else
               {
                  AbstractAdvice advice = (AbstractAdvice)icptrs[i];
                  Object aspectInstance = null;
                  if (icptrs[i] instanceof PerInstanceAdvice && !Modifier.isStatic(info.getMethod().getModifiers()))
                  {
                     requiresInstanceAdvisor = true;
                     InstanceAdvisor ia = getProxyInstanceAdvisor();
                     aspectInstance = ((PerInstanceAdvice)advice).getAspectInstance(ia);
                  }
                  else if (icptrs[i] instanceof PerJoinpointAdvice && !Modifier.isStatic(info.getMethod().getModifiers()))
                  {
                     requiresInstanceAdvisor = true;
                     InstanceAdvisor ia = getProxyInstanceAdvisor();
                     aspectInstance = ((PerJoinpointAdvice)advice).getAspectInstance(ia);
                  }
                  else
                  {
                     aspectInstance = advice.getAspectInstance();
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

         }
      }
     
      private InstanceAdvisor getProxyInstanceAdvisor()
      {
         InstanceAdvisor ia = proxy.proxyInstance.getInstanceAdvisor();
         proxy.checkInstanceAdvisor((InstanceProxyContainer)ia);
         return ia;
      }
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

         detached = true;
         Object obj = invocation.getTargetObject();
         if(! (obj instanceof Advised) )
            throw new RuntimeException("Interception on non-advised pojo " +obj.toString());

         InstanceAdvisor advisor = ((Advised)obj)._getInstanceAdvisor();
         CacheInterceptor interceptor = (CacheInterceptor) AopUtil.findCacheInterceptor(advisor);
         if (interceptor != null)
         {
            if (log_.isDebugEnabled()) {
               log_.debug("isPojoDetached(): removed cache interceptor fqn: " + fqn + " interceptor: "+interceptor);
            }
            advisor.removeInterceptor(interceptor.getName());
         }
      }

      return detached;
   }
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

         }
         catch(Exception e) {
            throw new CacheException("failed creating instance of " + clazz.getName(), e);
         }
         // Insert interceptor at runtime
         InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor();
         CacheInterceptor interceptor = new CacheInterceptor(cache_, fqn, type);
         interceptor.setAopInstance(aopInstance);
         advisor.appendInterceptor(interceptor);
         cache_.addUndoInterceptor(advisor, interceptor, ModificationEntry.INTERCEPTOR_ADD);

      } else { // Must be Collection classes. We will use aop.ClassProxy instance instead.
         try {
            if( (obj = collectionHandler_.collectionObjectGet(fqn, clazz)) != null ) {
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

      // store object in cache
      if (obj instanceof Advised) {
         CachedType type = cache_.getCachedType(obj.getClass());
         // add interceptor
         InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor();
         if(advisor == null)
            throw new RuntimeException("_putObject(): InstanceAdvisor is null for: " +obj);

         // Step Check for cross references
         Interceptor interceptor = AopUtil.findCacheInterceptor(advisor);
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

      {
         Object obj = it.next();

         if(obj instanceof InstanceAdvisor)
         {
            InstanceAdvisor advisor = (InstanceAdvisor)obj;
            BaseInterceptor interceptor = (BaseInterceptor)undoMap.get(advisor);

            if(interceptor == null)
            {
               throw new IllegalStateException("TreeCacheAopDelegate.undoInterceptorDetach(): null interceptor");
            }

            advisor.appendInterceptor(interceptor);
         } else
         {
            BaseInterceptor interceptor = (BaseInterceptor)undoMap.get(obj);
            boolean copyToCache = false;
            ((AbstractCollectionInterceptor)interceptor).attach(null, copyToCache);
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

   protected boolean pojoGraphMultipleReferenced(Object obj, Map undoMap) throws CacheException {
      // store object in cache
      if (obj instanceof Advised) {
         CachedType type = cache_.getCachedType(obj.getClass());
         // add interceptor
         InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor();
         if(advisor == null)
            throw new RuntimeException("pojoGraphMultipleReferenced(): InstanceAdvisor is null for: " +obj);

         BaseInterceptor interceptor = (BaseInterceptor)AopUtil.findCacheInterceptor(advisor);
         // just in case
         if(interceptor == null)
         {
            return false;
         }
         AOPInstance aopInstance = interceptor.getAopInstance();
         // Check if there is cross referenced.
         if(aopInstance.getRefCount() != 0) return true; // I have been referenced
         if(aopInstance.getRefFqn() != null) return true; // I am referencing others

         boolean hasFieldAnnotation = hasAnnotation(obj.getClass(), ((Advised)obj)._getAdvisor(), type);
         // Check the fields
         for (Iterator i = type.getFieldsIterator(); i.hasNext();) {
            Field field = (Field) i.next();
            Object value = null;
            try {
               value=field.get(obj);
            }
            catch(IllegalAccessException e) {
               throw new CacheException("field access failed", e);
            }

            CachedType fieldType = cache_.getCachedType(field.getType());

            // we simply treat field that has @Serializable as a primitive type.
            if (fieldType.isImmediate() ||
                    (hasFieldAnnotation &&
                            CachedType.hasSerializableAnnotation(field, ((Advised)obj)._getAdvisor())))
            {
               continue;
            }

            // check for non-replicatable types
            if(CachedType.isNonReplicatable(field, ((Advised)obj)._getAdvisor()))
            {
               continue;
            }

            if(!hasFieldAnnotation)
            {
               if(CachedType.hasTransientAnnotation(field, ((Advised)obj)._getAdvisor()))
               {
                  continue;
               }
            }

            // Need to do a getObject just in case this is a failover removeObject.
            if(value == null)
              value = _getObject(new Fqn(interceptor.getFqn(), field.getName()));

            if(value == null) continue; // this is no brainer.

            if(pojoGraphMultipleReferenced(value, undoMap)) return true;
         }
         boolean detachOnly = false;
         detachInterceptor(advisor, interceptor, detachOnly, undoMap);
      } else if (obj instanceof Map || obj instanceof List || obj instanceof Set)
      {
         // TODO Is this really necessary?
         if(!(obj instanceof ClassProxy)) return false;

         InstanceAdvisor advisor = ((ClassProxy)obj)._getInstanceAdvisor();
         BaseInterceptor interceptor = (BaseInterceptor)AopUtil.findCollectionInterceptor(advisor);
         AOPInstance aopInstance = interceptor.getAopInstance();
         if(aopInstance == null) return false; // safeguard
         // Check if there is cross referenced.
         if(aopInstance.getRefCount() != 0) return true; // I have been referenced
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

   }

   protected void _regularRemoveObject(Fqn fqn, boolean removeCacheInterceptor, Object result, Class clazz,
                                       boolean evict) throws CacheException
   {
      InstanceAdvisor advisor = ((Advised) result)._getInstanceAdvisor();
      CachedType type = cache_.getCachedType(clazz);
      for (Iterator i = type.getFieldsIterator(); i.hasNext();) {
         Field field = (Field) i.next();

         Object value = null;
         try {
            value=field.get(result);
         }
         catch(IllegalAccessException e) {
            throw new CacheException("field access failed", e);
         }

         CachedType fieldType = cache_.getCachedType(field.getType());
         if (!fieldType.isImmediate()) {
            _removeObject(new Fqn(fqn, field.getName()), removeCacheInterceptor, evict);
         }

         // Check for Collection field so we need to restore the original reference.
         if(value instanceof ClassProxy)
         {
            Interceptor interceptor = CollectionInterceptorUtil.getInterceptor((ClassProxy)value);
            Object ori = ((AbstractCollectionInterceptor)interceptor).getOriginalInstance();
            try {
               field.set(result, ori);
            } catch (IllegalAccessException e) {
               throw new CacheException("field access failed", e);
            }
         }
      }

      // batch remove
      cache_.removeData(fqn);

      // Determine if we want to keep the interceptor for later use.
      if(removeCacheInterceptor) {
         CacheInterceptor interceptor = (CacheInterceptor) AopUtil.findCacheInterceptor(advisor);
         // Remember to remove the interceptor from in-memory object but make sure it belongs to me first.
         if (interceptor != null)
         {
            if (log.isDebugEnabled()) {
               log.debug("regularRemoveObject(): removed cache interceptor fqn: " + fqn + " interceptor: "+interceptor);
            }
            advisor.removeInterceptor(interceptor.getName());
            cache_.addUndoInterceptor(advisor, interceptor, ModificationEntry.INTERCEPTOR_REMOVE);
         }
      }

   }
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

      // Rollback the pojo interceptor add/remove
      List list = cache_.getModList();
      if (list != null) {
         for (int i = (list.size() - 1); i >= 0; i--) {
            ModificationEntry ent = (ModificationEntry) list.get(i);
            InstanceAdvisor advisor = ent.getInstanceAdvisor();
            BaseInterceptor interceptor = ent.getCacheInterceptor();
            switch (ent.getOpType()) {
               case ModificationEntry.INTERCEPTOR_ADD:
                  advisor.removeInterceptor(interceptor.getName());
                  break;
               case ModificationEntry.INTERCEPTOR_REMOVE:
                  advisor.appendInterceptor(interceptor);
                  break;
               case ModificationEntry.COLLECTION_REPLACE:
                  Field field = ent.getField();
                  Object key = ent.getKey();
                  Object value = ent.getOldValue();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.