Example usage for java.util.logging Logger getLogger

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

Introduction

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

Prototype




@CallerSensitive
public static Logger getLogger(String name) 

Source Link

Document

Find or create a logger for a named subsystem.

Usage

From source file:jfreechart.ViewGirlsBoysAvgChart.java

public static void viweGirlsAvgChart(List<String> testId, ArrayList<Double> totAvg, ArrayList<Double> girlsAvg,
        ArrayList<Double> boysAvg) throws SQLException, ClassNotFoundException {
    try {//from w  ww. j a  va  2s  .co m
        UIManager.setLookAndFeel(new McWinLookAndFeel());
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(ViewEachStudentChart.class.getName()).log(Level.SEVERE, null, ex);
    }
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();

    for (Double marks : totAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line1", marks);

    }
    for (Double marks : girlsAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line2", marks);

    }
    //        for (Double testMark : bAvgList) {
    //            Double mark = testMark;
    //            //String tstId = testId.split(",")[3];
    //            objDataset.setValue(mark, "", mark);
    //            
    //            
    //        }
    JFreeChart objChart = ChartFactory.createLineChart("Marks Chart", //Chart title
            "Test", //Domain axis label
            "Marks", //Range axis label
            objDataset, //Chart Data 
            PlotOrientation.VERTICAL, // orientation
            true, // include legend?
            true, // include tooltips?
            false // include URLs?
    );

    ChartFrame frame = new ChartFrame("Dakma Higher Education Center", objChart);
    frame.setLocationRelativeTo(frame);
    frame.pack();
    frame.setVisible(true);
}

From source file:bridgempp.EndpointTranslator.java

