List of usage examples for java.util.logging Level FINE
Level FINE
To view the source code for java.util.logging Level FINE.
Click Source Link
From source file:com.stratuscom.harvester.deployer.StarterServiceDeployer.java
public VirtualFileSystemClassLoader createServiceClassloader(String appName, FileObject serviceRoot, CodeSource codeSource) throws IOException, FileSystemException { String parentLoaderName = configNode .search(new Class[] { ASTconfig.class, ASTclassloader.class, ASTparent.class }).get(0) .jjtGetChild(0).toString();//from w w w. jav a 2 s . c o m log.log(Level.FINE, MessageNames.SERVICE_PARENT_CLASSLOADER_IS, parentLoaderName); boolean isAppPriority = false; if (!configNode.search(new Class[] { ASTconfig.class, ASTclassloader.class, ASTappPriority.class }) .isEmpty()) { isAppPriority = true; } ClassLoader parentLoader = (ClassLoader) context.get(parentLoaderName); VirtualFileSystemClassLoader cl = createChildOfGivenClassloader(parentLoader, codeSource, isAppPriority); cl.setDebugName("App classloader for " + appName); /* Include platform jars from the container's lib directory. */ List classpathNodes = configNode .search(new Class[] { ASTconfig.class, ASTclassloader.class, ASTjars.class, ASTclasspath.class }); if (classpathNodes.size() > 0) { ASTclasspath platformJarSpec = (ASTclasspath) classpathNodes.get(0); addPlatformJarsToClassloader(platformJarSpec, cl); } addLibDirectoryJarsToClasspath(serviceRoot, cl); return cl; }
From source file:org.syncany.connection.plugins.webdav.WebdavTransferManager.java
@Override public <T extends RemoteFile> Map<String, T> list(Class<T> remoteFileClass) throws StorageException { connect();//from w w w .j ava 2 s. co m try { // List folder String remoteFileUrl = getRemoteFilePath(remoteFileClass); logger.log(Level.INFO, "WebDAV: Listing objects in " + remoteFileUrl + " ..."); List<DavResource> resources = sardine.list(remoteFileUrl); // Create RemoteFile objects String rootPath = repoPath.substring(0, repoPath.length() - new URI(repoPath).getRawPath().length()); Map<String, T> remoteFiles = new HashMap<String, T>(); for (DavResource res : resources) { // WebDAV returns the parent resource itself; ignore it String fullResourceUrl = rootPath + res.getPath().replaceAll("/$", "") + "/"; boolean isParentResource = remoteFileUrl.equals(fullResourceUrl.toString()); if (!isParentResource) { try { T remoteFile = RemoteFile.createRemoteFile(res.getName(), remoteFileClass); remoteFiles.put(res.getName(), remoteFile); logger.log(Level.FINE, "WebDAV: Matching WebDAV resource: " + res); } catch (Exception e) { logger.log(Level.FINEST, "Cannot create instance of " + remoteFileClass.getSimpleName() + " for object " + res.getName() + "; maybe invalid file name pattern. Ignoring file."); } } } return remoteFiles; } catch (Exception ex) { logger.log(Level.SEVERE, "WebDAV: Unable to list WebDAV directory.", ex); throw new StorageException(ex); } }
From source file:com.github.jinahya.sql.database.metadata.bind.MetadataContext.java
private <T> T bindSingle(final ResultSet resultSet, final Class<T> beanClass, final T beanInstance) throws SQLException, ReflectiveOperationException { if (resultSet != null) { final Set<String> resultLabels = ResultSets.getColumnLabels(resultSet); // @SuppressWarnings("unchecked") // final List<Field> fields // = Reflections.fields(beanClass, Label.class); final Field[] fields = FieldUtils.getFieldsWithAnnotation(beanClass, Label.class); for (final Field field : fields) { final String label = field.getAnnotation(Label.class).value(); final String suppression = suppression(beanClass, field); final String info = String.format("field=%s, label=%s, suppression=%s", field, label, suppression); if (suppressed(suppression)) { logger.log(Level.FINE, "suppressed; {0}", info); continue; }/*from w w w .j a va2 s. c om*/ if (!resultLabels.remove(label)) { final String message = "unknown column; " + info; if (!suppressUnknownColumns()) { throw new RuntimeException(message); } logger.warning(message); continue; } final Object value; try { value = resultSet.getObject(label); } catch (final Exception e) { final String message = "failed to get value; " + info; logger.severe(message); if (e instanceof SQLException) { throw (SQLException) e; } throw new RuntimeException(e); } Values.set(field.getName(), beanInstance, value); //Reflections.fieldValue(field, beanInstance, value); //FieldUtils.writeField(field, beanInstance, value); //FieldUtils.writeField(field, beanInstance, value, true); } if (!resultLabels.isEmpty()) { for (final String resultLabel : resultLabels) { final Object resultValue = resultSet.getObject(resultLabel); logger.log(Level.WARNING, "unknown result; {0}({1})", new Object[] { resultLabel, resultValue }); } } } // @SuppressWarnings("unchecked") // final List<Field> fields // = Reflections.fields(beanClass, Invocation.class); final List<Field> fields = FieldUtils.getFieldsListWithAnnotation(beanClass, Invocation.class); for (final Field field : fields) { final Invocation invocation = field.getAnnotation(Invocation.class); final String suppression = suppression(beanClass, field); final String info = String.format("field=%s, invocation=%s, suppression=%s", field, invocation, suppression); if (suppressed(suppression)) { logger.log(Level.FINE, "suppressed; {0}", new Object[] { info }); continue; } final String name = invocation.name(); getMethodNames().remove(name); final Class<?>[] types = invocation.types(); final Method method; try { method = DatabaseMetaData.class.getMethod(name, types); } catch (final NoSuchMethodException nsme) { final String message = "unknown methods; " + info; if (!suppressUnknownMethods()) { throw new RuntimeException(message); } logger.warning(message); continue; } for (final InvocationArgs invocationArgs : invocation.argsarr()) { final String[] names = invocationArgs.value(); final Object[] args = Invocations.args(beanClass, beanInstance, types, names); final Object value; try { value = method.invoke(database, args); } catch (final Exception e) { logger.log(Level.SEVERE, "failed to invoke" + info, e); throw new RuntimeException(e); } catch (final AbstractMethodError ame) { logger.log(Level.SEVERE, "failed by abstract" + info, ame); throw ame; } setValue(field, beanInstance, value, args); } } if (TableDomain.class.isAssignableFrom(beanClass)) { getMethodNames().remove("getCrossReference"); final List<Table> tables = ((TableDomain) beanInstance).getTables(); final List<CrossReference> crossReferences = getCrossReferences(tables); ((TableDomain) beanInstance).setCrossReferences(crossReferences); } return beanInstance; }
From source file:core.messaging.Messenger.java
private void sendImmediately(final String to, final String from, final String subject, final String body, ByteArrayDataSource attachment) { try {/* w ww . j ava2 s. co m*/ logger.log(Level.INFO, "Sending email to={0},from={1},subject={2},body={3},attachment={4},fileName{5},mimeType={6}", new Object[] { to, from, subject, body, attachment, attachment == null ? "null" : attachment.getName(), attachment == null ? "null" : attachment.getContentType() }); // Create the email message MultiPartEmail email = new MultiPartEmail(); email.addTo(to); email.setFrom(from); email.setSubject(subject); email.setMsg(body); String logLocation = Play.configuration.getProperty("log.mail"); logger.log(Level.FINE, "logging message to {0}, attachment size={1}", new Object[] { logLocation, attachment == null ? 0 : attachment.getBytes().length }); long timestamp = System.currentTimeMillis(); //TODO * log email contents also (body) FileLogHelper.createInstance().log(logLocation, to + "-" + timestamp, email.getSubject().getBytes()); if (attachment != null) { String attachmentName = to + "-" + timestamp + "-attachment-" + attachment.getName(); FileLogHelper.createInstance().log(logLocation, attachmentName, attachment.getBytes()); // add the attachment EmailAttachment emailAttachment = new EmailAttachment(); //write to mailerbean dir then read from there, that is fine emailAttachment.setPath(logLocation + "/" + attachmentName); emailAttachment.setDisposition(EmailAttachment.ATTACHMENT); emailAttachment.setDescription(attachment.getName()); emailAttachment.setName(attachment.getName()); email.attach(emailAttachment); } logger.log(Level.FINE, "Sending message"); Future<Boolean> send = Mail.send(email); } catch (Exception ex) { Logger.getLogger(Messenger.class.getName()).log(Level.SEVERE, null, ex); throw new MessangerException(ex); } }
From source file:org.couch4j.http.DatabaseChangeNotificationService.java
void removeChangeListener(ChangeListener l) { listener.remove(l);//from w ww.j av a 2s. co m if (listener.isEmpty()) { // unsubscribe receivingChangeNotifications = false; if (null != executor) { if (logger.isLoggable(Level.FINE)) { logger.fine("Shutdown executor service..."); } executor.shutdown(); } } }
From source file:edu.usu.sdl.openstorefront.service.OrganizationServiceImpl.java
private <T extends BaseEntity> void updateOrganizationOnEntity(T entityExample, String toMergeOrg, Organization organizationTarget) { if (entityExample instanceof OrganizationModel) { log.log(Level.FINE, MessageFormat.format("Updating organizations on {0}", entityExample.getClass().getSimpleName())); ((OrganizationModel) entityExample).setOrganization(toMergeOrg); List<T> entities = entityExample.findByExampleProxy(); entities.forEach(entity -> {//ww w . j av a 2 s. c o m ((OrganizationModel) entity).setOrganization(organizationTarget.getName()); ((StandardEntity) entity).populateBaseUpdateFields(); persistenceService.persist(entity); }); log.log(Level.FINE, MessageFormat.format("Updated: ", entities.size())); } else { throw new OpenStorefrontRuntimeException("Entity does not implement Organization", "Programming error"); } }
From source file:com.cedarsoft.couchdb.CouchDatabase.java
@Override @Nonnull// w w w.j a va 2 s. c o m public ActionResponse put(@Nonnull DocId docId, @Nullable Revision revision, @Nonnull MediaType mediaType, @Nonnull InputStream content) throws ActionFailedException { WebResource resource = getDbRoot().path(docId.asString()); //Add the revision is necessary if (revision != null) { resource = resource.queryParam(PARAM_REV, revision.asString()); } if (LOG.isLoggable(Level.FINE)) { LOG.fine("HEAD " + resource.toString()); } WebResource.Builder path = resource.type(mediaType).accept(JSON_TYPE); ClientResponse clientResponse = path.put(ClientResponse.class, content); return ActionResponseSerializer.create(clientResponse); }
From source file:com.clothcat.hpoolauto.model.Model.java
/** * Process a receive transaction// w w w .j a v a 2 s . c o m */ private void processReceipt(JSONObject j) { HLogger.log(Level.FINEST, "Processing receipt\n" + j.toString()); try { if (isNewTransaction(j)) { HLogger.log("new transaction! " + j.getString("txid")); // get the transaction for this receipt String txid = j.getString("txid"); String s = rpcWorker.getTransaction(txid); HLogger.log(Level.FINEST, "Got transaction: " + s); JSONTokener jt = new JSONTokener(s); JSONObject tx = new JSONObjectDuplicates(jt); JSONArray vout = tx.getJSONArray("vout"); HLogger.log(Level.FINEST, "Extracted vout array: \n" + vout.toString()); String sendingAddress = vout.getJSONObject(0).getJSONObject("scriptPubKey") .getJSONArray("addresses").getString(0); HLogger.log(Level.FINEST, "Extracted sending address: " + sendingAddress); // see if the sending address belongs to us if (rpcWorker.isOurAddress(sendingAddress)) { HLogger.log(Level.FINEST, "sending address belongs to us, ignoring " + "transaction"); } else { String receivingAddress = vout.getJSONObject(1).getJSONObject("scriptPubKey") .getJSONArray("addresses").getString(0); HLogger.log(Level.FINEST, "Extracted receiving address: " + receivingAddress); String amountStr = vout.getJSONObject(1).getString("value"); HLogger.log(Level.FINEST, "Extracted amount: " + amountStr); double d = Double.valueOf(amountStr); d *= Constants.uH_IN_HYP; long amount = (long) d; HLogger.log(Level.FINEST, "Amount in uHyp is: " + d); Pool p = getPool(getCurrPoolName()); long minSpace = getMinFill() - p.calculateFillAmount(); long maxSpace = getMaxFill() - p.calculateFillAmount(); HLogger.log(Level.FINEST, "minSpace: " + minSpace + "; maxSpace: " + maxSpace); if (amount < minSpace) { // investment fits in pool but does not fill it HLogger.log(Level.FINE, "amount < minSpace"); Investment inv = new Investment(); inv.setAmount(amount); inv.setDatestamp(new java.util.Date().getTime() / 1000); inv.setFromAddress(sendingAddress); p.getInvestments().add(inv); HLogger.log(Level.FINE, "added investment to pool: \n" + inv.toJson()); } else if (amount < maxSpace) { // investment fits in pool and fills it HLogger.log(Level.FINE, "amount < maxSpace"); Investment inv = new Investment(); inv.setAmount(amount); inv.setDatestamp(new java.util.Date().getTime() / 1000); inv.setFromAddress(sendingAddress); p.getInvestments().add(inv); HLogger.log(Level.FINE, "added investment to pool: \n" + inv.toJson()); HLogger.log(Level.FINE, "Moving to next pool"); moveToNextPool(); } else { HLogger.log(Level.FINE, "amount > minSpace"); // investment overflows pool, so fill it and then rollover // what's left as the first investment in the next pool. // we want to take a random amount of investment that // lets the pool size be between min and max, but which // still leaves the investor enough for the minimum // investment for the next pool. long maxInvAmount = minOf(amount - getMinInvestment(), 1000); HLogger.log(Level.FINE, "maxInvAmount: " + maxInvAmount); long minInvAmount = minSpace; HLogger.log(Level.FINE, "minInvAmount: " + minInvAmount); long randomAmount = getRandomLongInRange(minInvAmount, maxInvAmount); HLogger.log(Level.FINE, "randomAmount: " + randomAmount); long remainingAmount = amount - randomAmount; HLogger.log(Level.FINE, "remainingAmount: " + remainingAmount); Investment inv = new Investment(); inv.setAmount(randomAmount); inv.setDatestamp(new java.util.Date().getTime() / 1000); inv.setFromAddress(sendingAddress); p.getInvestments().add(inv); HLogger.log(Level.FINE, "added investment to pool: \n" + inv.toJson()); HLogger.log(Level.FINE, "moving to next pool with remaining amount"); moveToNextPool(); Pool p2 = getPool(getCurrPoolName()); Investment inv2 = new Investment(); inv2.setAmount(remainingAmount); inv2.setDatestamp(new java.util.Date().getTime() / 1000); inv2.setFromAddress(sendingAddress); p2.getInvestments().add(inv2); HLogger.log(Level.FINE, "added investment to new pool: " + p2.getPoolName() + "\n" + inv.toJson()); } } HLogger.log(Level.FINE, "Marking txid as done: " + txid); setTransactionDone(txid); } } catch (JSONException ex) { HLogger.log(Level.SEVERE, "Caught exception in processReceipt()", ex); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:bookkeepr.jettyhandlers.WebHandler.java
public void handle(String path, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { if (path.equals("/")) { response.sendRedirect("/web/"); }//from w w w . jav a 2 s. c om HttpClient httpclient = null; if (path.startsWith("/web/xmlify")) { ((Request) request).setHandled(true); if (request.getMethod().equals("POST")) { try { String remotePath = path.substring(11); BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); XMLAble xmlable = null; try { xmlable = httpForm2XmlAble(reader.readLine()); } catch (BookKeeprException ex) { response.sendError(400, "Server could not form xml from the form data you submitted. " + ex.getMessage()); return; } if (xmlable == null) { response.sendError(500, "Server could not form xml from the form data you submitted. The server created a null value!"); return; } // XMLWriter.write(System.out, xmlable); // if(true)return; HttpPost httppost = new HttpPost(bookkeepr.getConfig().getExternalUrl() + remotePath); httppost.getParams().setBooleanParameter("http.protocol.strict-transfer-encoding", false); ByteArrayOutputStream out = new ByteArrayOutputStream(1024); XMLWriter.write(out, xmlable); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); httppost.setEntity(new InputStreamEntity(in, -1)); Logger.getLogger(WebHandler.class.getName()).log(Level.INFO, "Xmlifier posting to " + bookkeepr.getConfig().getExternalUrl() + remotePath); httpclient = bookkeepr.checkoutHttpClient(); HttpResponse httpresp = httpclient.execute(httppost); for (Header head : httpresp.getAllHeaders()) { if (head.getName().equalsIgnoreCase("transfer-encoding")) { continue; } response.setHeader(head.getName(), head.getValue()); } response.setStatus(httpresp.getStatusLine().getStatusCode()); httpresp.getEntity().writeTo(response.getOutputStream()); } catch (HttpException ex) { Logger.getLogger(WebHandler.class.getName()).log(Level.WARNING, "HttpException " + ex.getMessage(), ex); response.sendError(500, ex.getMessage()); } catch (URISyntaxException ex) { Logger.getLogger(WebHandler.class.getName()).log(Level.WARNING, ex.getMessage(), ex); response.sendError(400, "Invalid target URI"); } finally { if (httpclient != null) { bookkeepr.returnHttpClient(httpclient); } } } return; } if (request.getMethod().equals("GET")) { if (path.startsWith("/web")) { ((Request) request).setHandled(true); if (badchar.matcher(path).matches()) { response.sendError(400, "User Error"); return; } String localpath = path.substring(4); Logger.getLogger(WebHandler.class.getName()).log(Level.FINE, "Transmitting " + localroot + localpath); File targetFile = new File(localroot + localpath); if (targetFile.isDirectory()) { if (path.endsWith("/")) { targetFile = new File(localroot + localpath + "index.html"); } else { response.sendRedirect(path + "/"); return; } } if (targetFile.exists()) { if (targetFile.getName().endsWith(".html") || targetFile.getName().endsWith(".xsl")) { BufferedReader in = new BufferedReader(new FileReader(targetFile)); PrintStream out = null; String hdr = request.getHeader("Accept-Encoding"); if (hdr != null && hdr.contains("gzip")) { // if the host supports gzip encoding, gzip the output for quick transfer speed. out = new PrintStream(new GZIPOutputStream(response.getOutputStream())); response.setHeader("Content-Encoding", "gzip"); } else { out = new PrintStream(response.getOutputStream()); } String line = in.readLine(); while (line != null) { if (line.trim().startsWith("%%%")) { BufferedReader wrapper = new BufferedReader( new FileReader(localroot + "/wrap/" + line.trim().substring(3) + ".html")); String line2 = wrapper.readLine(); while (line2 != null) { out.println(line2); line2 = wrapper.readLine(); } wrapper.close(); } else if (line.trim().startsWith("***chooser")) { String[] elems = line.trim().split("\\s"); try { int type = TypeIdManager .getTypeFromClass(Class.forName("bookkeepr.xmlable." + elems[1])); List<IdAble> items = this.bookkeepr.getMasterDatabaseManager() .getAllOfType(type); out.printf("<select name='%sId'>\n", elems[1]); for (IdAble item : items) { out.printf("<option value='%x'>%s</option>", item.getId(), item.toString()); } out.println("</select>"); } catch (Exception e) { Logger.getLogger(WebHandler.class.getName()).log(Level.WARNING, "Could not make a type ID for " + line.trim()); } } else { out.println(line); } line = in.readLine(); } in.close(); out.close(); } else { outputToInput(new FileInputStream(targetFile), response.getOutputStream()); } } else { response.sendError(HttpStatus.SC_NOT_FOUND); } } } }
From source file:org.fourthline.cling.transport.impl.apache.StreamServerImpl.java
protected boolean isConnectionOpen(Socket socket, byte[] heartbeat) { if (log.isLoggable(Level.FINE)) log.fine("Checking if client connection is still open on: " + socket.getRemoteSocketAddress()); try {//w w w . ja v a 2 s. c om socket.getOutputStream().write(heartbeat); socket.getOutputStream().flush(); return true; } catch (IOException ex) { if (log.isLoggable(Level.FINE)) log.fine("Client connection has been closed: " + socket.getRemoteSocketAddress()); return false; } }