Package org.jboss.remoting.loading

Examples of org.jboss.remoting.loading.RemotingClassLoader


      if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); }

      // Set up marshaller and unmarshaller.
      Marshaller marshaller = null;
      UnMarshaller unmarshaller = null;
      RemotingClassLoader rcl = null;
      synchronized (MicroRemoteClientInvoker.class)
      {
         marshaller = getMarshaller();
         if (marshaller == null)
         {
            // try by locator (in case marshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader(), map);
            if (marshaller == null)
            {
               // need to have a marshaller, so create a default one
               marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType());
               if (marshaller == null)
               {
                  // went as far as possible to find a marshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid marshaller for data type: " + getDataType());
               }
            }
            setMarshaller(marshaller);
         }
        
         unmarshaller = getUnMarshaller();
         if (unmarshaller == null)
         {
            // try by locator (in case unmarshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader(), map);
            if (unmarshaller == null)
            {
               unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
               if (unmarshaller == null)
               {
                  // went as far as possible to find a unmarshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid unmarshaller for data type: " + getDataType());
               }
            }
            setUnMarshaller(unmarshaller);
         }

         // Each unmarshaller gets a RemotingClassloader classloader containing the
         // remoting class loader (for remote classloading) and the current thread's
         // class loader.  This allows to load remoting classes as well as user's
         // classes.  If possible, will simply reset context classloader on existing
         // RemotingClassLoader.
         final ClassLoader contextClassLoader = getContextClassLoader(Thread.currentThread());
         if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
         {
            UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller;
            ClassLoader cl = uclum.getClassLoader();
            if (cl instanceof RemotingClassLoader)
            {
               rcl = (RemotingClassLoader) cl;
               rcl.setUserClassLoader(contextClassLoader);
            }
            else
            {
               rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
               unmarshaller.setClassLoader(rcl);
            }
         }
         else
         {
            rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
            unmarshaller.setClassLoader(rcl)
         }
      }

      // if raw, then send only param of invocation request
      Object payload = null;
      Map metadata = invocationReq.getRequestPayload();
      if (metadata != null && metadata.get(Client.RAW) != null)
      {
         payload = invocationReq.getParameter();
      }
      else
      {
         payload = invocationReq;
      }

      try
      {
         String sessionId = invocationReq.getSessionId();
         returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller);
      }
      finally
      {
         // Delete reference to current thread's context classloader.
         synchronized (MicroRemoteClientInvoker.class)
         {
            rcl.unsetUserClassLoader();
         }
      }
     
      // Now check if is remoting response and process
      if (returnValue instanceof InvocationResponse)
View Full Code Here


   static private RemotingClassLoader createRemotingClassLoader(final ClassLoader remotingClassLoader,
         final ClassLoader userClassLoader, final boolean parentFirstDelegation)
   {
      if (SecurityUtility.skipAccessControl())
      {
         return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
      }

      return (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction()
      {
         public Object run()
         {
            return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
         }
      });
   }