public static void saveHumanReadableEndpoint(Endpoint endpoint, String endpointName) {
    try {//from   w  w  w .  j a v a  2  s  .  com
        ConfigurationManager.endpointConfiguration
                .setProperty("endpoints.id" + computeEndpointID(endpoint.getIdentifer()), endpointName);
        ConfigurationManager.endpointConfiguration.save();
    } catch (ConfigurationException ex) {
        Logger.getLogger(EndpointTranslator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.smallfe.clerk.util.DigestUtil.java

public static String getSHA256(String message) {
    try {/*  ww  w  . j a v a 2 s . com*/
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        md.update(message.getBytes());

        byte byteData[] = md.digest();

        //convert the byte to hex format method 1
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
        return sb.toString();
    } catch (NoSuchAlgorithmException ex) {
        Logger.getLogger(DigestUtil.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}

From source file:com.eu.evaluation.web.controller.pojo.EvaluateVersionVO.java

public static EvaluateVersionVO cloneWith(EvaluateVersion ev) {
    EvaluateVersionVO vo = new EvaluateVersionVO();
    try {// w ww.  java2s .  c o m
        BeanUtils.copyProperties(vo, ev);
        vo.setTokens(new String[] { ev.getName() });
        vo.setValue(ev.getName());
    } catch (IllegalAccessException ex) {
        Logger.getLogger(EvaluateVersionVO.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InvocationTargetException ex) {
        Logger.getLogger(EvaluateVersionVO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return vo;
}

From source file:it.cnr.ilc.tokenizer.utils.Utilities.java

public static String readFileContent(String filepath) throws IOException {
    String message = "";
    File initialFile;// w w  w.  ja va2  s  .  c  om
    InputStream targetStream = null;
    String theString = "";

    try {
        initialFile = new File(filepath);
        targetStream = FileUtils.openInputStream(initialFile);
        theString = IOUtils.toString(targetStream, "UTF-8");
    } catch (IOException e) {

        message = "IOaaException in reading the stream for " + filepath + " " + e.getMessage();
        Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, message);
        //System.exit(-1);
    } finally {
        if (targetStream != null) {
            try {
                targetStream.close();
            } catch (IOException e) {
                message = "IOException in closing the stream for " + filepath + " " + e.getMessage();
                Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, message);
                //System.exit(-1);
            }

        }

    }
    //System.err.println(theString);
    return theString;
}

From source file:com.lushell.tc.dbpaas.api.utils.MyHttpUtil.java

public static String getDataFromUrl(String url, int timeout) {
    try {/* w w w.  j  a v  a  2s. c om*/
        HttpClient httpClient = HttpClients.createDefault();
        HttpGet httpget = new HttpGet(url);
        HttpResponse response = httpClient.execute(httpget);
        HttpEntity entity = response.getEntity();
        //StatusLine statusLine = response.getStatusLine();
        String body = EntityUtils.toString(entity);
        return body;
    } catch (IOException ex) {
        Logger.getLogger(MyHttpUtil.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}

From source file:net.maxgigapop.mrs.driver.openstack.OpenStackModelBuilder.java

public static OntModel createOntology(String hostName, String tenantName, String tenantPasswd)
        throws IOException {

    String host = "charon.dragon.maxgigapop.net";
    String tenant = "admin";
    String tenantId;/*from  ww w  .  j  av  a  2s.  c o m*/
    String token;

    Logger logger = Logger.getLogger(OpenStackModelBuilder.class.getName());

    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);

    model.setNsPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    model.setNsPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    model.setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#");
    model.setNsPrefix("owl", "http://www.w3.org/2002/07/owl#");
    model.setNsPrefix("nml", "http://schemas.ogf.org/nml/2013/03/base#");
    model.setNsPrefix("mrs", "http://schemas.ogf.org/mrs/2013/12/topology#");

    Property hasNode = model.createProperty("http://schemas.ogf.org/nml/2013/03/base#hasNode");
    Property hasService = model.createProperty("http://schemas.ogf.org/nml/2013/03/base#hasService");
    Property providesVM = model.createProperty("http://schemas.ogf.org/mrs/2013/12/topology#providesVM");
    Property type = model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
    Property memory_mb = model.createProperty("http://schemas.ogf.org/mrs/2013/12/topology#memory_mb");
    Property num_core = model.createProperty("http://schemas.ogf.org/mrs/2013/12/topology#num_core");
    Property disk_gb = model.createProperty("http://schemas.ogf.org/mrs/2013/12/topology#disk_gb");

    Resource HypervisorService = model
            .createResource("http://schemas.ogf.org/mrs/2013/12/topology#HypervisorService");
    Resource Node = model.createResource("http://schemas.ogf.org/nml/2013/03/base#Node");
    Resource Topology = model.createResource("http://schemas.ogf.org/mrs/2013/12/topology#Topology");
    Resource VirtualSwitchService = model
            .createResource("http://schemas.ogf.org/mrs/2013/12/topology#VirtualSwitchService");
    Resource NamedIndividual = model.createResource("http://www.w3.org/2002/07/owl#NamedIndividual");
    Resource Nova = model.createResource("urn:ogf:network:dragon.maxgigapop.net:openstack-nova");
    Resource Neutron = model.createResource("urn:ogf:network:dragon.maxgigapop.net:openstack-neutron");
    Resource OpenstackTopology = model.createResource("urn:ogf:network:dragon.maxgigapop.net:topology");

    model.add(model.createStatement(OpenstackTopology, type, Topology));
    model.add(model.createStatement(OpenstackTopology, type, NamedIndividual));

    model.add(model.createStatement(Nova, type, HypervisorService));
    model.add(model.createStatement(Nova, type, NamedIndividual));

    model.add(model.createStatement(Neutron, type, VirtualSwitchService));
    model.add(model.createStatement(Neutron, type, NamedIndividual));

    token = OpenStackRESTClient.getToken(host, tenant, "admin", "admin");
    tenantId = OpenStackRESTClient.getTenantId(host, tenant, token);
    JSONArray novaDescription = OpenStackRESTClient.pullNovaConfig(host, tenantId, token);

    for (Object o : novaDescription) {

        JSONArray node = (JSONArray) ((JSONObject) o).get("host");

        if (node != null) {

            JSONObject resource = (JSONObject) ((JSONObject) node.get(0)).get("resource");
            String nodeName = (String) resource.get("host");
            Long numCpu = (Long) resource.get("cpu");
            Long memMb = (Long) resource.get("memory_mb");
            Long diskGb = (Long) resource.get("disk_gb");

            Resource computeNode = model.createResource("urn:ogf:network:dragon.maxgigapop.net:" + nodeName);
            Literal cpu = model.createTypedLiteral(numCpu);
            Literal mem = model.createTypedLiteral(memMb);
            Literal disk = model.createTypedLiteral(diskGb);

            model.add(model.createStatement(OpenstackTopology, hasNode, computeNode));
            model.add(model.createStatement(computeNode, type, Node));
            model.add(model.createStatement(computeNode, type, NamedIndividual));
            model.add(model.createStatement(computeNode, hasService, Nova));

            model.add(model.createStatement(computeNode, memory_mb, mem));
            model.add(model.createStatement(computeNode, disk_gb, disk));
            model.add(model.createStatement(computeNode, num_core, cpu));
        }

        JSONObject networkHost = (JSONObject) ((JSONObject) o).get("network_host");
        if (networkHost != null) {

            Resource networkNode = model.createResource(
                    "urn:ogf:network:dragon.maxgigapop.net:" + (String) networkHost.get("host_name"));

            model.add(model.createStatement(OpenstackTopology, hasNode, networkNode));
            model.add(model.createStatement(networkNode, type, Node));
            model.add(model.createStatement(networkNode, type, NamedIndividual));
            model.add(model.createStatement(networkNode, hasService, Neutron));
        }
    }

    tenantId = OpenStackRESTClient.getTenantId(host, "demo", token);
    token = OpenStackRESTClient.getToken(host, "demo", "demo", "demo");
    JSONArray vms = OpenStackRESTClient.pullNovaVM(host, tenantId, token);

    for (Object o : vms) {

        String vmName = (String) ((JSONObject) o).get("name");
        Resource vm = model.createResource("urn:ogf:network:dragon.maxgigapop.net:" + vmName);

        model.add(model.createStatement(vm, type, Node));
        model.add(model.createStatement(vm, type, NamedIndividual));

        model.add(model.createStatement(Nova, providesVM, vm));

    }

    /* 
    JSONArray ports = (JSONArray) OpenStackRESTClient.pullNeutron(host, tenantId, token).get("ports");        
    for(Object o : ports) {
            
            
    } */

    logger.log(Level.INFO, "Ontology model for OpenStack driver rewritten");

    return model;
}

From source file:com.mycompany.client.bank.utils.CryptMessage.java

public static List fromInternal(String SuperSecret, Object... criptStrings) {
    paramLst = new ArrayList<>();
    byte[] syperSecretBytes = null;
    try {/* ww w  .jav  a 2  s.  co  m*/
        syperSecretBytes = SuperSecret.getBytes("utf-8");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(CryptMessage.class.getName()).log(Level.SEVERE, null, ex);
    }
    int colvo = 0;
    for (Object str : criptStrings) {
        try {
            if (str != null) {
                byte[] mybyte = str.toString().getBytes("utf-8");
                int i = 0;
                ByteTransform(syperSecretBytes, mybyte, i);
                paramLst.add(colvo++, new String(mybyte, "utf-8"));
            } else {
                paramLst.add(colvo++, null);
            }
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(CryptMessage.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return paramLst;
}

From source file:bizlogic.Sensors.java

public static void list(Connection DBcon) throws IOException, ParseException, SQLException {

    Statement st = null;/*from  www  .j  av a 2s .c  om*/
    ResultSet rs = null;

    try {
        st = DBcon.createStatement();
        rs = st.executeQuery("SELECT * FROM USERCONF.SENSORLIST");

    } catch (SQLException ex) {
        Logger lgr = Logger.getLogger(Sensors.class.getName());
        lgr.log(Level.SEVERE, ex.getMessage(), ex);
    }
    try {
        FileWriter sensorsFile = new FileWriter("/var/lib/tomcat8/webapps/ROOT/Records/sensors.json");
        sensorsFile.write("");
        sensorsFile.flush();

        JSONParser parser = new JSONParser();

        JSONObject Records = new JSONObject();

        JSONObject operation_Obj = new JSONObject();
        JSONObject operand_Obj = new JSONObject();
        JSONObject unit_Obj = new JSONObject();
        JSONObject name_Obj = new JSONObject();
        JSONObject ip_Obj = new JSONObject();
        JSONObject port_Obj = new JSONObject();

        int _total = 0;

        JSONArray sensorList = new JSONArray();

        while (rs.next()) {

            JSONObject sensor_Obj = new JSONObject();
            int id = rs.getInt("sensor_id");
            String operation = rs.getString("operation");
            int operand = rs.getInt("operand");
            String unit = rs.getString("unit");
            String name = rs.getString("name");
            String ip = rs.getString("IP");
            int port = rs.getInt("port");

            sensor_Obj.put("recid", id);
            sensor_Obj.put("operation", operation);
            sensor_Obj.put("operand", operand);
            sensor_Obj.put("unit", unit);
            sensor_Obj.put("name", name);
            sensor_Obj.put("IP", ip);
            sensor_Obj.put("port", port);

            sensorList.add(sensor_Obj);
            _total++;

        }
        rs.close();

        Records.put("total", _total);
        Records.put("records", sensorList);

        sensorsFile.write(Records.toJSONString());
        sensorsFile.flush();
        sensorsFile.close();
    }

    catch (IOException ex) {
        Logger.getLogger(Sensors.class.getName()).log(Level.WARNING, null, ex);
    }
}

From source file:com.nunofacha.chestmaster.commands.ChestHashCommand.java

public static String getDigest(InputStream is, MessageDigest md, int byteArraySize) {

    try {// www .j ava  2 s.c  o  m
        md.reset();
        byte[] bytes = new byte[byteArraySize];
        int numBytes;
        while ((numBytes = is.read(bytes)) != -1) {
            md.update(bytes, 0, numBytes);
        }
        byte[] digest = md.digest();
        String result = new String(Hex.encodeHex(digest));
        return result;
    } catch (IOException ex) {
        Logger.getLogger(ChestHashCommand.class.getName()).log(Level.SEVERE, null, ex);
    }
    return "Failed to get hash!";
}