Example usage for java.util.logging Logger getAnonymousLogger

List of usage examples for java.util.logging Logger getAnonymousLogger

Introduction

In this page you can find the example usage for java.util.logging Logger getAnonymousLogger.

Prototype

public static Logger getAnonymousLogger() 

Source Link

Document

Create an anonymous Logger.

Usage

From source file:org.jaxygen.typeconverter.util.BeanUtil.java

/**
 * Copies bean content from one bean to another. The bean is copied using the
 * set and get methods. Method invokes all getXX methods on the from object,
 * and result pass to the corresponding setXX methods in the to object. Note
 * that it is not obvious that both object are of the same type.
 * If get and set methods do not match then it tries to use appropriate
 * converter registered in default type converter factory.
 *
 * @param from data provider object./*from  w ww . j a va 2 s .  c  o m*/
 * @param to data acceptor object.
 */
public static void translateBean(Object from, Object to) {
    PropertyDescriptor[] fromGetters = null;
    fromGetters = PropertyUtils.getPropertyDescriptors(from.getClass());
    for (PropertyDescriptor pd : fromGetters) {
        if (pd.getReadMethod().isAnnotationPresent(BeanTransient.class) == false) {
            if (PropertyUtils.isWriteable(to, pd.getName())) {
                try {
                    PropertyDescriptor wd = PropertyUtils.getPropertyDescriptor(to, pd.getName());
                    if (!wd.getWriteMethod().isAnnotationPresent(BeanTransient.class)) {
                        Object copyVal = PropertyUtils.getProperty(from, pd.getName());
                        if (wd.getPropertyType().isAssignableFrom(pd.getPropertyType())) {
                            PropertyUtils.setProperty(to, wd.getName(), copyVal);
                        } else {
                            try {
                                Object convertedCopyVal = TypeConverterFactory.instance().convert(copyVal,
                                        wd.getPropertyType());
                                PropertyUtils.setProperty(to, wd.getName(), convertedCopyVal);
                            } catch (ConversionError ex) {
                                Logger.getAnonymousLogger().log(Level.WARNING,
                                        "Method {0}.{1} of type {2} is not compatible to {3}.{4} of type{5}",
                                        new Object[] { from.getClass().getName(), pd.getName(),
                                                pd.getPropertyType(), to.getClass().getName(), wd.getName(),
                                                wd.getPropertyType() });
                            }
                        }
                    }
                } catch (IllegalAccessException ex) {
                    throw new java.lang.IllegalArgumentException("Could not translate bean", ex);
                } catch (InvocationTargetException ex) {
                    throw new java.lang.IllegalArgumentException("Could not translate bean", ex);
                } catch (NoSuchMethodException ex) {
                    throw new java.lang.IllegalArgumentException("Could not translate bean", ex);
                }
            }
        }
    }
}

From source file:com.adamantium.company.gwtp.server.spring.ServerModule.java

@Bean
public LoggerFactoryBean getLogger() {
    Logger logger = Logger.getAnonymousLogger();
    logger.setLevel(Level.FINEST);
    return new LoggerFactoryBean(logger);
}

From source file:net.sqs2.omr.app.MarkReaderControllerImpl.java

private MarkReaderControllerImpl(int rmiPort) throws UnknownHostException, IOException {

    System.setProperty("java.rmi.server.hostname", getHostname());

    long key = MarkReaderConstants.RANDOM.nextLong();
    Logger.getAnonymousLogger().warning("master key=" + key);

    SessionServiceImpl sessionService = SessionServiceImpl.createInstance(key,
            MarkReaderConstants.CLIENT_TIMEOUT_IN_SEC);
    this.localTaskExecutorEnv = new TaskExecutorEnv(sessionService, null, key);

    this.networkPeer = new NetworkPeer(rmiPort, MarkReaderConstants.SESSION_SERVICE_PATH);

    this.sessionThreadManager = new SessionThreadManager();

    exportSessionService();//from   ww w  .  j a v a 2s  .c  o  m

    this.localTaskBroker = new TaskBroker("Local", this.networkPeer.getTaskExecutorPeer(),
            localTaskExecutorEnv);
}

From source file:com.tckb.geo.stubgen.Generator.java

/**
 * Gets the json from the webservice and saves it in local as JSON file
 *
 * @throws IOException// w w w . j a v a  2s.c o m
 */
public static void getRawJsonFromRemote() throws IOException {

    deviceJson = createJSONFile(getRawData(remoteService.getDeviceJSON()), "resp_device");
    clusterJson = createJSONFile(getRawData(remoteService.getClusterJSON()), "resp_cluster");
    //        locationJson = createJSONFile(getRawData(remoteService.geLocationJSON()), "resp_loc.json");

    Logger.getAnonymousLogger().info("Parsing raw data...");

}

From source file:com.tckb.geo.stubgen.Generator.java

/**
 * Retrieves the raw data response from the webservice
 *
 * @param r//ww  w.  ja v  a  2 s .com
 * @return
 * @throws IOException
 */
public static String getRawData(Response r) throws IOException {
    Logger.getAnonymousLogger().log(Level.INFO, "Retrieving raw data from remote url: {0}", r.getUrl());
    if (r.getStatus() == 200) {
        BufferedReader br = new BufferedReader(new InputStreamReader(r.getBody().in()));
        String line;
        StringBuilder sb = new StringBuilder();
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        return sb.toString();
    } else {
        Logger.getAnonymousLogger().log(Level.WARNING, "Server returned {0} status while retrieving{1} !",
                new Object[] { String.valueOf(r.getStatus()), r.getUrl() });
        return "_NO_CONTENT_";
    }
}

From source file:com.vmware.photon.controller.api.client.resource.ApiBase.java

