Package org.jboss.forge.furnace.exception

Examples of org.jboss.forge.furnace.exception.ContainerException


   public Object invoke(final Object self, final Method thisMethod, final Method proceed, final Object[] args)
            throws Throwable
   {
      if (Thread.currentThread().isInterrupted())
      {
         throw new ContainerException("Thread.interrupt() requested.");
      }

      Callable<Object> task = new Callable<Object>()
      {
         @Override
         public Object call() throws Exception
         {
            try
            {
               if (thisMethod.getDeclaringClass().getName().equals(ForgeProxy.class.getName()))
               {
                  if (thisMethod.getName().equals("getDelegate"))
                     return ClassLoaderInterceptor.this.getDelegate();
                  if (thisMethod.getName().equals("getHandler"))
                     return ClassLoaderInterceptor.this.getHandler();
               }
            }
            catch (Exception e)
            {
            }

            ClassLoader previousLoader = null;
            Object result;
            try
            {
               previousLoader = setCurrentLoader(loader);

               if (thisMethod.equals(EQUALS_METHOD))
               {
                  Object object = args[0];
                  Object unwrapped = Proxies.unwrap(object);
                  args[0] = unwrapped;
               }

               result = thisMethod.invoke(delegate, args);
            }
            catch (InvocationTargetException e)
            {
               if (e.getCause() instanceof Exception)
                  throw (Exception) e.getCause();
               throw e;
            }
            finally
            {
               setCurrentLoader(previousLoader);
            }
            return result;
         }
      };

      Object result = ClassLoaders.executeIn(loader, task);

      if (Thread.currentThread().isInterrupted())
      {
         throw new ContainerException("Thread.interrupt() requested.");
      }

      return result;
   }
View Full Code Here


      {
         return loader.loadClass(typeName);
      }
      catch (ClassNotFoundException | LinkageError e)
      {
         throw new ContainerException("Could not locate class [" + typeName + "] in Loader [" + loader + "]", e);
      }
   }
View Full Code Here

      {
         return loader.loadClass(type.getName());
      }
      catch (ClassNotFoundException | LinkageError e)
      {
         throw new ContainerException("Could not locate class [" + type.getName() + "] in Loader [" + loader + "]", e);
      }
   }
View Full Code Here

   public Object invoke(final Object obj, final Method thisMethod, final Method proceed, final Object[] args)
            throws Throwable
   {
      if (Thread.currentThread().isInterrupted())
      {
         throw new ContainerException("Thread.interrupt() requested.");
      }

      Object result = ClassLoaders.executeIn(delegateLoader, new Callable<Object>()
      {
         @Override
         public Object call() throws Exception
         {
            try
            {
               if (thisMethod.getDeclaringClass().getName().equals(ForgeProxy.class.getName()))
               {
                  if (thisMethod.getName().equals("getDelegate"))
                     return ClassLoaderAdapterCallback.this.getDelegate();
                  if (thisMethod.getName().equals("getHandler"))
                     return ClassLoaderAdapterCallback.this.getHandler();
               }
            }
            catch (final Exception e)
            {
            }

            final Method delegateMethod = getDelegateMethod(thisMethod);

            final List<Object> parameterValues = enhanceParameterValues(args, delegateMethod);

            AccessibleObject.setAccessible(new AccessibleObject[] { delegateMethod }, true);
            try
            {
               final Object[] parameterValueArray = parameterValues.toArray();
               final Object result = delegateMethod.invoke(delegate, parameterValueArray);
               return enhanceResult(thisMethod, result);
            }
            catch (final InvocationTargetException e)
            {
               if (e.getCause() instanceof Exception)
                  throw enhanceException(delegateMethod, (Exception) e.getCause());
               throw enhanceException(delegateMethod, e);
            }

         }

         private Method getDelegateMethod(final Method proxy) throws ClassNotFoundException, NoSuchMethodException
         {

            Method delegateMethod = null;
            try
            {
               final List<Class<?>> parameterTypes = translateParameterTypes(proxy);
               delegateMethod = delegate.getClass().getMethod(proxy.getName(),
                        parameterTypes.toArray(new Class<?>[parameterTypes.size()]));
            }
            catch (final ClassNotFoundException e)
            {
               method: for (final Method m : delegate.getClass().getMethods())
               {
                  final String methodName = proxy.getName();
                  final String delegateMethodName = m.getName();
                  if (methodName.equals(delegateMethodName))
                  {
                     final Class<?>[] methodParameterTypes = proxy.getParameterTypes();
                     final Class<?>[] delegateParameterTypes = m.getParameterTypes();

                     if (methodParameterTypes.length == delegateParameterTypes.length)
                     {
                        for (int i = 0; i < methodParameterTypes.length; i++)
                        {
                           final Class<?> methodType = methodParameterTypes[i];
                           final Class<?> delegateType = delegateParameterTypes[i];

                           if (!methodType.getName().equals(delegateType.getName()))
                           {
                              continue method;
                           }
                        }

                        delegateMethod = m;
                        break;
                     }
                  }
               }
               if (delegateMethod == null)
                  throw e;
            }

            return delegateMethod;
         }
      });

      if (Thread.currentThread().isInterrupted())
      {
         throw new ContainerException("Thread.interrupt() requested.");
      }

      return result;
   }
View Full Code Here

         final Class<Enum> callingType = (Class<Enum>) loader.loadClass(instance.getClass().getName());
         return Enum.valueOf(callingType, ((Enum) instance).name());
      }
      catch (final ClassNotFoundException e)
      {
         throw new ContainerException(
                  "Could not enhance instance [" + instance + "] of type [" + instance.getClass() + "]", e);
      }
   }
View Full Code Here

         });
      }
      catch (final Exception e)
      {
         throw new ContainerException("Failed to create proxy for type [" + delegateType + "]", e);
      }
   }
View Full Code Here

                        );
            }
         }
         catch (IOException e)
         {
            throw new ContainerException("Could not load resources from [" + file.getAbsolutePath() + "]", e);
         }
      }
   }
View Full Code Here

                     dependency.isOptional()));
         }
      }

      if (!dependency.isOptional() && (addonId == null || moduleId == null))
         throw new ContainerException("Dependency [" + dependency + "] could not be loaded for addon [" + found
                  + "]");
   }
View Full Code Here

         method.setAccessible(true);
         method.invoke(null);
      }
      catch (Exception e)
      {
         throw new ContainerException("Could not install Modules MBean server", e);
      }
   }
View Full Code Here

                                       .getPosition()];
                           }
                        }
                        else
                        {
                           throw new ContainerException(
                                    "Cannot handle producer for non-Field and non-Method member type: " + member);
                        }

                        return ExportedInstanceLazyLoader.create(
                                 BeanManagerUtils.getContextualInstance(manager, AddonRegistry.class),
View Full Code Here

TOP

Related Classes of org.jboss.forge.furnace.exception.ContainerException

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.