APISonar


org.osgi.service.log.LogService.log

> org > osgi > service > log > LogService > log
org APIs osgi APIs service APIs log APIs LogService APIs log APIs

Example 1
private LogService logService;

    private void log(int level, String message) {
        if (logService != null) {
            logService.log(level, message);
        }
    }
Example 2
private LogService log = null;

	public synchronized void activate(ComponentContext context) {
		log.log(LogService.LOG_INFO, "SubscriptionManager activated");
		bc = context.getBundleContext();

		trySubscribePendingFeeds();
		unsubscriptionTimer.schedule();
	}
Example 3
private LogService log;

    private void registerService(BundleContext context, HttpService httpService) {
        log.log(LogService.LOG_INFO, "registerService: " + context.getBundle());
        ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
        try {
            Properties initParams = new Properties();
            initParams.setProperty("initProp", "SomeValue");
            httpService.registerServlet("/example-http/servlet", new EndpointServlet(context), initParams, null);
            httpService.registerResources("/example-http/file", "/res", null);
        } catch (Exception ex) {
            throw new RuntimeException("Cannot register context", ex);
        } finally {
            // [AS7-903] 3rd party code may leak TCCL
            Thread.currentThread().setContextClassLoader(ctxLoader);
        }
    }
Example 4
private LogService logService;

    public Class<? extends ServerResource> getTargetClass() {
        if (targetClass == null) {
            try {
                targetClass = (Class<? extends ServerResource>) bundle
                        .loadClass(className);
            } catch (ClassNotFoundException e) {
                if (logService != null)
                    logService.log(LogService.LOG_ERROR,
                            "Failed to load class: '" + className + "'", e);
            }
        }

        return targetClass;
    }
Example 5
public void warn(String msg) {
        LogService logService = parent.getLogService();
        if (logService != null) {
            logService.log(LogService.LOG_WARNING, prefix + msg);
        } else {
            fallback.warn(msg);
        }
    }
Example 6
public void start(BundleContext context) throws Exception {
        tracker = new ServiceTracker(context, LogService.class.getName(), null) {
            @Override
            public Object addingService(ServiceReference reference) {
                LogService service = (LogService) super.addingService(reference);
                service.log(LogService.LOG_INFO, "Hello from " + context.getBundle());
                return service;
            }
        };
        tracker.open();
    }
Example 7
private final LogService logService;

    public void publish(LogRecord record) {
        logService.log(new LogRecordReference(record), toServiceLevel(record.getLevel()), record.getMessage(),
                       record.getThrown());
    }
Example 8
private void prepareErrorLog(Exception exp,String msg) {
        ServiceReference logServiceReference = createMock(ServiceReference.class);
        LogService logService = createMock(LogService.class);
        expect(context.getServiceReference(LogService.class.getName())).andReturn(logServiceReference);
        expect(context.getService(logServiceReference)).andReturn(logService);
        logService.log(eq(LogService.LOG_ERROR), find(msg), eq(exp));
        expect(context.ungetService(logServiceReference)).andReturn(false);
        replay(logServiceReference, logService);
    }
Example 9
private LogService logService;

    private void registerServlet(ApplicationProvider applicationProvider) {
        ApplicationServlet servlet = new ApplicationServlet(applicationProvider);

        try {
            httpService.registerServlet(applicationProvider.getAlias(),
                    servlet, applicationProvider.getInitParms(),
                    applicationProvider.getContext());
        } catch (Exception e) {
            if (logService != null)
                logService.log(LogService.LOG_ERROR,
                        "Failed to register the application servlet at alias: '"
                                + applicationProvider.getAlias() + "'", e);
        }
    }