Skip to content

Commit

Permalink
Reformat all java files
Browse files Browse the repository at this point in the history
Formatting was previously being handled by code_style–ij.xml which is not really
compatible with many new IDEs. This PR changes formating to GoogleStyle enforced by
the spotless gradle plugin in conjunction with jdtls, which is compatible with
vscode and eclipse.
  • Loading branch information
DiegoTavares committed Jan 7, 2025
1 parent 9c72a3e commit 32209a2
Show file tree
Hide file tree
Showing 385 changed files with 50,619 additions and 57,836 deletions.
10 changes: 10 additions & 0 deletions cuebot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id('com.google.protobuf') version "0.9.1"
id('jacoco')
id('org.sonarqube') version "2.8"
id('com.diffplug.spotless') version "5.16.0"
}

sourceCompatibility = 11
Expand Down Expand Up @@ -171,3 +172,12 @@ test {
}
}
}

spotless {
java {
targetExclude 'src/compiled_protobuf/**'
toggleOffOn()
eclipse().configFile('jdtls.xml')
indentWithSpaces(4)
}
}
67 changes: 0 additions & 67 deletions cuebot/code_style_ij.xml

This file was deleted.

337 changes: 337 additions & 0 deletions cuebot/jdtls.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,39 @@
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.Status;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import org.apache.logging.log4j.Logger;

public class CueServerInterceptor implements ServerInterceptor {

private static final Logger logger = LogManager.getLogger(CueServerInterceptor.class);
private static final Logger accessLogger = LogManager.getLogger("API");
private static final Logger logger = LogManager.getLogger(CueServerInterceptor.class);
private static final Logger accessLogger = LogManager.getLogger("API");

@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> serverCall, Metadata metadata,
ServerCallHandler<ReqT, RespT> serverCallHandler) {
accessLogger.info("gRPC [" +
serverCall.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR) +
"]: " + serverCall.getMethodDescriptor().getFullMethodName());
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall,
Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) {
accessLogger.info("gRPC [" + serverCall.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR)
+ "]: " + serverCall.getMethodDescriptor().getFullMethodName());

