Package java.lang.reflect

Examples of java.lang.reflect.Method


              // if we need to improve on this then we'll have to move to a system more akin to
              // the dir-loaded plugins
           
            Class  cla = root_class_loader.loadClass( builtin_plugins[i][1]);
                   
                Method  load_method = cla.getMethod( "load", new Class[]{ PluginInterface.class });
               
                load_method.invoke( null, new Object[]{ getDefaultInterfaceSupport() });
               
          Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING,
              "Built-in plugin '" + builtin_plugins[i][0] + "' ok"));
              }catch( NoSuchMethodException e ){
               
              }catch( Throwable e ){
               
          if ( builtin_plugins[i][4].equalsIgnoreCase("true" )){
             
            Debug.printStackTrace( e );
         
            Logger.log(new LogAlert(LogAlert.UNREPEATABLE,
                "Load of built in plugin '" + builtin_plugins[i][2] + "' fails", e));
          }
          }finally{
           
            loading_builtin = false;
          }
        }else{
          if (Logger.isEnabled())
            Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING,
                "Built-in plugin '" + builtin_plugins[i][2] + "' is disabled"));
        }
      }
     
     if (Logger.isEnabled())
      Logger.log(new LogEvent(LOGID, "Loading dynamically registered plugins"));
    
    for (int i=0;i<registration_queue.size();i++){
     
      Object  entry = registration_queue.get(i);
       
      Class  cla;
      String  id;
     
      if ( entry instanceof Class ){
       
          cla = (Class)entry;
         
          id  = cla.getName();     
      }else{
       
        Object[]  x = (Object[])entry;
       
        Plugin  plugin = (Plugin)x[0];
       
        cla  = plugin.getClass();
       
        id  = (String)x[1];
      }
     
      try{
          // lazyness here, for dynamic we use static load method with default plugin interface
          // if we need to improve on this then we'll have to move to a system more akin to
          // the dir-loaded plugins
                         
        Method  load_method = cla.getMethod( "load", new Class[]{ PluginInterface.class });
           
            load_method.invoke( null, new Object[]{ getDefaultInterfaceSupport() });
           
        }catch( NoSuchMethodException e ){
           
        }catch( Throwable e ){
           
View Full Code Here


            boolean bEnabled = (loading_for_startup) ? plugin_interface.getPluginState().isLoadedAtStartup() : initialise;
            plugin_interface.getPluginState().setDisabled(!bEnabled);

            try{

              Method  load_method = plugin.getClass().getMethod( "load", new Class[]{ PluginInterface.class });

              load_method.invoke( plugin, new Object[]{ plugin_interface });

            }catch( NoSuchMethodException e ){

            }catch( Throwable e ){
View Full Code Here

             run()
               throws PluginException
             {
               try{

                 Method  load_method = plugin_class.getMethod( "load", new Class[]{ PluginInterface.class });

                 load_method.invoke( plugin, new Object[]{ plugin_interface });

               }catch( NoSuchMethodException e ){

               }catch( Throwable e ){
View Full Code Here

            // attempt to set up 1.4 and later's Socket.connect method which
            // provides a timeout
            try {
                // get the correct connect method
                Class socketAddress = Class.forName("java.net.SocketAddress");
                Method connectMethod = Socket.class.getMethod("connect", new Class[] {
                        socketAddress, int.class });
               
                // create an unconnected socket instance
                Socket sock = (Socket) Socket.class.newInstance();

                // need an InetSocketAddress instance for connect()
                Class inetSocketAddress = Class.forName("java.net.InetSocketAddress");
                Constructor inetSocketAddressCtr =
                    inetSocketAddress.getConstructor(
                            new Class[] { InetAddress.class, int.class });
                Object address = inetSocketAddressCtr.newInstance(
                        new Object[] { host, new Integer(port) });

                // now invoke the connect method with the timeout
                log.debug("Invoking connect with timeout=" + timeout);
                connectMethod.invoke(sock, new Object[]{address, new Integer(timeout)});
                log.debug("Connected successfully");
                return sock;
            }
            catch (InvocationTargetException ex) {
                Throwable target = ex.getTargetException();
View Full Code Here

    public static boolean isConnected(Socket sock) throws IOException {
        if (!isConnectedSupported)
            return true;
        try {
            // get the isConnected method
            Method connectedMethod = Socket.class.getMethod("isConnected", (Class[])null);
           
            Boolean result = (Boolean)connectedMethod.invoke(sock, (Object[])null);
            return result.booleanValue();
        }
        catch (InvocationTargetException ex) {
            Throwable target = ex.getTargetException();
            if (target instanceof IOException)
View Full Code Here

            TvDataServiceProxy service = TvDataServiceProxyManager.getInstance().findDataServiceById(
                pluginName.toLowerCase() + '.' + pluginName);

            Class<?> pluginClass = classLoader.loadClass(pluginName.toLowerCase() + '.' + pluginName);

            Method getVersion = pluginClass.getMethod("getVersion", new Class[0]);

            Version version1 = null;
            try {
              version1 = (Version) getVersion.invoke(pluginClass, new Object[0]);
            } catch (Throwable t1) {
              t1.printStackTrace();
            }

            if (installedPlugin != null && (installedPlugin.getInfo().getVersion().compareTo(version1) > 0 || (installedPlugin.getInfo().getVersion().compareTo(version1) == 0 && version1.isStable()))) {
View Full Code Here

                log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call);

            if(method_call.getMode() == MethodCall.ID) {
                if(method_lookup == null)
                    throw new Exception("MethodCall uses ID=" + method_call.getId() + ", but method_lookup has not been set");
                Method m=method_lookup.findMethod(method_call.getId());
                if(m == null)
                    throw new Exception("no method found for " + method_call.getId());
                method_call.setMethod(m);
            }
           
View Full Code Here

  public void setCVID(Object obj, String moduleName, String className)
  {
    Class classCV[] = new Class[1];
    Class arg[] = new Class[1];
    Object idCV[] = new Object[1];
    Method method = null;
    Object ret = null;
    String met = "";
    String id = "";

    try
    {
      if (moduleName.equals("Invoice"))
        return;

      classCV[0] = Class.forName(className);
      method = classCV[0].getMethod("getExternalID", null);
      ret = method.invoke(obj, null);

      id = getIDFromEXID(moduleName, ret.toString());

      if (isEntityModule(moduleName))
      {
        moduleName = "Entity";
        met = "setContactID";
      } else if (moduleName.equals("Individual"))
      {
        met = "setIndividualID";
      } else if (moduleName.equals("PurchaseOrder"))
      {
        met = "setPurchaseOrderId";
      } else if (moduleName.equals("Expense"))
      {
        met = "setExpenseID";
      } else if (isItemModule(moduleName))
      {
        moduleName = "Item";
        met = "setItemId";
      } else if (moduleName.equals("Payment"))
      {
        met = "setPaymentID";
      } else if (moduleName.equals("PaymentMethod"))
      {
        met = "setMethodID";
      } else if (moduleName.equals("GLAccount"))
      {
        met = "setGlaccountID";
      }
      arg[0] = Integer.TYPE;
      idCV[0] = getObjectByName("int", id);
      method = classCV[0].getMethod(met, arg);
      method.invoke(obj, idCV);
    } catch (Exception e)
    {
      System.out.print(e);
      e.printStackTrace();
    }
View Full Code Here

    try
    {

      Class argumentType[] = new Class[1];
      Method method = null;
      Class classCV[] = new Class[1];
      classCV[0] = Class.forName(className);
      Object arguments[] = new Object[1];

      if (className.equals("com.centraview.contact.entity.EntityVO") || className.equals("com.centraview.contact.individual.IndividualVO"))
      {

        if (className.equals("com.centraview.contact.entity.EntityVO"))
        {
          argumentType[0] = Class.forName("java.lang.String");
          sep = getValueOfNodeByTagName(configXML, TAG_SEPARATOR);
          method = classCV[0].getMethod("setCustomType", argumentType);
          arguments[0] = sep;
          method.invoke(objectCV, arguments);

          arguments[0] = getObjectByName("int", "1");
        } else
        {
          arguments[0] = getObjectByName("int", "2");
        }
        argumentType[0] = Integer.TYPE;
        method = classCV[0].getMethod("setContactType", argumentType);
        method.invoke(objectCV, arguments);
      } else if (className.equals("com.centraview.account.item.ItemVO"))
      {
        String type = "";
        sep = getValueOfNodeByTagName(configXML, TAG_SEPARATOR);
        if (sep.equals("ItemInventory"))
        {
          type = "1";
        } else if (sep.equals("ItemNonInventory"))
        {
          type = "2";
        } else if (sep.equals("ItemService"))
        {
          type = "3";
        }
        argumentType[0] = Integer.TYPE;
        arguments[0] = getObjectByName("int", type);
        method = classCV[0].getMethod("setItemTypeId", argumentType);
        method.invoke(objectCV, arguments);
      }

    } catch (Exception e)
    {
      logger.error("[setType] Exception thrown.", e);
View Full Code Here

      int length = listItem.getLength();

      classCV[0] = Class.forName(className);
      objectCV = classCV[0].newInstance();

      Method method = null;
      setType(objectCV, configXML, className);

      for (int i = 0; i < length; i++)
      {
        tagName = listItem.item(i).getNodeName();

        if (tagName.equals("#text") || !listItem.item(i).hasAttributes())
        {
          continue;
        }

        attr = listItem.item(i).getAttributes();

        if (attr.getNamedItem("aatocv") != null)
        {
          tmpNodeList = getDocumentFromString(xml.toString()).getElementsByTagName(tagName);

          if (tmpNodeList.getLength() != 0)
          {
            setAAtoCV(objectCV, attr, tmpNodeList, classCV, tagName);
          }
          continue;
        }

        if (attr.getNamedItem("xml") != null)
        {
          configForQBXML = getDocumentFromString(getDocumentFromString(attr.getNamedItem("xml").getNodeValue()).getElementsByTagName(attr.getNamedItem("tag").getNodeValue()).item(0).toString());
          tmpNodeList = getDocumentFromString(xml.toString()).getElementsByTagName(tagName);

          if (tmpNodeList.item(0) != null)
          {
            forward(objectCV, attr, tmpNodeList.item(0), classCV, className, configForQBXML);
          }
          continue;
        }

        value = getValueOfNodeByTagName(xml, tagName);

        if (value == null)
          continue;

        typeArg = attr.getNamedItem("type").getNodeValue();

        argumentType[0] = getArgType(typeArg);
        arguments[0] = getObjectByName(typeArg, value);

        method = classCV[0].getMethod(attr.getNamedItem("set").getNodeValue(), argumentType);
        method.invoke(objectCV, arguments);
      }
    } catch (Exception e)
    {
      logger.error("QBXMLTag = <" + tagName + "> ********* Error while loading up/down classes : ", e);
    }
View Full Code Here

TOP

Related Classes of java.lang.reflect.Method

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.