Package org.jboss.aop

Examples of org.jboss.aop.InstanceAdvisor


         Object callingObject = ((CallerInvocation) invocation).getCallingObject();
         // called from non-static method
         if (callingObject != null)
         {
            Advised advised = (Advised) callingObject;
            InstanceAdvisor advisor = advised._getInstanceAdvisor();
            Interceptor interceptor = (Interceptor) advisor.getPerInstanceJoinpointAspect(joinpoint, aspectDefinition);
            if (interceptor != null)
            {
               return interceptor.invoke(invocation);
            }
         }
        
      }
      else
      {
         Object targetObject = invocation.getTargetObject();
         // non-static method call or non-static field call
         if (targetObject != null)
         {
            InstanceAdvisor instanceAdvisor = getInstanceAdvisor(invocation, targetObject);
            if (instanceAdvisor != null)
            {
               Interceptor interceptor = getAspectInstance(instanceAdvisor);
               if (interceptor != null)
               {
View Full Code Here


               {
                  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];
                  }
                  if (icptr != null)
                  {
                     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

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

      if (instanceResolver != null) return instanceResolver;
      if (getTargetObject() != null)
      {
         if (getTargetObject() instanceof InstanceAdvised)
         {
            InstanceAdvisor ia = ((InstanceAdvised) getTargetObject())._getInstanceAdvisor();
            if (ia != null)
            {

               instanceResolver = ia.getMetaData();
               return instanceResolver;
            }
         }
      }
      return null;
View Full Code Here

      String proxyFamilyName = objectId.toString() + locator.getProtocol() + partitionName;
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);

      HATarget target = null;
      Map families = null;
      InstanceAdvisor advisor = null;
      Class clazz;

      if (obj instanceof Advised)
      {
         advisor = ((Advised) obj)._getInstanceAdvisor();
         clazz = obj.getClass();
         Dispatcher.singleton.registerTarget(objectId, obj);
      }
      else
      {
         clazz = obj.getClass();
         ClassProxy proxy = ClassProxyFactory.newInstance(obj.getClass());
         advisor = proxy._getInstanceAdvisor();
         advisor.insertInterceptor(new ForwardingInterceptor(obj));
         Dispatcher.singleton.registerTarget(objectId, proxy);
      }
      families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES);
      if (families != null)
      {
         target = (HATarget) families.get(proxyFamilyName);
         if (target == null)
         {
            target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
            ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
            families.put(proxyFamilyName, target);
         }
      }
      else
      {
         families = new HashMap();
         target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
         ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
         families.put(proxyFamilyName, target);
         advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families));
      }

      ClassProxy proxy = ClassProxyFactory.newInstance(clazz);
      InstanceAdvisor proxyAdvisor = proxy._getInstanceAdvisor();
      proxyAdvisor.insertInterceptor(IsLocalInterceptor.singleton);
      advisor.insertInterceptor(SecurityClientInterceptor.singleton);
      advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton);
      proxyAdvisor.insertInterceptor(MergeMetaDataInterceptor.singleton);
      proxyAdvisor.insertInterceptor(ClusterChooserInterceptor.singleton);
      proxyAdvisor.insertInterceptor(InvokeRemoteInterceptor.singleton);

      proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
      CLUSTER_FAMILY_WRAPPER,
      new FamilyWrapper(proxyFamilyName, target.getReplicants()),
      PayloadKey.AS_IS);

      // LB policy should be AS_IS so that remoting framework downloads the classes
      proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
      LOADBALANCE_POLICY,
      lb,
      PayloadKey.AS_IS);

      proxyAdvisor.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING,
      InvokeRemoteInterceptor.SUBSYSTEM,
      "AOP",
      PayloadKey.AS_IS);

      proxyAdvisor.getMetaData().addMetaData(Dispatcher.DISPATCHER,
      Dispatcher.OID,
      objectId,
      PayloadKey.AS_IS);

      return proxy;
View Full Code Here

   public static void unregisterClusteredObject(Object object)
   {
      try
      {
         ClassProxy proxy = (ClassProxy) object;
         InstanceAdvisor advisor = proxy._getInstanceAdvisor();

         String oid = (String) advisor.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
         InstanceAdvised registeredObject = (InstanceAdvised) Dispatcher.singleton.getRegistered(oid);
         if (registeredObject == null) throw new NotRegisteredException(oid.toString() + " is not registered");
         Dispatcher.singleton.unregisterTarget(oid);

         advisor = registeredObject._getInstanceAdvisor();
         Map families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES);
         Iterator it = families.values().iterator();
         while (it.hasNext())
         {
            HATarget target = (HATarget) it.next();
            target.destroy();
View Full Code Here

         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.getPerInstanceJoinpointAspect(joinpoint, 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.getPerInstanceJoinpointAspect(joinpoint, aspectDefinition);
     
     
      if (!initialized)
      {
         init(adviceName, aspect.getClass());
View Full Code Here

         }
         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

      // 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

      {
         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

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.