Package org.bladerunnerjs.logging

Examples of org.bladerunnerjs.logging.Logger


  }

  @Override
  public Logger logger(Class<?> clazz)
  {
    return new Logger()
    {

      @Override
      public String getName()
      {
View Full Code Here


  }
 
  @Test
  public void testGettingLoggerForClass() throws Exception
  {
    Logger logger = brjs.logger(this.getClass());
    assertEquals("org.bladerunnerjs.model.navigation", logger.getName());
  }
View Full Code Here

 
  List<I> getSubTypesOfClass(BRJS brjs, Class<I> iFace)
  {
    List<I> objectList = new ArrayList<I>();

    Logger logger = brjs.logger(BRJSPluginLocator.class);

    ServiceLoader<I> loader = ServiceLoader.load(iFace);
    try
    {
      Iterator<I> classes = loader.iterator();
      while (classes.hasNext())
      {
        I clazz = classes.next();
        objectList.add(clazz);
      }
    }
    catch (ServiceConfigurationError serviceError)
    {
      Throwable cause = serviceError.getCause();
      if (cause != null && cause.getClass() == InstantiationException.class)
      {
        logger.error(Messages.CANNOT_CREATE_INSTANCE_LOG_MSG, cause.getMessage());       
      } else
      {
        logger.error(Messages.ERROR_CREATING_OBJECT_LOG_MSG, serviceError);
      }
    }

    return objectList;
  }
View Full Code Here

    {
      throw new RuntimeException(ex);
    }
   
   
    Logger logger = brjs.logger(BRJSPluginLocator.class);
    List<P> objectList = new ArrayList<P>();
   
    try
    {
      ServiceLoader<P> loader = ServiceLoader.load(pluginInterface, classLoader);
      Iterator<P> objectIterator = loader.iterator();
     
      while (objectIterator.hasNext())
      {
        P object = objectIterator.next();
       
        if (virtualProxyClass != null)
        {
          object = virtualProxyClass.getConstructor(pluginInterface).newInstance(object);
        }
       
        objectList.add(object);
      }
    }
    catch (ServiceConfigurationError serviceError)
    {
      Throwable cause = serviceError.getCause();
     
      if (cause != null && cause.getClass() == InstantiationException.class)
      {
        if (logger != null)
        {
          logger.error(Messages.CANNOT_CREATE_INSTANCE_LOG_MSG, cause.getMessage());
        }
        else
        {
          System.err.println( String.format(Messages.CANNOT_CREATE_INSTANCE_LOG_MSG, cause.getMessage()) );
        }
      } else
      {
        if (logger != null)
        {
          logger.error(Messages.ERROR_CREATING_OBJECT_LOG_MSG, serviceError);
        }
        else
        {
          System.err.println( String.format(Messages.ERROR_CREATING_OBJECT_LOG_MSG, serviceError) );
        }
View Full Code Here

    return doRunCommand(brjs, args);
  }

  private static int doRunCommand(BRJS brjs, String[] args) throws CommandOperationException
  {
    Logger logger = brjs.logger(UserCommandRunner.class);
    try {
      checkApplicationLibVersions(brjs, logger);
      return brjs.runCommand(args);
    }
    catch (NoSuchCommandException e) {
      if (e.getCommandName().length() > 0)
      {
        logger.println(e.getMessage());
        logger.println("--------");
        logger.println("");
      }
      return doRunCommand(brjs, new String[] {new HelpCommand().getCommandName() });
    }
    catch (CommandArgumentsException e) {
      logger.println("Problem:");
      logger.println("  " + e.getMessage());
      logger.println("");
      logger.println("Usage:");
      logger.println("  brjs " + e.getCommand().getCommandName() + " " + e.getCommand().getCommandUsage());
    }
    catch (CommandOperationException e) {
      logger.println("Error:");
      logger.println("  " + e.getMessage());
     
      if (e.getCause() != null) {
        logger.println("");
        logger.println("Caused By:");
        logger.println("  " + e.getCause().getMessage());
      }
     
      logger.println("");
      logger.println("Stack Trace:");
      StringWriter stackTrace = new StringWriter();
      e.printStackTrace(new PrintWriter(stackTrace));
      logger.println(stackTrace.toString());
     
      throw e;
    }
    return -1;
  }
View Full Code Here

  }
 
  public static ResponseContent handle(BundleSet bundleSet, String logicalRequestpath, UrlContentAccessor contentAccessor, String version) throws MalformedRequestException, ResourceNotFoundException, ContentProcessingException {
    BundlableNode bundlableNode = bundleSet.getBundlableNode();
    App app = bundlableNode.app();
    Logger logger = app.root().logger(BundleSetRequestHandler.class);
   
    logger.debug(Messages.REQUEST_HANDLED_MSG, logicalRequestpath, app.getName());
   
    String name = (bundlableNode instanceof NamedNode) ? ((NamedNode) bundlableNode).getName() : "default";
    logger.debug(Messages.CONTEXT_IDENTIFIED_MSG, bundlableNode.getTypeName(), name, logicalRequestpath);
   
    ContentPlugin contentProvider = app.root().plugins().contentPluginForLogicalPath(logicalRequestpath);
   
    if(contentProvider == null) {
      throw new ResourceNotFoundException("No content provider could be found found the logical request path '" + logicalRequestpath + "'");
    }
   
    logger.debug(Messages.BUNDLER_IDENTIFIED_MSG, contentProvider.getPluginClass().getSimpleName(), logicalRequestpath);
   
    ParsedContentPath contentPath = contentProvider.getContentPathParser().parse(logicalRequestpath);
    return contentProvider.handleRequest(contentPath, bundleSet, contentAccessor, version);
  }
View Full Code Here

    return getDriver(testSpecifiedBrowser, new HashMap<String, String>());
  }
 
  public static WebDriver getDriver(String testSpecifiedBrowser, Map<String, String> driverOptions) throws Exception
  {
    Logger logger = ThreadSafeStaticBRJSAccessor.root.logger(WebDriverProvider.class);
   
    String browserName = (commandLineSpecifiedBrowser != null) ? commandLineSpecifiedBrowser : testSpecifiedBrowser;
    WebDriver driver = null;
   
    for(DriverFactory driverFactory : driverFactories)
    {
      if(driverFactory.canHandleBrowser(browserName))
      {
        File browserPath = getBrowserPathFromConf(browserName);
        logger.debug("using '" + browserName + "' browser ('" + browserPath + "')");
       
        driver = driverFactory.createDriver(browserPath, driverOptions);
      }
    }
   
View Full Code Here

    public static final String FILE_HAS_NO_DEPENDENCIES_MSG = "File '%s' has no dependencies.";
    public static final String FILE_DEPENDENCIES_MSG = "File '%s' depends on %s.";
  }
 
  public static BundleSet createBundleSet(BundlableNode bundlableNode) throws ModelOperationException {
    Logger logger = bundlableNode.root().logger(BundleSetCreator.class);
   
    BundleSetBuilder bundleSetBuilder = new BundleSetBuilder(bundlableNode);
    List<LinkedAsset> seedFiles = bundlableNode.seedAssets();
   
    String name = (bundlableNode instanceof NamedNode) ? ((NamedNode) bundlableNode).getName() : "default";
    if(seedFiles.isEmpty()) {
      logger.debug(Messages.BUNDLABLE_NODE_HAS_NO_SEED_FILES_MSG, bundlableNode.getTypeName(), name);
    }
    else {
      logger.debug(Messages.BUNDLABLE_NODE_SEED_FILES_MSG, bundlableNode.getTypeName(), name, seedFilePaths(bundlableNode, seedFiles));
    }
   
    logger.debug(Messages.APP_SOURCE_LOCATIONS_MSG, bundlableNode.app().getName(), assetContainerPaths(bundlableNode.app()));
   
    bundleSetBuilder.addSeedFiles(seedFiles);
   
    return bundleSetBuilder.createBundleSet();
  }
View Full Code Here

  }
 
  @Override
  public void create() throws InvalidNameException, ModelUpdateException
  {
    Logger logger = rootNode.logger(Node.class);
   
    try {
      if(dirExists()) throw new DirectoryAlreadyExistsModelException(this);
      if(this instanceof NamedNode) ((NamedNode) this).assertValidName();
     
      try {
        FileUtils.forceMkdir(dir);
        notifyObservers(new NodeCreatedEvent(), this);
        logger.debug(Messages.NODE_CREATED_LOG_MSG, getTypeName(), dir().getPath());
       
        rootNode.getFileInfo(dir()).resetLastModified();
      }
      catch(IOException e) {
        throw new ModelUpdateException(e);
      }
    }
    catch(Exception e) {
      logger.error(Messages.NODE_CREATION_FAILED_LOG_MSG, getTypeName(), dir().getPath());
      throw e;
    }
  }
View Full Code Here

    }
  }
 
  protected void createDefaultNode() throws InvalidNameException, ModelUpdateException
  {
    Logger logger = rootNode.logger(Node.class);
   
    try {
      if(this instanceof NamedNode) ((NamedNode) this).assertValidName();
     
      notifyObservers(new NodeCreatedEvent(), this);
      logger.debug(Messages.NODE_CREATED_LOG_MSG, getTypeName(), dir().getPath());
       
      rootNode.getFileInfo(dir().getParentFile()).resetLastModified();
    }
    catch(Exception e) {
      logger.error(Messages.NODE_CREATION_FAILED_LOG_MSG, getTypeName(), dir().getPath());
      throw e;
    }
  }
View Full Code Here

TOP

Related Classes of org.bladerunnerjs.logging.Logger

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.