Package org.slf4j

Examples of org.slf4j.Logger


    {
        lock.check();

        assert serviceDef != null;

        Logger logger = getServiceLogger(serviceDef.getServiceId());

        Orderer<ServiceDecorator> orderer = new Orderer<ServiceDecorator>(logger);

        for (Module module : moduleToServiceDefs.keySet())
        {
View Full Code Here


    {
        lock.check();

        assert serviceDef != null;

        Logger logger = getServiceLogger(serviceDef.getServiceId());

        Orderer<ServiceAdvisor> orderer = new Orderer<ServiceAdvisor>(logger);

        for (Module module : moduleToServiceDefs.keySet())
        {
View Full Code Here

            if (ctx != null && ctx.getAuthentication() != null) {
                auditMessage.append('[').append(ctx.getAuthentication().getName()).append(']').append(' ');
            }
            auditMessage.append(message);

            Logger logger = LoggerFactory.getLogger(auditLoggerName.toLoggerName());
            if (throwable == null) {
                logger.debug(auditMessage.toString());
            } else {
                logger.debug(auditMessage.toString(), throwable);
            }
        }
    }
View Full Code Here

     */
    public void execute(final JobExecutionContext context) throws JobExecutionException {

        final JobDataMap data = context.getJobDetail().getJobDataMap();
        final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
        final Logger logger = (Logger)data.get(QuartzScheduler.DATA_MAP_LOGGER);

        // check run on information
        final String[] runOn = (String[])data.get(QuartzScheduler.DATA_MAP_RUN_ON);
        if ( runOn != null ) {
            if ( runOn.length == 1 && Scheduler.VALUE_RUN_ON_LEADER.equals(runOn[0])
                 || runOn.length == 1 && Scheduler.VALUE_RUN_ON_SINGLE.equals(runOn[0]) ) {
                if ( DISCOVERY_INFO_AVAILABLE.get() ) {
                    if ( !IS_LEADER.get() ) {
                        logger.debug("Excluding job {} with name {} and config {}.",
                                new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), runOn[0]});
                        return;
                    }
                } else {
                    logger.warn("No discovery info available. Executing job {} with name {} and config {} anyway.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), runOn[0]});
                }
            } else { // sling IDs
                final String myId = SLING_ID;
                boolean schedule = false;
                if ( myId == null ) {
                    logger.warn("No Sling ID available. Executing job {} with name {} and config {} anyway.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), Arrays.toString(runOn)});
                    schedule = true;
                } else {
                    for(final String id : runOn ) {
                        if ( myId.equals(id) ) {
                            schedule = true;
                            break;
                        }
                    }
                }
                if ( !schedule ) {
                    logger.debug("Excluding job {} with name {} and config {}.",
                            new Object[] {job, data.get(QuartzScheduler.DATA_MAP_NAME), Arrays.toString(runOn)});
                    return;
                }
            }
        }

        try {
            logger.debug("Executing job {} with name {}", job, data.get(QuartzScheduler.DATA_MAP_NAME));
            if (job instanceof org.apache.sling.commons.scheduler.Job) {
                @SuppressWarnings("unchecked")
                final Map<String, Serializable> configuration = (Map<String, Serializable>) data.get(QuartzScheduler.DATA_MAP_CONFIGURATION);
                final String name = (String) data.get(QuartzScheduler.DATA_MAP_NAME);

                final JobContext jobCtx = new JobContextImpl(name, configuration);
                ((org.apache.sling.commons.scheduler.Job) job).execute(jobCtx);
            } else if (job instanceof Runnable) {
                ((Runnable) job).run();
            } else {
                logger.error("Scheduled job {} is neither a job nor a runnable.", job);
            }
        } catch (final Throwable t) {
            // if this is a quartz exception, rethrow it
            if (t instanceof JobExecutionException) {
                throw (JobExecutionException) t;
            }
            // there is nothing we can do here, so we just log
            logger.error("Exception during job execution of " + job + " : " + t.getMessage(), t);
        }
    }
View Full Code Here

    @Test
    public void testOrderForValueAnnotationField() {
        // make sure that that the correct injection is used
        // make sure that log is adapted from value map
        // and not coming from request attribute
        Logger logFromValueMap = LoggerFactory.getLogger(this.getClass());

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("first", "first-value");
        map.put("log", logFromValueMap);
        ValueMap vm = new ValueMapDecorator(map);
View Full Code Here

    }

    @Test
    public void testOSGiServiceField() throws InvalidSyntaxException {
        ServiceReference ref = mock(ServiceReference.class);
        Logger log = mock(Logger.class);
        when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(
                new ServiceReference[] { ref });
        when(bundleContext.getService(ref)).thenReturn(log);

        InjectorSpecificAnnotationModel model = factory.getAdapter(request, InjectorSpecificAnnotationModel.class);
View Full Code Here

    @Test
    public void testOrderForValueAnnotationConstructor() {
        // make sure that that the correct injection is used
        // make sure that log is adapted from value map
        // and not coming from request attribute
        Logger logFromValueMap = LoggerFactory.getLogger(this.getClass());

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("first", "first-value");
        map.put("log", logFromValueMap);
        ValueMap vm = new ValueMapDecorator(map);
View Full Code Here

    }

    @Test
    public void testOSGiServiceConstructor() throws InvalidSyntaxException {
        ServiceReference ref = mock(ServiceReference.class);
        Logger log = mock(Logger.class);
        when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(
                new ServiceReference[] { ref });
        when(bundleContext.getService(ref)).thenReturn(log);

        org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
View Full Code Here

    }

    private void initializeLogbackManager(boolean immediateInit) throws InvalidSyntaxException {
        logManager = new LogbackManager(context);
       
        final Logger log = LoggerFactory.getLogger(getClass());
        if(immediateInit) {
            log.info("LogbackManager initialized at bundle startup");
        } else {
            log.info("LogbackManager initialized after waiting for Slf4j, {} msec after startup", System.currentTimeMillis() - startTime);
        }
    }
View Full Code Here

        //In case logging system completely fails then log the message in System out
        //otherwise make it part of 'normal' logs
        if (!initSuccess) {
            System.out.println(sb.toString());
        } else {
            Logger logger = LoggerFactory.getLogger(SlingStatusPrinter.class);
            logger.info(sb.toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.slf4j.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.