View Full Code Here

      if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); }

      // Set up marshaller and unmarshaller.
      Marshaller marshaller = null;
      UnMarshaller unmarshaller = null;
      RemotingClassLoader rcl = null;
      synchronized (MicroRemoteClientInvoker.class)
      {
         marshaller = getMarshaller();
         if (marshaller == null)
         {
            // try by locator (in case marshaller class name specified)
            marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader());
            if (marshaller == null)
            {
               // need to have a marshaller, so create a default one
               marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType());
               if (marshaller == null)
               {
                  // went as far as possible to find a marshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid marshaller for data type: " + getDataType());
               }
            }
            setMarshaller(marshaller);
         }
        
         unmarshaller = getUnMarshaller();
         if (unmarshaller == null)
         {
            // try by locator (in case unmarshaller class name specified)
            unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader());
            if (unmarshaller == null)
            {
               unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
               if (unmarshaller == null)
               {
                  // went as far as possible to find a unmarshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid unmarshaller for data type: " + getDataType());
               }
            }
            setUnMarshaller(unmarshaller);
         }

         // Each unmarshaller gets a RemotingClassloader classloader containing the
         // remoting class loader (for remote classloading) and the current thread's
         // class loader.  This allows to load remoting classes as well as user's
         // classes.  If possible, will simply reset context classloader on existing
         // RemotingClassLoader.
         final ClassLoader contextClassLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
         {
            public Object run()
            {
               return Thread.currentThread().getContextClassLoader();
            }
         });
         if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
         {
            UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller;
            ClassLoader cl = uclum.getClassLoader();
            if (cl instanceof RemotingClassLoader)
            {
               rcl = (RemotingClassLoader) cl;
               rcl.setUserClassLoader(contextClassLoader);
            }
            else
            {
               rcl = (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction()
               {
                  public Object run()
                  {
                     return new RemotingClassLoader(getClassLoader(), contextClassLoader);
                  }
               });

               unmarshaller.setClassLoader(rcl);
            }
         }
         else
         {
            rcl = (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction()
            {
               public Object run()
               {
                  return new RemotingClassLoader(getClassLoader(), contextClassLoader);
               }
            });
            unmarshaller.setClassLoader(rcl)
         }
      }

      // if raw, then send only param of invocation request
      Object payload = null;
      Map metadata = invocationReq.getRequestPayload();
      if (metadata != null && metadata.get(Client.RAW) != null)
      {
         payload = invocationReq.getParameter();
      }
      else
      {
         payload = invocationReq;
      }

      try
      {
         String sessionId = invocationReq.getSessionId();
         returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller);
      }
      finally
      {
         // Delete reference to current thread's context classloader.
         rcl.unsetUserClassLoader();
      }
     
      // Now check if is remoting response and process
      if (returnValue instanceof InvocationResponse)
      {
View Full Code Here

      if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); }

      // Set up marshaller and unmarshaller.
      Marshaller marshaller = null;
      UnMarshaller unmarshaller = null;
      RemotingClassLoader rcl = null;
      synchronized (MicroRemoteClientInvoker.class)
      {
         marshaller = getMarshaller();
         if (marshaller == null)
         {
            // try by locator (in case marshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader(), map);
            if (marshaller == null)
            {
               // need to have a marshaller, so create a default one
               marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType());
               if (marshaller == null)
               {
                  // went as far as possible to find a marshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid marshaller for data type: " + getDataType());
               }
            }
            setMarshaller(marshaller);
         }
        
         unmarshaller = getUnMarshaller();
         if (unmarshaller == null)
         {
            // try by locator (in case unmarshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader(), map);
            if (unmarshaller == null)
            {
               unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
               if (unmarshaller == null)
               {
                  // went as far as possible to find a unmarshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid unmarshaller for data type: " + getDataType());
               }
            }
            setUnMarshaller(unmarshaller);
         }

         // Each unmarshaller gets a RemotingClassloader classloader containing the
         // remoting class loader (for remote classloading) and the current thread's
         // class loader.  This allows to load remoting classes as well as user's
         // classes.  If possible, will simply reset context classloader on existing
         // RemotingClassLoader.
         final ClassLoader contextClassLoader = getContextClassLoader(Thread.currentThread());
         if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
         {
            UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller;
            ClassLoader cl = uclum.getClassLoader();
            if (cl instanceof RemotingClassLoader)
            {
               rcl = (RemotingClassLoader) cl;
               rcl.setUserClassLoader(contextClassLoader);
            }
            else
            {
               rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
               unmarshaller.setClassLoader(rcl);
            }
         }
         else
         {
            rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
            unmarshaller.setClassLoader(rcl)
         }
      }

      // if raw, then send only param of invocation request
      Object payload = null;
      Map metadata = invocationReq.getRequestPayload();
      if (metadata != null && metadata.get(Client.RAW) != null)
      {
         payload = invocationReq.getParameter();
      }
      else
      {
         payload = invocationReq;
      }

      try
      {
         String sessionId = invocationReq.getSessionId();
         returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller);
      }
      finally
      {
         // Delete reference to current thread's context classloader.
         rcl.unsetUserClassLoader();
      }
     
      // Now check if is remoting response and process
      if (returnValue instanceof InvocationResponse)
      {
View Full Code Here

   static private RemotingClassLoader createRemotingClassLoader(final ClassLoader remotingClassLoader,
         final ClassLoader userClassLoader, final boolean parentFirstDelegation)
   {
      if (SecurityUtility.skipAccessControl())
      {
         return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
      }

      return (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction()
      {
         public Object run()
         {
            return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
         }
      });
   }
View Full Code Here

   }

   private void setResponseObject() throws ClassNotFoundException, IllegalAccessException, InstantiationException
   {
//      Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.http.TestObject");
      RemotingClassLoader loader = new RemotingClassLoader(MarshallerLoadingServer.class.getClassLoader(), Thread.currentThread().getContextClassLoader());
      Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject", false, loader);

      RESPONSE_VALUE = testObjClass.newInstance();
   }
View Full Code Here

   }

   private void setResponseObject() throws ClassNotFoundException, IllegalAccessException, InstantiationException
   {
//      Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject");
      RemotingClassLoader loader = new RemotingClassLoader(MarshallerLoadingServer.class.getClassLoader(), Thread.currentThread().getContextClassLoader());
      Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject", false, loader);
      RESPONSE_VALUE = testObjClass.newInstance();
   }
