Ejemplo n.º 1
0
 public virtual void AddCallback(Net.Vpc.Upa.Callback callback)
 {
     if (callback.GetCallbackType() == Net.Vpc.Upa.CallbackType.ON_EVAL)
     {
         throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported", callback.GetCallbackType());
     }
     listeners.AddCallback(callback);
 }
Ejemplo n.º 2
0
        public virtual void AddCallback(Net.Vpc.Upa.Callback callback)
        {
            Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback        dcallback = (Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback)callback;
            System.Collections.Generic.IDictionary <string, object> conf      = dcallback.GetConfiguration();
            //        if (conf == null) {
            //            conf = new HashMap<String, Object>();
            //        }
            bool   fireBefore         = callback.GetPhase() == Net.Vpc.Upa.EventPhase.BEFORE;
            string nameFilter         = null;
            bool   trackSystemObjects = true;

            if (conf != null && conf.ContainsKey("trackSystemObjects"))
            {
                trackSystemObjects = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "trackSystemObjects")).Value;
            }
            nameFilter = conf == null ? null : (string)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "nameFilter");
            if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(nameFilter))
            {
                nameFilter = null;
            }
            if (fireBefore)
            {
                Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
                System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(this.before, k);
                if (ss == null)
                {
                    ss             = new System.Collections.Generic.List <Net.Vpc.Upa.Callback>();
                    this.before[k] = ss;
                }
                ss.Add(callback);
            }
            else
            {
                Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
                System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(this.after, k);
                if (ss == null)
                {
                    ss            = new System.Collections.Generic.List <Net.Vpc.Upa.Callback>();
                    this.after[k] = ss;
                }
                ss.Add(callback);
                if (callback is Net.Vpc.Upa.PreparedCallback)
                {
                    System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> sss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> >(this.preparedAfter, k);
                    if (sss == null)
                    {
                        sss = new System.Collections.Generic.List <Net.Vpc.Upa.PreparedCallback>();
                        this.preparedAfter[k] = sss;
                    }
                    sss.Add((Net.Vpc.Upa.PreparedCallback)callback);
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void RemoveCallback(Net.Vpc.Upa.Callback callback)
        {
            Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback        dcallback = (Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback)callback;
            System.Collections.Generic.IDictionary <string, object> conf      = dcallback.GetConfiguration();
            //        if (conf == null) {
            //            conf = new HashMap<String, Object>();
            //        }
            bool   fireBefore         = true;
            bool   fireAfter          = true;
            bool   trackSystemObjects = true;
            string nameFilter         = null;

            if (conf != null)
            {
                if (conf.ContainsKey("before"))
                {
                    fireBefore = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "before")).Value;
                }
                if (conf.ContainsKey("after"))
                {
                    fireBefore = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "after")).Value;
                }
                if (conf.ContainsKey("trackSystemObjects"))
                {
                    trackSystemObjects = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "trackSystemObjects")).Value;
                }
                nameFilter = (string)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "nameFilter");
            }
            if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(nameFilter))
            {
                nameFilter = null;
            }
            Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
            System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(before, k);
            if (ss != null)
            {
                ss.Remove(callback);
            }
            ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(after, k);
            if (ss != null)
            {
                ss.Remove(callback);
            }
            if (callback is Net.Vpc.Upa.PreparedCallback)
            {
                System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> sss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> >(preparedAfter, k);
                if (sss != null)
                {
                    sss.Remove((Net.Vpc.Upa.PreparedCallback)callback);
                }
            }
        }
 public virtual void RemoveCallback(Net.Vpc.Upa.Callback callback)
 {
     callbackManager.RemoveCallback(callback);
 }
 public virtual void AddCallback(Net.Vpc.Upa.Callback callback)
 {
     callbackManager.AddCallback(callback);
 }