ServerCall.Listener<ReqT> delegate = serverCallHandler.startCall(serverCall, metadata);
return new SimpleForwardingServerCallListener<ReqT>(delegate) {
@Override
public void onHalfClose() {
try {
super.onHalfClose();
} catch (Exception e) {
logger.error("Caught an unexpected error.", e);
serverCall.close(Status.INTERNAL
.withCause(e)
.withDescription(e.toString() + "\n" + e.getMessage()),
new Metadata());
}
}
ServerCall.Listener<ReqT> delegate = serverCallHandler.startCall(serverCall, metadata);
return new SimpleForwardingServerCallListener<ReqT>(delegate) {
@Override
public void onHalfClose() {
try {
super.onHalfClose();
} catch (Exception e) {
logger.error("Caught an unexpected error.", e);
serverCall.close(
Status.INTERNAL.withCause(e).withDescription(e.toString() + "\n" + e.getMessage()),
new Metadata());
}
}

@Override
public void onMessage(ReqT request) {
accessLogger.info("Request Data: " + request);
super.onMessage(request);
}
};
}
@Override
public void onMessage(ReqT request) {
accessLogger.info("Request Data: " + request);
super.onMessage(request);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,76 +38,74 @@
import com.imageworks.spcue.servant.ManageTask;
import com.imageworks.spcue.servant.RqdReportStatic;


public class GrpcServer implements ApplicationContextAware {

private static final Logger logger = LogManager.getLogger(GrpcServer.class);
private static final Logger logger = LogManager.getLogger(GrpcServer.class);

private static final String DEFAULT_NAME = "CueGrpcServer";
private static final String DEFAULT_PORT = "8443";
private static final int DEFAULT_MAX_MESSAGE_BYTES = 104857600;
private static final String DEFAULT_NAME = "CueGrpcServer";
private static final String DEFAULT_PORT = "8443";
private static final int DEFAULT_MAX_MESSAGE_BYTES = 104857600;

private String name;
private int port;
private int maxMessageBytes;
private Server server;
private ApplicationContext applicationContext;
private String name;
private int port;
private int maxMessageBytes;
private Server server;
private ApplicationContext applicationContext;

public GrpcServer() {
this(DEFAULT_NAME, DEFAULT_PORT, new Properties(), DEFAULT_MAX_MESSAGE_BYTES);
}
public GrpcServer() {
this(DEFAULT_NAME, DEFAULT_PORT, new Properties(), DEFAULT_MAX_MESSAGE_BYTES);
}

public GrpcServer(String name, String port, Properties props, Integer maxMessageBytes) {
logger.info("Setting up gRPC server...");
this.name = name;
this.port = Integer.parseInt(port);
this.maxMessageBytes = maxMessageBytes;
}
public GrpcServer(String name, String port, Properties props, Integer maxMessageBytes) {
logger.info("Setting up gRPC server...");
this.name = name;
this.port = Integer.parseInt(port);
this.maxMessageBytes = maxMessageBytes;
}

public void shutdown() {
if (!server.isShutdown()) {
logger.info("gRPC server shutting down on " + this.name + " at port " + this.port);
server.shutdown();
}
public void shutdown() {
if (!server.isShutdown()) {
logger.info("gRPC server shutting down on " + this.name + " at port " + this.port);
server.shutdown();
}
}

public void start() throws IOException {
server = ServerBuilder
.forPort(this.port)
.addService(applicationContext.getBean("rqdReportStatic", RqdReportStatic.class))
.addService(applicationContext.getBean("cueStaticServant", CueStatic.class))
.addService(applicationContext.getBean("manageAction", ManageAction.class))
.addService(applicationContext.getBean("manageAllocation", ManageAllocation.class))
.addService(applicationContext.getBean("manageComment", ManageComment.class))
.addService(applicationContext.getBean("manageDeed", ManageDeed.class))
.addService(applicationContext.getBean("manageDepartment", ManageDepartment.class))
.addService(applicationContext.getBean("manageDepend", ManageDepend.class))
.addService(applicationContext.getBean("manageFacility", ManageFacility.class))
.addService(applicationContext.getBean("manageFilter", ManageFilter.class))
.addService(applicationContext.getBean("manageFrame", ManageFrame.class))
.addService(applicationContext.getBean("manageGroup", ManageGroup.class))
.addService(applicationContext.getBean("manageHost", ManageHost.class))
.addService(applicationContext.getBean("manageJob", ManageJob.class))
.addService(applicationContext.getBean("manageLayer", ManageLayer.class))
.addService(applicationContext.getBean("manageLimit", ManageLimit.class))
.addService(applicationContext.getBean("manageMatcher", ManageMatcher.class))
.addService(applicationContext.getBean("manageOwner", ManageOwner.class))
.addService(applicationContext.getBean("manageProc", ManageProc.class))
.addService(applicationContext.getBean("manageRenderPartition", ManageRenderPartition.class))
.addService(applicationContext.getBean("manageService", ManageService.class))
.addService(applicationContext.getBean("manageServiceOverride", ManageServiceOverride.class))
.addService(applicationContext.getBean("manageShow", ManageShow.class))
.addService(applicationContext.getBean("manageSubscription", ManageSubscription.class))
.addService(applicationContext.getBean("manageTask", ManageTask.class))
.maxInboundMessageSize(maxMessageBytes)
.intercept(new CueServerInterceptor())
.build();
server.start();
logger.info("gRPC server started on " + this.name + " at port " + this.port + " !");
}
public void start() throws IOException {
server = ServerBuilder.forPort(this.port)
.addService(applicationContext.getBean("rqdReportStatic", RqdReportStatic.class))
.addService(applicationContext.getBean("cueStaticServant", CueStatic.class))
.addService(applicationContext.getBean("manageAction", ManageAction.class))
.addService(applicationContext.getBean("manageAllocation", ManageAllocation.class))
.addService(applicationContext.getBean("manageComment", ManageComment.class))
.addService(applicationContext.getBean("manageDeed", ManageDeed.class))
.addService(applicationContext.getBean("manageDepartment", ManageDepartment.class))
.addService(applicationContext.getBean("manageDepend", ManageDepend.class))
.addService(applicationContext.getBean("manageFacility", ManageFacility.class))
.addService(applicationContext.getBean("manageFilter", ManageFilter.class))
.addService(applicationContext.getBean("manageFrame", ManageFrame.class))
.addService(applicationContext.getBean("manageGroup", ManageGroup.class))
.addService(applicationContext.getBean("manageHost", ManageHost.class))
.addService(applicationContext.getBean("manageJob", ManageJob.class))
.addService(applicationContext.getBean("manageLayer", ManageLayer.class))
.addService(applicationContext.getBean("manageLimit", ManageLimit.class))
.addService(applicationContext.getBean("manageMatcher", ManageMatcher.class))
.addService(applicationContext.getBean("manageOwner", ManageOwner.class))
.addService(applicationContext.getBean("manageProc", ManageProc.class))
.addService(
applicationContext.getBean("manageRenderPartition", ManageRenderPartition.class))
.addService(applicationContext.getBean("manageService", ManageService.class))
.addService(
applicationContext.getBean("manageServiceOverride", ManageServiceOverride.class))
.addService(applicationContext.getBean("manageShow", ManageShow.class))
.addService(applicationContext.getBean("manageSubscription", ManageSubscription.class))
.addService(applicationContext.getBean("manageTask", ManageTask.class))
.maxInboundMessageSize(maxMessageBytes).intercept(new CueServerInterceptor()).build();
server.start();
logger.info("gRPC server started on " + this.name + " at port " + this.port + " !");
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
Loading

0 comments on commit 32209a2

Please sign in to comment.