Package org.jboss.aop

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


   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

        //assertEquals(1,baseNew.size());
  }

  private ClassProxy createPOJOProxy() throws Exception {
    ClassProxy proxy = ClassProxyFactory.newInstance(BaseClass.class);
        InstanceAdvisor advisor = proxy._getInstanceAdvisor();
        advisor.appendInterceptor(new LocalInterceptor(new BaseClass()));
    return proxy;
  }
View Full Code Here

    return proxy;
  }
 
  private ClassProxy createArrayListProxy() throws Exception {
    ClassProxy proxy = ClassProxyFactory.newInstance(ArrayList.class);
        InstanceAdvisor advisor = proxy._getInstanceAdvisor();
        advisor.appendInterceptor(new LocalInterceptorArrayList(new ArrayList()));
    return proxy;
  }
View Full Code Here

/* 254 */     if (this.instanceResolver != null) return this.instanceResolver;
/* 255 */     if (getTargetObject() != null)
/*     */     {
/* 257 */       if ((getTargetObject() instanceof InstanceAdvised))
/*     */       {
/* 259 */         InstanceAdvisor ia = ((InstanceAdvised)getTargetObject())._getInstanceAdvisor();
/* 260 */         if (ia != null)
/*     */         {
/* 263 */           this.instanceResolver = ia.getMetaData();
/* 264 */           return this.instanceResolver;
/*     */         }
/*     */       }
/*     */     }
/* 268 */     return null;
View Full Code Here

/* 158 */     makeRemotable(proxy, locator, objectId, interceptors, "AOP");
/*     */   }
/*     */
/*     */   public static void makeRemotable(InstanceAdvised proxy, InvokerLocator locator, Object objectId, List<Interceptor> interceptors, String subsystem)
/*     */   {
/* 173 */     InstanceAdvisor advisor = proxy._getInstanceAdvisor();
/* 174 */     for (Interceptor i : interceptors)
/* 175 */       advisor.insertInterceptor(i);
/* 176 */     advisor.getMetaData().addMetaData("REMOTING", "INVOKER_LOCATOR", locator, PayloadKey.AS_IS);
/*     */
/* 180 */     advisor.getMetaData().addMetaData("REMOTING", "SUBSYSTEM", subsystem, PayloadKey.AS_IS);
/*     */
/* 184 */     advisor.getMetaData().addMetaData("DISPATCHER", "OID", objectId, PayloadKey.AS_IS);
/*     */   }
View Full Code Here

/*  58 */     String proxyFamilyName = objectId.toString() + locator.getProtocol() + partitionName;
/*  59 */     HAPartition partition = (HAPartition)new InitialContext().lookup("/HAPartition/" + partitionName);
/*     */
/*  61 */     HATarget target = null;
/*  62 */     Map families = null;
/*  63 */     InstanceAdvisor advisor = null;
/*     */     Class clazz;
/*  66 */     if ((obj instanceof Advised))
/*     */     {
/*  68 */       advisor = ((Advised)obj)._getInstanceAdvisor();
/*  69 */       Class clazz = obj.getClass();
/*  70 */       Dispatcher.singleton.registerTarget(objectId, obj);
/*     */     }
/*     */     else
/*     */     {
/*  74 */       clazz = obj.getClass();
/*  75 */       ClassProxy proxy = ClassProxyFactory.newInstance(obj.getClass());
/*  76 */       advisor = proxy._getInstanceAdvisor();
/*  77 */       advisor.insertInterceptor(new ForwardingInterceptor(obj));
/*  78 */       Dispatcher.singleton.registerTarget(objectId, proxy);
/*     */     }
/*  80 */     families = (Map)advisor.getMetaData().getMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILIES");
/*  81 */     if (families != null)
/*     */     {
/*  83 */       target = (HATarget)families.get(proxyFamilyName);
/*  84 */       if (target == null)
/*     */       {
/*  86 */         target = new HATarget(partition, proxyFamilyName, locator, 2);
/*  87 */         ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
/*  88 */         families.put(proxyFamilyName, target);
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/*  93 */       families = new HashMap();
/*  94 */       target = new HATarget(partition, proxyFamilyName, locator, 2);
/*  95 */       ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
/*  96 */       families.put(proxyFamilyName, target);
/*  97 */       advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families));
/*     */     }
/*     */
/* 100 */     ClassProxy proxy = ClassProxyFactory.newInstance(clazz);
/* 101 */     InstanceAdvisor proxyAdvisor = proxy._getInstanceAdvisor();
/* 102 */     proxyAdvisor.insertInterceptor(IsLocalInterceptor.singleton);
/* 103 */     advisor.insertInterceptor(SecurityClientInterceptor.singleton);
/* 104 */     advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton);
/* 105 */     proxyAdvisor.insertInterceptor(MergeMetaDataInterceptor.singleton);
/* 106 */     proxyAdvisor.insertInterceptor(ClusterChooserInterceptor.singleton);
/* 107 */     proxyAdvisor.insertInterceptor(InvokeRemoteInterceptor.singleton);
/*     */
/* 109 */     proxyAdvisor.getMetaData().addMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILY_WRAPPER", new FamilyWrapper(proxyFamilyName, target.getReplicants()), PayloadKey.AS_IS);
/*     */
/* 115 */     proxyAdvisor.getMetaData().addMetaData("CLUSTERED_REMOTING", "LOADBALANCE_POLICY", lb, PayloadKey.AS_IS);
/*     */
/* 120 */     proxyAdvisor.getMetaData().addMetaData("REMOTING", "SUBSYSTEM", "AOP", PayloadKey.AS_IS);
/*     */
/* 125 */     proxyAdvisor.getMetaData().addMetaData("DISPATCHER", "OID", objectId, PayloadKey.AS_IS);
/*     */
/* 130 */     return proxy;
/*     */   }
View Full Code Here