Ejemplo n.º 6
0
 public virtual void PersistenceUnitItemScanned(Net.Vpc.Upa.ScanEvent @event)
 {
     if (listener != null)
     {
         listener.PersistenceUnitItemScanned(@event);
     }
     Net.Vpc.Upa.PersistenceUnit persistenceUnit = @event.GetPersistenceUnit();
     System.Type contract = @event.GetContract();
     System.Type type     = @event.GetVisitedType();
     if (Net.Vpc.Upa.Impl.Config.URLAnnotationStrategySupport.IsPersistenceUnitItemDefinitionListener(contract))
     {
         object i = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type);
         if (i == null)
         {
             i = persistenceUnit.GetFactory().CreateObject <object>(type);
             instances[type] = i;
         }
         Net.Vpc.Upa.Config.Decoration at = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject();
         string _filter             = at.GetString("filter");
         bool   _trackSystemObjects = at.GetBoolean("trackSystemObjects");
         //                    Callback cb = (Callback) at.getAnnotation();
         if ((_filter).Length == 0)
         {
             persistenceUnit.AddDefinitionListener((Net.Vpc.Upa.Callbacks.DefinitionListener)i, _trackSystemObjects);
         }
         else
         {
             persistenceUnit.AddDefinitionListener(_filter, (Net.Vpc.Upa.Callbacks.DefinitionListener)i, _trackSystemObjects);
         }
     }
     else if (typeof(Net.Vpc.Upa.Callbacks.PersistenceUnitListener).Equals(contract))
     {
         object i = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type);
         if (i == null)
         {
             i = persistenceUnit.GetFactory().CreateObject <object>(type);
             instances[type] = i;
         }
         persistenceUnit.AddPersistenceUnitListener((Net.Vpc.Upa.Callbacks.PersistenceUnitListener)i);
     }
     else if (typeof(Net.Vpc.Upa.Callbacks.EntityInterceptor).Equals(contract))
     {
         Net.Vpc.Upa.Callbacks.EntityInterceptor i = (Net.Vpc.Upa.Callbacks.EntityInterceptor)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, object>(instances, type);
         if (i == null)
         {
             try {
                 i = (Net.Vpc.Upa.Callbacks.EntityInterceptor)persistenceUnit.GetFactory().CreateObject <object>(type);
             } catch (System.Exception ex) {
                 log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(null, ex));
             }
             if (i != null)
             {
                 instances[type] = i;
             }
         }
         if (i != null)
         {
             Net.Vpc.Upa.Config.Decoration at = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject();
             string _filter = at.GetString("filter");
             string _name   = at.GetString("name");
             if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(_name))
             {
                 _name = (i.GetType()).Name;
             }
             bool _trackSystemObjects = at.GetBoolean("trackSystemObjects");
             //                    Callback cb = (Callback) at.getAnnotation();
             persistenceUnit.AddTrigger(_name, i, _filter, _trackSystemObjects);
         }
     }
     else if (typeof(Net.Vpc.Upa.EntityDescriptor).Equals(@event.GetContract()))
     {
         Net.Vpc.Upa.EntityDescriptor desc = (Net.Vpc.Upa.EntityDescriptor)@event.GetUserObject();
         persistenceUnit.AddEntity(desc);
     }
     else if (typeof(Net.Vpc.Upa.Function).Equals(@event.GetContract()))
     {
         Net.Vpc.Upa.Function          f = (Net.Vpc.Upa.Function)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType());
         Net.Vpc.Upa.Config.Decoration d = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject();
         //                net.vpc.upa.config.FunctionDefinition d = type.getAnnotation();
         Net.Vpc.Upa.Types.DataType dt = Net.Vpc.Upa.Types.TypesFactory.ForPlatformType(d.GetType("returnType"));
         string n = d.GetString("name");
         if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(n))
         {
             n = d.GetLocationType();
         }
         persistenceUnit.GetExpressionManager().AddFunction(n, dt, f);
     }
     else if (typeof(Net.Vpc.Upa.Callback).Equals(@event.GetContract()))
     {
         Net.Vpc.Upa.Callback callbackType = (Net.Vpc.Upa.Callback)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType());
         persistenceUnit.AddCallback(callbackType);
     }
     else if (typeof(Net.Vpc.Upa.EntitySecurityManager).Equals(@event.GetContract()))
     {
         Net.Vpc.Upa.Config.Decoration     d    = (Net.Vpc.Upa.Config.Decoration)@event.GetUserObject();
         Net.Vpc.Upa.EntitySecurityManager secu = (Net.Vpc.Upa.EntitySecurityManager)persistenceUnit.GetFactory().CreateObject <T>(@event.GetVisitedType());
         Net.Vpc.Upa.Impl.Config.EntityConfiguratorProcessor.ConfigureOneShot(persistenceUnit, new Net.Vpc.Upa.Impl.Util.SimpleEntityFilter(new Net.Vpc.Upa.Impl.Util.EqualsStringFilter(d.GetString("entity"), false, false), true), new Net.Vpc.Upa.Impl.Config.SecurityManagerEntityConfigurator(secu));
     }
     else if (@event.GetUserObject() is Net.Vpc.Upa.Impl.Config.DecoratedMethodScan)
     {
         Net.Vpc.Upa.Impl.Config.DecoratedMethodScan dms  = (Net.Vpc.Upa.Impl.Config.DecoratedMethodScan)@event.GetUserObject();
         Net.Vpc.Upa.Config.Decoration callbackDecoration = dms.GetDecoration();
         ConfigureMethodCallback(type, dms.GetMethod(), callbackDecoration, persistenceUnit);
     }
 }
Ejemplo n.º 7
0
 public virtual void RemoveCallback(Net.Vpc.Upa.Callback callback)
 {
     listeners.RemoveCallback(callback);
 }