Skip to content
Permalink
Browse files
fix checkstyle issues in our codebase
  • Loading branch information
struberg committed Feb 28, 2014
1 parent 5e41734 commit 19114f5d3c5e2d24457142fb060c4b65da46b839
Show file tree
Hide file tree
Showing 57 changed files with 394 additions and 202 deletions.
@@ -22,9 +22,13 @@
import org.apache.camel.impl.DefaultCamelContext;

public class CamelBridge {
protected static final DefaultCamelContext CONTEXT = new DefaultCamelContext();
protected static final ProducerTemplate PRODUCER_TEMPLATE = CONTEXT.createProducerTemplate();
protected static final ConsumerTemplate CONSUMER_TEMPLATE = CONTEXT.createConsumerTemplate();
static final DefaultCamelContext CONTEXT = new DefaultCamelContext();
static final ProducerTemplate PRODUCER_TEMPLATE = CONTEXT.createProducerTemplate();
static final ConsumerTemplate CONSUMER_TEMPLATE = CONTEXT.createConsumerTemplate();

private CamelBridge() {
// private utility class ct
}

protected static Object process(final String locator, final String endpoint, final Object body) throws Exception {
final BeanLocator.LocatorInstance<CamelTemplateLocator> locatorInstance = locator(locator);
@@ -33,11 +33,11 @@

import static org.testng.Assert.assertEquals;

public class CamelProcessorTest extends CamelBridge {
public class CamelProcessorTest {
@Test
public void process() throws Exception {
final List<Exchange> exchanges = new ArrayList<Exchange>(2);
final Consumer consumer = CONTEXT.getEndpoint("direct:processor").createConsumer(new Processor() {
final Consumer consumer = CamelBridge.CONTEXT.getEndpoint("direct:processor").createConsumer(new Processor() {
@Override
public void process(final Exchange exchange) throws Exception {
exchanges.add(exchange);
@@ -30,16 +30,16 @@

import static org.testng.Assert.assertEquals;

public class CamelReaderTest extends CamelBridge {
public class CamelReaderTest {
@Test
public void read() throws Exception {
final ProducerTemplate tpl = CONTEXT.createProducerTemplate();
final ProducerTemplate tpl = CamelBridge.CONTEXT.createProducerTemplate();

final JobOperator jobOperator = BatchRuntime.getJobOperator();

final long id = jobOperator.start("camel-reader", new Properties());

while (DirectEndpoint.class.cast(CONTEXT.getEndpoint("direct:reader")).getConsumer() == null) {
while (DirectEndpoint.class.cast(CamelBridge.CONTEXT.getEndpoint("direct:reader")).getConsumer() == null) {
Thread.sleep(100);
}

@@ -34,10 +34,10 @@

import static org.testng.Assert.assertTrue;

public class CamelWriterTest extends CamelBridge {
public class CamelWriterTest {
@Test
public void write() throws Exception {
final ConsumerTemplate tpl = CONTEXT.createConsumerTemplate();
final ConsumerTemplate tpl = CamelBridge.CONTEXT.createConsumerTemplate();
final Collection<Object> received = new ArrayList<Object>(2);

final ExecutorService thread = Executors.newSingleThreadExecutor();
@@ -53,7 +53,7 @@ public void run() {

do { // starting the listener in another thread w can get timing issues so ensuring we are in the right state
Thread.sleep(20);
} while (DirectEndpoint.class.cast(CONTEXT.getEndpoint("direct:writer")).getConsumer() == null);
} while (DirectEndpoint.class.cast(CamelBridge.CONTEXT.getEndpoint("direct:writer")).getConsumer() == null);

final JobOperator jobOperator = BatchRuntime.getJobOperator();
Batches.waitForEnd(jobOperator, jobOperator.start("camel-writer", new Properties()));
@@ -28,7 +28,8 @@
import java.lang.reflect.Method;

public final class Groovys {
public static <T> GroovyInstance<T> newInstance(final Class<T> expected, final String path, final JobContext jobContext, final StepContext stepContext) throws IllegalAccessException, InstantiationException {
public static <T> GroovyInstance<T> newInstance(final Class<T> expected, final String path, final JobContext jobContext, final StepContext stepContext)
throws IllegalAccessException, InstantiationException {
if (path == null) {
throw new BatchRuntimeException("no script configured expected");
}
@@ -22,6 +22,11 @@
import java.io.InputStream;

final class IOs {

private IOs() {
// private utility class ct
}

public static InputStream findConfiguration(final String path) throws IOException {
if (new File(path).exists()) {
return new FileInputStream(path);
@@ -60,10 +60,12 @@ public static Class<?>[] createObjectTypes(final String objectTypes) throws Clas
configuration.setValidationMode(ValidationMode.valueOf(validationMode));
}
if (objectAccessorProvider != null) {
configuration.setObjectAccessorProvider(ObjectAccessorProvider.class.cast(Thread.currentThread().getContextClassLoader().loadClass(objectAccessorProvider).newInstance()));
configuration.setObjectAccessorProvider(ObjectAccessorProvider.class.cast(
Thread.currentThread().getContextClassLoader().loadClass(objectAccessorProvider).newInstance()));
}
if (simpleTypeProvider != null) {
configuration.setSimpleTypeConverterProvider(SimpleTypeConverterProvider.class.cast(Thread.currentThread().getContextClassLoader().loadClass(simpleTypeProvider).newInstance()));
configuration.setSimpleTypeConverterProvider(SimpleTypeConverterProvider.class.cast(
Thread.currentThread().getContextClassLoader().loadClass(simpleTypeProvider).newInstance()));
}
if (typeMappingRegistry != null) {
configuration.setTypeMappingRegistry((A) Thread.currentThread().getContextClassLoader().loadClass(typeMappingRegistry).newInstance());
@@ -73,12 +75,14 @@ public static Class<?>[] createObjectTypes(final String objectTypes) throws Clas
}
}

//CHECKSTYLE:OFF
public static <A extends RbfLowLevelConfiguration> void setRbfConfiguration(final RbfConfiguration<A> configuration,
final String validationMode, final String validationProvider,
final String lowLevelConfiguration, final String objectAccessorProvider,
final String lineFilter, final String lineFilterLimit,
final String specialRecordDelimiter, final String simpleTypeProvider,
final String typeMappingRegistry) throws Exception {
//CHECKSTYLE:ON
setConfiguration(configuration, validationMode, validationProvider, objectAccessorProvider, simpleTypeProvider, typeMappingRegistry);
if (lineFilter != null) {
configuration.setLineFilter(LineFilter.class.cast(Thread.currentThread().getContextClassLoader().loadClass(lineFilter).newInstance()));
@@ -94,34 +98,40 @@ public static <A extends RbfLowLevelConfiguration> void setRbfConfiguration(fina
}
}

//CHECKSTYLE:OFF
public static XmlConfiguration newXmlConfiguration(final String lineBreak, final String dataTypeDefaultNameRegistry, final String lineIndentation,
final String lowLevelConfiguration, final String namespaceManager, final String dataTypeAttributeName,
final String validationMode, final String validationProvider,
final String objectAccessorProvider, final String simpleTypeProvider,
final String typeMappingRegistry) throws Exception {
//CHECKSTYLE:ON
final XmlConfiguration configuration = new XmlConfiguration();
JsefaConfigurations.setConfiguration(configuration, validationMode, validationProvider, objectAccessorProvider, simpleTypeProvider, typeMappingRegistry);
if (lineBreak != null) {
configuration.setLineBreak(lineBreak);
}
if (dataTypeDefaultNameRegistry != null) {
configuration.setDataTypeDefaultNameRegistry(XmlDataTypeDefaultNameRegistry.class.cast(Thread.currentThread().getContextClassLoader().loadClass(dataTypeDefaultNameRegistry).newInstance()));
configuration.setDataTypeDefaultNameRegistry(XmlDataTypeDefaultNameRegistry.class.cast(
Thread.currentThread().getContextClassLoader().loadClass(dataTypeDefaultNameRegistry).newInstance()));
}
if (lineIndentation != null) {
configuration.setLineIndentation(lineIndentation);
}
if (lowLevelConfiguration != null) {
configuration.setLowLevelConfiguration(XmlLowLevelConfiguration.class.cast(Thread.currentThread().getContextClassLoader().loadClass(lowLevelConfiguration).newInstance()));
configuration.setLowLevelConfiguration(XmlLowLevelConfiguration.class.cast(
Thread.currentThread().getContextClassLoader().loadClass(lowLevelConfiguration).newInstance()));
}
if (namespaceManager != null) {
configuration.setNamespaceManager(NamespaceManager.class.cast(Thread.currentThread().getContextClassLoader().loadClass(namespaceManager).newInstance()));
}
if (dataTypeAttributeName != null) {
configuration.setDataTypeAttributeName(QName.create(dataTypeAttributeName.substring(1, dataTypeAttributeName.indexOf("}")), dataTypeAttributeName.substring(dataTypeAttributeName.indexOf("}") + 1))); // allow {xxx}yyy syntax
configuration.setDataTypeAttributeName(QName.create(dataTypeAttributeName.substring(1, dataTypeAttributeName.indexOf("}")),
dataTypeAttributeName.substring(dataTypeAttributeName.indexOf("}") + 1))); // allow {xxx}yyy syntax
}
return configuration;
}

//CHECKSTYLE:OFF
public static CsvConfiguration newCsvConfiguration(final String defaultNoValueString, final String defaultQuoteMode,
final String fieldDelimiter, final String lineBreak, final String quoteCharacter,
final String quoteCharacterEscapeMode, final String useDelimiterAfterLastField,
@@ -130,6 +140,7 @@ public static CsvConfiguration newCsvConfiguration(final String defaultNoValueSt
final String lineFilterLimit, final String objectAccessorProvider,
final String specialRecordDelimiter, final String simpleTypeProvider,
final String typeMappingRegistry) throws Exception {
//CHECKSTYLE:ON
final CsvConfiguration configuration = new CsvConfiguration();
setRbfConfiguration(configuration, validationMode, validationProvider, lowLevelConfiguration, objectAccessorProvider,
lineFilter, lineFilterLimit, specialRecordDelimiter, simpleTypeProvider, typeMappingRegistry);
@@ -157,12 +168,14 @@ public static CsvConfiguration newCsvConfiguration(final String defaultNoValueSt
return configuration;
}

//CHECKSTYLE:OFF
public static FlrConfiguration newFlrConfiguration(final String defaultPadCharacter, final String lineBreak,
final String validationMode, final String validationProvider,
final String lineFilter, final String lowLevelConfiguration,
final String lineFilterLimit, final String objectAccessorProvider,
final String specialRecordDelimiter, final String simpleTypeProvider,
final String typeMappingRegistry) throws Exception {
//CHECKSTYLE:ON
final FlrConfiguration configuration = new FlrConfiguration();
setRbfConfiguration(configuration, validationMode, validationProvider, lowLevelConfiguration, objectAccessorProvider,
lineFilter, lineFilterLimit, specialRecordDelimiter, simpleTypeProvider, typeMappingRegistry);
@@ -19,8 +19,9 @@
import javax.batch.runtime.Metric;

public final class MetricsHelper {
public MetricsHelper() {
// no-op

private MetricsHelper() {
// private utility class ct
}

public static String toString(final Metric[] metrics) {
@@ -126,9 +126,9 @@ public long start(final String jobXMLName, final Properties jobParameters) throw
}

/*
* The whole point of this method is to have JobStartException serve as a blanket exception for anything other
* than the rest of the more specific exceptions declared on the throws clause. So we won't log but just rethrow.
*/
* The whole point of this method is to have JobStartException serve as a blanket exception for anything other
* than the rest of the more specific exceptions declared on the throws clause. So we won't log but just rethrow.
*/
try {
return startInternal(jobXMLName, jobParameters);
} catch (final JobSecurityException e) {
@@ -336,11 +336,12 @@ public List<StepExecution> getStepExecutions(long executionId)
}

@Override
public long restart(long oldExecutionId, Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
/*
* The whole point of this method is to have JobRestartException serve as a blanket exception for anything other
* than the rest of the more specific exceptions declared on the throws clause. So we won't log but just rethrow.
*/
public long restart(long oldExecutionId, Properties restartParameters)
throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
/*
* The whole point of this method is to have JobRestartException serve as a blanket exception for anything other
* than the rest of the more specific exceptions declared on the throws clause. So we won't log but just rethrow.
*/
try {
return restartInternal(oldExecutionId, restartParameters);
} catch (JobExecutionAlreadyCompleteException e) {
@@ -356,7 +357,8 @@ public long restart(long oldExecutionId, Properties restartParameters) throws Jo
}
}

private long restartInternal(final long oldExecutionId, final Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
private long restartInternal(final long oldExecutionId, final Properties restartParameters)
throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(oldExecutionId))) {
throw new JobSecurityException("The current user is not authorized to perform this operation");
}
@@ -387,4 +389,4 @@ public void stop(final long executionId) throws NoSuchJobExecutionException, Job
public void waitFor(final long id) {
callbackService.waitFor(id);
}
}
}
@@ -58,7 +58,7 @@ public ExecutionStatus execute() {

//Create a decider proxy and inject the associated properties

/* Set the contexts associated with this scope */
/* Set the contexts associated with this scope */
//job context is always in scope
//the parent controller will only pass one valid context to a decision controller
//so two of these contexts will always be null
@@ -71,11 +71,13 @@ public static DecisionController getDecisionController(final ServicesManager ser
return new DecisionController(jobExecutionImpl, decision, servicesManager);
}

public static FlowController getFlowController(final ServicesManager servicesManager, final RuntimeJobExecution jobExecutionImpl, final Flow flow, final long rootJobExecutionId) {
public static FlowController getFlowController(final ServicesManager servicesManager, final RuntimeJobExecution jobExecutionImpl,
final Flow flow, final long rootJobExecutionId) {
return new FlowController(jobExecutionImpl, flow, rootJobExecutionId, servicesManager);
}

public static SplitController getSplitController(final BatchKernelService kernel, final RuntimeJobExecution jobExecutionImpl, final Split split, final long rootJobExecutionId) {
public static SplitController getSplitController(final BatchKernelService kernel, final RuntimeJobExecution jobExecutionImpl,
final Split split, final long rootJobExecutionId) {
return new SplitController(jobExecutionImpl, split, rootJobExecutionId, kernel);
}

@@ -118,6 +118,9 @@ public ExecutionStatus originateExecutionOnThread() {
case EXCEPTION_THROWN:
updateJobBatchStatus(BatchStatus.FAILED);
break;
default:
// all ok
break;
}
}
} catch (final Throwable t) {
@@ -30,6 +30,10 @@
public class PartitionedStepBuilder {
public static final String JOB_ID_SEPARATOR = ":"; // Use something permissible in NCName to allow us to key off of.

private PartitionedStepBuilder() {
// private utility class ct
}

/*
* Build a generated job with only one flow in it to submit to the
* BatchKernel. This is used to build subjobs from splits.

0 comments on commit 19114f5

Please sign in to comment.