Examples of InstanceAdvisor


Examples of org.jboss.aop.InstanceAdvisor

         assertEquals(1, perClass2.constructorCalled);
         assertEquals(1, perClass2.methodCalled);
         assertEquals(1, perClass2.fieldRead);
         assertEquals(1, perClass2.fieldWrite);

         InstanceAdvisor ia = ((Advised) pojo)._getInstanceAdvisor();
         AspectPerInstance perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance");
         System.out.println("pojo perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite);
         assertEquals(1, perInstance.methodCalled);
         assertEquals(1, perInstance.fieldRead);
         assertEquals(1, perInstance.fieldWrite);

         ia = ((Advised) pojo2)._getInstanceAdvisor();
         perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance");
         System.out.println("pojo2 perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite);
         assertEquals(1, perInstance.methodCalled);
         assertEquals(1, perInstance.fieldRead);
         assertEquals(1, perInstance.fieldWrite);
      }
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

         assertEquals(1, perClass2.constructorCalled);
         assertEquals(1, perClass2.methodCalled);
         assertEquals(1, perClass2.fieldRead);
         assertEquals(1, perClass2.fieldWrite);

         InstanceAdvisor ia = ((Advised) pojo)._getInstanceAdvisor();
         AspectPerInstance perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance");
         System.out.println("pojo perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite);
         assertEquals(1, perInstance.methodCalled);
         assertEquals(1, perInstance.fieldRead);
         assertEquals(1, perInstance.fieldWrite);

         ia = ((Advised) pojo2)._getInstanceAdvisor();
         perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance");
         System.out.println("pojo2 perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite);
         assertEquals(1, perInstance.methodCalled);
         assertEquals(1, perInstance.fieldRead);
         assertEquals(1, perInstance.fieldWrite);
      }
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

   public void XtestSerialization() throws Throwable
   {

      Person p = (Person) tester.testSerialization();
      if (p instanceof Advised) {
         InstanceAdvisor advisor = ((Advised) p)._getInstanceAdvisor();
         org.jboss.aop.advice.Interceptor[] interceptors = advisor.getInterceptors();
         for (int i = 0; i < interceptors.length; i++) {
            assertTrue("CacheInterceptor shouldn't be serialized",
                  !(interceptors[i] instanceof AbstractInterceptor));
         }
      }
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
   {
      Advised advised = ((Advised) result);
      InstanceAdvisor advisor = advised._getInstanceAdvisor();
      Advisor advisorAdvisor = advised._getAdvisor();
      CachedType type = cache_.getCachedType(clazz);
      for (Iterator i = type.getFieldsIterator(); i.hasNext();) {
         Field field = (Field) i.next();

         Object value = null;

         CachedType fieldType = cache_.getCachedType(field.getType());
         if (fieldType.isImmediate()|| CachedType.hasSerializableAnnotation(field, advisorAdvisor)) {
            value = cache_.get(fqn, field.getName());
         } else {
            value = _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);
            value = ((AbstractCollectionInterceptor)interceptor).getOriginalInstance();
         }
        
         try {
            field.set(result, value);
         } 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

         Object callingObject = ((CallerInvocation) invocation).getCallingObject();

         if (callingObject == null) return invocation.invokeNext(); // called from static method
        
         Advised advised = (Advised) callingObject;
         InstanceAdvisor advisor = advised._getInstanceAdvisor();
         aspect = advisor.getPerInstanceAspect(aspectDefinition);
      }
      else
      {   
        Object targetObject = invocation.getTargetObject();
        if (targetObject == null) return invocation.invokeNext(); // static method call or static field call
 
          InstanceAdvisor instanceAdvisor = null;
          if (targetObject instanceof Advised)
          {
             Advised advised = (Advised)targetObject;
             instanceAdvisor = advised._getInstanceAdvisor();
          }
          else
          {
             Advisor advisor = invocation.getAdvisor();
             if (advisor == null)
             {
                return invocation.invokeNext();
             }
             else if (advisor instanceof InstanceAdvisor)
             {
                instanceAdvisor = (InstanceAdvisor) advisor;
             }
             else if (advisor instanceof ClassProxyContainer && invocation instanceof ContainerProxyMethodInvocation)
             {
                ContainerProxyMethodInvocation pi = (ContainerProxyMethodInvocation)invocation;
                instanceAdvisor = pi.getProxy().getInstanceAdvisor();
             }
             else
             {
                return invocation.invokeNext();
             }
          }
          aspect = instanceAdvisor.getPerInstanceAspect(aspectDefinition);
      }
     
      if (!initialized)
      {
         init(adviceName, aspect.getClass());
View Full Code Here

Examples of org.jboss.aop.InstanceAdvisor

         Object callingObject = ((CallerInvocation) invocation).getCallingObject();

         if (callingObject == null) return invocation.invokeNext(); // called from static method
        
         Advised advised = (Advised) callingObject;
         InstanceAdvisor advisor = advised._getInstanceAdvisor();
         Interceptor interceptor = (Interceptor) advisor.getPerInstanceJoinpointAspect(joinpoint, aspectDefinition);
         return interceptor.invoke(invocation);        
        
      }
      else
      {
         Object targetObject = invocation.getTargetObject();
         if (targetObject == null) return invocation.invokeNext(); // static method call or static field call

         InstanceAdvisor instanceAdvisor = null;
         if (targetObject instanceof Advised)
         {
            Advised advised = (Advised) targetObject;
            instanceAdvisor = advised._getInstanceAdvisor();
         }
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.