Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 Red Hat, Inc. and/or its affiliates.
  *
  * Licensed under the Eclipse Public License version 1.0, available at
  * http://www.eclipse.org/legal/epl-v10.html
  */
 package org.jboss.forge.arquillian.maven;
 

Author(s):
Lincoln Baxter, III
   public <T> T lookup(final Class<T> type)
   {
      try
      {
         return ClassLoaders.executeIn(Thread.currentThread().getContextClassLoader(), new Callable<T>()
         {
            @Override
            public T call() throws Exception
            {
               return getPlexusContainer().lookup(type);
            }
         });
      }
      catch (Exception e)
      {
         throw new RuntimeException("Could not look up component of type [" + type.getName() + "]"e);
      }
   }
   public void shutdown()
   {
      if ( != null)
      {
         .dispose();
          = null;
      }
   }
   {
      if ( == null)
      {
          = ClassLoaders.executeIn(Thread.currentThread().getContextClassLoader(),
                  new Callable<DefaultPlexusContainer>()
                  {
                     @Override
                     public DefaultPlexusContainer call() throws Exception
                     {
                        try
                        {
                           ContainerConfiguration config = new DefaultContainerConfiguration().setAutoWiring(true);
                            = new DefaultPlexusContainer(config);
                           ConsoleLoggerManager loggerManager = new ConsoleLoggerManager();
                           loggerManager.setThreshold("ERROR");
                           ((DefaultPlexusContainer).setLoggerManager(loggerManager);
                           return (DefaultPlexusContainer;
                        }
                        catch (Exception e)
                        {
                           throw new RuntimeException(
                                    "Could not initialize Maven"e);
                        }
                     }
                  });
      }
      return ;
   }
New to GrepCode? Check out our FAQ X