Beispiel #1
0
        public virtual void Install(Net.Vpc.Upa.Entity e)
        {
            string cname = callbackName;

            if (Net.Vpc.Upa.Impl.Config.Annotationparser.AnnotationParserUtils.IsEmptyString(cname))
            {
                cname = (dataInterceptor.GetType()).Name;
            }
            addedTriggers.Add(e.AddTrigger(cname, dataInterceptor));
        }
 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);
     }
 }