/*     */   public static void unregisterClusteredObject(Object object)
/*     */   {
/*     */     try
/*     */     {
/* 137 */       ClassProxy proxy = (ClassProxy)object;
/* 138 */       InstanceAdvisor advisor = proxy._getInstanceAdvisor();
/*     */
/* 140 */       String oid = (String)advisor.getMetaData().getMetaData("DISPATCHER", "OID");
/* 141 */       InstanceAdvised registeredObject = (InstanceAdvised)Dispatcher.singleton.getRegistered(oid);
/* 142 */       if (registeredObject == null) throw new NotRegisteredException(oid.toString() + " is not registered");
/* 143 */       Dispatcher.singleton.unregisterTarget(oid);
/*     */
/* 145 */       advisor = registeredObject._getInstanceAdvisor();
/* 146 */       Map families = (Map)advisor.getMetaData().getMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILIES");
/* 147 */       Iterator it = families.values().iterator();
/* 148 */       while (it.hasNext())
/*     */       {
/* 150 */         HATarget target = (HATarget)it.next();
/* 151 */         target.destroy();
View Full Code Here

/*  59 */       Object callingObject = ((CallerInvocation)invocation).getCallingObject();
/*     */
/*  61 */       if (callingObject == null) return invocation.invokeNext();
/*     */
/*  63 */       Advised advised = (Advised)callingObject;
/*  64 */       InstanceAdvisor advisor = advised._getInstanceAdvisor();
/*  65 */       Interceptor interceptor = (Interceptor)advisor.getPerInstanceAspect(this.aspectDefinition);
/*  66 */       return interceptor.invoke(invocation);
/*     */     }
/*     */
/*  71 */     Object targetObject = invocation.getTargetObject();
/*  72 */     if (targetObject == null) return invocation.invokeNext();
/*     */
/*  74 */     InstanceAdvisor instanceAdvisor = null;
/*  75 */     if ((targetObject instanceof Advised))
/*     */     {
/*  77 */       Advised advised = (Advised)targetObject;
/*  78 */       instanceAdvisor = advised._getInstanceAdvisor();
/*     */     }
/*     */     else
/*     */     {
/*  82 */       Advisor advisor = invocation.getAdvisor();
/*  83 */       if (advisor == null)
/*     */       {
/*  85 */         return invocation.invokeNext();
/*     */       }
/*     */
/*  88 */       if ((advisor instanceof InstanceAdvisor))
/*     */       {
/*  90 */         instanceAdvisor = (InstanceAdvisor)advisor;
/*     */       }
/*  94 */       else if (((advisor instanceof ClassProxyContainer)) && ((invocation instanceof ContainerProxyMethodInvocation)))
/*     */       {
/*  96 */         ContainerProxyMethodInvocation pi = (ContainerProxyMethodInvocation)invocation;
/*  97 */         instanceAdvisor = pi.getProxy().getInstanceAdvisor();
/*     */       }
/*     */       else
/*     */       {
/* 101 */         return invocation.invokeNext();
/*     */       }
/*     */     }
/*     */
/* 105 */     Interceptor interceptor = (Interceptor)instanceAdvisor.getPerInstanceAspect(this.aspectDefinition);
/* 106 */     return interceptor.invoke(invocation);
/*     */   }
View Full Code Here

/* 118 */       Object callingObject = ((CallerInvocation)invocation).getCallingObject();
/*     */
/* 120 */       if (callingObject == null) return invocation.invokeNext();
/*     */
/* 122 */       Advised advised = (Advised)callingObject;
/* 123 */       InstanceAdvisor advisor = advised._getInstanceAdvisor();
/* 124 */       aspect = advisor.getPerInstanceJoinpointAspect(this.joinpoint, this.aspectDefinition);
/*     */     }
/*     */     else
/*     */     {
/* 128 */       Object targetObject = invocation.getTargetObject();
/* 129 */       if (targetObject == null) return invocation.invokeNext();
/*     */
/* 131 */       InstanceAdvisor instanceAdvisor = null;
/* 132 */       if ((targetObject instanceof Advised))
/*     */       {
/* 134 */         Advised advised = (Advised)targetObject;
/* 135 */         instanceAdvisor = advised._getInstanceAdvisor();
/*     */       }
/*     */       else
/*     */       {
/* 139 */         Advisor advisor = invocation.getAdvisor();
/* 140 */         if (advisor == null)
/*     */         {
/* 142 */           return invocation.invokeNext();
/*     */         }
/* 144 */         if ((advisor instanceof InstanceAdvisor))
/*     */         {
/* 146 */           instanceAdvisor = (InstanceAdvisor)advisor;
/*     */         }
/* 148 */         else if (((advisor instanceof ClassProxyContainer)) && ((invocation instanceof ContainerProxyMethodInvocation)))
/*     */         {
/* 150 */           ContainerProxyMethodInvocation pi = (ContainerProxyMethodInvocation)invocation;
/* 151 */           instanceAdvisor = pi.getProxy().getInstanceAdvisor();
/*     */         }
/*     */         else
/*     */         {
/* 155 */           return invocation.invokeNext();
/*     */         }
/*     */       }
/* 158 */       aspect = instanceAdvisor.getPerInstanceJoinpointAspect(this.joinpoint, this.aspectDefinition);
/*     */     }
/*     */
/* 161 */     if (!this.initialized)
/*     */     {
/* 163 */       init(this.adviceName, aspect.getClass());
View Full Code Here

TOP

Related Classes of org.jboss.aop.InstanceAdvisor

Copyright © 2018 www.massapicom. 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.