Skip to content
Permalink
Browse files
Minor code cleanup (remove unnecessary casts, declarations, imports, …
…loggers)

git-svn-id: https://svn.apache.org/repos/asf/james/postage/trunk@684436 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Stefano Bagnara committed Aug 10, 2008
1 parent f5d8a05 commit fb6501570a22838095fb327fe0bcf747d204f253
Showing 5 changed files with 8 additions and 13 deletions.
@@ -44,7 +44,7 @@ public class JVMResourceSampler implements Sampler {
public static boolean isJMXAvailable() {
try {
// this class is only present, when the package _is run_ at least under Java 5
Class jmxFactoryClass = Class.forName("javax.management.remote.JMXConnectorFactory");
Class.forName("javax.management.remote.JMXConnectorFactory");
} catch (ClassNotFoundException e) {
return false;
}
@@ -83,7 +83,7 @@ public JVMResourceSampler(String host, int port, PostageRunnerResult results) {
public void connectRemoteJamesJMXServer() throws SamplingException {
if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)");
try {
m_connectMethod.invoke(jvmResourceSampleWorker, (Object[])VOID_ARGUMENT_LIST);
m_connectMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
} catch (Exception e) {
throw new SamplingException("could not establish connection to remote James JMX. is James really configured for JMX and running under JSE5 or later?");
}
@@ -92,7 +92,7 @@ public void connectRemoteJamesJMXServer() throws SamplingException {
public void doSample() throws SamplingException {
if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)");
try {
m_doSampleMethod.invoke(jvmResourceSampleWorker, (Object[])VOID_ARGUMENT_LIST);
m_doSampleMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
} catch (Exception e) {
throw new SamplingException(e);
}
@@ -86,7 +86,6 @@ private void takeMemorySample(JVMResourcesRecord jvmResourcesRecord) throws Samp
}

private void takeThreadingSample(JVMResourcesRecord jvmResourcesRecord) throws SamplingException {
CompositeDataSupport data = null;
AttributeList attributes = getRemoteThreadingAttributeValues();
jvmResourcesRecord.setThreadCountCurrent(((Integer)getAttributeValue(attributes, "ThreadCount")).longValue());
jvmResourcesRecord.setThreadCountPeak(((Integer)getAttributeValue(attributes, "PeakThreadCount")).longValue());
@@ -50,7 +50,7 @@ public static char getRandomChar() {
}

private static int getRandomInt() {
return (int)(Math.random() * (double)(CHARSET.length - 1));
return (int)(Math.random() * (CHARSET.length - 1));
}

public static byte getRandomByte() {
@@ -109,7 +109,7 @@ public Message createMail(Session mailSession, MailSender mailSender, MailProces
abstract protected Class getValidatorClass();

protected int generateRandomPartSize(int sizeMin, int sizeMax) {
return (int)(Math.random() * (double)(sizeMax - sizeMin)) + sizeMin;
return (int)(Math.random() * (sizeMax - sizeMin)) + sizeMin;
}

}
@@ -18,21 +18,17 @@
****************************************************************/
package org.apache.james.postage.mail;

import org.apache.james.postage.result.MailProcessingRecord;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMultipart;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.james.postage.result.MailProcessingRecord;

/**
* this validator is used together with DefaultMailFactory
*/
public class DefaultMailValidator implements MailValidator {

private static Log log = LogFactory.getLog(DefaultMailValidator.class);

public boolean validate(Message message, MailProcessingRecord record) {

MimeMultipart mimeMultipart;
@@ -74,7 +74,7 @@ public String getDomain() {

public String getRandomUsername() {
if (m_users.isEmpty()) return null;
return (String)m_users.get((int)(Math.random() * (double)(m_users.size() - 1)));
return (String)m_users.get((int)(Math.random() * (m_users.size() - 1)));
}

public String getEmailAddress(String username) {

0 comments on commit fb65015

Please sign in to comment.