Package org.jboss.remoting.transport

Examples of org.jboss.remoting.transport.ClientInvoker


         ref = new WeakReference(invoker);
      }
     
      public void run()
      {
         ClientInvoker invoker = (ClientInvoker) ref.get();
         log.trace(this + " calling InvokerRegistry.destroyClientInvoker() for " + invoker);
         InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
         ref.clear();
         ref = null;
      }
View Full Code Here


       * to sync method (and take performance hit)
       * Although this may cause having multiple instances of invoker in existance at
       * one time, should avoid having reference changed by another thread while in
       * execution path for method.
       */
      ClientInvoker localInvoker = invoker;

      if(localInvoker != null)
      {
         /**
          * This is here due to way the InvokerRegistry works.  Since it will cache references to
          * client invokers it creates based on locator, it is possible that this instance will
          * have a reference to the same instance of the invoker as another client.  So is possible
          * that client will disconnect, which will cause the invoker to be disconnected.  Therefore,
          * if this were to happen, we would create a new one by calling the createClientInvoker() method.
          */
         if(localInvoker.isConnected() == false)
         {
            log.debug("invoke called, but our invoker is disconnected, discarding and fetching another fresh invoker for: " + invoker.getLocator());

            localInvoker = InvokerRegistry.createClientInvoker(localInvoker.getLocator(), configuration);
            connect(localInvoker);
         }
      }
      else
      {
         throw new Exception("Can not perform invoke because invoker is null.");
      }

      Object ret = localInvoker.invoke(new InvocationRequest(sessionId, subsystem, param, metadata, null, callbackServerLocator));
      this.invoker = localInvoker;
      return ret;
   }
View Full Code Here

    *
    * @param locator
    */
   public static void destroyClientInvoker(InvokerLocator locator)
   {
      ClientInvoker invoker = null;

      synchronized(clientLock)
      {
         invoker = (ClientInvoker) clientLocators.remove(locator);
         log.debug("destroying client for locator: " + locator + ", invoker:" + invoker + ", remaining list:" + clientLocators);
      }

      if(invoker != null)
      {
         invoker.disconnect();
         invoker = null;
      }

   }
View Full Code Here

      {
         throw new NullPointerException("locator cannot be null");
      }
      synchronized(clientLock)
      {
         ClientInvoker invoker = (ClientInvoker) clientLocators.get(locator);
         if(invoker != null)
         {
            return invoker;
         }

         boolean isPassByValue = false;
         Map parameters = locator.getParameters();
         if(parameters != null)
         {
            String value = (String) parameters.get(InvokerLocator.BYVALUE);
            if(value != null && Boolean.valueOf(value).booleanValue())
            {
               isPassByValue = true;
            }
         }

         // Check to see if server invoker is local
         // If in server locators map, then created locally by this class
         ServerInvoker svrInvoker = (ServerInvoker) serverLocators.get(locator);
         if(svrInvoker != null && !isPassByValue)
         {
            LocalClientInvoker localInvoker = new LocalClientInvoker(locator);
            // have to set reference to local server invoker so client in invoke directly
            localInvoker.setServerInvoker(svrInvoker);
            invoker = localInvoker;
            InvokerLocator l = invoker.getLocator();
            clientLocators.put(l, invoker);
         }
         else //not local
         {
            String protocol = locator.getProtocol();
            if(protocol == null)
            {
               throw new NullPointerException("protocol cannot be null for the locator");
            }
            Class cl = (Class) clientInvokers.get(protocol);
            if(cl == null)
            {
               cl = loadClientInvoker(protocol);
               if(cl == null)
               {
                  throw new RuntimeException("Couldn't find valid client invoker class for transport '" + protocol + "'");
               }
            }

            if(configuration != null)
            {
               Constructor ctor = cl.getConstructor(new Class[]{InvokerLocator.class, Map.class});
               invoker = (ClientInvoker) ctor.newInstance(new Object[]{locator, configuration});
            }
            else
            {
               Constructor ctor = cl.getConstructor(new Class[]{InvokerLocator.class});
               invoker = (ClientInvoker) ctor.newInstance(new Object[]{locator});
            }

            InvokerLocator l = invoker.getLocator();
            clientLocators.put(l, invoker);
         }
         return invoker;
      }
   }
View Full Code Here

      {
         InvokerLocator locator = invoker.getLocator();
         unregisterLocator(locator);
         if(clientLocators.get(locator) instanceof LocalClientInvoker)
         {
            ClientInvoker clientInvoker = (ClientInvoker) clientLocators.remove(locator);
            if(clientInvoker != null)
            {
               clientInvoker.disconnect();
            }
         }
      }
   }
View Full Code Here

      InvokerLocator il[] = detection.getLocators();
      for(int c = 0; c < il.length; c++)
      {
         try
         {
            ClientInvoker ci = InvokerRegistry.createClientInvoker(il[c]);

            if(ci.isConnected() == false)
            {
               ci.connect();
            }

            boolean isValid = ConnectionValidator.checkConnection(ci);
            if(isValid)
            {
View Full Code Here

   public static boolean checkConnection(InvokerLocator locator, Map config) throws Throwable
   {
      boolean pingWorked = false;
      Map configMap = createPingConfig(config, null);
      int pingTimeout = Integer.parseInt((String) configMap.get(ServerInvoker.TIMEOUT));
      ClientInvoker innerClientInvoker = null;

      try
      {
         innerClientInvoker = InvokerRegistry.createClientInvoker(locator, configMap);

         if (!innerClientInvoker.isConnected())
         {
            if (trace) { log.trace("inner client invoker not connected, connecting ..."); }
            innerClientInvoker.connect();
         }

         pingWorked = doCheckConnection(innerClientInvoker, pingTimeout);
      }
      catch (Throwable throwable)
      {
            log.debug("ConnectionValidator unable to connect to server " +
            innerClientInvoker.getLocator().getProtocol() + "://" +
            innerClientInvoker.getLocator().getHost() + ":" +
            innerClientInvoker.getLocator().getPort(), throwable);
      }
      finally
      {
         if (innerClientInvoker != null)
         {
View Full Code Here

         getParametersFromMap(client.getInvoker().getLocator().getParameters());
      }
      getParametersFromMap(client.getConfiguration());
      getParametersFromMap(metadata);
     
      ClientInvoker clientInvoker = client.getInvoker();
      if (clientInvoker instanceof MicroRemoteClientInvoker)
      {
         sharedInvoker = (MicroRemoteClientInvoker) clientInvoker;
         invokerSessionId = sharedInvoker.getSessionId();
      }
View Full Code Here

            {
               log.warn(this + " could not convert " + STOP_LEASE_ON_FAILURE + " value" +
               " to a boolean: must be a String");
            }
         }
         ClientInvoker invoker = client.getInvoker();
         if (invoker == null)
         {
            if (trace) log.trace(this + " client invoker == null");
         }
         else
         {
            if (trace) log.trace(this + " InvokerLocator: " + invoker.getLocator());
         }
         o = config.get(FAILURE_DISCONNECT_TIMEOUT);
         if (trace) log.trace(this + " \"failureDisconnectTimeout\" set to " + o);
         if (o != null)
         {
View Full Code Here

     
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
 
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
View Full Code Here

TOP

Related Classes of org.jboss.remoting.transport.ClientInvoker

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.