View Full Code Here

      if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); }

      // Set up marshaller and unmarshaller.
      Marshaller marshaller = null;
      UnMarshaller unmarshaller = null;
      RemotingClassLoader rcl = null;
      synchronized (MicroRemoteClientInvoker.class)
      {
         marshaller = getMarshaller();
         if (marshaller == null)
         {
            // try by locator (in case marshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader(), map);
            if (marshaller == null)
            {
               // need to have a marshaller, so create a default one
               marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType());
               if (marshaller == null)
               {
                  // went as far as possible to find a marshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid marshaller for data type: " + getDataType());
               }
            }
            setMarshaller(marshaller);
         }
        
         unmarshaller = getUnMarshaller();
         if (unmarshaller == null)
         {
            // try by locator (in case unmarshaller class name specified)
            Map map = passConfigMapToMarshalFactory ? configuration : null;
            unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader(), map);
            if (unmarshaller == null)
            {
               unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
               if (unmarshaller == null)
               {
                  // went as far as possible to find a unmarshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid unmarshaller for data type: " + getDataType());
               }
            }
            setUnMarshaller(unmarshaller);
         }

         // Each unmarshaller gets a RemotingClassloader classloader containing the
         // remoting class loader (for remote classloading) and the current thread's
         // class loader.  This allows to load remoting classes as well as user's
         // classes.  If possible, will simply reset context classloader on existing
         // RemotingClassLoader.
         final ClassLoader contextClassLoader = getContextClassLoader(Thread.currentThread());
         if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
         {
            UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller;
            ClassLoader cl = uclum.getClassLoader();
            if (cl instanceof RemotingClassLoader)
            {
               rcl = (RemotingClassLoader) cl;
               rcl.setUserClassLoader(contextClassLoader);
            }
            else
            {
               rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
               unmarshaller.setClassLoader(rcl);
            }
         }
         else
         {
            rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
            unmarshaller.setClassLoader(rcl)
         }
      }

      // if raw, then send only param of invocation request
      Object payload = null;
      Map metadata = invocationReq.getRequestPayload();
      if (metadata != null && metadata.get(Client.RAW) != null)
      {
         payload = invocationReq.getParameter();
      }
      else
      {
         payload = invocationReq;
      }

      try
      {
         String sessionId = invocationReq.getSessionId();
         returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller);
      }
      finally
      {
         // Delete reference to current thread's context classloader.
         synchronized (MicroRemoteClientInvoker.class)
         {
            rcl.unsetUserClassLoader();
         }
      }
     
      // Now check if is remoting response and process
      if (returnValue instanceof InvocationResponse)
View Full Code Here

   static private RemotingClassLoader createRemotingClassLoader(final ClassLoader remotingClassLoader,
         final ClassLoader userClassLoader, final boolean parentFirstDelegation)
   {
      if (SecurityUtility.skipAccessControl())
      {
         return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
      }

      return (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction()
      {
         public Object run()
         {
            return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation);
         }
      });
   }
View Full Code Here

      if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); }

      // Set up marshaller and unmarshaller.
      Marshaller marshaller = null;
      UnMarshaller unmarshaller = null;
      RemotingClassLoader rcl = null;
      synchronized (MicroRemoteClientInvoker.class)
      {
         marshaller = getMarshaller();
         if (marshaller == null)
         {
            // try by locator (in case marshaller class name specified)
            marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader());
            if (marshaller == null)
            {
               // need to have a marshaller, so create a default one
               marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType());
               if (marshaller == null)
               {
                  // went as far as possible to find a marshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid marshaller for data type: " + getDataType());
               }
            }
            setMarshaller(marshaller);
         }
        
         unmarshaller = getUnMarshaller();
         if (unmarshaller == null)
         {
            // try by locator (in case unmarshaller class name specified)
            unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader());
            if (unmarshaller == null)
            {
               unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
               if (unmarshaller == null)
               {
                  // went as far as possible to find a unmarshaller, will have to give up
                  throw new InvalidMarshallingResource(
                        "Can not find a valid unmarshaller for data type: " + getDataType());
               }
            }
            setUnMarshaller(unmarshaller);
         }

         // Each unmarshaller gets a RemotingClassloader classloader containing the
         // remoting class loader (for remote classloading) and the current thread's
         // class loader.  This allows to load remoting classes as well as user's
         // classes.  If possible, will simply reset context classloader on existing
         // RemotingClassLoader.
         final ClassLoader contextClassLoader = SecurityUtility.getContextClassLoader(Thread.currentThread());
         if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
         {
            UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller;
            ClassLoader cl = uclum.getClassLoader();
            if (cl instanceof RemotingClassLoader)
            {
               rcl = (RemotingClassLoader) cl;
               rcl.setUserClassLoader(contextClassLoader);
            }
            else
            {
               rcl = SecurityUtility.createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
               unmarshaller.setClassLoader(rcl);
            }
         }
         else
         {
            rcl = SecurityUtility.createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading);
            unmarshaller.setClassLoader(rcl)
         }
      }

      // if raw, then send only param of invocation request
      Object payload = null;
      Map metadata = invocationReq.getRequestPayload();
      if (metadata != null && metadata.get(Client.RAW) != null)
      {
         payload = invocationReq.getParameter();
      }
      else
      {
         payload = invocationReq;
      }

      try
      {
         String sessionId = invocationReq.getSessionId();
         returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller);
      }
      finally
      {
         // Delete reference to current thread's context classloader.
         rcl.unsetUserClassLoader();
      }
     
      // Now check if is remoting response and process
      if (returnValue instanceof InvocationResponse)
      {
View Full Code Here

TOP

Related Classes of org.jboss.remoting.loading.RemotingClassLoader

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.