/**
 * Creates an object as async./*  www  .ja v  a 2s  .c om*/
 *
 * @param path
 * @param responseCallback
 * @throws IOException
 */
public final void createObjectAsync(final String path, final HttpEntity payload,
        final FutureCallback<Task> responseCallback) throws IOException {

    this.restClient.performAsync(RestClient.Method.POST, path, payload,
            new org.apache.http.concurrent.FutureCallback<HttpResponse>() {
                @Override
                public void completed(HttpResponse result) {
                    Task task = null;
                    try {
                        restClient.checkResponse(result, HttpStatus.SC_CREATED);
                        task = restClient.parseHttpResponse(result, new TypeReference<Task>() {
                        });
                    } catch (Throwable e) {
                        responseCallback.onFailure(e);
                    }

                    if (task != null) {
                        Logger.getAnonymousLogger().log(Level.INFO, String
                                .format("createObjectAsync returned task [%s] %s", this.toString(), path));
                        responseCallback.onSuccess(task);
                    } else {
                        Logger.getAnonymousLogger().log(Level.INFO,
                                String.format("createObjectAsync failed [%s] %s", this.toString(), path));
                    }
                }

                @Override
                public void failed(Exception ex) {
                    Logger.getAnonymousLogger().log(Level.INFO, "{}", ex);
                    responseCallback.onFailure(ex);
                }

                @Override
                public void cancelled() {
                    responseCallback.onFailure(
                            new RuntimeException(String.format("createAsync %s was cancelled", path)));
                }
            });
}

From source file:io.jenkins.blueocean.blueocean_git_pipeline.GitCloneReadSaveRequest.java

GitClient cloneRepo() throws InterruptedException, IOException {
    EnvVars environment = new EnvVars();
    TaskListener taskListener = new LogTaskListener(Logger.getAnonymousLogger(), Level.ALL);
    String gitExe = gitTool.getGitExe();
    GitClient git = Git.with(taskListener, environment).in(repositoryPath).using(gitExe).getClient();

    git.addCredentials(gitSource.getRemote(), getCredential());

    try {/*from   ww  w . ja v  a2s .  co  m*/
        git.clone(gitSource.getRemote(), "origin", true, null);

        log.fine("Repository " + gitSource.getRemote() + " cloned to: " + repositoryPath.getCanonicalPath());
    } catch (GitException e) {
        // check if this is an empty repository
        boolean isEmptyRepo = false;
        try {
            if (git.getRemoteReferences(gitSource.getRemote(), null, true, false).isEmpty()) {
                isEmptyRepo = true;
            }
        } catch (GitException ge) {
            // *sigh* @ this necessary hack; {@link org.jenkinsci.plugins.gitclient.CliGitAPIImpl#getRemoteReferences}
            if ("unexpected ls-remote output ".equals(ge.getMessage())) { // blank line, command succeeded
                isEmptyRepo = true;
            }
            // ignore other reasons
        }

        if (isEmptyRepo) {
            git.init();
            git.addRemoteUrl("origin", gitSource.getRemote());

            log.fine("Repository " + gitSource.getRemote() + " not found, created new to: "
                    + repositoryPath.getCanonicalPath());
        } else {
            throw e;
        }
    }

    return git;
}

From source file:org.silverpeas.core.viewer.service.ViewServiceCacheDemonstrationBefore.java

@Test
public void demonstrateCache() throws Exception {
    if (canPerformViewConversionTest()) {
        SimpleDocument document = getSimpleDocumentNamed("file.odt");
        long start = System.currentTimeMillis();
        DocumentView documentView = viewService.getDocumentView(ViewerContext.from(document));
        assertDocumentView(documentView);
        long end = System.currentTimeMillis();
        long conversionDuration = end - start;
        Logger.getAnonymousLogger().info(
                "Conversion duration + cache in " + DurationFormatUtils.formatDurationHMS(conversionDuration));
        assertThat(conversionDuration, greaterThan(250l));
        saveInTemporaryPath(ViewServiceCacheDemonstrationITSuite.CONVERSION_DURATION_FILE_NAME,
                String.valueOf(conversionDuration));
        saveInTemporaryPath(ViewServiceCacheDemonstrationITSuite.DOCUMENT_VIEW_FILE_NAME,
                SerializationUtil.serializeAsString(documentView));
    }/* w ww  .  ja  v a 2  s .  c  om*/
}

From source file:org.silverpeas.core.viewer.service.ViewServiceNoCacheDemonstrationBefore.java

@Test
public void demonstrateNoCache() throws Exception {
    if (canPerformViewConversionTest()) {
        SimpleDocument document = getSimpleDocumentNamed("file.odt");
        long start = System.currentTimeMillis();
        DocumentView documentView = viewService.getDocumentView(ViewerContext.from(document));
        assertDocumentView(documentView);
        long end = System.currentTimeMillis();
        long conversionDuration = end - start;
        Logger.getAnonymousLogger().info("Conversion duration without cache in "
                + DurationFormatUtils.formatDurationHMS(conversionDuration));
        assertThat(conversionDuration, greaterThan(250l));
        saveInTemporaryPath(ViewServiceNoCacheDemonstrationITSuite.CONVERSION_DURATION_FILE_NAME,
                String.valueOf(conversionDuration));
        saveInTemporaryPath(ViewServiceNoCacheDemonstrationITSuite.DOCUMENT_VIEW_FILE_NAME,
                SerializationUtil.serializeAsString(documentView));
    }//from w w w .  j a va2s. c  o m
}

From source file:org.sakaiproject.genericdao.springutil.SmartDataSourceWrapper.java

public Logger getParentLogger() throws SQLFeatureNotSupportedException {
    return Logger.getAnonymousLogger();
}