Package nexj.core.meta

Examples of nexj.core.meta.Argument


               sArgName = sArgName.substring(0, sArgName.length() - 3);
            }

            try
            {
               m_event.addArgument(new Argument(sArgName));
            }
            catch (Throwable t)
            {
               error(m_methodDoc, "Could not add argument", t);
View Full Code Here


   public void testEvent() throws Exception
   {
      Metadata metadata = new XMLMetadata(null, null, null, null, null);
      Metaclass metaclass = new Metaclass("Test");
      Attribute attr = new Attribute("attr");
      Argument untyped = new Argument("untyped");
      Argument anytyped = new Argument("anytyped");
      Argument inttyped = new Argument("inttyped");
      Argument listtyped = new Argument("listtyped");
      Event protectedEv = new Event("protected");
      Event publicEv = new Event("public");
      Event staticEv = new Event("static");
      MockServer server = new MockServer(new Object[]{null});
      Timestamp ts =
         SOAPUtil.parseDateTime("1234-05-06T07:08:09", true, true, TimeZone.getDefault());

      attr.setType(Primitive.ANY);
      anytyped.setType(Primitive.ANY);
      inttyped.setType(Primitive.INTEGER);
      listtyped.setType(Primitive.STRING);
      listtyped.setCollection(true);
      protectedEv.setVisibility(Metaclass.PROTECTED);
      publicEv.addArgument(untyped);
      publicEv.addArgument(anytyped);
      publicEv.addArgument(inttyped);
      publicEv.addArgument(listtyped);
View Full Code Here

    * @param sName The argument name.
    * @return The defined Argument.
    */
   protected Argument loadArgument(Element element, String sName)
   {
      final Argument arg = new Argument(sName);
      final String sType = XMLUtil.getReqStringAttr(element, "type");
      Type type = Primitive.find(sType);

      if (type == null && s_unsupportedIntrinsicSet.contains(sType))
      {
         type = Primitive.ANY;
      }

      arg.setRequired(XMLUtil.getBooleanAttr(element, "required"));
      arg.setCollection(XMLUtil.getBooleanAttr(element, "collection"));
      arg.setDescription(XMLUtil.getStringAttr(element, "description"));

      if (type == null)
      {
         type = m_metadata.defineMetaclass(sType, arg);
      }

      arg.setType(type);

      return arg;
   }
View Full Code Here

      if (sArgList != null)
      {
         for (StringTokenizer tokenizer = new StringTokenizer(sArgList); tokenizer.hasMoreTokens();)
         {
            String sArgName = tokenizer.nextToken();
            Argument arg = (Argument)argMap.remove(sArgName);

            XMLMetadataHelper.validateName(sArgName);
            event.addArgument((arg == null) ? new Argument(sArgName) : arg);
         }
      }

      MetadataCompoundValidationException e = null;
View Full Code Here

    * @param args The event argument value list.
    * @return The argument value, or null if not found.
    */
   public static Object findValue(Event event, String sName, Pair args)
   {
      Argument arg = event.findArgument(sName);

      if (arg == null)
      {
         return null;
      }

      for (int i = arg.getOrdinal(); i != 0; --i)
      {
         args = args.getNext();
      }

      return args.getHead();
View Full Code Here

    * @param args The event argument value array.
    * @param The value to set.
    */
   public static void setValue(Event event, String sName, Object[] args, Object value)
   {
      Argument arg = event.findArgument(sName);

      if (arg != null)
      {
         args[arg.getOrdinal() + 1] = value;
      }
   }
View Full Code Here

         {
            argArray = Pair.toArray((Pair)args);
            event = (Event)metaclass.getSelector((Symbol)argArray[0]).getMember(argArray.length - 1);
            argArray[0] = metaclass;

            Argument result = event.getResult();

            if (result != null && !result.getType().isPrimitive())
            {
               metaclass = (Metaclass)result.getType();
            }
         }
         else if (args instanceof String)
         {
            event = (Event)metaclass.getSelector((String)args).getMember(6);
View Full Code Here

                     for (PropertyIterator itr = tobj.getIterator(); itr.hasNext();)
                     {
                        itr.next();

                        Argument arg = event.findArgument(itr.getName());

                        if (arg == null || arg == event.getArgument(nEventArgCount))
                        {
                           args[++nArg] = new Pair(Symbol.define(itr.getName()), instanceFactory.instantiate(itr.getValue()));
                        }
                     }
                  }
               }

               // Allow auditing of static events
               identityMap.put(tobj, null);
            }
            else
            {
               args[0] = instanceFactory.instantiate(tobj);
            }

            eventArray[i] = event;
            argArray[i] = args;
            eventMap.put(tobj, event);
         }

         Lookup diffMap = null;

         // Instantiate the transfer objects from the instance filters
         if (bInstanceFilter)
         {
            diffMap = new HashTab();

            for (int i = 0; i < nFilterCount; ++i)
            {
               m_context.setTransient(bTransient);

               TransferObject tobj = request.getFilter(i);
               Object instances = tobj.findValue("instances");

               if (instances != null)
               {
                  List instanceList = (List)instances;
                  int nCount = instanceList.size();

                  for (int k = 0; k < nCount; ++k)
                  {
                     tobj = (TransferObject)instanceList.get(k);

                     Instance inst = instanceFactory.instantiate(tobj);

                     instanceList.set(k, inst);

                     if (inst != null)
                     {
                        diffMap.put(inst, tobj);
                     }
                  }
               }
            }
         }

         instanceFactory.complete();
         instanceFactory = null;
         GenericServer.auditRequest(identityMap, eventMap, m_context);
         identityMap = null;

         Object[] resultArray = new Object[nInvocationCount << 1];

         // Unset the pending event flag on the request argument instances
         for (int i = 0; i < nInvocationCount; ++i)
         {
            Object[] args = argArray[i];
            Object obj = args[0];

            if (obj instanceof Instance)
            {
               Instance instance = (Instance)obj;

               if (args.length == 1 && eventArray[i].getName().equals(instance.getPendingEventName()))
               {
                  resultArray[i << 1] = instance;
               }

               instance.suspendEvent();
            }
         }

         m_context.setTransient(false);
         uow.invokePendingEvents(false, false);

         // Invoke the events and accumulate the results
         for (int i = 0; i < nInvocationCount; ++i)
         {
            TransferObject tobj = request.getObject(i);
            Event event = eventArray[i];
            Pair attributes = EMPTY_PAIR;
            Object[] args = argArray[i];
            Object obj = args[0];
            int nAttrIndex = -1;

            m_context.setTransient(event.isTransient(bTransient));

            if (event.getArgumentCount() != 0)
            {
               Argument arg = event.findArgument("attributes");

               if (arg != null)
               {
                  nAttrIndex = arg.getOrdinal() + 1;

                  Object value = args[nAttrIndex];

                  attributes = (value instanceof Pair) ? (Pair)value : null;
               }
            }

            if (nAttrIndex < 0)
            {
               Object value = tobj.findValue("attributes", EMPTY_PAIR);

               if (value != EMPTY_PAIR)
               {
                  nAttrIndex = 0;
                  attributes =  (Pair)value;
               }
            }

            if (event.isStatic() && m_context.isProtected() && m_context.isSecure())
            {
               Metaclass metaclass = event.getMetaclass();
               Argument result = event.getResult();

               if (result != null && !result.getType().isPrimitive())
               {
                  metaclass = (Metaclass)result.getType();
               }

               if (nAttrIndex > 0)
               {
                  Pair security = metaclass.checkReadAccess(attributes, m_context.getPrivilegeSet());
View Full Code Here

    * @param args The argument array. The instance is at index 0.
    * @param tobj The transfer object.
    */
   protected static Object findArg(Event event, String sName, Object[] args, TransferObject tobj)
   {
      Argument arg = (event.getActionCount() == 0) ? null : event.findArgument(sName);

      if (arg != null)
      {
         return args[arg.getOrdinal() + 1];
      }

      return tobj.findValue(sName);
   }
View Full Code Here

      {
         instance = new TransferObject(event.getMetaclass().getName(), 0);
         instance.setOID(oid);
      }

      Argument result = event.getResult();
      XMLInvocationRequest request;

      if (result == null) // untyped event
      {
         QName element = WADLGenerator.computeElementType(Primitive.ANY, false);

         request = new XMLInvocationRequest(event, instance, element, false);
      }
      else
      {
         QName element = WADLGenerator.computeElementType(result.getType(), result.isCollection());

         request = new XMLInvocationRequest(event, instance, element, result.isCollection());
      }

      for (int i = 0, nCount = event.getArgumentCount(); i < nCount; ++i)
      {
         request.addArgument(unmarshal(event.getArgument(i))); // unmarshal each argument
View Full Code Here

TOP

Related Classes of nexj.core.meta.Argument

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.