Package org.jboss.aop

Examples of org.jboss.aop.Advised


         //to make sure that there is only one instance per target rather than caller
         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);
            }
View Full Code Here


   private InstanceAdvisor getInstanceAdvisor(Invocation invocation, Object targetObject)
   {
      if (targetObject instanceof Advised)
      {
         Advised advised = (Advised) targetObject;
         return advised._getInstanceAdvisor();
      }
      Advisor advisor = invocation.getAdvisor();
      if (advisor == null)
      {
         return null;
View Full Code Here

      {
         version = new MarshalledValue(currentObject).get();
         if (version instanceof Advised)
         {
            // REVISIT: Currently share the InstanceAdvisor between versions
            Advised versionAdvised = (Advised)version;
            Advised currentAdvised = (Advised)currentObject;
            versionAdvised._setInstanceAdvisor(currentAdvised._getInstanceAdvisor());
         }
         versionId = ++versionIdGenerator;
      }
      finally
      {
View Full Code Here

         //to make sure that there is only one instance per target rather than caller
         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)
View Full Code Here

   }

   public static void makePerFieldVersioned(Object target) throws Exception
   {
      if (!(target instanceof Advised)) throw new IllegalArgumentException("Cannot do per field versioning with a non-Advised object");
      Advised advised = (Advised)target;
      getLocalVersionManager().makeVersioned(advised);
   }
View Full Code Here

   {
      log.trace("building a " + classname + " of guid " + guid);
      this.versionManager = versionManager;
      this.synchManager = manager;
      Class clazz = Thread.currentThread().getContextClassLoader().loadClass(classname);
      Advised advised = (Advised)clazz.newInstance();
      this.advisedRef = new WeakReference(advised);
      versionManager.addVersioning(this, advised);
      manager.putState(guid, this);
      manager.putObject(guid, advised);

      Iterator it = fieldMap.values().iterator();
      while(it.hasNext())
      {
         DistributedFieldUpdate update = (DistributedFieldUpdate)it.next();
         ClassAdvisor advisor = (ClassAdvisor)advised._getAdvisor();
         log.trace("build field " + advisor.getAdvisedFields()[update.getFieldIndex()].getName());
         Object val = update.getNonDereferencedValue();
         if (val != null && (val instanceof VersionReference))
         {
            VersionReference ref = (VersionReference)val;
View Full Code Here

      Integer index = new Integer(fieldInvocation.getIndex());
      Object val = fieldInvocation.getValue();

      if (val instanceof Advised)
      {
         Advised advisedValue = (Advised)val;
         val = versionManager.makeVersioned(advisedValue);
      }

      Transaction tx = tm.getTransaction();
      if (tx == null)
View Full Code Here

         Integer index = (Integer)entry.getKey();
         DistributedFieldUpdate update = (DistributedFieldUpdate)entry.getValue();
         DistributedFieldUpdate orig = (DistributedFieldUpdate)fieldMap.get(index);
         if (update.getVersionId() <= orig.getVersionId())
         {
            Advised advised = null;
            if (advisedRef != null)
            {
               advised = (Advised)advisedRef.get();
            }
            if (advised != null)
            {
               ClassAdvisor advisor = (ClassAdvisor)advised._getAdvisor();
               Field field = advisor.getAdvisedFields()[index.intValue()];
               throw new OptimisticLockFailure("optimistic lock failure for field " + field.getName()
                                               + " of class " + field.getDeclaringClass().getName());
            }
         }
View Full Code Here

         else
         {
            return obj;
         }
      }
      Advised advised = (Advised)obj;
      org.jboss.aop.metadata.SimpleMetaData metaData = advised._getInstanceAdvisor().getMetaData();
      GUID guid;
      synchronized (metaData)
      {
         if (isVersioned(advised)) return obj;
         guid = tag(advised);
      }
      System.out.println("VersionManager: " + guid);
      DistributedPOJOState manager = new DistributedPOJOState(guid, timeout, advised, this, synchManager);
      StateManager.setStateManager(advised, manager);
      StateChangeInterceptor interceptor = new StateChangeInterceptor(manager);
      manager.acquireWriteLock();
      advised._getInstanceAdvisor().appendInterceptor(interceptor);
      try
      {
         Field[] advisedFields = ((ClassAdvisor)advised._getAdvisor()).getAdvisedFields();
         for (int i = 0; i < advisedFields.length; i++)
         {
            Field field = advisedFields[i];
            if (Modifier.isStatic(field.getModifiers())) continue;
            Object fieldVal = field.get(advised);
            if (fieldVal != null)
            {
               if (fieldVal instanceof Advised)
               {
                  Advised fieldAdvised = (Advised)fieldVal;
                  makeVersioned(fieldAdvised, newObjects);
                  fieldVal = new VersionReference(getGUID(fieldAdvised), fieldAdvised);
               }
               else if (fieldVal instanceof List)
               {
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;
View Full Code Here

TOP

Related Classes of org.jboss.aop.Advised

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.